peng
4 天以前 b2dfffe3b575466f4422011589e159a0220dd2fb
排序调整
1个文件已修改
19 ■■■■■ 已修改文件
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
@@ -124,6 +124,9 @@
    private Cache<GoodsVO> cache;
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private COSUtil cosUtil;
    @Override
@@ -431,8 +434,22 @@
        LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(Goods::getGoodsSort,req.getSort());
        updateWrapper.eq(Goods::getId, req.getGoodsId());
        result = this.update(updateWrapper);
        //查询出比当前排序大的商品
        LambdaQueryWrapper<Goods> query = Wrappers.<Goods>lambdaQuery();
        query.gt(Goods::getGoodsSort,req.getSort());
        List<Goods> goods = goodsService.list(query);
        List<String> goodsIds = new ArrayList<>();
        if (goods != null && !goods.isEmpty()) {
         //适配没有排序的商品排序字段为null
            goods.forEach(item -> {
                if (item.getGoodsSort() != null) {
                    item.setGoodsSort(item.getGoodsSort() + 1);
                    goodsIds.add(item.getId());
                }
            });
            goodsService.updateBatchById(goods);
        }
        result = this.update(updateWrapper);
        goodsIds.add(req.getGoodsId());
        this.updateEsGoods(goodsIds);
        return result;