|
@@ -40,6 +40,7 @@ use App\Model\MaterialReturn;
|
|
|
use App\Model\MaterialReturnSub;
|
|
|
use App\Model\PaymentReceipt;
|
|
|
use App\Model\PaymentReceiptInfo;
|
|
|
+use App\Model\Product;
|
|
|
use App\Model\PurchaseOrder;
|
|
|
use App\Model\PurchaseOrderInfo;
|
|
|
use App\Model\ReturnExchangeOrder;
|
|
@@ -69,6 +70,7 @@ class ExportFileService extends Service
|
|
|
const type_five = 5;
|
|
|
const type_six = 6;
|
|
|
const type_seven = 7;
|
|
|
+ const type_eight = 8;
|
|
|
|
|
|
//导出文件方法
|
|
|
protected static $fuc = [
|
|
@@ -79,6 +81,7 @@ class ExportFileService extends Service
|
|
|
self::type_five => 'five',
|
|
|
self::type_six => 'six',
|
|
|
self::type_seven => 'seven',
|
|
|
+ self::type_eight => 'eight',
|
|
|
];
|
|
|
|
|
|
protected static $fuc_name = [
|
|
@@ -89,6 +92,7 @@ class ExportFileService extends Service
|
|
|
self::type_five => '采购单',
|
|
|
self::type_six => '退换货单',
|
|
|
self::type_seven => '发货单',
|
|
|
+ self::type_eight => '进销存报表',
|
|
|
];
|
|
|
|
|
|
public static $filename = "";
|
|
@@ -104,12 +108,12 @@ class ExportFileService extends Service
|
|
|
ini_set('memory_limit', -1);
|
|
|
|
|
|
$function = self::$fuc[$data['type']];
|
|
|
- $return = $this->$function($data);
|
|
|
+ $return = $this->$function($data,$user);
|
|
|
|
|
|
return [true, $return];
|
|
|
}
|
|
|
|
|
|
- public function one($ergs){
|
|
|
+ public function one($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -336,7 +340,7 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
- public function two($ergs){
|
|
|
+ public function two($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -529,7 +533,7 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
- public function three($ergs){
|
|
|
+ public function three($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -620,7 +624,7 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
- public function four($ergs){
|
|
|
+ public function four($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -745,7 +749,7 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
- public function five($ergs){
|
|
|
+ public function five($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -863,7 +867,7 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
- public function six($ergs){
|
|
|
+ public function six($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -995,7 +999,7 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
- public function seven($ergs){
|
|
|
+ public function seven($ergs,$user){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
@@ -1134,6 +1138,75 @@ class ExportFileService extends Service
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|
|
|
|
|
|
+ public function eight($ergs,$user){
|
|
|
+ $id = $ergs['id'];
|
|
|
+
|
|
|
+ // 导出数据
|
|
|
+ $return = [];
|
|
|
+ $total = [
|
|
|
+ 'code' => "",
|
|
|
+ 'title' => "",
|
|
|
+ 'last_jc_number' => 0,
|
|
|
+ 'last_jc_price' => "",
|
|
|
+ 'last_jc_money' => 0,
|
|
|
+ 'this_in_number' => 0,
|
|
|
+ 'this_in_price' => "",
|
|
|
+ 'this_in_money' => 0,
|
|
|
+ 'this_out_number' => 0,
|
|
|
+ 'this_out_price' => "",
|
|
|
+ 'this_out_money' => 0,
|
|
|
+ 'this_jc_number' => 0,
|
|
|
+ 'this_jc_price' => "",
|
|
|
+ 'this_jc_money' => 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $model = Product::ProductClear2($user,$ergs);
|
|
|
+ $model->whereIn('id', $id)
|
|
|
+ ->select('title','id','code','depart_id','top_depart_id','product_attribute')
|
|
|
+ ->orderBy('id','desc')
|
|
|
+ ->chunk(500,function ($data) use(&$return,&$total,$user,$ergs){
|
|
|
+ $data = $data->toArray();
|
|
|
+ $list['data'] = $data;
|
|
|
+ $service = new StatisticsService();
|
|
|
+ $list = $service->fillData($list,$user,$ergs);
|
|
|
+ foreach ($list['data'] as $value){
|
|
|
+ $return[] = [
|
|
|
+ 'code' => $value['code'],
|
|
|
+ 'title' => $value['title'],
|
|
|
+ 'last_jc_number' => $value['last_jc_number'],
|
|
|
+ 'last_jc_price' => $value['last_jc_price'],
|
|
|
+ 'last_jc_money' => $value['last_jc_money'],
|
|
|
+ 'this_in_number' => $value['this_in_number'],
|
|
|
+ 'this_in_price' => $value['this_in_price'],
|
|
|
+ 'this_in_money' => $value['this_in_money'],
|
|
|
+ 'this_out_number' => $value['this_out_number'],
|
|
|
+ 'this_out_price' => $value['this_out_price'],
|
|
|
+ 'this_out_money' => $value['this_out_money'],
|
|
|
+ 'this_jc_number' => $value['this_jc_number'],
|
|
|
+ 'this_jc_price' => $value['this_jc_price'],
|
|
|
+ 'this_jc_money' => $value['this_jc_money'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $total['last_jc_number'] += $value['last_jc_number'];
|
|
|
+ $total['last_jc_money'] += $value['last_jc_money'];
|
|
|
+ $total['this_in_number'] += $value['this_in_number'];
|
|
|
+ $total['this_in_money'] += $value['this_in_money'];
|
|
|
+ $total['this_out_number'] += $value['this_out_number'];
|
|
|
+ $total['this_out_money'] += $value['this_out_money'];
|
|
|
+ $total['this_jc_number'] += $value['this_jc_number'];
|
|
|
+ $total['this_jc_money'] += $value['this_jc_money'];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $header = [
|
|
|
+ ['产品编码','产品名称','上月结存','','','本月入库','','','本月出库','','','本月结存','',''],
|
|
|
+ ['产品编码','产品名称','数量','单价','金额','数量','单价','金额','数量','单价','金额','数量','单价','金额'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $return[] = $total;
|
|
|
+ return $this->saveExportData($return,$header,'jc');
|
|
|
+ }
|
|
|
+
|
|
|
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';
|