|
@@ -500,9 +500,13 @@ class CustomerService extends Service
|
|
|
public function customerList($data,$user){
|
|
|
$model = Customer::Clear($user,$data);
|
|
|
$model = $model->where('del_time',0)
|
|
|
- ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','pond_state','top_depart_id','code')
|
|
|
+ ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','pond_state','top_depart_id','fp_time')
|
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
+ if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
|
|
|
+ $id = $this->getCustomerId($data,$user);
|
|
|
+ $model->whereIn('id',$id);
|
|
|
+ }
|
|
|
if(! empty($data['pond_state'])) {
|
|
|
$search_depart_id = $data['top_depart_id'] ?? 0; //顶级公司
|
|
|
if(empty($search_depart_id)){
|
|
@@ -567,6 +571,93 @@ class CustomerService extends Service
|
|
|
return [true, $list];
|
|
|
}
|
|
|
|
|
|
+ public function customerList2($data,$user){
|
|
|
+ $model = Customer::Clear($user,$data);
|
|
|
+ $model = $model->where('del_time',0)
|
|
|
+ ->where('fp_time','>',0)
|
|
|
+ ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','pond_state','top_depart_id','fp_time')
|
|
|
+ ->orderby('id', 'desc')
|
|
|
+ ->orderby('fp_time', 'desc');
|
|
|
+
|
|
|
+ if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
|
|
|
+ $id = $this->getCustomerId($data,$user);
|
|
|
+ $model->whereIn('id',$id);
|
|
|
+ }
|
|
|
+ if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
+ if(! empty($data['time_type'])) {
|
|
|
+ if($data['time_type'] == 1) {
|
|
|
+ $start = strtotime('today');
|
|
|
+ $end = strtotime('tomorrow') - 1;
|
|
|
+ }elseif ($data['time_type'] == 2){
|
|
|
+ $start = strtotime('this week',strtotime('today'));
|
|
|
+ $end = strtotime('this week +6 days 23:59:59', strtotime('today'));
|
|
|
+ }
|
|
|
+ if(! empty($start) && ! empty($end)) {
|
|
|
+ $model->where('crt_time','>=',$start);
|
|
|
+ $model->where('crt_time','<=',$end);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(! empty($data['model_type'])) $model->where('model_type',$data['model_type']);
|
|
|
+ if(! empty($data['consulting_product'])) $model->where('consulting_product','LIKE', '%'.$data['consulting_product'].'%');
|
|
|
+ if(! empty($data['mark'])) $model->where('mark','LIKE', '%'.$data['mark'].'%');
|
|
|
+ if(! empty($data['customer_intention'])) $model->where('customer_intention',$data['customer_intention']);
|
|
|
+ if(! empty($data['customer_from'])) $model->where('customer_from',$data['customer_from']);
|
|
|
+ if(! empty($data['customer_type'])) $model->where('customer_type',$data['customer_type']);
|
|
|
+ if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
|
|
|
+ $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|
|
|
+ $model->where('crt_time','>=',$return[0]);
|
|
|
+ $model->where('crt_time','<=',$return[1]);
|
|
|
+ }
|
|
|
+ if(! empty($data['crt_name'])){
|
|
|
+ $id = (new RangeService())->crtNameSearch($data);
|
|
|
+ $model->whereIn('crt_id',$id);
|
|
|
+ }
|
|
|
+ if(! empty($data['fz'])){
|
|
|
+ $id = (new RangeService())->customerSearch($data);
|
|
|
+ $model->whereIn('id',$id);
|
|
|
+ }
|
|
|
+ if(! empty($data['last_visit_time'])){
|
|
|
+ $id = (new FollowUpRecordService())->getLastVisitData($data['last_visit_time']);
|
|
|
+ $model->whereIn('id',$id);
|
|
|
+ }
|
|
|
+ if(! empty($data['contact_info'])){
|
|
|
+ $customer_info = CustomerInfo::where('del_time',0)
|
|
|
+ ->where("type",CustomerInfo::type_one)
|
|
|
+ ->where('contact_info','LIKE', '%'.$data['contact_info'].'%')
|
|
|
+ ->select('customer_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('id',array_column($customer_info,'customer_id'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
+ $list = $this->fillData($list,$data);
|
|
|
+
|
|
|
+ return [true, $list];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCustomerId($data,$user){
|
|
|
+ $return = [];
|
|
|
+ if(! empty($data['my_fz'])){
|
|
|
+ $info = CustomerInfo::where('del_time',0)
|
|
|
+ ->where('data_id',$user['id'])
|
|
|
+ ->where('type',CustomerInfo::type_two)
|
|
|
+ ->select('customer_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $return = array_unique(array_column($info,'customer_id'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(! empty($data['my_xt'])){
|
|
|
+ $info = CustomerInfo::where('del_time',0)
|
|
|
+ ->where('data_id',$user['id'])
|
|
|
+ ->where('type',CustomerInfo::type_three)
|
|
|
+ ->select('customer_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $return = array_unique(array_column($info,'customer_id'));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 客户参数规则
|
|
|
* @param $data
|
|
@@ -690,7 +781,6 @@ class CustomerService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
$customer_info = CustomerInfo::where('del_time',0)
|
|
|
->whereIn('customer_id',array_column($data['data'],'id'))
|
|
|
->whereIn('type',[CustomerInfo::type_one,CustomerInfo::type_two])
|