diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamSummaryQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamSummaryQryExe.java index caef3747..8a5b7da4 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamSummaryQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamSummaryQryExe.java @@ -38,6 +38,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -164,26 +165,22 @@ public class BdTeamSummaryQryExe { private BdTeamSummaryCO.TeamSummaryItem queryBdSummary(Long bdUserId, Integer currentBillBelong) { BdTeamSummaryCO.TeamSummaryItem item = new BdTeamSummaryCO.TeamSummaryItem(); - // 查询该用户下的所有 Agency 团队 - List bdTeamList = businessDevelopmentTeamService.listByUserId(bdUserId); - - if (CollectionUtils.isEmpty(bdTeamList)) { - item.setCount(0); - item.setTotalIncome(BigDecimal.ZERO); - return item; - } - List bdInfos = businessDevelopmentBaseInfoService.listBdByLeadUserId(bdUserId); - bdInfos = filterBdLeader(bdUserId, bdInfos); - item.setCount(bdInfos.size()); + List list = bdInfos.stream() + .filter(e -> !e.getUserId().equals(bdUserId)) + .map(BusinessDevelopmentBaseInfo::getUserId).toList(); - List list = bdInfos.stream().map(BusinessDevelopmentBaseInfo::getUserId).toList(); - bdTeamList = bdTeamList.stream().filter(e -> list.contains(e.getUserId())).collect(Collectors.toList()); - - // 计算总收入 - BigDecimal totalIncome = calculateBdTotalIncome(bdTeamList, currentBillBelong); + BigDecimal totalIncome = list.stream().map(bUserId -> { + // 查询该用户的bd下的所有 Agency 团队 + List bdTeamList = businessDevelopmentTeamService.listByUserId(bUserId); + if (CollectionUtils.isNotEmpty(bdTeamList)) { + // 计算总收入 + return calculateBdTotalIncome(bdTeamList, currentBillBelong); + } + return BigDecimal.ZERO; + }).reduce(BigDecimal.ZERO, BigDecimal::add); item.setTotalIncome(totalIncome); return item;