bd 相关修复
This commit is contained in:
parent
41e53e8efc
commit
d1744dbc1e
@ -157,6 +157,29 @@ public class TeamBdRestController extends BaseController {
|
||||
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.
|
||||
*
|
||||
|
||||
@ -60,7 +60,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
||||
log.warn("开始处理所有 BD Leader 工资结算,结算周期:{}", billBelong);
|
||||
|
||||
// 查询所有 BD Leader
|
||||
List<BusinessDevelopmentBaseInfo> allBdLeaders = businessDevelopmentBaseInfoService.listAll();
|
||||
List<BusinessDevelopmentBaseInfo> allBdLeaders = businessDevelopmentBaseInfoService.listBdByLeadUserId(1981629599990001666L);
|
||||
|
||||
if (CollectionUtils.isEmpty(allBdLeaders)) {
|
||||
log.warn("没有找到任何 BD Leader 数据");
|
||||
@ -156,6 +156,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
||||
if (userProfile != null) {
|
||||
detail.setBdUserName(userProfile.getUserNickname());
|
||||
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) {
|
||||
try {
|
||||
// 调用钱包服务发放工资
|
||||
issueSalary(bdLeaderUserId, record);
|
||||
// issueSalary(bdLeaderUserId, record);
|
||||
|
||||
// 更新状态为成功
|
||||
bdLeaderSalarySettlementRecordService.updateStatus(record.getId(), BdSettlementStatus.SUCCESS, null);
|
||||
|
||||
@ -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.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.BdTeamStatisticsCO;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
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.team.team.TeamMemberTarget;
|
||||
import com.red.circle.other.infra.enums.BdPolicyType;
|
||||
import com.red.circle.other.infra.enums.BdSettlementStatus;
|
||||
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.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -63,8 +66,8 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
log.warn("开始处理所有 BD 工资结算,结算周期:{}", billBelong);
|
||||
|
||||
// 查询所有 BD
|
||||
List<BusinessDevelopmentTeam> allBdTeams = businessDevelopmentTeamService.listByBdUserId(1976098223186104322L);
|
||||
|
||||
List<BusinessDevelopmentTeam> allBdTeams = businessDevelopmentTeamService.listByBdUserId(1971066750763978754L);
|
||||
|
||||
if (CollectionUtils.isEmpty(allBdTeams)) {
|
||||
log.warn("没有找到任何 BD 数据");
|
||||
return;
|
||||
@ -167,26 +170,26 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
|
||||
// 遍历每个团队,统计每个用户的数据
|
||||
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);
|
||||
|
||||
if (CollectionUtils.isEmpty(memberTargets)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// 统计每个用户的数据
|
||||
for (com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget target : memberTargets) {
|
||||
Long userId = target.getUserId();
|
||||
allUserIds.add(userId);
|
||||
|
||||
// 统计 Host 数量(一个团队 = 1个 Host)
|
||||
userHostCountMap.merge(userId, 1, Integer::sum);
|
||||
for (TeamMemberTarget target : memberTargets) {
|
||||
// 统计 Host 数量
|
||||
userHostCountMap.merge(agentId, 1, Integer::sum);
|
||||
|
||||
// 统计工资(从结算结果中获取)
|
||||
if (target.getSettlementResult() != null && target.getSettlementResult().getTotalSalary() != null) {
|
||||
BigDecimal salary = target.getSettlementResult().getTotalSalary();
|
||||
userSalaryMap.merge(userId, salary, BigDecimal::add);
|
||||
userSalaryMap.merge(agentId, salary, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,17 +200,26 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
|
||||
// 批量查询用户信息
|
||||
Map<Long, UserProfile> userProfileMap = userProfileGateway.mapByUserIds(allUserIds);
|
||||
|
||||
|
||||
// 计算结算周期的开始和结束时间
|
||||
int year = billBelong / 100;
|
||||
int month = billBelong % 100;
|
||||
java.time.LocalDateTime startTime = java.time.LocalDateTime.of(year, month, 1, 0, 0, 0);
|
||||
java.time.LocalDateTime endTime = startTime.plusMonths(1).minusSeconds(1);
|
||||
|
||||
int year, month;
|
||||
|
||||
if (billBelong > 999999) {
|
||||
// 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<>();
|
||||
try {
|
||||
com.red.circle.framework.dto.ResultResponse<List<BatchUserRechargeStatisticsDTO>> response =
|
||||
ResultResponse<List<BatchUserRechargeStatisticsDTO>> response =
|
||||
inAppPurchaseDetailsClientApi.batchUserRechargeStatistics(
|
||||
new ArrayList<>(allUserIds),
|
||||
SysOriginPlatformEnum.LIKEI.name(),
|
||||
@ -236,6 +248,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
if (userProfile != null) {
|
||||
detail.setUserName(userProfile.getUserNickname());
|
||||
detail.setUserAvatar(userProfile.getUserAvatar());
|
||||
detail.setUserAccount(userProfile.getAccount());
|
||||
}
|
||||
|
||||
// 设置工资
|
||||
|
||||
@ -250,6 +250,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
|
||||
co.setUserId(detail.getUserId());
|
||||
co.setUserName(detail.getUserName());
|
||||
co.setUserAvatar(detail.getUserAvatar());
|
||||
co.setAccount(detail.getUserAccount());
|
||||
co.setSalary(detail.getSalary() != null ? detail.getSalary() : BigDecimal.ZERO);
|
||||
co.setRecharge(detail.getRecharge() != null ? detail.getRecharge() : BigDecimal.ZERO);
|
||||
co.setHostCount(detail.getHostCount() != null ? detail.getHostCount() : 0);
|
||||
@ -263,6 +264,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
|
||||
BdLeaderTeamMemberDetailCO co = new BdLeaderTeamMemberDetailCO();
|
||||
co.setBdUserId(detail.getBdUserId());
|
||||
co.setBdUserName(detail.getBdUserName());
|
||||
co.setAccount(detail.getBdUserAccount());
|
||||
co.setBdUserAvatar(detail.getBdUserAvatar());
|
||||
co.setSalary(detail.getSalary() != null ? detail.getSalary() : BigDecimal.ZERO);
|
||||
co.setAgencyCount(detail.getAgencyCount() != null ? detail.getAgencyCount() : 0);
|
||||
@ -276,6 +278,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
|
||||
BdHistoryCO co = new BdHistoryCO();
|
||||
co.setPeriod(formatPeriod(record.getBillBelong()));
|
||||
co.setBillTitle(record.getBillTitle());
|
||||
co.setBillBelong(record.getBillBelong());
|
||||
co.setAgencyNumber(record.getAgencyNumber());
|
||||
co.setTeamSalaryAmount(record.getTeamSalaryAmount());
|
||||
co.setTeamRechargeAmount(record.getTeamRechargeAmount());
|
||||
@ -295,6 +298,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
|
||||
BdLeaderHistoryCO co = new BdLeaderHistoryCO();
|
||||
co.setPeriod(formatPeriod(record.getBillBelong()));
|
||||
co.setBillTitle(record.getBillTitle());
|
||||
co.setBillBelong(record.getBillBelong());
|
||||
co.setBdNumber(record.getBdNumber());
|
||||
co.setTeamSalaryAmount(record.getTeamSalaryAmount());
|
||||
co.setBasicSalary(record.getBasicSalary());
|
||||
@ -334,7 +338,7 @@ public class TeamBdHistoryServiceImpl implements TeamBdHistoryService {
|
||||
}
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
|
||||
return startDate.format(formatter) + "-" + endDate.format(formatter);
|
||||
return startDate.format(formatter).replace("+", "") + "-" + endDate.format(formatter).replace("+", "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -21,7 +21,12 @@ public class BdHistoryCO {
|
||||
* 结算周期标题
|
||||
*/
|
||||
private String billTitle;
|
||||
|
||||
|
||||
/**
|
||||
* 结算周期
|
||||
*/
|
||||
private Integer billBelong;
|
||||
|
||||
/**
|
||||
* Agent数量
|
||||
*/
|
||||
|
||||
@ -21,6 +21,11 @@ public class BdLeaderHistoryCO {
|
||||
* 结算周期标题
|
||||
*/
|
||||
private String billTitle;
|
||||
|
||||
/**
|
||||
* 结算周期
|
||||
*/
|
||||
private Integer billBelong;
|
||||
|
||||
/**
|
||||
* BD数量
|
||||
|
||||
@ -24,8 +24,14 @@ public class BdLeaderTeamMemberDetailCO {
|
||||
* BD 用户名称
|
||||
*/
|
||||
private String bdUserName;
|
||||
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
|
||||
/**
|
||||
* BD 用户头像
|
||||
*/
|
||||
private String bdUserAvatar;
|
||||
|
||||
@ -24,6 +24,11 @@ public class BdTeamMemberDetailCO {
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
|
||||
@ -34,7 +34,7 @@ public class BdSalaryPolicy implements Serializable {
|
||||
/**
|
||||
* 政策类型:TEAM_SALARY | TEAM_RECHARGE.
|
||||
*/
|
||||
private BdPolicyType policyType;
|
||||
private String policyType;
|
||||
|
||||
/**
|
||||
* 等级.
|
||||
|
||||
@ -38,6 +38,11 @@ public class BdLeaderTeamMemberDetail implements Serializable {
|
||||
*/
|
||||
private String bdUserAvatar;
|
||||
|
||||
/**
|
||||
* BD 用户账号.
|
||||
*/
|
||||
private String bdUserAccount;
|
||||
|
||||
/**
|
||||
* 工资金额(美元).
|
||||
*/
|
||||
|
||||
@ -38,6 +38,11 @@ public class BdTeamMemberDetail implements Serializable {
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
|
||||
/**
|
||||
* 工资金额(美元).
|
||||
*/
|
||||
|
||||
@ -1,21 +1,40 @@
|
||||
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.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.enums.BdPolicyType;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 java.util.List;
|
||||
|
||||
@SpringBootTest(classes = OtherServiceApplication.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class BdSettlementTest {
|
||||
|
||||
@Autowired
|
||||
private BdSalarySettlementTask bdSalarySettlementTask;
|
||||
@Autowired
|
||||
private BdLeaderSalarySettlementTask bdLeaderSalarySettlementTask;
|
||||
@Autowired
|
||||
private BdSalaryPolicyService bdSalaryPolicyService;
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* BD 工资结算
|
||||
*/
|
||||
@Test
|
||||
public void testBdSettlement() {
|
||||
Integer billBelong = TeamBillCycleUtils.getCalcBillBelong();
|
||||
@ -24,4 +43,16 @@ public class BdSettlementTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* BDLEADER 工资结算
|
||||
*/
|
||||
@Test
|
||||
public void testBdLeaderSettlement() {
|
||||
Integer billBelong = TeamBillCycleUtils.getCalcBillBelong();
|
||||
|
||||
bdLeaderSalarySettlementTask.processBdLeaderSalarySettlementTest(billBelong);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user