You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.8 KiB
68 lines
1.8 KiB
4 months ago
|
<?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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|