From 5878beb0d60c5051ae6af61cfbe4f904bf6068e7 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 31 Oct 2025 10:43:58 +0800 Subject: [PATCH] =?UTF-8?q?bd=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/team/TeamBdRestController.java | 37 +-------- .../bd/query/TeamBdMemberBillListQryExe.java | 77 ++++++++++++------- .../app/service/TeamBdBillServiceImpl.java | 3 +- .../dto/clientobject/TeamBdMemberBillCO.java | 25 ++---- .../app/dto/clientobject/TeamBdMemberCO.java | 19 +++++ .../dto/clientobject/team/BdHistoryCO.java | 25 +++++- .../other/app/service/TeamBdBillService.java | 3 +- 7 files changed, 103 insertions(+), 86 deletions(-) create mode 100644 rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberCO.java diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java index 0a37aad1..40f11bb0 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java @@ -4,6 +4,7 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.app.AppFlowCmd; import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.web.controller.BaseController; +import com.red.circle.other.app.dto.clientobject.TeamBdMemberCO; import com.red.circle.other.app.dto.clientobject.team.*; import com.red.circle.other.app.dto.cmd.activity.LotteryWithdrawCmd; import com.red.circle.other.app.dto.cmd.team.*; @@ -11,11 +12,7 @@ import com.red.circle.other.app.service.team.TeamBdHistoryService; import com.red.circle.other.app.service.team.TeamBdService; import com.red.circle.other.app.service.TeamBdBillService; import com.red.circle.other.app.dto.cmd.TeamBdMemberBillCmd; -import com.red.circle.other.app.dto.cmd.TeamBdMemberBillDetailCmd; -import com.red.circle.other.app.dto.cmd.TeamBdMonthlyIncomeCmd; import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillCO; -import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillDetailCO; -import com.red.circle.other.app.dto.clientobject.TeamBdMonthlyIncomeCO; import com.red.circle.other.infra.database.mongo.entity.team.bd.MessageInviteGroup; import java.util.List; @@ -251,40 +248,10 @@ public class TeamBdRestController extends BaseController { * @eo.request-type formdata */ @GetMapping("/member-bill/list") - public List queryMemberBillList(@Validated TeamBdMemberBillCmd cmd) { + public TeamBdMemberCO queryMemberBillList(@Validated TeamBdMemberBillCmd cmd) { return teamBdBillService.queryMemberBillList(cmd); } - /** - * 查询BD成员账单明细列表. - * - * @param cmd 查询命令 - * @return 成员账单明细列表 - * @eo.name 查询BD成员账单明细列表 - * @eo.url /member-bill/detail-list - * @eo.method get - * @eo.request-type formdata - */ - @GetMapping("/member-bill/detail-list") - public List queryMemberBillDetailList(TeamBdMemberBillDetailCmd cmd) { - return teamBdBillService.queryMemberBillDetailList(cmd); - } - - /** - * 查询BD团队月度收入汇总. - * - * @param cmd 查询命令 - * @return 月度收入汇总 - * @eo.name 查询BD团队月度收入 - * @eo.url /monthly-income - * @eo.method get - * @eo.request-type formdata - */ - @GetMapping("/monthly-income") - public TeamBdMonthlyIncomeCO queryMonthlyIncome(@Validated TeamBdMonthlyIncomeCmd cmd) { - return teamBdBillService.queryMonthlyIncome(cmd); - } - /** * 提交提现申请. * diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java index 9230255b..567ac2d8 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java @@ -2,6 +2,7 @@ package com.red.circle.other.app.command.bd.query; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillCO; +import com.red.circle.other.app.dto.clientobject.TeamBdMemberCO; import com.red.circle.other.app.dto.cmd.TeamBdMemberBillCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.mongo.dto.team.TeamBillSettleResult; @@ -12,6 +13,7 @@ import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils import com.red.circle.other.infra.database.mongo.service.team.team.TeamBillCycleService; import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberService; import com.red.circle.other.infra.database.mongo.service.team.team.TeamProfileService; +import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentBaseInfo; import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentTeam; import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService; import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentTeamService; @@ -57,18 +59,51 @@ public class TeamBdMemberBillListQryExe { * @param cmd 查询命令 * @return 账单列表 */ - public List execute(TeamBdMemberBillCmd cmd) { + public TeamBdMemberCO execute(TeamBdMemberBillCmd cmd) { List bdTeamList = new ArrayList<>(); if ("BD".equals(cmd.getType())) { bdTeamList.addAll(businessDevelopmentTeamService.listByUserId(cmd.getReqUserId())); } else { -// bdTeamList.addAll(buildBdTeamVO(teamMemberService.listTeamMember(cmd.getReqUserId(), 100))); + List baseInfos = businessDevelopmentBaseInfoService.listBdByLeadUserId(cmd.getReqUserId()); + + + Set bdIdSet = baseInfos.stream() + .map(BusinessDevelopmentBaseInfo::getUserId) + .collect(Collectors.toSet()); + Map userProfileMap = userProfileAppConvertor.toMapUserProfileDTO( + userProfileGateway.mapByUserIds(bdIdSet)); + + List list = baseInfos.stream().map(e -> { + TeamBdMemberBillCO billCO = new TeamBdMemberBillCO(); + + // 代理用户信息 + UserProfileDTO userProfile = userProfileMap.get(e.getUserId()); + if (userProfile != null) { + billCO.setAgentId(userProfile.getId()); + billCO.setAgentAccount(userProfile.getAccount()); + billCO.setAgentName(userProfile.getUserNickname()); + billCO.setAgentAvatar(userProfile.getUserAvatar()); + } + billCO.setTeamSalaryAmount(BigDecimal.ZERO); + billCO.setTeamMemberCount(e.getMemberQuantity().intValue()); + + return billCO; + + }).toList(); + + TeamBdMemberCO teamBdMemberCO = new TeamBdMemberCO(); + teamBdMemberCO.setMemberBillList(list); + teamBdMemberCO.setTotalSalary(BigDecimal.ZERO); + teamBdMemberCO.setTotalRecharge(BigDecimal.ZERO); + teamBdMemberCO.setBillTitle(TeamBillCycleUtils.parseBillBelongToDateRangeStr(TeamBillCycleUtils.getCalcBillBelong())); + + return teamBdMemberCO; } // 1. 查询BD关联的所有代理 if (CollectionUtils.isEmpty(bdTeamList)) { - return Collections.emptyList(); + return new TeamBdMemberCO(); } // 2. 获取团队ID集合 @@ -94,9 +129,16 @@ public class TeamBdMemberBillListQryExe { userProfileGateway.mapByUserIds(agentIdSet)); // 7. 组装返回结果 - return bdTeamList.stream() - .map(bdTeam -> buildMemberBillCO(bdTeam, billCycleMap, teamProfileMap, userProfileMap, currentBillBelong)) - .collect(Collectors.toList()); + List collect = bdTeamList.stream() + .map(bdTeam -> buildMemberBillCO(bdTeam, billCycleMap, teamProfileMap, userProfileMap, currentBillBelong)) + .collect(Collectors.toList()); + + TeamBdMemberCO teamBdMemberCO = new TeamBdMemberCO(); + teamBdMemberCO.setMemberBillList(collect); + teamBdMemberCO.setTotalSalary(collect.stream().map(TeamBdMemberBillCO::getTeamSalaryAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); + teamBdMemberCO.setTotalRecharge(collect.stream().map(TeamBdMemberBillCO::getTeamRechargeAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); + teamBdMemberCO.setBillTitle(TeamBillCycleUtils.parseBillBelongToDateRangeStr(TeamBillCycleUtils.getCalcBillBelong())); + return teamBdMemberCO; } private Collection buildBdTeamVO(List teamMembers) { @@ -124,6 +166,7 @@ public class TeamBdMemberBillListQryExe { UserProfileDTO userProfile = userProfileMap.get(bdTeam.getAgentId()); if (userProfile != null) { co.setAgentId(bdTeam.getAgentId()); + co.setAgentAccount(userProfile.getAccount()); co.setAgentName(userProfile.getUserNickname()); co.setAgentAvatar(userProfile.getUserAvatar()); } @@ -154,31 +197,11 @@ public class TeamBdMemberBillListQryExe { // 团队薪资和充值 co.setTeamSalaryAmount(settleResult.getTotalSalary()); co.setTeamRechargeAmount(BigDecimal.ZERO); - - // BD收益计算(这里使用默认比例,实际应该从配置读取) - BigDecimal salaryRatio = new BigDecimal("0.03"); // 3% - BigDecimal rechargeRatio = new BigDecimal("0.05"); // 5% - - co.setBdRatioSalary(salaryRatio.multiply(new BigDecimal("100"))); // 转换为百分比 - co.setBdRatioRecharge(rechargeRatio.multiply(new BigDecimal("100"))); - - BigDecimal bdSalaryIncome = Optional.ofNullable(settleResult.getTotalSalary()) - .orElse(BigDecimal.ZERO) - .multiply(salaryRatio); - BigDecimal bdRechargeIncome = Optional.ofNullable(BigDecimal.ZERO) - .orElse(BigDecimal.ZERO) - .multiply(rechargeRatio); - - co.setBdIncomeSalary(bdSalaryIncome); - co.setBdIncomeRecharge(bdRechargeIncome); + } else { // 如果没有账单周期,设置默认值 co.setTeamSalaryAmount(BigDecimal.ZERO); co.setTeamRechargeAmount(BigDecimal.ZERO); - co.setBdIncomeSalary(BigDecimal.ZERO); - co.setBdIncomeRecharge(BigDecimal.ZERO); - co.setBdRatioSalary(BigDecimal.ZERO); - co.setBdRatioRecharge(BigDecimal.ZERO); } return co; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TeamBdBillServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TeamBdBillServiceImpl.java index c6cc0948..07dc6dbd 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TeamBdBillServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/TeamBdBillServiceImpl.java @@ -6,6 +6,7 @@ import com.red.circle.other.app.command.bd.query.TeamBdMonthlyIncomeQryExe; import com.red.circle.other.app.command.bd.query.TeamBdWithdrawExe; import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillCO; import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillDetailCO; +import com.red.circle.other.app.dto.clientobject.TeamBdMemberCO; import com.red.circle.other.app.dto.clientobject.TeamBdMonthlyIncomeCO; import com.red.circle.other.app.dto.cmd.TeamBdMemberBillCmd; import com.red.circle.other.app.dto.cmd.TeamBdMemberBillDetailCmd; @@ -34,7 +35,7 @@ public class TeamBdBillServiceImpl implements TeamBdBillService { private final TeamBdWithdrawExe teamBdWithdrawExe; @Override - public List queryMemberBillList(TeamBdMemberBillCmd cmd) { + public TeamBdMemberCO queryMemberBillList(TeamBdMemberBillCmd cmd) { return teamBdMemberBillListQryExe.execute(cmd); } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberBillCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberBillCO.java index 7bc0254c..f651a650 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberBillCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberBillCO.java @@ -24,6 +24,11 @@ public class TeamBdMemberBillCO implements Serializable { @JsonSerialize(using = ToStringSerializer.class) private Long agentId; + /** + * 代理账号 + */ + private String agentAccount; + /** * 代理用户名. */ @@ -65,24 +70,4 @@ public class TeamBdMemberBillCO implements Serializable { */ private BigDecimal teamRechargeAmount; - /** - * BD收益-薪资部分(单位:元). - */ - private BigDecimal bdIncomeSalary; - - /** - * BD收益-充值部分(单位:元). - */ - private BigDecimal bdIncomeRecharge; - - /** - * BD收益比例-薪资(%). - */ - private BigDecimal bdRatioSalary; - - /** - * BD收益比例-充值(%). - */ - private BigDecimal bdRatioRecharge; - } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberCO.java new file mode 100644 index 00000000..2043468f --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/TeamBdMemberCO.java @@ -0,0 +1,19 @@ +package com.red.circle.other.app.dto.clientobject; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class TeamBdMemberCO { + + private String billTitle; + + private BigDecimal totalRecharge; + + private BigDecimal totalSalary; + + private List memberBillList; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdHistoryCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdHistoryCO.java index 3d0403e8..e2960b22 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdHistoryCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdHistoryCO.java @@ -41,8 +41,29 @@ public class BdHistoryCO { * 最终结算工资(美元) */ private BigDecimal settlementSalary; - + /** + * BD收益-薪资部分(单位:元). + */ + private BigDecimal bdIncomeSalary; + + /** + * BD收益-充值部分(单位:元). + */ + private BigDecimal bdIncomeRecharge; + + /** + * BD收益比例-薪资(%). + */ + private BigDecimal bdRatioSalary; + + /** + * BD收益比例-充值(%). + */ + private BigDecimal bdRatioRecharge; + + + /** * 结算状态: PENDING(In Progress) | SUCCESS(Completed) | FAILED */ private String status; @@ -56,7 +77,7 @@ public class BdHistoryCO { * 命中的政策类型 */ private String hitPolicyType; - + /** * 命中的等级 */ diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/TeamBdBillService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/TeamBdBillService.java index 4bd8d29b..71dcf3d7 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/TeamBdBillService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/TeamBdBillService.java @@ -2,6 +2,7 @@ package com.red.circle.other.app.service; import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillCO; import com.red.circle.other.app.dto.clientobject.TeamBdMemberBillDetailCO; +import com.red.circle.other.app.dto.clientobject.TeamBdMemberCO; import com.red.circle.other.app.dto.clientobject.TeamBdMonthlyIncomeCO; import com.red.circle.other.app.dto.cmd.TeamBdMemberBillCmd; import com.red.circle.other.app.dto.cmd.TeamBdMemberBillDetailCmd; @@ -24,7 +25,7 @@ public interface TeamBdBillService { * @param cmd 查询命令 * @return 账单列表 */ - List queryMemberBillList(TeamBdMemberBillCmd cmd); + TeamBdMemberCO queryMemberBillList(TeamBdMemberBillCmd cmd); /** * 查询 BD 成员账单明细列表.