cqpCow 1 năm trước cách đây
mục cha
commit
be385c9f45

+ 25 - 23
app/Service/CustomerService.php

@@ -679,38 +679,38 @@ class CustomerService extends Service
             }
         }
 
-        $customer_info_map = [];
-        if(! empty($ergs['customer_detail'])){
-            $customer_info = CustomerInfo::where('del_time',0)
-                ->whereIn('customer_id',array_column($data['data'],'id'))
-                ->where('contact_type','>',0)
-                ->select('contact_type','contact_info','customer_id')
-                ->get()->toArray();
-            $basic_maps = BasicType::where('id',array_unique(array_column($customer_info,'contact_type')))->pluck('title','id')->toArray();
-            foreach ($customer_info as $key=>$value){
-                $value['contact_type_title'] = $basic_maps[$value['contact_type']] ?? "";
-                $customer_info_map[$value['customer_id']][] = $value;
-            }
-        }
 
         $customer_info = CustomerInfo::where('del_time',0)
             ->whereIn('customer_id',array_column($data['data'],'id'))
-            ->where('type',CustomerInfo::type_two)
-            ->select('data_id','customer_id')
+            ->whereIn('type',[CustomerInfo::type_one,CustomerInfo::type_two])
+            ->select('type','contact_type','contact_info','customer_id','data_id')
             ->get()->toArray();
-        $emp_map = Employee::whereIn('id',array_column($customer_info,'data_id'))
+
+        //客户的联系方式  客户的负责人
+        $customer_info_map = $fz = $customer_info_map2 = [];
+        $emp_map = Employee::whereIn('id',array_filter(array_column($customer_info,'data_id')))
             ->pluck('emp_name','id')
             ->toArray();
