feat: #10000 盘点导入优化
This commit is contained in:
parent
790ab6bdca
commit
16dca74eda
@ -36,7 +36,6 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
$updateIds = [];
|
||||
$day = DateTimeUtils::getToday();
|
||||
$dateTime = date('Y-m-d H:i:s');
|
||||
$syncIds = [];
|
||||
foreach ($collection as $row) {
|
||||
if (!isset($hasGoods[$row[0]])) {
|
||||
continue;
|
||||
@ -55,17 +54,15 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
}
|
||||
$goodsSku->cost = $row[8];
|
||||
$goodsSku->save();
|
||||
// event(new StockUpdateEvent($goodsSku));
|
||||
$updateIds[] = $goodsSku->id;
|
||||
DailyStockRecord::query()->where('sku_id', $goodsSku->id)->where('day', $day)->update([
|
||||
'arrived_today_num' => $row[7],
|
||||
'inventory' => $row[6],
|
||||
'inventory_time' => $dateTime
|
||||
]);
|
||||
$syncIds[] = $goodsSku->id;
|
||||
}
|
||||
$onSkuIds = GoodsSku::query()
|
||||
->where('status', '<>', 0)
|
||||
->where('status', '>', 0)
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
$downSkuIds = array_diff($onSkuIds, $updateIds);
|
||||
@ -74,9 +71,7 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
$goodsSku->yesterday_num -= $goodsSku->stock;
|
||||
$goodsSku->stock = 0;
|
||||
$goodsSku->save();
|
||||
$syncIds[] = $goodsSku->id;
|
||||
// event(new StockUpdateEvent($goodsSku));
|
||||
}
|
||||
event(new StockUpdateEvent($syncIds));
|
||||
event(new StockUpdateEvent($onSkuIds));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user