From dc6e870c25c9e4debc54e844544f447dc7bcfbac Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期三, 15 一月 2025 21:04:06 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 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..5d23be9 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); @@ -330,7 +330,11 @@ @Override public Long addGoods(ShoppingCart shoppingCart) { Long userid = tokenService.getLoginUserApplet().getUserid(); - Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), null, userid); + long goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), null, userid); + long count = count(new LambdaQueryWrapper<ShoppingCart>() + .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()) + .eq(ShoppingCart::getAppUserId, userid)); + goodsSaleNum += count; Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + shoppingCart.getNumber()) > goods.getPurchaseLimit()){ throw new ServiceException("超出购买数量限制"); @@ -357,15 +361,16 @@ */ @Override public R setGoodsNumber(SetGoodsNumber setGoodsNumber) { + + ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); 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