| | |
| | | import com.ruoyi.system.vo.TOrderStockVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | |
| | | // dto.setStockTotalPrice(sum); |
| | | this.save(dto); |
| | | // 添加商品 |
| | | orderStockGoods.forEach(orderSaleGoods1 -> orderSaleGoods1.setOrderId(dto.getId())); |
| | | orderStockGoods.forEach(orderSaleGoods1 -> { |
| | | orderSaleGoods1.setId(null); |
| | | orderSaleGoods1.setOrderId(dto.getId()); |
| | | }); |
| | | tOrderStockGoodsService.saveBatch(orderStockGoods); |
| | | } |
| | | |
| | |
| | | tOrderStockGoodsService.remove(Wrappers.lambdaQuery(TOrderStockGoods.class) |
| | | .eq(TOrderStockGoods::getOrderId,dto.getId())); |
| | | // 添加商品 |
| | | orderStockGoods.forEach(orderSaleGoods1 -> orderSaleGoods1.setOrderId(dto.getId())); |
| | | orderStockGoods.forEach(orderSaleGoods1 -> { |
| | | orderSaleGoods1.setId(null); |
| | | orderSaleGoods1.setOrderId(dto.getId()); |
| | | }); |
| | | tOrderStockGoodsService.saveBatch(orderStockGoods); |
| | | } |
| | | |
| | |
| | | List<TOrderStockVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | // 查询商品 |
| | | List<Long> orderIds = list.stream().map(TOrderStockVO::getId).collect(Collectors.toList()); |
| | | List<TOrderStockGoods> orderStockGoods = tOrderStockGoodsService.list(Wrappers.lambdaQuery(TOrderStockGoods.class) |
| | | .in(TOrderStockGoods::getOrderId, orderIds)); |
| | | list.forEach(orderSale -> { |
| | | List<TOrderStockGoods> collect = orderStockGoods.stream().filter(orderSaleGoods -> orderSaleGoods.getOrderId().equals(orderSale.getId())).collect(Collectors.toList()); |
| | | orderSale.setOrderStockGoods(collect); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(orderIds)){ |
| | | List<TOrderStockGoods> orderStockGoods = tOrderStockGoodsService.list(Wrappers.lambdaQuery(TOrderStockGoods.class) |
| | | .in(TOrderStockGoods::getOrderId, orderIds)); |
| | | list.forEach(orderSale -> { |
| | | List<TOrderStockGoods> collect = orderStockGoods.stream().filter(orderSaleGoods -> orderSaleGoods.getOrderId().equals(orderSale.getId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | orderSale.setOrderStockGoods(collect); |
| | | orderSale.setTotalPrice(collect.stream().map(TOrderStockGoods::getCostPrice).reduce(BigDecimal::add).get()); |
| | | } |
| | | }); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |