|
@@ -441,20 +441,20 @@ class CustomerService extends Service
|
|
|
$customer['customer_contact'][] = $tmp;
|
|
|
}elseif ($value['type'] == CustomerInfo::type_two){
|
|
|
$tmp = [
|
|
|
- 'id' => $value['employee_id'],
|
|
|
- 'name' => $emp_map[$value['employee_id']] ?? '',
|
|
|
+ 'id' => $value['data_id'],
|
|
|
+ 'name' => $emp_map[$value['data_id']] ?? '',
|
|
|
];
|
|
|
$customer['employee_one'][] = $tmp;
|
|
|
}elseif ($value['type'] == CustomerInfo::type_three){
|
|
|
$tmp = [
|
|
|
- 'id' => $value['employee_id'],
|
|
|
- 'name' => $emp_map[$value['employee_id']] ?? '',
|
|
|
+ 'id' => $value['data_id'],
|
|
|
+ 'name' => $emp_map[$value['data_id']] ?? '',
|
|
|
];
|
|
|
$customer['employee_two'][] = $tmp;
|
|
|
}elseif ($value['type'] == CustomerInfo::type_four){
|
|
|
$tmp = [
|
|
|
- 'id' => $value['employee_id'],
|
|
|
- 'name' => $emp_map[$value['employee_id']] ?? '',
|
|
|
+ 'id' => $value['data_id'],
|
|
|
+ 'name' => $emp_map[$value['data_id']] ?? '',
|
|
|
];
|
|
|
$customer['employee_three'][] = $tmp;
|
|
|
}elseif ($value['type'] == CustomerInfo::type_five){
|
|
@@ -471,14 +471,14 @@ class CustomerService extends Service
|
|
|
$customer['file'][] = $tmp;
|
|
|
}elseif ($value['type'] == CustomerInfo::type_seven){
|
|
|
$tmp = [
|
|
|
- 'id' => $value['depart_id'],
|
|
|
- 'name' => $depart_map[$value['depart_id']],
|
|
|
+ 'id' => $value['data_id'],
|
|
|
+ 'name' => $depart_map[$value['data_id']],
|
|
|
];
|
|
|
$customer['depart'][] = $tmp;
|
|
|
}elseif ($value['type'] == CustomerInfo::type_eight){
|
|
|
$tmp = [
|
|
|
- 'id' => $value['employee_id'],
|
|
|
- 'name' => $emp_map[$value['employee_id']] ?? '',
|
|
|
+ 'id' => $value['data_id'],
|
|
|
+ 'name' => $emp_map[$value['data_id']] ?? '',
|
|
|
];
|
|
|
$customer['employee'][] = $tmp;
|
|
|
}
|
|
@@ -631,4 +631,60 @@ class CustomerService extends Service
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ //抢客户
|
|
|
+ public function customerGrabbing($data, $user){
|
|
|
+ $key = Customer::$limitKey . $data['customer_id'];
|
|
|
+ list($status,$msg) = $this->customerGrabbingRule($data,$key);
|
|
|
+ if(! $status) return [false,$msg];
|
|
|
+
|
|
|
+ try {
|
|
|
+ DB::beginTransaction();
|
|
|
+ $time = time();
|
|
|
+
|
|
|
+ //销售/负责/协同人清空
|
|
|
+ CustomerInfo::where('del_time',0)
|
|
|
+ ->where('customer_id',$data['customer_id'])
|
|
|
+ ->whereIn('type', CustomerInfo::$man2)
|
|
|
+ ->update(['del_time' => $time]);
|
|
|
+ //增加自己为负责人
|
|
|
+ $insert[] = [
|
|
|
+ 'customer_id' => $data['customer_id'],
|
|
|
+ 'data_id' => $user['id'],
|
|
|
+ 'type' => CustomerInfo::type_two,
|
|
|
+ 'crt_time' => $time
|
|
|
+ ];
|
|
|
+ CustomerInfo::insert($insert);
|
|
|
+ Customer::where('id',$data['customer_id'])->update([
|
|
|
+ 'pond_state' => 0
|
|
|
+ ]);
|
|
|
+
|
|
|
+ DB::commit();
|
|
|
+ }catch (\Exception $exception){
|
|
|
+ //释放锁
|
|
|
+ $this->dellimitingSendRequestBackg($key);
|
|
|
+
|
|
|
+ DB::rollBack();
|
|
|
+ return [false,$exception->getMessage()];
|
|
|
+ }
|
|
|
+
|
|
|
+ //释放锁
|
|
|
+ $this->dellimitingSendRequestBackg($key);
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function customerGrabbingRule($data, $key){
|
|
|
+ if(empty($data['customer_id'])) return [false,'请选择客户'];
|
|
|
+ //上锁
|
|
|
+ list($status,$msg) = $this->limitingSendRequestBackg($key);
|
|
|
+ if(! $status) return [false,$msg];
|
|
|
+
|
|
|
+ $customer = Customer::where('del_time',0)->where('id',$data['customer_id'])->first();
|
|
|
+ if(empty($customer)) return [false,'客户不存在或已被删除'];
|
|
|
+ $customer = $customer->toArray();
|
|
|
+ if(empty($customer['pond_state'])) return [false,'客户已退出公海池'];
|
|
|
+
|
|
|
+ return [true,''];
|
|
|
+ }
|
|
|
}
|