bd修复
This commit is contained in:
parent
d1744dbc1e
commit
27ea713593
@ -115,7 +115,7 @@ public class TeamBdMemberBillListQryExe {
|
||||
Integer currentBillBelong = TeamBillCycleUtils.getCalcBillBelong();
|
||||
|
||||
// 4. 查询当前周期的账单
|
||||
Map<Long, TeamBillCycle> billCycleMap = teamBillCycleService.mapByTeamIds(
|
||||
Map<Long, TeamBillCycle> billCycleMap = teamBillCycleService.mapByTeamIds2(
|
||||
teamIdSet, currentBillBelong, TeamBillCycleStatus.SETTLED);
|
||||
|
||||
// 5. 获取团队Profile信息(包含团队人数)
|
||||
|
||||
@ -60,7 +60,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
||||
log.warn("开始处理所有 BD Leader 工资结算,结算周期:{}", billBelong);
|
||||
|
||||
// 查询所有 BD Leader
|
||||
List<BusinessDevelopmentBaseInfo> allBdLeaders = businessDevelopmentBaseInfoService.listBdByLeadUserId(1981629599990001666L);
|
||||
List<BusinessDevelopmentBaseInfo> allBdLeaders = businessDevelopmentBaseInfoService.listAll();
|
||||
|
||||
if (CollectionUtils.isEmpty(allBdLeaders)) {
|
||||
log.warn("没有找到任何 BD Leader 数据");
|
||||
@ -140,6 +140,12 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
||||
bdRecord.getSettlementSalary().setScale(2, RoundingMode.DOWN) : BigDecimal.ZERO);
|
||||
detail.setAgencyCount(bdRecord.getAgencyNumber() != null ? bdRecord.getAgencyNumber() : 0);
|
||||
|
||||
memberDetails.add(detail);
|
||||
} else {
|
||||
BdLeaderTeamMemberDetail detail = new BdLeaderTeamMemberDetail();
|
||||
detail.setBdUserId(bdUserId);
|
||||
detail.setSalary(BigDecimal.ZERO);
|
||||
detail.setAgencyCount(0);
|
||||
memberDetails.add(detail);
|
||||
}
|
||||
}
|
||||
@ -150,7 +156,7 @@ public class BdLeaderSalarySettlementServiceImpl implements BdLeaderSalarySettle
|
||||
if (!CollectionUtils.isEmpty(memberDetails)) {
|
||||
Set<Long> bdUserIdSet = new HashSet<>(bdUserIds);
|
||||
Map<Long, UserProfile> userProfileMap = userProfileGateway.mapByUserIds(bdUserIdSet);
|
||||
|
||||
|
||||
for (BdLeaderTeamMemberDetail detail : memberDetails) {
|
||||
UserProfile userProfile = userProfileMap.get(detail.getBdUserId());
|
||||
if (userProfile != null) {
|
||||
@ -176,7 +182,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);
|
||||
|
||||
@ -66,7 +66,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
log.warn("开始处理所有 BD 工资结算,结算周期:{}", billBelong);
|
||||
|
||||
// 查询所有 BD
|
||||
List<BusinessDevelopmentTeam> allBdTeams = businessDevelopmentTeamService.listByBdUserId(1971066750763978754L);
|
||||
List<BusinessDevelopmentTeam> allBdTeams = businessDevelopmentTeamService.listAll();
|
||||
|
||||
if (CollectionUtils.isEmpty(allBdTeams)) {
|
||||
log.warn("没有找到任何 BD 数据");
|
||||
@ -128,11 +128,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
if (record.getSettlementSalary() != null && record.getSettlementSalary().compareTo(BigDecimal.ZERO) > 0) {
|
||||
try {
|
||||
// 调用钱包服务发放工资
|
||||
// issueSalary(bdUserId, record);
|
||||
|
||||
// 更新状态为成功
|
||||
bdSalarySettlementRecordService.updateStatus(record.getId(), BdSettlementStatus.SUCCESS, null);
|
||||
record.setStatus(BdSettlementStatus.SUCCESS);
|
||||
issueSalary(bdUserId, record);
|
||||
|
||||
log.info("BD {} 工资发放成功,金额:{} USD", bdUserId, record.getSettlementSalary());
|
||||
} catch (Exception e) {
|
||||
@ -145,6 +141,9 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
} else {
|
||||
log.info("BD {} 本周期未达到结算标准,无工资发放", bdUserId);
|
||||
}
|
||||
// 更新状态为成功
|
||||
bdSalarySettlementRecordService.updateStatus(record.getId(), BdSettlementStatus.SUCCESS, null);
|
||||
record.setStatus(BdSettlementStatus.SUCCESS);
|
||||
|
||||
return convertToCO(record);
|
||||
}
|
||||
@ -324,14 +323,22 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
||||
|
||||
try {
|
||||
// 计算结算周期的开始和结束时间
|
||||
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);
|
||||
|
||||
// 调用订单服务批量查询用户充值统计
|
||||
com.red.circle.framework.dto.ResultResponse<List<BatchUserRechargeStatisticsDTO>> response =
|
||||
ResultResponse<List<BatchUserRechargeStatisticsDTO>> response =
|
||||
inAppPurchaseDetailsClientApi.batchUserRechargeStatistics(
|
||||
userIds,
|
||||
SysOriginPlatformEnum.LIKEI.name(),
|
||||
|
||||
@ -22,6 +22,11 @@ public interface TeamBillCycleService {
|
||||
*/
|
||||
Map<Long, TeamBillCycle> mapByTeamIds(Set<Long> teamIds, Integer billBelong, TeamBillCycleStatus status);
|
||||
|
||||
/**
|
||||
* 获取一组账单信息2.
|
||||
*/
|
||||
Map<Long, TeamBillCycle> mapByTeamIds2(Set<Long> teamIds, Integer billBelong, TeamBillCycleStatus status);
|
||||
|
||||
/**
|
||||
* 获取一组账单信息.
|
||||
*/
|
||||
|
||||
@ -102,6 +102,59 @@ public class TeamBillCycleServiceImpl implements TeamBillCycleService {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, TeamBillCycle> mapByTeamIds2(Set<Long> teamIds, Integer billBelong, TeamBillCycleStatus status) {
|
||||
|
||||
if (CollectionUtils.isEmpty(teamIds) || Objects.isNull(status)) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
Criteria criteria = new Criteria().orOperator(
|
||||
Criteria.where("billBelong").is(billBelong)
|
||||
);
|
||||
|
||||
List<TeamBillCycle> teamBillCycles = mongoTemplate.find(
|
||||
Query.query(criteria.and("teamId").in(teamIds).and("status").is(status)),
|
||||
TeamBillCycle.class);
|
||||
|
||||
if (CollectionUtils.isEmpty(teamBillCycles)) {
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
return teamBillCycles.stream()
|
||||
.collect(Collectors.toMap(
|
||||
TeamBillCycle::getTeamId,
|
||||
v -> v,
|
||||
(v1, v2) -> {
|
||||
// 当teamId重复时,累加settleResult中的totalSalary
|
||||
BigDecimal totalSalary1 = BigDecimal.ZERO;
|
||||
BigDecimal totalSalary2 = BigDecimal.ZERO;
|
||||
|
||||
// 获取v1的totalSalary
|
||||
if (v1.getSettleResult() != null && v1.getSettleResult().getTotalSalary() != null) {
|
||||
totalSalary1 = v1.getSettleResult().getTotalSalary();
|
||||
}
|
||||
|
||||
// 获取v2的totalSalary
|
||||
if (v2.getSettleResult() != null && v2.getSettleResult().getTotalSalary() != null) {
|
||||
totalSalary2 = v2.getSettleResult().getTotalSalary();
|
||||
}
|
||||
|
||||
// 累加totalSalary
|
||||
BigDecimal sumTotalSalary = totalSalary1.add(totalSalary2);
|
||||
|
||||
// 确保v1有settleResult对象
|
||||
if (v1.getSettleResult() == null) {
|
||||
v1.setSettleResult(new TeamBillSettleResult());
|
||||
}
|
||||
|
||||
// 设置累加后的totalSalary
|
||||
v1.getSettleResult().setTotalSalary(sumTotalSalary);
|
||||
return v1;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, TeamBillCycle> mapByBillIds(Set<Long> teamIds, Set<Integer> billBelongs) {
|
||||
if (CollectionUtils.isEmpty(teamIds) || CollectionUtils.isEmpty(billBelongs)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user