客户重复检测

This commit is contained in:
2025-08-25 18:13:16 +08:00
parent 97e19834fd
commit 7b280afd72
5 changed files with 53 additions and 6 deletions
+32
View File
@@ -319,4 +319,36 @@ class CustomerService
return $customer;
}
public function distinct($params,$corpId){
$customer = Customer::Orwhere('email', '=', $params['email'])
->Orwhere('phone', '=', $params['phone'])
->Orwhere('whatsApp', '=', $params['whatsApp'])
->first();
if (!empty($customer)) {
//客户重复,消息通知
$user = User::where('id', $customer->user_id)->first();
if($corpId != $customer->corp_id){
return false;
}
$contacts = $customer->contacts??$params['phone'];
$contacts = $contacts??$params['whatsApp'];
$contacts = $contacts??$params['email'];
$data = [
'sender_id' => 0, //发送人ID 0默认系统
'sender_type' => 'system', //发送者类型 user admin system
'title' => '客户跟进提醒 - ' . $contacts, //标题
'content' => $contacts . '有新的询单,请及时跟进', //内容
'scene' => 1, //场景 0系统公共 1系统通知
'recipient' => [$customer->user_id], //接收人 空为全部
'push_method' => 0 //推送方式0系统推送1手动推送
];
// 异步推送
\Webman\RedisQueue\Redis::send('notice', $data);
return true;
}
return false;
}
}