CRMEB_PRO_M/app/services/message/notice/EnterpriseWechatService.php

68 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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;
}
}
}