查询客户是否重复
This commit is contained in:
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user