bd 修改

This commit is contained in:
tianfeng 2025-10-31 10:43:58 +08:00
parent ff420940c8
commit 5878beb0d6
7 changed files with 103 additions and 86 deletions

View File

@ -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<TeamBdMemberBillCO> 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<TeamBdMemberBillDetailCO> 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);
}
/**
* 提交提现申请.
*

View File

@ -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<TeamBdMemberBillCO> execute(TeamBdMemberBillCmd cmd) {
public TeamBdMemberCO execute(TeamBdMemberBillCmd cmd) {
List<BusinessDevelopmentTeam> bdTeamList = new ArrayList<>();
if ("BD".equals(cmd.getType())) {
bdTeamList.addAll(businessDevelopmentTeamService.listByUserId(cmd.getReqUserId()));
} else {
// bdTeamList.addAll(buildBdTeamVO(teamMemberService.listTeamMember(cmd.getReqUserId(), 100)));
List<BusinessDevelopmentBaseInfo> baseInfos = businessDevelopmentBaseInfoService.listBdByLeadUserId(cmd.getReqUserId());
Set<Long> bdIdSet = baseInfos.stream()
.map(BusinessDevelopmentBaseInfo::getUserId)
.collect(Collectors.toSet());
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
userProfileGateway.mapByUserIds(bdIdSet));
List<TeamBdMemberBillCO> 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<TeamBdMemberBillCO> 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<? extends BusinessDevelopmentTeam> buildBdTeamVO(List<TeamMember> 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;

View File

@ -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<TeamBdMemberBillCO> queryMemberBillList(TeamBdMemberBillCmd cmd) {
public TeamBdMemberCO queryMemberBillList(TeamBdMemberBillCmd cmd) {
return teamBdMemberBillListQryExe.execute(cmd);
}

View File

@ -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;
}

View File

@ -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<TeamBdMemberBillCO> memberBillList;
}

View File

@ -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;
/**
* 命中的等级
*/

View File

@ -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<TeamBdMemberBillCO> queryMemberBillList(TeamBdMemberBillCmd cmd);
TeamBdMemberCO queryMemberBillList(TeamBdMemberBillCmd cmd);
/**
* 查询 BD 成员账单明细列表.