|
@@ -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';
|