From 9a3055a717c98a27a193e566a8febda4a1dd2413 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 15 一月 2025 20:08:04 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 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 4904c61..64920fb 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 @@ -191,7 +191,7 @@ info.setVip(appUser.getVipId()); GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格 - if((null == goodsSeckill || (null != goodsSeckill.getCashPayment() && null != goodsSeckill.getPointPayment())) || type == 1){ + if((null == goodsSeckill || (null == goodsSeckill.getCashPayment() && null == goodsSeckill.getPointPayment())) || type == 1){ //没有秒杀价,则判断门店特价 GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice(); goodsBargainPrice.setGoodsId(goodsId); @@ -357,15 +357,22 @@ */ @Override public R setGoodsNumber(SetGoodsNumber setGoodsNumber) { + + Long userid = tokenService.getLoginUserApplet().getUserid(); + ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); + 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("超出购买数量限制"); + } if(0 >= setGoodsNumber.getNumber()){ return R.fail("修改数量不能小于等于0"); } - ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); if(null != shoppingCart){ - Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); - if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && goods.getPurchaseLimit() < setGoodsNumber.getNumber()){ + Goods goods1 = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); + if(null != goods1.getPurchaseLimit() && -1 != goods1.getPurchaseLimit() && goods1.getPurchaseLimit() < setGoodsNumber.getNumber()){ return R.fail("修改数量不能大于限购数量"); } -- Gitblit v1.7.1