|
|
@@ -802,7 +802,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
Map<String, List<FollowCompanyFeeVO>> followGroupMap = followCompanyFeeVos.stream()
|
|
|
.collect(Collectors.groupingBy(this::buildGroupKey));
|
|
|
|
|
|
- // 【核心优化】提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
|
|
|
+ // 提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
|
|
|
Set<String> allFollowIds = new HashSet<>();
|
|
|
Set<String> allSettlementIds = new HashSet<>();
|
|
|
followGroupMap.values().forEach(list -> {
|
|
|
@@ -838,10 +838,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
// 应收金额(取第一条)
|
|
|
InsFeeFollowOrder firstFollow = followOrderMap.get(followIds.get(0));
|
|
|
- BigDecimal receivablePremium = Optional.ofNullable(firstFollow)
|
|
|
- .map(InsFeeFollowOrder::getReceivablePremium)
|
|
|
+// BigDecimal receivablePremium = Optional.ofNullable(firstFollow)
|
|
|
+// .map(InsFeeFollowOrder::getReceivablePremium)
|
|
|
+// .orElse(BigDecimal.ZERO);
|
|
|
+ // 对账金额
|
|
|
+ BigDecimal reconciliationAmount = Optional.ofNullable(firstFollow)
|
|
|
+ .map(InsFeeFollowOrder::getReconciliationAmount)
|
|
|
.orElse(BigDecimal.ZERO);
|
|
|
- vo.setTotalReceivable(receivablePremium);
|
|
|
+ vo.setTotalReceivable(reconciliationAmount);
|
|
|
|
|
|
// 已开票总额
|
|
|
BigDecimal totalInvoiced = followIds.stream()
|
|
|
@@ -850,7 +854,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
.map(InsFeeFollowOrder::getInvoiced)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
vo.setTotalInvoiced(totalInvoiced);
|
|
|
- vo.setTotalUnInvoiced(receivablePremium.subtract(totalInvoiced));
|
|
|
+ // 根据需求,未开票总金额 = 对账金额 - 已开票金额
|
|
|
+ vo.setTotalUnInvoiced(reconciliationAmount.subtract(totalInvoiced));
|
|
|
|
|
|
// 已结算总额
|
|
|
BigDecimal totalSettlementAmount = settlementIds.stream()
|