luodangjia
2025-01-13 976a372f42b438edd8465a66e084b36deef38500
12.18
6个文件已修改
44 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java
@@ -39,6 +39,11 @@
            public R editGoodsList(List<Goods> goods) {
                return R.fail("编辑商品信息失败:" + cause.getMessage());
            }
            @Override
            public R<Void> editGoodsNum(Integer goodsId, Integer num) {
                return R.fail();
            }
        };
    }
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java
@@ -6,6 +6,7 @@
import com.ruoyi.other.api.factory.GoodsClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@@ -48,4 +49,10 @@
     */
    @PostMapping("/goods/editGoods")
    R editGoodsList(@RequestBody List<Goods> goods);
    /**
     * 商品销量增加
     */
    @PutMapping("/goods/editGoodsNum")
    R<Void> editGoodsNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("num") Integer num);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java
@@ -82,10 +82,13 @@
        int fromIndex = (int) ((current - 1) * size);
        int toIndex = (int) Math.min(fromIndex + size, walletStatisticsDetailList.size());
        if (fromIndex >= walletStatisticsDetailList.size()) {
            return new WalletStatistics();
        }
        Page<WalletStatisticsDetail> walletStatisticsDetailPage = new Page<>();
        WalletStatistics walletStatistics = new WalletStatistics();
        if (fromIndex >= walletStatisticsDetailList.size()) {
            walletStatistics.setPage(walletStatisticsDetailPage);
            return walletStatistics;
        }
        Map<Integer, BigDecimal> shopCommissionMap = walletStatisticsDetailList.stream()
                .collect(Collectors.groupingBy(
@@ -103,8 +106,6 @@
        List<WalletStatisticsDetail> walletStatisticsDetailList2 = walletStatisticsDetailList.subList(fromIndex, toIndex);
        WalletStatistics walletStatistics = new WalletStatistics();
        Page<WalletStatisticsDetail> walletStatisticsDetailPage = new Page<>();
        walletStatisticsDetailPage.setCurrent(current);
        walletStatisticsDetailPage.setSize(size);
        walletStatisticsDetailPage.setTotal(walletStatisticsDetailList.size());
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -1499,6 +1499,11 @@
        List<OrderGood> list = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().eq(OrderGood::getOrderId, order.getId()));
        List<Integer> goodsIds = list.stream().map(OrderGood::getGoodsId).collect(Collectors.toList());
        this.remove(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds));
        //商品销量增加
        for (Integer goodsId : goodsIds) {
            goodsClient.editGoodsNum(goodsId, 1);
        }
        return R.ok();
    }
    
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -10,6 +10,7 @@
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.redis.annotation.DistributedLock;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.domain.VipSetting;
import com.ruoyi.other.api.feignClient.VipSettingClient;
@@ -220,5 +221,18 @@
        goodsService.updateBatchById(goods);
        return R.ok();
    }
    /**
     * 商品销量增加
     */
    @PutMapping("/editGoodsNum")
    @DistributedLock(lockNamePre = "#goods_lock", lockNamePost = "#goodsId")
    public R<Void> editGoodsNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("num") Integer num){
        Goods goods = goodsService.getById(goodsId);
        goods.setSaleNum(goods.getSaleNum() + num);
        goodsService.updateById(goods);
        return R.ok();
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -116,8 +116,6 @@
                goods.setSellingPrice(price.getCash());
                goods.setIntegral(price.getPoint());
            }
            Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData();
            goods.setSaleNum(data);
        }
        //手动排序