cqpCow 11 months ago
parent
commit
4e77e6fa1b
2 changed files with 13 additions and 4 deletions
  1. 7 2
      app/Service/CustomerService.php
  2. 6 2
      app/Service/DeleteService.php

+ 7 - 2
app/Service/CustomerService.php

@@ -500,7 +500,7 @@ 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','fp_time')
+            ->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')
             ->orderby('id', 'desc');
 
         if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
@@ -575,7 +575,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')
+            ->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')
             ->orderby('id', 'desc')
             ->orderby('fp_time', 'desc');
 
@@ -812,6 +812,9 @@ class CustomerService extends Service
             }
         }
 
+        $array2 = array_unique(array_merge_recursive(array_column($data['data'],'top_depart_id'),array_column($data['data'],'fp_top_depart_id')));
+        $depart = Depart::whereIn('id',$array2)->pluck('title','id')->toArray();
+
         $address_map = config('address');
         foreach ($data['data'] as $key => $value){
             $address_str = [];
@@ -845,6 +848,8 @@ class CustomerService extends Service
             $data['data'][$key]['has_record'] = $record_tmp ? "查看" : "无记录";
             $data['data'][$key]['follow_record'] = $record_array[$value['id']] ?? "";
             $data['data'][$key]['order_number'] = Customer::$order_number . "|" . $value['id'] . "|" . $value['title'];
+            $data['data'][$key]['top_depart_title'] = $depart[$value['top_depart_id']] ?? "";
+            $data['data'][$key]['fp_top_depart_title'] = $depart[$value['fp_top_depart_id']] ?? "";
         }
 
         return $data;

+ 6 - 2
app/Service/DeleteService.php

@@ -178,6 +178,7 @@ class DeleteService extends Service
 
             CustomerInfo::insert($insert);
 
+            $fp_top_depart_id = $data['fp_top_depart_id'] ?? 0;
             if(! is_array($data['id'])){
                 $title = Customer::where('id',$data['id'])->value('title') ?? "";
                 (new OrderOperationService())->add([
@@ -185,7 +186,7 @@ class DeleteService extends Service
                     'msg' => OrderOperation::$type[OrderOperation::twenty_three] ?? "",
                     'type' => OrderOperation::twenty_three
                 ],$user);
-                Customer::where('id',$data['id'])->update(['fp_time' => $time]);
+                Customer::where('id',$data['id'])->update(['fp_time' => $time, 'fp_top_depart_id' => $fp_top_depart_id]);
             }else{
                 $title = Customer::whereIn('id',$data['id'])->pluck('title','id')->toArray();
                 foreach($data['id'] as $value){
@@ -196,7 +197,7 @@ class DeleteService extends Service
                         'type' => OrderOperation::twenty_three
                     ],$user);
                 }
-                Customer::whereIn('id',$data['id'])->update(['fp_time' => $time]);
+                Customer::whereIn('id',$data['id'])->update(['fp_time' => $time,'fp_top_depart_id' => $fp_top_depart_id]);
             }
 
 //            foreach ($data['man'] as $value){
@@ -293,6 +294,7 @@ class DeleteService extends Service
             }
             CustomerInfo::insert($insert);
 
+            $fp_top_depart_id = $data['fp_top_depart_id'] ?? 0;
             if(! is_array($data['id'])){
                 $title = Customer::where('id',$data['id'])->value('title') ?? "";
                 (new OrderOperationService())->add([
@@ -300,6 +302,7 @@ class DeleteService extends Service
                     'msg' => OrderOperation::$type[OrderOperation::twenty_four] ?? "",
                     'type' => OrderOperation::twenty_four
                 ],$user);
+                Customer::where('id',$data['id'])->update(['fp_time' => $time, 'fp_top_depart_id' => $fp_top_depart_id]);
             }else{
                 $title = Customer::whereIn('id',$data['id'])->pluck('title','id')->toArray();
                 foreach($data['id'] as $value){
@@ -310,6 +313,7 @@ class DeleteService extends Service
                         'type' => OrderOperation::twenty_four
                     ],$user);
                 }
+                Customer::whereIn('id',$data['id'])->update(['fp_time' => $time,'fp_top_depart_id' => $fp_top_depart_id]);
             }
         }
     }