cqp 8 сар өмнө
parent
commit
ce83e539ad

+ 5 - 2
app/Service/ConstructionService.php

@@ -559,12 +559,15 @@ class ConstructionService extends Service
         return [true, $construction];
     }
 
-    public function constructionCommon($data,$user){
+    public function constructionCommon($data,$user,$field = []){
+        if(empty($field)){
+            $field = ['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','service_price','storehouse_id','start_time','end_time','pq_state','day_start_stamp','day_end_stamp','vin_no'];
+        }
         $model = Construction::Clear($user,$data);
         $model = $model->where('del_time',0)
             ->orderby('id', 'desc');
         if(empty($data['select_field'])){
-            $model->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','service_price','storehouse_id','start_time','end_time','pq_state','day_start_stamp','day_end_stamp','vin_no');
+            $model->select($field);
         }else{
             $model->select('sales_order_id');
         }

+ 5 - 2
app/Service/CustomerService.php

@@ -519,10 +519,13 @@ class CustomerService extends Service
         return [true, $customer];
     }
 
-    public function customerCommonSearch($data,$user){
+    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'];
+        }
         $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','fp_top_depart_id','enter_time')
+            ->select($field)
             ->orderby('id', 'desc');
 
         if(! empty($data['title_t'])) {

+ 71 - 3
app/Service/ExportFileService.php

@@ -62,8 +62,8 @@ class ExportFileService extends Service
     ];
 
     protected static $fuc_name = [
-        self::type_one => '合同订单',
-        self::type_two => '派工订单',
+        self::type_one => '订单合同',
+        self::type_two => '派单合同',
         self::type_three => '收付款单',
         self::type_four => '施工单',
         self::type_five => '采购单',
@@ -76,11 +76,31 @@ class ExportFileService extends Service
 
     public static $filename = "";
 
+    //导出的方式 0 选择导出的数据 1 查询后 导出指定的数据(最多每次一千条)
+    public static $export_type = [
+        0,
+        1
+    ];
+
     public function exportAll($data,$user){
-        if(empty($data['id'])) return [false,'请选择导出数据'];
         if(empty($data['type']) || ! isset(self::$fuc[$data['type']])) return [false,'导出文件类型错误或者不存在'];
         self::$filename = self::$fuc_name[$data['type']] ?? "";
 
+        $export_type = $data['export_type'] ?? 0;
+        if(! isset(self::$export_type[$export_type])) return [false,'导出文件方式错误或者不存在'];
+        if(empty($export_type)){
+            if(empty($data['id'])) return [false,'请选择导出数据'];
+        }else{
+            if(empty($data['order_search'])) return [false,'搜索条件不能为空'];
+            $search = $data['order_search'];
+            if(empty($search['page_index'])) return [false,'请选择导出数据的开始页码'];
+            if(empty($search['page_size'])) return [false,'请选择导出数据的条数'];
+            if($search['page_size'] > 1000) return [false,'请选择导出数据的条数每次最多1000条'];
+            $id = $this->getListForSearch($data, $user);
+            $data['id'] = $id;
+            unset($data['order_search']);
+        }
+
         //不超时
         ini_set('max_execution_time', 0);
         //内存设置
@@ -1329,6 +1349,54 @@ class ExportFileService extends Service
         return $this->saveExportData($return,$header);
     }
 
+    public function getListForSearch($ergs, $user){
+        $data = $ergs['order_search'];
+        $id = [];
+        if(in_array($ergs['type'], [self::type_one, self::type_two])){
+            $service = new SalesOrderService();
+            $model = $service->salesOrderCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_three){
+            $service = new PaymentReceiptService();
+            $model = $service->customerCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_four){
+            $service = new ConstructionService();
+            $model = $service->constructionCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_five){
+            $service = new PurchaseOrderService();
+            $model = $service->purchaseCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_six){
+            $service = new ReturnExchangeOrderService();
+            $model = $service->returnCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_seven){
+            $service = new InvoiceOrderService();
+            $model = $service->invoiceCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_nine){
+            $service = new PurchaseOrderSpecialService();
+            $model = $service->purchaseCommon($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }elseif ($ergs['type'] == self::type_ten){
+            $service = new CustomerService();
+            $model = $service->customerCommonSearch($data, $user, ['id']);
+            $return = $this->limitData($model,'',$data);
+            $id = array_column($return,'id');
+        }
+
+        return $id;
+    }
+
     public function saveExportData($data, $headers, $type = 'default',$file_name = ''){
         if(empty($file_name)) $file_name = self::$filename . "_". date("Y-m-d") . "_". rand(1000,9999);
         $filename =  $file_name . '.' . 'xlsx';

+ 16 - 8
app/Service/InvoiceOrderService.php

@@ -222,16 +222,13 @@ class InvoiceOrderService extends Service
         return [true,''];
     }
 
-    /**
-     * 获取发货单列表
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function getList($data,$user){
+    public function invoiceCommon($data,$user,$field = []){
+        if(empty($field)){
+            $field = ['id','order_number','sales_order_id','depart_id','send','send_time','take','take_address','take_phone','logistics_company','logistics_number','crt_id','mark','state','crt_time','storehouse_id','top_depart_id'];
+        }
         $model = InvoiceOrder::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('id','order_number','sales_order_id','depart_id','send','send_time','take','take_address','take_phone','logistics_company','logistics_number','crt_id','mark','state','crt_time','storehouse_id','top_depart_id')
+            ->select($field)
             ->orderby('id', 'desc');
         if(! empty($data['order_number'])) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
         if(isset($data['state'])) $model->where('state',$data['state']);
@@ -276,6 +273,17 @@ class InvoiceOrderService extends Service
             $model->whereIn('sales_order_id',array_unique(array_column($sale,'id')));
         }
 
+        return $model;
+    }
+
+    /**
+     * 获取发货单列表
+     * @param $data
+     * @param $user
+     * @return array
+     */
+    public function getList($data,$user){
+        $model = $this->invoiceCommon($data, $user);
         $list = $this->limit($model,'',$data);
         $list = $this->fillListData($list);
 

+ 5 - 2
app/Service/PaymentReceiptService.php

@@ -417,10 +417,13 @@ class PaymentReceiptService extends Service
         return $return;
     }
 
-    public function customerCommon($data,$user){
+    public function customerCommon($data,$user,$field = []){
+        if(empty($field)){
+            $field = ['type','id','data_type','order_number','data_order_no','amount','account','pay_way','crt_id','crt_time','mark','state','payment_receipt_date'];
+        }
         $model = PaymentReceipt::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('type','id','data_type','order_number','data_order_no','amount','account','pay_way','crt_id','crt_time','mark','state','payment_receipt_date')
+            ->select($field)
             ->orderby('id', 'desc');
 
         if(isset($data['state'])) $model->where('state', $data['state']);

+ 5 - 2
app/Service/PurchaseOrderService.php

@@ -446,10 +446,13 @@ class PurchaseOrderService extends Service
         return [true, ['file' => ['old' => $old]]];
     }
 
-    public function purchaseCommon($data,$user){
+    public function purchaseCommon($data,$user,$field = []){
+        if(empty($field)){
+            $field = ['order_number','id','depart_id','top_depart_id','mark','crt_time','state','crt_id','order_type','sales_order_id','supplier','purchase_id','purchase_total','discount_fee','other_fee','total','storehouse_id','invoice_state'];
+        }
         $model = PurchaseOrder::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('order_number','id','depart_id','top_depart_id','mark','crt_time','state','crt_id','order_type','sales_order_id','supplier','purchase_id','purchase_total','discount_fee','other_fee','total','storehouse_id','invoice_state')
+            ->select($field)
             ->orderby('id', 'desc');
 
         if(! empty($data['purchase_id'])) $model->where('id', $data['purchase_id']);

+ 18 - 8
app/Service/PurchaseOrderSpecialService.php

@@ -224,15 +224,13 @@ class PurchaseOrderSpecialService extends Service
         return [true,''];
     }
 
-    /**
-     * 获取采购单列表
-     * @param $data
-     * @param $user
-     * @return array
-     */
-    public function getList($data,$user){
+    public function purchaseCommon($data,$user,$field = []){
+        if(empty($field)){
+            $field = ['order_number','id','depart_id','top_depart_id','mark','crt_time','state','crt_id','sales_order_id','supplier','purchase_id','purchase_total','storehouse_id','total','other_fee','type','discount_fee'];
+        }
         $model = PurchaseOrderSpecial::Clear($user,$data);
-        $model = $model->where('del_time',0)->select('order_number','id','depart_id','top_depart_id','mark','crt_time','state','crt_id','sales_order_id','supplier','purchase_id','purchase_total','storehouse_id','total','other_fee','type','discount_fee')
+        $model = $model->where('del_time',0)
+            ->select($field)
             ->orderby('id', 'desc');
         if(! empty($data['order_number'])) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
         if(isset($data['state'])) $model->where('state',$data['state']);
@@ -261,6 +259,18 @@ class PurchaseOrderSpecialService extends Service
             $model->whereIn('supplier',array_column($id,'id'));
         }
 
+        return $model;
+    }
+
+    /**
+     * 获取采购单列表
+     * @param $data
+     * @param $user
+     * @return array
+     */
+    public function getList($data,$user){
+        $model = $this->purchaseCommon($data, $user);
+
         $list = $this->limit($model,'',$data);
         $list = $this->fillListData($list,$data,$user);
 

+ 5 - 2
app/Service/ReturnExchangeOrderService.php

@@ -314,10 +314,13 @@ class ReturnExchangeOrderService extends Service
         return [true,''];
     }
 
-    public function returnCommon($data,$user){
+    public function returnCommon($data,$user,$field = []){
+        if(empty($field)){
+            $field = ['id','order_number','data_id','difference_amount','state','crt_time','crt_id','mark','model_type','storehouse_id','type'];
+        }
         $model = ReturnExchangeOrder::Clear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('id','order_number','data_id','difference_amount','state','crt_time','crt_id','mark','model_type','storehouse_id','type')
+            ->select($field)
             ->orderby('id', 'desc');
 
         if(! empty($data['order_number'])) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');

+ 6 - 2
app/Service/SalesOrderService.php

@@ -805,10 +805,14 @@ class SalesOrderService extends Service
         $sales['not_payment_receipt_amount'] = bcsub($sales['contract_fee'],$sales['payment_receipt_list']['not_confirm_receipt_amount'],2);
     }
 
-    public function salesOrderCommon($data,$user){
+    public function salesOrderCommon($data,$user, $field = []){
+        if(empty($field)){
+            $field = ['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','contact_order_no','type','top_depart_id'];
+        }
+
         $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','dispatch_time_second','contact_order_no','type','top_depart_id');
+            ->select($field);
 
         if(! empty($data['order_list'])){
             if($data['order_list'] == 1){

+ 10 - 0
app/Service/Service.php

@@ -35,6 +35,16 @@ class Service
         return $data;
     }
 
+    //分页共用2
+    public function limitData($db, $columns, $request)
+    {
+        $per_page = $request['page_size'] ?? 1000;
+        $page = $request['page_index'] ?? 1;
+        $return = $db->paginate($per_page, $columns, 'page', $page)->toArray();
+
+        return $return['data'];
+    }
+
 
     //抽象一个查询条件,省的每天写很多行
     protected function is_exist_db($data, $word, $words, $db, $formula = '=', $type = '')