diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index d97078f6..a8c99c2a 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -112,6 +112,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository throw new ValidateException('活动商品限购1个'); } } + $oldProductId = $cart->product->old_product_id ?? 0; + if (in_array($oldProductId, [1, 2, 3])) { + $oldProductStock = Db::name('store_product')->where('product_id', $oldProductId)->value('stock'); + if ($oldProductStock < $cart['cart_num']) { + throw new ValidateException('商品库存不足'); + } + } if ($cart['product_type'] <= 97 && $cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) { throw new ValidateException('活动商品必须单独购买'); }