!127 盘点导入更新

Merge pull request !127 from develop
This commit is contained in:
赵世界 2022-11-03 09:10:13 +00:00 committed by Gitee
commit 00f15b382c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 3 additions and 14 deletions

View File

@ -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));
}
}

View File

@ -34,7 +34,7 @@ class StockUpdateListener
return;
}
foreach ($shops as $shop) {
if (isset($event->goodsSku) && '下架' !== $event->goodsSku->status) {
if (isset($event->goodsSku)) {
$num = $event->goodsSku->stock;
$businessGoodsSkus = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('is_sync', 1)->where('external_sku_id', $event->goodsSku->goods['goods_code'] . '_' . $event->goodsSku->sku_code)->get();
foreach ($businessGoodsSkus as $businessGoodsSku) {
@ -43,9 +43,6 @@ class StockUpdateListener
}
if (isset($event->goodsSkus)) {
foreach ($event->goodsSkus as $goodsSku) {
if ('下架' === $goodsSku->status) {
continue;
}
$num = $goodsSku->stock;
$businessGoodsSkus = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('is_sync', 1)->where('external_sku_id', $goodsSku->goods['goods_code'] . '_' . $goodsSku->sku_code)->get();
foreach ($businessGoodsSkus as $businessGoodsSku) {

View File

@ -46,9 +46,6 @@ class UpdateBusinessGoodsStock implements ShouldQueue
return;
}
if ('下架' === $event->goodsSku->status) {
return;
}
$builder = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP]);
// 非订单影响库存变更,只更新本店铺下商品
if (!isset($event->businessGoods['business_order_id'])) {