bd 相关修复

This commit is contained in:
tianfeng 2025-10-31 14:29:29 +08:00
parent 41e53e8efc
commit d1744dbc1e
12 changed files with 127 additions and 24 deletions

View File

@ -157,6 +157,29 @@ public class TeamBdRestController extends BaseController {
return teamBdService.listBdInviteMessage(cmd); return teamBdService.listBdInviteMessage(cmd);
} }
/**
* 获取邀请Bd的消息-邀请BD.
*
* @eo.name 获取被Bd邀请消息-邀请BD.
* @eo.url /invite-bd-message
* @eo.method get
* @eo.request-type formdata
*/
@GetMapping("/invite-bd-message-own")
public List<BdInviteMessageCO> listInviteBdMessageOwn(BdInviteQryCmd cmd) {
cmd.setGroup(MessageInviteGroup.BD_LEADER_INVITE_BD.name());
return teamBdService.listBdInviteMessageOwn(cmd);
}
/**
* 邀请BD-撤销
*/
@PostMapping("/invite-bd-cancel/{id}")
public void inviteBdCancel(@PathVariable("id") String id) {
teamBdService.inviteAgentCancel(id);
}
/** /**
* 处理邀请-邀请BD. * 处理邀请-邀请BD.
* *

View File

@ -60,7 +60,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
log.warn("开始处理所有 BD Leader 工资结算,结算周期:{}", billBelong); log.warn("开始处理所有 BD Leader 工资结算,结算周期:{}", billBelong);
// 查询所有 BD Leader // 查询所有 BD Leader
List<BusinessDevelopmentBaseInfo> allBdLeaders = businessDevelopmentBaseInfoService.listAll(); List<BusinessDevelopmentBaseInfo> allBdLeaders = businessDevelopmentBaseInfoService.listBdByLeadUserId(1981629599990001666L);
if (CollectionUtils.isEmpty(allBdLeaders)) { if (CollectionUtils.isEmpty(allBdLeaders)) {
log.warn("没有找到任何 BD Leader 数据"); log.warn("没有找到任何 BD Leader 数据");
@ -156,6 +156,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
if (userProfile != null) { if (userProfile != null) {
detail.setBdUserName(userProfile.getUserNickname()); detail.setBdUserName(userProfile.getUserNickname());
detail.setBdUserAvatar(userProfile.getUserAvatar()); detail.setBdUserAvatar(userProfile.getUserAvatar());
detail.setBdUserAccount(userProfile.getAccount());
} }
} }
@ -175,7 +176,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
if (record.getSettlementSalary() != null && record.getSettlementSalary().compareTo(BigDecimal.ZERO) > 0) { if (record.getSettlementSalary() != null && record.getSettlementSalary().compareTo(BigDecimal.ZERO) > 0) {
try { try {
// 调用钱包服务发放工资 // 调用钱包服务发放工资
issueSalary(bdLeaderUserId, record); // issueSalary(bdLeaderUserId, record);
// 更新状态为成功 // 更新状态为成功
bdLeaderSalarySettlementRecordService.updateStatus(record.getId(), BdSettlementStatus.SUCCESS, null); bdLeaderSalarySettlementRecordService.updateStatus(record.getId(), BdSettlementStatus.SUCCESS, null);

View File

@ -2,11 +2,13 @@ package com.red.circle.other.app.service;
import com.red.circle.common.business.core.enums.ReceiptType; import com.red.circle.common.business.core.enums.ReceiptType;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.dto.clientobject.BdSalarySettlementCO; import com.red.circle.other.app.dto.clientobject.BdSalarySettlementCO;
import com.red.circle.other.app.dto.clientobject.BdTeamStatisticsCO; import com.red.circle.other.app.dto.clientobject.BdTeamStatisticsCO;
import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.infra.database.mongo.entity.bd.detail.BdTeamMemberDetail; import com.red.circle.other.infra.database.mongo.entity.bd.detail.BdTeamMemberDetail;
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget;
import com.red.circle.other.infra.enums.BdPolicyType; import com.red.circle.other.infra.enums.BdPolicyType;
import com.red.circle.other.infra.enums.BdSettlementStatus; import com.red.circle.other.infra.enums.BdSettlementStatus;
import com.red.circle.other.infra.database.mongo.entity.bd.BdSalaryPolicy; import com.red.circle.other.infra.database.mongo.entity.bd.BdSalaryPolicy;
@ -34,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -63,7 +66,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
log.warn("开始处理所有 BD 工资结算,结算周期:{}", billBelong); log.warn("开始处理所有 BD 工资结算,结算周期:{}", billBelong);
// 查询所有 BD // 查询所有 BD
List<BusinessDevelopmentTeam> allBdTeams = businessDevelopmentTeamService.listByBdUserId(1976098223186104322L); List<BusinessDevelopmentTeam> allBdTeams = businessDevelopmentTeamService.listByBdUserId(1971066750763978754L);
if (CollectionUtils.isEmpty(allBdTeams)) { if (CollectionUtils.isEmpty(allBdTeams)) {
log.warn("没有找到任何 BD 数据"); log.warn("没有找到任何 BD 数据");
@ -167,8 +170,11 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
// 遍历每个团队统计每个用户的数据 // 遍历每个团队统计每个用户的数据
for (BusinessDevelopmentTeam bdTeam : bdTeams) { for (BusinessDevelopmentTeam bdTeam : bdTeams) {
Long agentId = bdTeam.getAgentId();
allUserIds.add(agentId);
// 查询该团队的成员目标记录 // 查询该团队的成员目标记录
List<com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget> memberTargets = List<TeamMemberTarget> memberTargets =
teamMemberTargetService.listByBillBelong(bdTeam.getTeamId(), billBelong); teamMemberTargetService.listByBillBelong(bdTeam.getTeamId(), billBelong);
if (CollectionUtils.isEmpty(memberTargets)) { if (CollectionUtils.isEmpty(memberTargets)) {
@ -176,17 +182,14 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
} }
// 统计每个用户的数据 // 统计每个用户的数据
for (com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget target : memberTargets) { for (TeamMemberTarget target : memberTargets) {
Long userId = target.getUserId(); // 统计 Host 数量
allUserIds.add(userId); userHostCountMap.merge(agentId, 1, Integer::sum);
// 统计 Host 数量一个团队 = 1个 Host
userHostCountMap.merge(userId, 1, Integer::sum);
// 统计工资从结算结果中获取 // 统计工资从结算结果中获取
if (target.getSettlementResult() != null && target.getSettlementResult().getTotalSalary() != null) { if (target.getSettlementResult() != null && target.getSettlementResult().getTotalSalary() != null) {
BigDecimal salary = target.getSettlementResult().getTotalSalary(); BigDecimal salary = target.getSettlementResult().getTotalSalary();
userSalaryMap.merge(userId, salary, BigDecimal::add); userSalaryMap.merge(agentId, salary, BigDecimal::add);
} }
} }
} }
@ -199,15 +202,24 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
Map<Long, UserProfile> userProfileMap = userProfileGateway.mapByUserIds(allUserIds); Map<Long, UserProfile> userProfileMap = userProfileGateway.mapByUserIds(allUserIds);
// 计算结算周期的开始和结束时间 // 计算结算周期的开始和结束时间
int year = billBelong / 100; int year, month;
int month = billBelong % 100;
java.time.LocalDateTime startTime = java.time.LocalDateTime.of(year, month, 1, 0, 0, 0); if (billBelong > 999999) {
java.time.LocalDateTime endTime = startTime.plusMonths(1).minusSeconds(1); // 8位格式20251016
year = billBelong / 10000;
month = (billBelong / 100) % 100;
} else {
// 6位格式202510
year = billBelong / 100;
month = billBelong % 100;
}
LocalDateTime startTime = java.time.LocalDateTime.of(year, month, 1, 0, 0, 0);
LocalDateTime endTime = startTime.plusMonths(1).minusSeconds(1);
// 批量查询用户充值统计 // 批量查询用户充值统计
Map<Long, BigDecimal> userRechargeMap = new HashMap<>(); Map<Long, BigDecimal> userRechargeMap = new HashMap<>();
try { try {
com.red.circle.framework.dto.ResultResponse<List<BatchUserRechargeStatisticsDTO>> response = ResultResponse<List<BatchUserRechargeStatisticsDTO>> response =
inAppPurchaseDetailsClientApi.batchUserRechargeStatistics( inAppPurchaseDetailsClientApi.batchUserRechargeStatistics(
new ArrayList<>(allUserIds), new ArrayList<>(allUserIds),
SysOriginPlatformEnum.LIKEI.name(), SysOriginPlatformEnum.LIKEI.name(),
@ -236,6 +248,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
if (userProfile != null) { if (userProfile != null) {
detail.setUserName(userProfile.getUserNickname()); detail.setUserName(userProfile.getUserNickname());
detail.setUserAvatar(userProfile.getUserAvatar()); detail.setUserAvatar(userProfile.getUserAvatar());
detail.setUserAccount(userProfile.getAccount());
} }
// 设置工资 // 设置工资

View File

@ -250,6 +250,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
co.setUserId(detail.getUserId()); co.setUserId(detail.getUserId());
co.setUserName(detail.getUserName()); co.setUserName(detail.getUserName());
co.setUserAvatar(detail.getUserAvatar()); co.setUserAvatar(detail.getUserAvatar());
co.setAccount(detail.getUserAccount());
co.setSalary(detail.getSalary() != null ? detail.getSalary() : BigDecimal.ZERO); co.setSalary(detail.getSalary() != null ? detail.getSalary() : BigDecimal.ZERO);
co.setRecharge(detail.getRecharge() != null ? detail.getRecharge() : BigDecimal.ZERO); co.setRecharge(detail.getRecharge() != null ? detail.getRecharge() : BigDecimal.ZERO);
co.setHostCount(detail.getHostCount() != null ? detail.getHostCount() : 0); co.setHostCount(detail.getHostCount() != null ? detail.getHostCount() : 0);
@ -263,6 +264,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
BdLeaderTeamMemberDetailCO co = new BdLeaderTeamMemberDetailCO(); BdLeaderTeamMemberDetailCO co = new BdLeaderTeamMemberDetailCO();
co.setBdUserId(detail.getBdUserId()); co.setBdUserId(detail.getBdUserId());
co.setBdUserName(detail.getBdUserName()); co.setBdUserName(detail.getBdUserName());
co.setAccount(detail.getBdUserAccount());
co.setBdUserAvatar(detail.getBdUserAvatar()); co.setBdUserAvatar(detail.getBdUserAvatar());
co.setSalary(detail.getSalary() != null ? detail.getSalary() : BigDecimal.ZERO); co.setSalary(detail.getSalary() != null ? detail.getSalary() : BigDecimal.ZERO);
co.setAgencyCount(detail.getAgencyCount() != null ? detail.getAgencyCount() : 0); co.setAgencyCount(detail.getAgencyCount() != null ? detail.getAgencyCount() : 0);
@ -276,6 +278,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
BdHistoryCO co = new BdHistoryCO(); BdHistoryCO co = new BdHistoryCO();
co.setPeriod(formatPeriod(record.getBillBelong())); co.setPeriod(formatPeriod(record.getBillBelong()));
co.setBillTitle(record.getBillTitle()); co.setBillTitle(record.getBillTitle());
co.setBillBelong(record.getBillBelong());
co.setAgencyNumber(record.getAgencyNumber()); co.setAgencyNumber(record.getAgencyNumber());
co.setTeamSalaryAmount(record.getTeamSalaryAmount()); co.setTeamSalaryAmount(record.getTeamSalaryAmount());
co.setTeamRechargeAmount(record.getTeamRechargeAmount()); co.setTeamRechargeAmount(record.getTeamRechargeAmount());
@ -295,6 +298,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
BdLeaderHistoryCO co = new BdLeaderHistoryCO(); BdLeaderHistoryCO co = new BdLeaderHistoryCO();
co.setPeriod(formatPeriod(record.getBillBelong())); co.setPeriod(formatPeriod(record.getBillBelong()));
co.setBillTitle(record.getBillTitle()); co.setBillTitle(record.getBillTitle());
co.setBillBelong(record.getBillBelong());
co.setBdNumber(record.getBdNumber()); co.setBdNumber(record.getBdNumber());
co.setTeamSalaryAmount(record.getTeamSalaryAmount()); co.setTeamSalaryAmount(record.getTeamSalaryAmount());
co.setBasicSalary(record.getBasicSalary()); co.setBasicSalary(record.getBasicSalary());
@ -334,7 +338,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
} }
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
return startDate.format(formatter) + "-" + endDate.format(formatter); return startDate.format(formatter).replace("+", "") + "-" + endDate.format(formatter).replace("+", "");
} }
/** /**

View File

@ -22,6 +22,11 @@ public class BdHistoryCO {
*/ */
private String billTitle; private String billTitle;
/**
* 结算周期
*/
private Integer billBelong;
/** /**
* Agent数量 * Agent数量
*/ */