-        $fz = [];
+        $basic_maps = BasicType::whereIn('id',array_unique(array_filter(array_column($customer_info,'contact_type'))))->pluck('title','id')->toArray();
         foreach ($customer_info as $value){
-            $tmp = $emp_map[$value['data_id']] ?? "";
-
-            if(isset($fz[$value['customer_id']])){
-                $fz[$value['customer_id']] .= ',' . $tmp;
+            if($value['type'] == CustomerInfo::type_one){
+                $value['contact_type_title'] = $basic_maps[$value['contact_type']] ?? "";
+                $customer_info_map[$value['customer_id']][] = $value;
+                if(! isset($customer_info_map2[$value['customer_id']])){
+                    $customer_info_map2[$value['customer_id']] = $value['contact_type_title'] . ": " . $value['contact_info'];
+                }else{
+                    $customer_info_map2[$value['customer_id']] .= ',' . $value['contact_type_title'] . ": " . $value['contact_info'];
+                }
             }else{
-                $fz[$value['customer_id']] = $tmp;
+                $tmp = $emp_map[$value['data_id']] ?? "";
+                if(isset($fz[$value['customer_id']])){
+                    $fz[$value['customer_id']] .= ',' . $tmp;
+                }else{
+                    $fz[$value['customer_id']] = $tmp;
+                }
             }
         }
+
         foreach ($data['data'] as $key => $value){
             if(! empty($value['address1'])) {
                 $tmp = json_decode($value['address1'],true);
@@ -732,7 +732,9 @@ class CustomerService extends Service
             $data['data'][$key]['depart_title'] = $depart_title[$value['depart_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_detail'] = $customer_info_map[$value['id']] ?? [];
+            $customer_tmp = $customer_info_map[$value['id']] ?? [];
+            $data['data'][$key]['customer_detail'] = $customer_tmp;
+            $data['data'][$key]['customer_detail2'] = $customer_info_map2[$value['id']] ?? "";
             $data['data'][$key]['fz'] = $fz[$value['id']] ?? [];
             $record_tmp = $record_array[$value['id']] ?? "";
             $data['data'][$key]['has_record'] = $record_tmp ? "查看" : "无记录";

+ 10 - 3
app/Service/SalesOrderService.php

@@ -710,8 +710,9 @@ class SalesOrderService extends Service
     public function salesOrderList($data,$user){
         $model = SalesOrder::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('id','sales_order_type','model_type','order_number','selling_price','vin_no','car_type','order_type','customer_id','sign_time','crt_id','crt_time','mark','product_total','rate','construction_time','handover_time','other_fee','discount_fee','contract_fee','pay_way','car_type','year','mileage','color','original_set','processing','state','invoice_state','plat_type','plat_order','install_method','install_position','customer_contact','is_confirm')
-            ->orderby('id', 'desc');
+            ->select('id','sales_order_type','model_type','order_number','selling_price','vin_no','car_type','order_type','customer_id','sign_time','crt_id','crt_time','mark','product_total','rate','construction_time','handover_time','other_fee','discount_fee','contract_fee','pay_way','car_type','year','mileage','color','original_set','processing','state','invoice_state','plat_type','plat_order','install_method','install_position','customer_contact','is_confirm','dispatch_time_second')
+            ->orderby('id', 'desc')
+            ->orderby('dispatch_time_second','desc');
 
         if(! empty($data['order_number'])) $model->where('order_number','LIKE', '%'.$data['order_number'].'%');
         if(! empty($data['sales_order_type'])) $model->where('sales_order_type',$data['sales_order_type']);
@@ -791,6 +792,11 @@ class SalesOrderService extends Service
             $customer_id = (new RangeService())->salesOrderCustomerCrtSearch($user,$data);
             $model->whereIn('customer_id',$customer_id);
         }
+        if(! empty($data['dispatch_time_second'][0]) && ! empty($data['dispatch_time_second'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['dispatch_time_second']);
+            $model->where('dispatch_time_second','>=',$return[0]);
+            $model->where('dispatch_time_second','<=',$return[1]);
+        }
 
         $list = $this->limit($model,'',$data);
         $list = $this->fillData($list,$data);
@@ -987,6 +993,7 @@ class SalesOrderService extends Service
             $data['data'][$key]['construction_time'] = $value['construction_time'] ? date('Y-m-d H:i:s',$value['construction_time']) : '';
             $data['data'][$key]['handover_time'] = $value['handover_time'] ? date('Y-m-d H:i:s',$value['handover_time']) : '';
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
+            $data['data'][$key]['dispatch_time_second_time'] = $value['dispatch_time_second'] ? date('Y-m-d H:i:s',$value['dispatch_time_second']) : '';
             $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
             $data['data'][$key]['product'] = $product[$value['id']] ?? [];
             $data['data'][$key]['fee'] = $fee[$value['id']] ?? "";
@@ -1261,7 +1268,7 @@ class SalesOrderService extends Service
 
     public function salesOrderListsalesOrderWxList($data,$user){
         $model = SalesOrder::where('del_time',0)
-            ->select('id','sales_order_type','model_type','order_number','selling_price','vin_no','car_type','order_type','customer_id','sign_time','crt_id','crt_time','mark','product_total','rate','construction_time','handover_time','other_fee','discount_fee','contract_fee','pay_way','car_type','year','mileage','color','original_set','processing','state','invoice_state','plat_type','plat_order','install_method','install_position','customer_contact','is_confirm')
+            ->select('id','sales_order_type','model_type','order_number','selling_price','vin_no','car_type','order_type','customer_id','sign_time','crt_id','crt_time','mark','product_total','rate','construction_time','handover_time','other_fee','discount_fee','contract_fee','pay_way','car_type','year','mileage','color','original_set','processing','state','invoice_state','plat_type','plat_order','install_method','install_position','customer_contact','is_confirm','dispatch_time_second')
             ->orderby('id', 'desc');
 
         if(! empty($data['openid'])){

+ 4 - 0
config/header/16.php

@@ -19,6 +19,10 @@ return [
         'value' => '客户名称',
     ],
     [
+        'key' => 'customer_detail2',
+        'value' => '联系方式',
+    ],
+    [
         'key' => 'fz',
         'value' => '负责人',
     ],

+ 4 - 0
config/header/43.php

@@ -99,6 +99,10 @@ return [
         'value' => '派遣门店',
     ],
     [
+        'key' => 'dispatch_time_second_time',
+        'value' => '派单时间',
+    ],
+    [
         'key' => 'pay_way_title',
         'value' => '付款方式',
     ],