客户重复通知

This commit is contained in:
2025-08-26 09:29:46 +08:00
parent 958f4448d6
commit e031c6dbd5
4 changed files with 52 additions and 15 deletions
+26 -10
View File
@@ -322,24 +322,40 @@ class CustomerService
public function distinct($params,$corpId){
$customer = Customer::Orwhere('email', '=', $params['email'])
$customer = Customer::where('corp_id',$corpId)
->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'];
// if($corpId != $customer->corp_id){
// return false;
// }
return $customer;
}
return false;
}
/**
* 客户重复通知
* @param $params
* @param $corpId
* @return Customer|false|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object
*/
public function distinctNotice($customer_id){
$customer = Customer::where('id', $customer_id)
->first();
if (!empty($customer)) {
$contacts = $customer->contacts??$customer['phone'];
$contacts = $contacts??$customer['whatsApp'];
$contacts = $contacts??$customer['email'];
$data = [
'sender_id' => 0, //发送人ID 0默认系统
'sender_type' => 'system', //发送者类型 user admin system
'title' => '客户跟进提醒 - ' . $contacts, //标题
'content' => $contacts . '有新的询单,请及时跟进', //内容
'content' => $contacts . ' 产生了新的询单,请及时跟进', //内容
'scene' => 1, //场景 0系统公共 1系统通知
'recipient' => [$customer->user_id], //接收人 空为全部
'push_method' => 0 //推送方式0系统推送1手动推送
@@ -347,7 +363,7 @@ class CustomerService
// 异步推送
\Webman\RedisQueue\Redis::send('notice', $data);
return true;
return $customer;
}
return false;
}