From df5465dcc83432b5fe1b0100a262335d99437eae Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 15 一月 2025 16:36:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
index 587ede5..4904c61 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -11,6 +11,7 @@
 import com.ruoyi.account.api.vo.PaymentUserCoupon;
 import com.ruoyi.account.api.vo.PaymentUserCouponVo;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.order.mapper.ShoppingCartMapper;
@@ -329,6 +330,11 @@
 	@Override
 	public Long addGoods(ShoppingCart shoppingCart) {
 		Long userid = tokenService.getLoginUserApplet().getUserid();
+		Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), null, userid);
+		Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
+		if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + shoppingCart.getNumber()) > goods.getPurchaseLimit()){
+			throw new ServiceException("超出购买数量限制");
+		}
 		ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid)
 				.eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()).eq(ShoppingCart::getType, shoppingCart.getType()).eq(ShoppingCart::getStatus, 1));
 		if(null != one){

--
Gitblit v1.7.1