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