询单与crm消息通知
This commit is contained in:
@@ -56,28 +56,54 @@ class InquiryToCrmNew implements Consumer
|
||||
|
||||
// 更改库信息
|
||||
$this->syncCustomer($info);
|
||||
|
||||
$wsdata = [
|
||||
'sender_id' => 0,
|
||||
'sender_type' => 'system',
|
||||
'title' => '有新的客户线索,' . $info->order_no . ',请及时处理',
|
||||
'content' => '有新的客户线索,' . $info->order_no . ',请及时处理',
|
||||
'scene' => 1,
|
||||
'recipient' => [$info->recipient]
|
||||
];
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $wsdata);
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
}
|
||||
}
|
||||
|
||||
public function pushWs($title, $content, $recipient)
|
||||
{
|
||||
$wsdata = [
|
||||
'sender_id' => 0,
|
||||
'sender_type' => 'system',
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'scene' => 1,
|
||||
'recipient' => $recipient
|
||||
];
|
||||
// 异步推送
|
||||
\Webman\RedisQueue\Redis::send('notice', $wsdata);
|
||||
}
|
||||
|
||||
public function syncCustomer(Model $info)
|
||||
{
|
||||
$uInfo = $this->recipientInfo($info);
|
||||
$crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first();
|
||||
if ($crmCustomerInfo) {
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 2 && empty($crmCustomerInfo->user_id)) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配]新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配]新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) {
|
||||
// $notice = '更新';
|
||||
$title = '[询单·更新]客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$content = '[询单·更新]客户线索' . $info->order_no . '有新的调整,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
} else {
|
||||
// $notice = '重新分配';
|
||||
$title = '[询单·分配]新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配]新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
|
||||
$udata = [
|
||||
'corp_abbr' => $uInfo['corpId'],
|
||||
'user_id' => $info->recipient,
|
||||
@@ -115,6 +141,23 @@ class InquiryToCrmNew implements Consumer
|
||||
if (!$crmCustomer->save() || !$info->save()) {
|
||||
throw new BusinessException('同步失败,创建客户线索失败');
|
||||
}
|
||||
|
||||
// 消息推送
|
||||
if ($info->status == 1) {
|
||||
// $notice = '发布';
|
||||
$title = '[询单·公海]新的客户线索【' . $info->order_no . '】发布';
|
||||
$content = '[询单·公海]新的客户线索【' . $info->order_no . '】发布';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
|
||||
if ($info->status == 2) {
|
||||
// $notice = '分配';
|
||||
$title = '[询单·分配]新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$content = '[询单·分配]新的客户线索【' . $info->order_no . '】,请及时处理';
|
||||
$recipient = [$info->recipient];
|
||||
$this->pushWs($title, $content, $recipient);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user