cqpCow 1 jaar geleden
bovenliggende
commit
f16b58446c
1 gewijzigde bestanden met toevoegingen van 8 en 4 verwijderingen
  1. 8 4
      app/Service/CustomerService.php

+ 8 - 4
app/Service/CustomerService.php

@@ -7,6 +7,7 @@ use App\Model\Customer;
 use App\Model\CustomerInfo;
 use App\Model\Depart;
 use App\Model\Employee;
+use App\Model\Product;
 use Illuminate\Support\Facades\DB;
 
 /**
@@ -313,6 +314,8 @@ class CustomerService extends Service
             ->first();
         if(empty($customer)) return [false,'客户不存在或已被删除'];
         $customer = $customer->toArray();
+        $product = Product::where('id',$customer['intention_product'])->value('title');
+        $customer['intention_product_title'] = $product;
         $address = '';
         if(! empty($customer['address1'])) {
             $tmp = json_decode($customer['address1'],true);
@@ -328,7 +331,6 @@ class CustomerService extends Service
             $customer['customer_from'],
             $customer['customer_type'],
             $customer['car_type'],
-            $customer['intention_product'],
             $customer['progress_stage'],
             $customer['state_type'],
             $customer['customer_state'],
@@ -344,7 +346,6 @@ class CustomerService extends Service
             $customer[$key]['customer_from_title'] = $basic_map[$value['customer_from']] ?? '';
             $customer[$key]['customer_type_title'] = $basic_map[$value['customer_type']] ?? '';
             $customer[$key]['car_type_title'] = $basic_map[$value['car_type']] ?? '';
-            $customer[$key]['intention_product_title'] = $basic_map[$value['intention_product']] ?? '';
             $customer[$key]['progress_stage_title'] = $basic_map[$value['progress_stage']] ?? '';
             $customer[$key]['state_type_title'] = $basic_map[$value['state_type']] ?? '';
             $customer[$key]['customer_state_title'] = $basic_map[$value['customer_state']] ?? '';
@@ -503,7 +504,7 @@ class CustomerService extends Service
     public function fillData($data){
         if(empty($data['data'])) return $data;
 
-        $array = array_unique(array_merge_recursive(array_column($data['data'],'customer_intention'),array_column($data['data'],'customer_from'),array_column($data['data'],'customer_type'),array_column($data['data'],'car_type'),array_column($data['data'],'intention_product'),array_column($data['data'],'progress_stage'),array_column($data['data'],'state_type'),array_column($data['data'],'customer_state'),array_column($data['data'],'customer_grade')));
+        $array = array_unique(array_merge_recursive(array_column($data['data'],'customer_intention'),array_column($data['data'],'customer_from'),array_column($data['data'],'customer_type'),array_column($data['data'],'car_type'),array_column($data['data'],'progress_stage'),array_column($data['data'],'state_type'),array_column($data['data'],'customer_state'),array_column($data['data'],'customer_grade')));
         $basic_map = BasicType::whereIn('id',$array)
             ->pluck('title','id')
             ->toArray();
@@ -513,6 +514,9 @@ class CustomerService extends Service
         $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
             ->pluck('emp_name','id')
             ->toArray();
+        $product = Product::whereIn('id',array_unique(array_column($data['data'],'intention_product')))
+            ->pluck('title','id')
+            ->toArray();
 
         foreach ($data['data'] as $key => $value){
             $address = '';
@@ -527,7 +531,7 @@ class CustomerService extends Service
             $data['data'][$key]['customer_from_title'] = $basic_map[$value['customer_from']] ?? '';
             $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'] = $basic_map[$value['intention_product']] ?? '';
+            $data['data'][$key]['intention_product_title'] = $product[$value['intention_product']] ?? '';
             $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']] ?? '';