|
@@ -582,6 +582,13 @@ public class ProductOrderService {
|
|
|
if (giftItem == null) {
|
|
if (giftItem == null) {
|
|
|
return Result.error("赠品项不存在");
|
|
return Result.error("赠品项不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ // 赠品商品库存复核(下单时再次校验,防止详情页与下单之间库存耗尽)
|
|
|
|
|
+ if ("product".equals(giftItem.getGiftType()) && giftItem.getGiftProductId() != null) {
|
|
|
|
|
+ Product gp = productMapper.selectById(giftItem.getGiftProductId());
|
|
|
|
|
+ if (gp == null || gp.getStock() == null || gp.getStock() <= 0) {
|
|
|
|
|
+ return Result.error("赠品商品库存不足: " + (giftItem.getGiftProductName() != null ? giftItem.getGiftProductName() : "赠品"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
ProductOrderGift orderGift = new ProductOrderGift();
|
|
ProductOrderGift orderGift = new ProductOrderGift();
|
|
|
orderGift.setOrderId(order.getId());
|
|
orderGift.setOrderId(order.getId());
|
|
|
orderGift.setOrderNo(order.getOrderNo());
|
|
orderGift.setOrderNo(order.getOrderNo());
|