// +---------------------------------------------------------------------- namespace app\services\message\notice; use app\services\message\NoticeService; use app\jobs\notice\EnterpriseWechatJob; use think\facade\Log; /** * 企业微信发送消息 * Created by PhpStorm. * User: xurongyao <763569752@qq.com> * Date: 2021/9/22 1:23 PM */ class EnterpriseWechatService extends NoticeService { /** * 判断是否开启权限 * @var bool */ private $isopend = true; /** * 是否开启权限 * @param string $mark * @return $this */ public function isOpen(string $mark) { $this->isopend = $this->noticeInfo['is_ent_wechat'] == 1 && $this->noticeInfo['url'] !== ''; return $this; } /** * 发送消息 * @param $uid uid * @param array $data 模板内容 */ public function sendMsg($data) { try { if ($this->isopend) { $url = $this->noticeInfo['url']; $ent_wechat_text = $this->noticeInfo['ent_wechat_text']; EnterpriseWechatJob::dispatchDo('doJob', [$data, $url, $ent_wechat_text]); } } catch (\Exception $e) { Log::error($e->getMessage()); return true; } } }