Commit b3efa9a20b94464f8b0b2f2db0800b014149da67
1 parent
97e3922c
fix:利润分析计算时,修复没有对订单id进行唯一判断,一个id只能找到一个利润信息。
Showing
1 changed file
with
12 additions
and
2 deletions
src/main/java/com/order/erp/service/order/impl/OrderProfitAnalysisServiceImpl.java
... | ... | @@ -234,11 +234,21 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl<OrderProfitAnaly |
234 | 234 | List<OrderProfitAnalysisDO> orderProfits = list(new LambdaQueryWrapper<OrderProfitAnalysisDO>() |
235 | 235 | .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) |
236 | 236 | .in(OrderProfitAnalysisDO::getOrderId, orderBaseInfoDOList.stream().map(OrderBaseInfoDO::getId).collect(Collectors.toSet()))); |
237 | + // 去重:按 orderId 保留第一个 | |
238 | + List<OrderProfitAnalysisDO> uniqueOrderProfits = new ArrayList<>( | |
239 | + orderProfits.stream() | |
240 | + .collect(Collectors.toMap( | |
241 | + OrderProfitAnalysisDO::getOrderId, | |
242 | + Function.identity(), | |
243 | + (existing, replacement) -> existing | |
244 | + )) | |
245 | + .values() | |
246 | + ); | |
237 | 247 | |
238 | - if (CollectionUtils.isEmpty(orderProfits)) { | |
248 | + if (CollectionUtils.isEmpty(uniqueOrderProfits)) { | |
239 | 249 | throw new BusinessException("选中的订单信息不存在"); |
240 | 250 | } |
241 | - return wrapperProfitResult(profitAnalysisVo, orderProfits); | |
251 | + return wrapperProfitResult(profitAnalysisVo, uniqueOrderProfits); | |
242 | 252 | } |
243 | 253 | |
244 | 254 | @Override | ... | ... |