order is_pre_sale
parent
3df12d381c
commit
ffcae9b66a
|
|
@ -115,7 +115,8 @@ class OrderService
|
|||
$sku = $product['sku'];
|
||||
|
||||
// 商品开启预售, 则不验证库存
|
||||
if (!$sku->spu->is_pre_sale && !$sku->is_pre_sale && $product['quantity'] > $sku->saleable_stock) {
|
||||
$is_pre_sale = $sku->spu->is_pre_sale || $sku->is_pre_sale;
|
||||
if (!$is_pre_sale && $product['quantity'] > $sku->saleable_stock) {
|
||||
throw new BizException('商品库存不足');
|
||||
}
|
||||
}
|
||||
|
|
@ -390,7 +391,8 @@ class OrderService
|
|||
]);
|
||||
|
||||
// 未开启预售, 扣除商品库存
|
||||
if (!$sku->spu->is_pre_sale && !$sku->is_pre_sale) {
|
||||
$is_pre_sale = $sku->spu->is_pre_sale || $sku->is_pre_sale;
|
||||
if (!$is_pre_sale) {
|
||||
$sku->update([
|
||||
'stock' => DB::raw("stock - {$qty}")
|
||||
]);
|
||||
|
|
@ -1208,7 +1210,8 @@ class OrderService
|
|||
'sales' => DB::Raw("sales - {$product->quantity}"),
|
||||
]);
|
||||
// 商品未开启预售,返还库存
|
||||
if (!$product->spu->is_pre_sale && !$product->sku->is_pre_sale) {
|
||||
$is_pre_sale = $product->spu->is_pre_sale || $product->sku->is_pre_sale;
|
||||
if (!$is_pre_sale) {
|
||||
$product->sku?->update([
|
||||
'stock' => DB::Raw("stock + {$product->quantity}"),
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue