调整商品限购

This commit is contained in:
luofei 2024-01-23 18:09:55 +08:00 committed by mkm
parent 4cba57d32c
commit 1c840cea03

View File

@ -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('活动商品必须单独购买');
}