luodangjia
2024-10-23 7ea47db47d3e039e25531cd511d8d7b1342ccfc0
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java
@@ -129,7 +129,7 @@
        if (goodType==1){
        TGoods byId = goodsService.getById(id);
        if (byId==null||byId.getStatus()==2){
            return R.fail(2,"内容不存在");
            return R.fail(2,"该商品已不存在");
        }
//            List<Integer> data = orderClient.getSalesCountByGoodsId(String.valueOf(id)).getData();
//            for (int i = 0; i < list.size(); i++) {
@@ -141,7 +141,7 @@
        else {
            TCoupon byId = couponService.getById(id);
            if (byId==null||byId.getStatus()==2){
                return R.fail(2,"内容不存在");
                return R.fail(2,"该商品已不存在");
            }
                return R.ok(byId);
            }
@@ -215,8 +215,10 @@
                return AjaxResult.error("当前用户已兑换"+count+"张");
            }else {
                //减少库存
                good.setInventory(good.getInventory()-exchangeDto.getNum());
                goodsService.updateById(good);
                if (good.getInventory()!=-1) {
                    good.setInventory(good.getInventory() - exchangeDto.getNum());
                    goodsService.updateById(good);
                }
            }
        if (user.getPoints()<good.getRedeemPoints()){
            return AjaxResult.error("当前用户积分不足");
@@ -232,8 +234,10 @@
            if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) {
                return AjaxResult.error("当前用户已到达兑换"+coupon+"次");
            }else {
                coupon.setInventoryQuantity(coupon.getInventoryQuantity()-1);
                couponService.updateById(coupon);
                if (coupon.getInventoryQuantity()!=-1) {
                    coupon.setInventoryQuantity(coupon.getInventoryQuantity() - 1);
                    couponService.updateById(coupon);
                }
            }