mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
commit
00f15b382c
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class StockUpdateListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach ($shops as $shop) {
|
foreach ($shops as $shop) {
|
||||||
if (isset($event->goodsSku) && '下架' !== $event->goodsSku->status) {
|
if (isset($event->goodsSku)) {
|
||||||
$num = $event->goodsSku->stock;
|
$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();
|
$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) {
|
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||||
@ -43,9 +43,6 @@ class StockUpdateListener
|
|||||||
}
|
}
|
||||||
if (isset($event->goodsSkus)) {
|
if (isset($event->goodsSkus)) {
|
||||||
foreach ($event->goodsSkus as $goodsSku) {
|
foreach ($event->goodsSkus as $goodsSku) {
|
||||||
if ('下架' === $goodsSku->status) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$num = $goodsSku->stock;
|
$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();
|
$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) {
|
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||||
|
|||||||
@ -46,9 +46,6 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('下架' === $event->goodsSku->status) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$builder = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP]);
|
$builder = Shop::query()->whereNotIn('status', [Shop::$STATUS_UNAUTHORIZED, Shop::$STATUS_STOP]);
|
||||||
// 非订单影响库存变更,只更新本店铺下商品
|
// 非订单影响库存变更,只更新本店铺下商品
|
||||||
if (!isset($event->businessGoods['business_order_id'])) {
|
if (!isset($event->businessGoods['business_order_id'])) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user