From 0f075a81f6c8316b9e063474c2f6f07e567146c6 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 26 Aug 2025 16:11:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=AE=A2=E6=88=B7=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/crm/controller/CustomerController.php | 2 +- app/crm/service/CustomerService.php | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/crm/controller/CustomerController.php b/app/crm/controller/CustomerController.php index 104eae5..5f3638a 100644 --- a/app/crm/controller/CustomerController.php +++ b/app/crm/controller/CustomerController.php @@ -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')); } diff --git a/app/crm/service/CustomerService.php b/app/crm/service/CustomerService.php index fc1215c..ee4b695 100644 --- a/app/crm/service/CustomerService.php +++ b/app/crm/service/CustomerService.php @@ -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){