|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Service;
|
|
|
|
|
|
use App\Model\BasicType;
|
|
|
+use App\Model\BasicTypeAllUse;
|
|
|
use App\Model\Customer;
|
|
|
use App\Model\CustomerInfo;
|
|
|
use App\Model\CustomerRepeat;
|
|
@@ -60,6 +61,7 @@ class CustomerService extends Service
|
|
|
$model->customer_type = $data['customer_type'] ?? 0;
|
|
|
$model->car_type = $data['car_type'] ?? 0;
|
|
|
$model->consulting_product = $data['consulting_product'] ?? '';
|
|
|
+ $model->consulting_product_new = $data['consulting_product_new'] ?? 0;
|
|
|
$model->intention_product = $data['intention_product'] ?? 0;
|
|
|
$model->progress_stage = $data['progress_stage'] ?? 0;
|
|
|
$model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
|
|
@@ -224,6 +226,7 @@ class CustomerService extends Service
|
|
|
$model->customer_type = $data['customer_type'] ?? 0;
|
|
|
$model->car_type = $data['car_type'] ?? 0;
|
|
|
$model->consulting_product = $data['consulting_product'] ?? '';
|
|
|
+ $model->consulting_product_new = $data['consulting_product_new'] ?? 0;
|
|
|
$model->intention_product = $data['intention_product'] ?? 0;
|
|
|
$model->progress_stage = $data['progress_stage'] ?? 0;
|
|
|
$model->address1 = ! empty($data['address1']) ? json_encode($data['address1']) : '';
|
|
@@ -398,6 +401,9 @@ class CustomerService extends Service
|
|
|
$customer['is_belong_to_main'] = $is_main;
|
|
|
$customer['order_number'] = Customer::$order_number . "|" . $data['id'] . "|" . $customer['title'];
|
|
|
$customer['intention_product_title'] = Product::where('id',$customer['intention_product'])->value('title') ?? "";
|
|
|
+ $customer['consulting_product_new_title'] = BasicTypeAllUse::where('id',$customer['consulting_product_new'])
|
|
|
+ ->where('type', BasicTypeAllUse::type_one)
|
|
|
+ ->value('title') ?? "";
|
|
|
$customer['product_category'] = [];
|
|
|
if(! empty($customer['intention_product'])){
|
|
|
$pro = (new ProductService())->getProductDetail([$customer['intention_product']]);
|
|
@@ -525,7 +531,7 @@ class CustomerService extends Service
|
|
|
|
|
|
public function customerCommonSearch($data,$user, $field = []){
|
|
|
if(empty($field)){
|
|
|
- $field = ['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','fp_top_depart_id','enter_time'];
|
|
|
+ $field = ['title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','consulting_product_new','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','fp_top_depart_id','enter_time'];
|
|
|
}
|
|
|
$model = Customer::Clear($user,$data);
|
|
|
$model = $model->where('del_time',0)
|
|
@@ -579,6 +585,7 @@ class CustomerService extends Service
|
|
|
}
|
|
|
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['consulting_product_new'])) $model->where('consulting_product_new',$data['consulting_product_new']);
|
|
|
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']);
|
|
@@ -587,6 +594,10 @@ class CustomerService extends Service
|
|
|
$id = (new RangeService())->customerBasicTypeSearch($data['customer_intention_title'],[1]);
|
|
|
$model->whereIn('customer_intention', $id);
|
|
|
}
|
|
|
+ if(! empty($data['consulting_product_new_title'])) {
|
|
|
+ $id = (new RangeService())->customerBasicTypeAllUseSearch($data['customer_from_title'],[BasicTypeAllUse::type_one]);
|
|
|
+ $model->whereIn('consulting_product_new', $id);
|
|
|
+ }
|
|
|
if(! empty($data['customer_from_title'])){
|
|
|
$id = (new RangeService())->customerBasicTypeSearch($data['customer_from_title'],[2]);
|
|
|
$model->whereIn('customer_from', $id);
|
|
@@ -709,7 +720,7 @@ class CustomerService extends Service
|
|
|
$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','fp_top_depart_id','enter_time')
|
|
|
+ ->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','consulting_product_new','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','fp_top_depart_id','enter_time')
|
|
|
->orderby('fp_time', 'desc');
|
|
|
|
|
|
if(! empty($data['customer_id'])){
|
|
@@ -1045,6 +1056,10 @@ class CustomerService extends Service
|
|
|
$basic_map = BasicType::whereIn('id',$array)
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
+ $basic_all_map = BasicTypeAllUse::where('type', BasicTypeAllUse::type_one)
|
|
|
+ ->whereIn('id',array_unique(array_column($data['data'],'consulting_product_new')))
|
|
|
+ ->pluck('title','id')
|
|
|
+ ->toArray();
|
|
|
$depart_title = Depart::where('id',array_unique(array_column($data['data'],'depart_id')))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
@@ -1130,6 +1145,7 @@ class CustomerService extends Service
|
|
|
$data['data'][$key]['customer_type_title'] = $basic_map[$value['customer_type']] ?? '';
|
|
|
$data['data'][$key]['car_type_title'] = $basic_map[$value['car_type']] ?? '';
|
|
|
$data['data'][$key]['intention_product_title'] = $product[$value['intention_product']] ?? '';
|
|
|
+ $data['data'][$key]['consulting_product_new_title'] = $basic_all_map[$value['consulting_product_new']] ?? '';
|
|
|
$data['data'][$key]['progress_stage_title'] = $basic_map[$value['progress_stage']] ?? '';
|
|
|
$data['data'][$key]['state_type_title'] = $basic_map[$value['state_type']] ?? '';
|
|
|
$data['data'][$key]['customer_state_title'] = $basic_map[$value['customer_state']] ?? '';
|