|
@@ -231,28 +231,47 @@ class FollowUpRecordService extends Service
|
|
|
if(empty($customer_id)){
|
|
|
if(empty($data['model_type'])) return [false,'客户模板类型不能为空'];
|
|
|
if(! in_array($data['model_type'],Customer::$model_type)) return [false,'客户模板类型错误'];
|
|
|
- }
|
|
|
-
|
|
|
- $bool = Customer::where('del_time',0)
|
|
|
- ->when(! empty($customer_id), function ($query) use ($customer_id) {
|
|
|
- return $query->where('id', '<>',$customer_id);
|
|
|
- })
|
|
|
- ->where('top_depart_id',$data['top_depart_id'])
|
|
|
- ->where('title', $data['customer_title'])
|
|
|
- ->exists();
|
|
|
- if($bool) return [false,'客户名称在该门店下已存在'];
|
|
|
|
|
|
- $boolean = CustomerInfo::from('customer_info as a')
|
|
|
- ->join('customer as b','b.id','a.customer_id')
|
|
|
- ->when(! empty($customer_id), function ($query) use ($customer_id) {
|
|
|
- return $query->where('b.id', '<>',$customer_id);
|
|
|
- })
|
|
|
- ->where('a.del_time',0)
|
|
|
- ->where('b.del_time',0)
|
|
|
- ->where('b.top_depart_id',$data['top_depart_id'])
|
|
|
- ->where('a.contact_info', $data['customer_contact'])
|
|
|
- ->exists();
|
|
|
- if($boolean) return [false,'客户联系内容已存在'];
|
|
|
+ $order = Customer::where('del_time',0)
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('title', $data['customer_title'])
|
|
|
+ ->first();
|
|
|
+ if(! empty($order)){
|
|
|
+ $order = $order->toArray();
|
|
|
+ $data['customer_id'] = $order['id'];
|
|
|
+
|
|
|
+ $info = CustomerInfo::from('customer_info as a')
|
|
|
+ ->join('customer as b','b.id','a.customer_id')
|
|
|
+ ->where('a.del_time',0)
|
|
|
+ ->where('b.del_time',0)
|
|
|
+ ->where('b.top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('a.contact_info', $data['customer_contact'])
|
|
|
+ ->select("a.id","a.customer_id")
|
|
|
+ ->first();
|
|
|
+ if(! empty($info)){
|
|
|
+ $info = $info->toArray();
|
|
|
+ if($info['customer_id'] != $data['customer_id']) return [false,'客户联系方式已存在'];
|
|
|
+ $data['customer_contact_id'] = $info['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $bool = Customer::where('del_time',0)
|
|
|
+ ->where('id', '<>',$customer_id)
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('title', $data['customer_title'])
|
|
|
+ ->exists();
|
|
|
+ if($bool) return [false,'客户名称在该门店下已存在'];
|
|
|
+
|
|
|
+ $boolean = CustomerInfo::from('customer_info as a')
|
|
|
+ ->join('customer as b','b.id','a.customer_id')
|
|
|
+ ->where('b.id', '<>',$customer_id)
|
|
|
+ ->where('a.del_time',0)
|
|
|
+ ->where('b.del_time',0)
|
|
|
+ ->where('b.top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('a.contact_info', $data['customer_contact'])
|
|
|
+ ->exists();
|
|
|
+ if($boolean) return [false,'客户联系方式已存在'];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if($this->isEmpty($data,'basic_type_id')) return [false,'跟进方式不能为空'];
|
|
@@ -431,7 +450,7 @@ class FollowUpRecordService extends Service
|
|
|
return [false, $exception->getFile() . $exception->getMessage() . $exception->getLine()];
|
|
|
}
|
|
|
|
|
|
- file_put_contents('follow_record.txt',date("Y-m-d H:i:s") . "请求参数:" . json_encode($data) . '操作人:' .$user['id'] . '|' .$user['emp_name'] . PHP_EOL,8);
|
|
|
+// file_put_contents('follow_record.txt',date("Y-m-d H:i:s") . "请求参数:" . json_encode($data) . '操作人:' .$user['id'] . '|' .$user['emp_name'] . PHP_EOL,8);
|
|
|
|
|
|
return [true, ['is_batch' => true, 'file' => ['new' => array_values($new)]]];
|
|
|
}
|
|
@@ -459,28 +478,48 @@ class FollowUpRecordService extends Service
|
|
|
if(empty($customer_id)){
|
|
|
if(empty($data['model_type'])) return [false,'客户模板类型不能为空'];
|
|
|
if(! in_array($data['model_type'],Customer::$model_type)) return [false,'客户模板类型错误'];
|
|
|
- }
|
|
|
|
|
|
- $bool = Customer::where('del_time',0)
|
|
|
- ->when(! empty($customer_id), function ($query) use ($customer_id) {
|
|
|
- return $query->where('id', '<>',$customer_id);
|
|
|
- })
|
|
|
- ->where('top_depart_id',$data['top_depart_id'])
|
|
|
- ->where('title', $data['customer_title'])
|
|
|
- ->exists();
|
|
|
- if($bool) return [false,'客户名称在该门店下已存在'];
|
|
|
-
|
|
|
- $boolean = CustomerInfo::from('customer_info as a')
|
|
|
- ->join('customer as b','b.id','a.customer_id')
|
|
|
- ->when(! empty($customer_id), function ($query) use ($customer_id) {
|
|
|
- return $query->where('b.id', '<>',$customer_id);
|
|
|
- })
|
|
|
- ->where('a.del_time',0)
|
|
|
- ->where('b.del_time',0)
|
|
|
- ->where('b.top_depart_id',$data['top_depart_id'])
|
|
|
- ->where('a.contact_info', $data['customer_contact'])
|
|
|
- ->exists();
|
|
|
- if($boolean) return [false,'客户联系方式已存在'];
|
|
|
+ $order = Customer::where('del_time',0)
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('title', $data['customer_title'])
|
|
|
+ ->first();
|
|
|
+ if(! empty($order)){
|
|
|
+ $order = $order->toArray();
|
|
|
+ $data['customer_id'] = $order['id'];
|
|
|
+
|
|
|
+ $info = CustomerInfo::from('customer_info as a')
|
|
|
+ ->join('customer as b','b.id','a.customer_id')
|
|
|
+ ->where('a.del_time',0)
|
|
|
+ ->where('b.del_time',0)
|
|
|
+ ->where('b.top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('a.contact_info', $data['customer_contact'])
|
|
|
+ ->select("a.id","a.customer_id")
|
|
|
+ ->first();
|
|
|
+ if(! empty($info)){
|
|
|
+ $info = $info->toArray();
|
|
|
+ if($info['customer_id'] != $data['customer_id']) return [false,'客户联系方式已存在'];
|
|
|
+ $data['customer_contact_id'] = $info['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $bool = Customer::where('del_time',0)
|
|
|
+ ->where('id', '<>',$customer_id)
|
|
|
+ ->where('top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('title', $data['customer_title'])
|
|
|
+ ->exists();
|
|
|
+ if($bool) return [false,'客户名称在该门店下已存在'];
|
|
|
+
|
|
|
+ $boolean = CustomerInfo::from('customer_info as a')
|
|
|
+ ->join('customer as b','b.id','a.customer_id')
|
|
|
+ ->where('b.id', '<>',$customer_id)
|
|
|
+ ->where('a.del_time',0)
|
|
|
+ ->where('b.del_time',0)
|
|
|
+ ->where('b.top_depart_id',$data['top_depart_id'])
|
|
|
+ ->where('a.contact_info', $data['customer_contact'])
|
|
|
+ ->exists();
|
|
|
+ if($boolean) return [false,'客户联系方式已存在'];
|
|
|
+ }
|
|
|
|
|
|
if($this->isEmpty($data,'basic_type_id')) return [false,'跟进方式不能为空'];
|
|
|
if($this->isEmpty($data,'visit_time')) return [false,'拜访时间不能为空'];
|