Commit 97e3922c64abca9ed4a606e1da4eff3d04b4d676
1 parent
f00456f9
fix:利润分析计算时,修复没有对订单id进行唯一判断,一个id只能找到一个利润信息。
Showing
1 changed file
with
11 additions
and
1 deletions
src/main/java/com/order/erp/service/order/impl/OrderProfitAnalysisServiceImpl.java
@@ -259,8 +259,18 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl<OrderProfitAnaly | @@ -259,8 +259,18 @@ public class OrderProfitAnalysisServiceImpl extends ServiceImpl<OrderProfitAnaly | ||
259 | if (CollectionUtils.isEmpty(orderProfits)) { | 259 | if (CollectionUtils.isEmpty(orderProfits)) { |
260 | throw new BusinessException("选中的订单信息不存在"); | 260 | throw new BusinessException("选中的订单信息不存在"); |
261 | } | 261 | } |
262 | + // 去重:按 orderId 保留第一个 | ||
263 | + List<OrderProfitAnalysisDO> uniqueOrderProfits = new ArrayList<>( | ||
264 | + orderProfits.stream() | ||
265 | + .collect(Collectors.toMap( | ||
266 | + OrderProfitAnalysisDO::getOrderId, | ||
267 | + Function.identity(), | ||
268 | + (existing, replacement) -> existing | ||
269 | + )) | ||
270 | + .values() | ||
271 | + ); | ||
262 | 272 | ||
263 | - return wrapperProfitResult(profitAnalysisVo, orderProfits); | 273 | + return wrapperProfitResult(profitAnalysisVo,uniqueOrderProfits); |
264 | } | 274 | } |
265 | 275 | ||
266 | /** | 276 | /** |