mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 06:30:49 +00:00
扣减后触发重算
This commit is contained in:
parent
2ca2352ba0
commit
625acfa290
@ -72,7 +72,7 @@ class BusinessOrdersUpdate
|
|||||||
$updateParam['status'] = GoodsSku::$STATUS_ON_SALE;
|
$updateParam['status'] = GoodsSku::$STATUS_ON_SALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info("sku 业务订单库存更新", $updateParam);
|
Log::info("sku 业务订单库存更:{$this->goodsSku->id}", $updateParam);
|
||||||
//乐观锁更新
|
//乐观锁更新
|
||||||
return GoodsSku::query()->where('external_sku_id', $this->businessGoodSku['external_sku_id'])->
|
return GoodsSku::query()->where('external_sku_id', $this->businessGoodSku['external_sku_id'])->
|
||||||
where("stock", "=", $oldStock)->update($updateParam);
|
where("stock", "=", $oldStock)->update($updateParam);
|
||||||
|
|||||||
@ -62,13 +62,13 @@ class CombinationGoodsStockUpdateListener implements ShouldQueue
|
|||||||
->with('goodsSku:id,stock')
|
->with('goodsSku:id,stock')
|
||||||
->whereIn('goods_sku_id', $combinationGoodsIds)
|
->whereIn('goods_sku_id', $combinationGoodsIds)
|
||||||
->get();
|
->get();
|
||||||
$num = !empty($event->num) ? $event->num : 1;
|
$num = !empty($event->num) ? $event->num : -1;
|
||||||
foreach ($combinationGoods as $item) {
|
foreach ($combinationGoods as $item) {
|
||||||
DB::transaction(function () use ($item, &$updateIds, $num) {
|
DB::transaction(function () use ($item, &$updateIds, $num) {
|
||||||
$goodsSku = GoodsSku::query()->lockForUpdate()->find($item['item_id']);
|
$goodsSku = GoodsSku::query()->lockForUpdate()->find($item['item_id']);
|
||||||
$stock = $goodsSku->stock - $item['item_num'] * $num;
|
$stock = $goodsSku->stock + $item['item_num'] * $num;
|
||||||
//新增逻辑 在线库存同步扣减
|
//新增逻辑 在线库存同步扣减
|
||||||
$saleStock = max($goodsSku->sale_stock - $item['item_num'] * $num, 0);
|
$saleStock = max($goodsSku->sale_stock + $item['item_num'] * $num, 0);
|
||||||
[$status, $stock] = $this->checkStatusAndStock($goodsSku, $stock, $saleStock);
|
[$status, $stock] = $this->checkStatusAndStock($goodsSku, $stock, $saleStock);
|
||||||
$goodsSku->status = $status;
|
$goodsSku->status = $status;
|
||||||
$goodsSku->stock = $stock;
|
$goodsSku->stock = $stock;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user