From 431b350add7ac371ed74b346a87172163a2eacc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Fri, 2 Sep 2022 17:05:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#10000=20=E5=AF=BC=E5=87=BA=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exports/GoodsSkusExport.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Exports/GoodsSkusExport.php b/app/Exports/GoodsSkusExport.php index 9ad2b68..dbec937 100644 --- a/app/Exports/GoodsSkusExport.php +++ b/app/Exports/GoodsSkusExport.php @@ -40,7 +40,7 @@ class GoodsSkusExport implements FromCollection, ShouldAutoSize ]; $map = [ 'cost' => ['成本', '更新前成本', '更新后成本'], - 'inventory' => ['库存', '盘点'], + 'inventory' => ['库存', '盘点', '更新前盘点'], ]; $headTitle = array_merge($headTitle, $map[$this->type]); $day = DateTimeUtils::getToday(); @@ -53,7 +53,7 @@ class GoodsSkusExport implements FromCollection, ShouldAutoSize ->orderBy('id', 'asc') ->get(); foreach ($logs as $log) { - if ($log['before_update'] != $log['after_update']) { + if ($log['before_update'] != $log['after_update'] || (int)$log['after_update']) { if (!isset($update[$log['target_id']])) { $update[$log['target_id']]['before_update'] = $log['before_update']; } @@ -72,7 +72,6 @@ class GoodsSkusExport implements FromCollection, ShouldAutoSize $query->with(['type:id,name', 'brand:id,name']); }]); if ('inventory' === $this->type) { - $model->where('stock', '<>', 0); $model->with(['daily' => function ($query) use ($day) { $query->where('day', $day); }]); @@ -90,13 +89,14 @@ class GoodsSkusExport implements FromCollection, ShouldAutoSize $arr[4] = $item['sku_code']; $arr[5] = $item['title']; if ('cost' === $this->type) { - $arr[6] = $item['cost']; - $arr[7] = $update[$item['id']]['before_update']; - $arr[8] = $update[$item['id']]['after_update']; + $arr[6] = (string)$item['cost']; + $arr[7] = (string)$update[$item['id']]['before_update']; + $arr[8] = (string)$update[$item['id']]['after_update']; } if ('inventory' === $this->type) { - $arr[6] = $item['stock']; - $arr[7] = $item['daily']['inventory']; + $arr[6] = (string)$item['stock']; + $arr[7] = (string)$item['daily']['inventory']; + $arr[8] = (string)$update[$item['id']]['before_update']; } $bodyData[] = $arr; }