飞书消息推送
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\inquiry\service\InquiryLogService;
|
||||
use app\common\model\CrmCustomer;
|
||||
use app\common\model\InquiryLog;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
use app\common\model\User;
|
||||
use app\common\utils\FeishuMessage;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
class InquiryToCrm implements Consumer
|
||||
@@ -21,7 +23,7 @@ class InquiryToCrm implements Consumer
|
||||
{
|
||||
try {
|
||||
// 获取询盘信息
|
||||
$info = InquiryLog::where('id', $data['id'])->where('sync_crm', 0)->first();
|
||||
$info = InquiryLog::with(['channelInfo', 'countryInfo', 'enter'])->where('id', $data['id'])->where('sync_crm', 0)->first();
|
||||
if ($info) {
|
||||
// 获取用户信息
|
||||
$recipient = 0;
|
||||
@@ -32,6 +34,13 @@ class InquiryToCrm implements Consumer
|
||||
if ($uinfo) {
|
||||
$corpId = $uinfo->corp_id;
|
||||
}
|
||||
// 消息推送参数 分配
|
||||
$scene = 'inquiry-person-allocation';
|
||||
$receiveType = 'person';
|
||||
} else {
|
||||
// 消息推送参数 发布
|
||||
$scene = 'inquiry-group-send';
|
||||
$receiveType = 'group';
|
||||
}
|
||||
// 同步客户数据
|
||||
$crmCustomer = new CrmCustomer();
|
||||
@@ -54,6 +63,15 @@ class InquiryToCrm implements Consumer
|
||||
if (!$crmCustomer->save() || !$info->save()) {
|
||||
throw new BusinessException('同步失败~');
|
||||
}
|
||||
|
||||
// 发送飞书消息
|
||||
$options = [
|
||||
'id' => $info->id,
|
||||
'category' => 'inquiry',
|
||||
'scene' => $scene,
|
||||
'receive_type' => $receiveType
|
||||
];
|
||||
\Webman\RedisQueue\Redis::send('feishu-message', $options);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
|
||||
Reference in New Issue
Block a user