查询客户是否重复
This commit is contained in:
@@ -307,7 +307,7 @@ class CustomerController extends BaseController
|
|||||||
$email = Util::getParam($request, 'email');
|
$email = Util::getParam($request, 'email');
|
||||||
$phone = Util::getParam($request, 'phone');
|
$phone = Util::getParam($request, 'phone');
|
||||||
$whatsApp = Util::getParam($request, 'WhatsApp', '');
|
$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'));
|
return $this->error(trans('contacts_not_null'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use app\crm\model\CustomerHis;
|
|||||||
use app\crm\model\Follow;
|
use app\crm\model\Follow;
|
||||||
use app\crm\utils\Util;
|
use app\crm\utils\Util;
|
||||||
use config\constants\Constants;
|
use config\constants\Constants;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,13 +321,26 @@ class CustomerService
|
|||||||
return $customer;
|
return $customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询客户关系是否重复
|
||||||
|
*/
|
||||||
public function distinct($params,$corpId){
|
public function distinct($params,$corpId){
|
||||||
|
|
||||||
$customer = Customer::where('corp_id',$corpId)
|
$customer = Customer::where('corp_id',$corpId)
|
||||||
->Orwhere('email', '=', $params['email'])
|
->where((function (Builder $query) use ($params) {
|
||||||
->Orwhere('phone', '=', $params['phone'])
|
if(!empty($params['email']))
|
||||||
->Orwhere('whatsApp', '=', $params['whatsApp'])
|
$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();
|
->first();
|
||||||
|
|
||||||
if (!empty($customer)) {
|
if (!empty($customer)) {
|
||||||
//客户重复,消息通知
|
//客户重复,消息通知
|
||||||
// if($corpId != $customer->corp_id){
|
// if($corpId != $customer->corp_id){
|
||||||
|
|||||||
Reference in New Issue
Block a user