查询客户是否重复

This commit is contained in:
2025-08-26 16:11:55 +08:00
parent e031c6dbd5
commit 0f075a81f6
2 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -307,7 +307,7 @@ class CustomerController extends BaseController
$email = Util::getParam($request, 'email');
$phone = Util::getParam($request, 'phone');
$whatsApp = Util::getParam($request, 'WhatsApp', '');
if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone)) {
if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone) && Util::isEmpty($whatsApp)) {
return $this->error(trans('contacts_not_null'));
}
+17 -3
View File
@@ -15,6 +15,7 @@ use app\crm\model\CustomerHis;
use app\crm\model\Follow;
use app\crm\utils\Util;
use config\constants\Constants;
use Illuminate\Database\Eloquent\Builder;
use support\Request;
/**
@@ -320,13 +321,26 @@ class CustomerService
return $customer;
}
/**
* 查询客户关系是否重复
*/
public function distinct($params,$corpId){
$customer = Customer::where('corp_id',$corpId)
->Orwhere('email', '=', $params['email'])
->Orwhere('phone', '=', $params['phone'])
->Orwhere('whatsApp', '=', $params['whatsApp'])
->where((function (Builder $query) use ($params) {
if(!empty($params['email']))
$query->Orwhere('email', '=', $params['email']);
if(!empty($params['phone']))
$query->Orwhere('phone', '=', $params['phone']);
if(!empty($params['whatsApp']))
$query->Orwhere('whatsApp', '=', $params['whatsApp']);
// $query->where('email', '=', $params['email'])
// ->Orwhere('phone', '=', $params['phone'])
// ->Orwhere('whatsApp', '=', $params['whatsApp']);
return $query;
}))
->first();
if (!empty($customer)) {
//客户重复,消息通知
// if($corpId != $customer->corp_id){