luodangjia
2024-12-09 5728732f45cc45f3c5cbde0abe7a7c5efee605b9
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -19,6 +19,7 @@
import com.ruoyi.other.vo.GoodsVO;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -103,19 +104,22 @@
        }
        Goods goods = this.getById(goodsId);
        List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
                .eq(GoodsShop::getGoodsId, goodsId));
        List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
        List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
                .in(Shop::getId, shopIds));
        GoodsVO goodsVO = new GoodsVO();
        goodsVO.setShopList(shopList);
        BeanUtils.copyBeanProp(goodsVO, goods);
        goodsVO.setGoodsId(goods.getId());
        goodsVO.setGoodsName(goods.getName());
        goodsVO.setSellingPrice(sellingPrice);
        goodsVO.setIntegral(integral);
        List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
                .eq(GoodsShop::getGoodsId, goodsId));
        if (!CollectionUtils.isEmpty(goodsShopList)){
            List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
            List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
                    .in(Shop::getId, shopIds));
            goodsVO.setShopList(shopList);
        }
        return goodsVO;
    }