View File

@ -22,6 +22,11 @@ public class BdLeaderHistoryCO {
*/ */
private String billTitle; private String billTitle;
/**
* 结算周期
*/
private Integer billBelong;
/** /**
* BD数量 * BD数量
*/ */

View File

@ -26,6 +26,12 @@ public class BdLeaderTeamMemberDetailCO {
private String bdUserName; private String bdUserName;
/** /**
* 账号
*/
private String account;
/**
* BD 用户头像 * BD 用户头像
*/ */
private String bdUserAvatar; private String bdUserAvatar;

View File

@ -25,6 +25,11 @@ public class BdTeamMemberDetailCO {
*/ */
private String userName; private String userName;
/**
* 账号
*/
private String account;
/** /**
* 用户头像 * 用户头像
*/ */

View File

@ -34,7 +34,7 @@ public class BdSalaryPolicy implements Serializable {
/** /**
* 政策类型TEAM_SALARY | TEAM_RECHARGE. * 政策类型TEAM_SALARY | TEAM_RECHARGE.
*/ */
private BdPolicyType policyType; private String policyType;
/** /**
* 等级. * 等级.

View File

@ -38,6 +38,11 @@ public class BdLeaderTeamMemberDetail implements Serializable {
*/ */
private String bdUserAvatar; private String bdUserAvatar;
/**
* BD 用户账号.
*/
private String bdUserAccount;
/** /**
* 工资金额美元. * 工资金额美元.
*/ */

View File

@ -38,6 +38,11 @@ public class BdTeamMemberDetail implements Serializable {
*/ */
private String userAvatar; private String userAvatar;
/**
* 用户账号
*/
private String userAccount;
/** /**
* 工资金额美元. * 工资金额美元.
*/ */

View File

@ -1,21 +1,40 @@
import com.red.circle.OtherServiceApplication; import com.red.circle.OtherServiceApplication;
import com.red.circle.other.app.scheduler.BdLeaderSalarySettlementTask;
import com.red.circle.other.app.scheduler.BdSalarySettlementTask; import com.red.circle.other.app.scheduler.BdSalarySettlementTask;
import com.red.circle.other.app.scheduler.TeamBillTask; import com.red.circle.other.app.scheduler.TeamBillTask;
import com.red.circle.other.infra.database.mongo.entity.bd.BdSalaryPolicy;
import com.red.circle.other.infra.database.mongo.service.bd.BdSalaryPolicyService;
import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils; import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils;
import com.red.circle.other.infra.enums.BdPolicyType;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@SpringBootTest(classes = OtherServiceApplication.class) @SpringBootTest(classes = OtherServiceApplication.class)
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class BdSettlementTest { public class BdSettlementTest {
@Autowired @Autowired
private BdSalarySettlementTask bdSalarySettlementTask; private BdSalarySettlementTask bdSalarySettlementTask;
@Autowired
private BdLeaderSalarySettlementTask bdLeaderSalarySettlementTask;
@Autowired
private BdSalaryPolicyService bdSalaryPolicyService;
@Autowired
private MongoTemplate mongoTemplate;
/**
* BD 工资结算
*/
@Test @Test
public void testBdSettlement() { public void testBdSettlement() {
Integer billBelong = TeamBillCycleUtils.getCalcBillBelong(); Integer billBelong = TeamBillCycleUtils.getCalcBillBelong();
@ -24,4 +43,16 @@ public class BdSettlementTest {
} }
/**
* BDLEADER 工资结算
*/
@Test
public void testBdLeaderSettlement() {
Integer billBelong = TeamBillCycleUtils.getCalcBillBelong();
bdLeaderSalarySettlementTask.processBdLeaderSalarySettlementTest(billBelong);
}
} }