| | |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | } |
| | | 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); |
| | | } |