ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -223,7 +223,7 @@ @ApiOperation(value = "修改", tags = {"后台-商品管理"}) public R updateGoods(@RequestBody TGoods dto) { TGoods byId = goodsService.getById(dto.getId()); if (byId.getTotal()!=null && !Objects.equals(byId.getTotal(), dto.getTotal())){ if (byId.getTotal()!=null && dto.getTotal()!=null &&!Objects.equals(byId.getTotal(), dto.getTotal())){ // 如果修改了商品总数 那么需要再判断当前商品已被购买了多少 List<TOrder> list = orderService.list(new QueryWrapper<TOrder>() .eq("goodsId", dto.getId())); ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java
@@ -229,7 +229,8 @@ } boolean canBuy = good.getTotal() - item >= number; if (!canBuy) { throw new GlobalException("商品库存不足,兑换失败!"); return R.exchangeError("商品库存不足,兑换失败!"); // throw new GlobalException("商品库存不足,兑换失败!"); } // 检查用户兑换数量是否超过单用户最大兑换数量 List<TOrder> orderList = orderService.lambdaQuery().eq(TOrder::getUserId, user.getId())