From d1cab4b2f2690d1331f12f0d9de78bbbf926f390 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 16 一月 2025 14:27:51 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 16 +++++++++++----- 1 files changed, 11 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..aeee681 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,12 @@ @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::getStatus,1) + .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 +362,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