mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: #10000 快团团请求优化
This commit is contained in:
parent
362f622a80
commit
6b6c49dd75
@ -17,7 +17,7 @@ class StockUpdateEvent
|
||||
|
||||
public $goodsSku;
|
||||
public $goodsSkus;
|
||||
|
||||
public $isBatch;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
@ -26,8 +26,9 @@ class StockUpdateEvent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
public function __construct($data, $isBatch = 0)
|
||||
{
|
||||
$this->isBatch = $isBatch;
|
||||
if (is_array($data)) {
|
||||
// ids集合
|
||||
$this->goodsSkus = GoodsSku::query()->whereIn('id', $data)->with(['goods:id,goods_code'])->get();
|
||||
|
||||
@ -73,6 +73,6 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
$goodsSku->stock = 0;
|
||||
$goodsSku->save();
|
||||
}
|
||||
event(new StockUpdateEvent($onSkuIds));
|
||||
event(new StockUpdateEvent($onSkuIds, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,13 @@ class StockUpdateListener
|
||||
->where('is_sync', 1)
|
||||
->where('external_sku_id', $event->goodsSku->goods['goods_code'] . '_' . $event->goodsSku->sku_code)
|
||||
->get();
|
||||
if ($event->isBatch) {
|
||||
BusinessFactory::init()->make($shop['plat_id'])->setShopWithId($shop['id'])->batchIncrQuantity($businessGoodsSkus->toArray(), $num, false);
|
||||
} else {
|
||||
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku->toArray(), $num, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($event->goodsSkus)) {
|
||||
foreach ($event->goodsSkus as $goodsSku) {
|
||||
@ -54,7 +60,13 @@ class StockUpdateListener
|
||||
->where('is_sync', 1)
|
||||
->where('external_sku_id', $goodsSku->goods['goods_code'] . '_' . $goodsSku->sku_code)
|
||||
->get();
|
||||
if ($event->isBatch) {
|
||||
BusinessFactory::init()->make($shop['plat_id'])->setShopWithId($shop['id'])->batchIncrQuantity($businessGoodsSkus->toArray(), $num, false);
|
||||
} else {
|
||||
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku->toArray(), $num, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user