Browse Source

施工单

cqpCow 1 năm trước cách đây
mục cha
commit
97f0f7ecf2
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      app/Service/ConstructionService.php

+ 9 - 2
app/Service/ConstructionService.php

@@ -24,6 +24,7 @@ class ConstructionService extends Service
             $model->order_number = $data['order_number'];
             $model->title = $data['title'] ?? '';
             $model->customer_id = $data['customer_id'] ?? 0;
+            $model->customer_contact_id = $data['customer_contact_id'] ?? 0;
             $model->install_method = $data['install_method'] ?? 0;
             $model->install_position = $data['install_position'] ?? '';
             $model->sales_order_id = $data['sales_order_id'] ?? 0;
@@ -110,6 +111,7 @@ class ConstructionService extends Service
             $model->order_number = $data['order_number'];
             $model->title = $data['title'] ?? '';
             $model->customer_id = $data['customer_id'] ?? 0;
+            $model->customer_contact_id = $data['customer_contact_id'] ?? 0;
             $model->install_method = $data['install_method'] ?? 0;
             $model->install_position = $data['install_position'] ?? '';
             $model->sales_order_id = $data['sales_order_id'] ?? 0;
@@ -211,6 +213,10 @@ class ConstructionService extends Service
             ->first();
         if(empty($construction)) return [false,'施工订单不存在或已被删除'];
         $construction = $construction->toArray();
+        $customer_title = Customer::where('id',$construction['customer_id'])->value('title');
+        $construction['customer_title'] = $customer_title;
+        $emp_title = Employee::where('id',$construction['customer_contact_id'])->value('emp_name');
+        $construction['customer_contact_title'] = $emp_title;
         $construction['employee_one'] = $construction['construction_contact'] = $construction['product'] = [];
         $array = [
             $construction['install_method'],
@@ -274,7 +280,7 @@ class ConstructionService extends Service
     public function constructionList($data,$user){
         $model = new Construction(['userData' => $user]);
         $model = $model->where('del_time',0)
-            ->select('title','id','model_type','order_number','customer_id','install_method','install_position','sales_order_id','construction_fee','construction_time','handover_time','urgency','crt_id','crt_time','mark','state','address1','address2','introduction')
+            ->select('title','id','model_type','order_number','customer_id','customer_contact_id','install_method','install_position','sales_order_id','construction_fee','construction_time','handover_time','urgency','crt_id','crt_time','mark','state','address1','address2','introduction')
             ->orderby('id', 'desc')
             ->where('model_type',$data['model_type']);
 
@@ -334,7 +340,7 @@ class ConstructionService extends Service
         $basic_map = BasicType::whereIn('id',$array)
             ->pluck('title','id')
             ->toArray();
-        $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
+        $emp = Employee::whereIn('id',array_unique(array_merge_recursive(array_column($data['data'],'crt_id'),array_column($data['data'],'customer_contact_id'))))
             ->pluck('emp_name','id')
             ->toArray();
         $customer = Customer::whereIn('id',array_unique(array_column($data['data'],'customer_id')))
@@ -347,6 +353,7 @@ class ConstructionService extends Service
             $data['data'][$key]['customer_title'] = $customer[$value['customer_id']] ?? '';
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
+            $data['data'][$key]['customer_contact_title'] = $emp[$value['customer_contact_id']] ?? '';
         }
 
         return $data;