xuhy
2026-01-14 4fa8b47fe5e653404da248149f8ec54eb1282599
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsShopController.java
@@ -173,21 +173,21 @@
        if (goodsIds.isEmpty()){
            ShopCarVO shopCarVO = new ShopCarVO();
            shopCarVO.setTotalPrice(BigDecimal.ZERO);
            shopCarVO.setList(new PageInfo<>());
            shopCarVO.setList(new ArrayList<>());
            return R.ok(shopCarVO);
        }
        TErpGoodsShopQuery tErpGoodsShopQuery = new TErpGoodsShopQuery();
        tErpGoodsShopQuery.setGoodsIds(goodsIds);
        PageInfo<TErpGoodsVO> tErpGoodsVOPageInfo = erpGoodsService.pageShopList(tErpGoodsShopQuery);
        List<TErpGoodsVO> records = tErpGoodsVOPageInfo.getRecords();
        for (TErpGoodsVO record : records) {
            for (ShoppingCartItem cartItem : cacheList) {
                if (cartItem.getId().equals(record.getId())) {
                    record.setNumber(cartItem.getNum());
                    record.setPrice(record.getSalesAmount().multiply(new BigDecimal(record.getNumber())).setScale(2, RoundingMode.HALF_UP));
                }
            }
        }
//        PageInfo<TErpGoodsVO> tErpGoodsVOPageInfo = erpGoodsService.pageShopList(tErpGoodsShopQuery);
//        List<TErpGoodsVO> records = tErpGoodsVOPageInfo.getRecords();
//        for (TErpGoodsVO record : records) {
//            for (ShoppingCartItem cartItem : cacheList) {
//                if (cartItem.getId().equals(record.getId())) {
//                    record.setNumber(cartItem.getNum());
//                    record.setPrice(record.getSalesAmount().multiply(new BigDecimal(record.getNumber())).setScale(2, RoundingMode.HALF_UP));
//                }
//            }
//        }
        List<TErpGoodsVO> listAll = erpGoodsService.pageShopListAll(tErpGoodsShopQuery);
        for (TErpGoodsVO record : listAll) {
            for (ShoppingCartItem cartItem : cacheList) {
@@ -197,8 +197,8 @@
                }
            }
        }
        BigDecimal totalPrice = records.stream().map(TErpGoodsVO::getPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
        res.setList(tErpGoodsVOPageInfo);
        BigDecimal totalPrice = listAll.stream().map(TErpGoodsVO::getPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
        res.setList(listAll);
        res.setTotalPrice(totalPrice);
        return R.ok(res);
    }