|
@@ -14,51 +14,6 @@ use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
|
class ExportFileService extends Service
|
|
|
{
|
|
|
- //导出文件
|
|
|
- const type_one = 1;
|
|
|
- const type_two = 2;
|
|
|
- const type_three = 3;
|
|
|
- const type_four = 4;
|
|
|
- const type_five = 5;
|
|
|
- const type_six = 6;
|
|
|
- const type_seven = 7;
|
|
|
- const type_eight = 8;
|
|
|
- const type_nine = 9;
|
|
|
- const type_ten = 10;
|
|
|
- const type_eve = 11;
|
|
|
- const type_twl = 12;
|
|
|
-
|
|
|
- //导出文件方法
|
|
|
- protected static $fuc = [
|
|
|
- self::type_one => 'one',
|
|
|
- self::type_two => 'two',
|
|
|
- self::type_three => 'three',
|
|
|
- self::type_four => 'four',
|
|
|
- self::type_five => 'five',
|
|
|
- self::type_six => 'six',
|
|
|
- self::type_seven => 'seven',
|
|
|
- self::type_eight => 'eight',
|
|
|
- self::type_nine => 'nine',
|
|
|
- self::type_ten => 'ten',
|
|
|
- self::type_eve => 'eve',
|
|
|
- self::type_twl => 'twl',
|
|
|
- ];
|
|
|
-
|
|
|
- protected static $fuc_name = [
|
|
|
- self::type_one => '存货',
|
|
|
- self::type_two => '运费设置',
|
|
|
- self::type_three => '收入成本统计表',
|
|
|
- self::type_four => '销货单统计表',
|
|
|
- self::type_five => '销售发票统计表',
|
|
|
- self::type_six => '回款单统计表',
|
|
|
- self::type_seven => '发放统计表',
|
|
|
- self::type_eight => '利润分配统计表',
|
|
|
- self::type_nine => '业务员工资统计表',
|
|
|
- self::type_ten => '客户',
|
|
|
- self::type_eve => '现存量',
|
|
|
- self::type_twl => '库存台账',
|
|
|
- ];
|
|
|
-
|
|
|
public static $filename = "";
|
|
|
|
|
|
//导出的方式 0 选择导出的数据 1 查询后 导出指定的数据(最多每次一千条)
|
|
@@ -68,25 +23,28 @@ class ExportFileService extends Service
|
|
|
];
|
|
|
|
|
|
public function exportAll($data,$user){
|
|
|
- if(empty($data['type']) || ! isset(self::$fuc[$data['type']])) return [false,'导出文件类型错误或者不存在'];
|
|
|
- self::$filename = self::$fuc_name[$data['type']] ?? "";
|
|
|
+ if(empty($data['e_menu_id'])) return [false, '菜单ID不能为空'];
|
|
|
+ list($function, $name) = EmployeeService::fillMenu2($data['e_menu_id'], $user);
|
|
|
+ if (empty($function) || ! method_exists(self::class, $function)) return [false, "导出方法不存在,请联系开发"];
|
|
|
+ self::$filename = $name;
|
|
|
|
|
|
$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{
|
|
|
+ $search_func = $function . "Search";
|
|
|
+ if (! method_exists(self::class, $search_func)) return [false, "导出方法(子方法)不存在,请联系开发"];
|
|
|
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'] > 5000) return [false,'请选择导出数据的条数每次最多5000条'];
|
|
|
- list($status,$id) = $this->getListForSearch($data, $user);
|
|
|
+ list($status,$id) = $this->$search_func($data, $user);
|
|
|
if(! $status) return [false, $id];
|
|
|
$data['id'] = $id;
|
|
|
}
|
|
|
|
|
|
- $function = self::$fuc[$data['type']];
|
|
|
$return = $this->$function($data,$user);
|
|
|
|
|
|
return [true, $return];
|
|
@@ -131,13 +89,13 @@ class ExportFileService extends Service
|
|
|
$return[] = $tmp;
|
|
|
}
|
|
|
|
|
|
- public function one($ergs,$user){
|
|
|
+ public function one($ergs, $user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
|
|
|
- $header_default = config("header.62") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('product')
|
|
@@ -156,13 +114,23 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function oneSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new ProductService();
|
|
|
+ $model = $service->productCommon($data, $user, ['id']);
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function two($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
|
|
|
- $header_default = config("header.66") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('freight')
|
|
@@ -181,13 +149,23 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function twoSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new FreightService();
|
|
|
+ $model = $service->freightCommon($data, $user, ['id']);
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function three($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
$service = new StatisticsService();
|
|
|
- $header_default = config("header.68") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('revenue_cost_total')
|
|
@@ -215,13 +193,24 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function threeSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new StatisticsService();
|
|
|
+ list($status, $model) = $service->statisticsRevenueCostCommon($data, $user, ['id']);
|
|
|
+ if(! $status) return [false, $model];
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function four($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
$service = new StatisticsService();
|
|
|
- $header_default = config("header.69") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('revenue_cost')
|
|
@@ -249,13 +238,25 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function fourSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $data['order_type'] = RevenueCost::ORDER_ONE;
|
|
|
+ $service = new StatisticsService();
|
|
|
+ list($status, $model) = $service->statisticsRevenueCostOneAndTwoCommon($data, $user, ['id']);
|
|
|
+ if(! $status) return [false, $model];
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function five($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
$service = new StatisticsService();
|
|
|
- $header_default = config("header.70") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('revenue_cost')
|
|
@@ -283,6 +284,18 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function fiveSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $data['order_type'] = RevenueCost::ORDER_TWO;
|
|
|
+ $service = new StatisticsService();
|
|
|
+ list($status, $model) = $service->statisticsRevenueCostOneAndTwoCommon($data, $user, ['id']);
|
|
|
+ if(! $status) return [false, $model];
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function six($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
@@ -294,7 +307,7 @@ class ExportFileService extends Service
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
$service = new StatisticsService();
|
|
|
- $header_default = config("header.71") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('revenue_cost')
|
|
@@ -324,12 +337,23 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function sixSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new StatisticsService();
|
|
|
+ list($status, $model) = $service->statisticsRevenueCostThreeCommon($data, $user, ['order_id']);
|
|
|
+ if(! $status) return [false, $model];
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'order_id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function seven($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
- $header_default = config("header.72") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default,'key');
|
|
|
$header = array_column($header_default,'value');
|
|
|
DB::table('give_out')
|
|
@@ -353,6 +377,16 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function sevenSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new GiveOutService();
|
|
|
+ $model = $service->giveOutCommon($data, $user, ['id']);
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function eight($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
@@ -361,7 +395,7 @@ class ExportFileService extends Service
|
|
|
$type = RevenueCost::ORDER_THREE;
|
|
|
|
|
|
$return = [];
|
|
|
- $header_default = config("header.74") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default, 'key');
|
|
|
$header = array_column($header_default, 'value');
|
|
|
DB::table('employee_index')
|
|
@@ -393,13 +427,24 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function eightSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new StatisticsService();
|
|
|
+ list($status,$model) = $service->statisticsProfitCommon($data, $user, ['employee_index.id']);
|
|
|
+ if(! $status) return [false, $model];
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function nine($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
$field = SalaryEmployee::$field;
|
|
|
|
|
|
$return = [];
|
|
|
- $header_default = config("header.73") ?? [];
|
|
|
+ $header_default = $user['e_header_default'];
|
|
|
$column = array_column($header_default, 'key');
|
|
|
$header = array_column($header_default, 'value');
|
|
|
DB::table('salary_employee')
|
|
@@ -423,6 +468,17 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function nineSearch($ergs, $user){
|
|
|
+ $data = $ergs['order_search'];
|
|
|
+ $service = new StatisticsService();
|
|
|
+ list($status,$model) = $service->statisticsEmployeeSalaryCommon($data, $user, ['id']);
|
|
|
+ if(! $status) return [false, $model];
|
|
|
+ $return = $this->limitData($model,'',$data);
|
|
|
+ $id = array_column($return,'id');
|
|
|
+
|
|
|
+ return [true, $id];
|
|
|
+ }
|
|
|
+
|
|
|
public function getListForSearch($ergs, $user){
|
|
|
$data = $ergs['order_search'];
|
|
|
$id = [];
|