增加管理员的bd工资结算逻辑

This commit is contained in:
tianfeng 2026-01-04 14:08:38 +08:00
parent 665d76fa71
commit 39c7b45b4b
3 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package com.red.circle.other.app.service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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;
@ -84,7 +85,6 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
Set<Long> adminUserIds = getAdminUserIds();
// BD 用户 ID 分组去重
Map<Long, List<BusinessDevelopmentTeam>> bdGroupMap = allBdTeams.stream()
.filter(info -> !adminUserIds.contains(info.getUserId()))
.collect(Collectors.groupingBy(BusinessDevelopmentTeam::getUserId));
log.warn("共找到 {} 个 BD", bdGroupMap.size());
@ -95,7 +95,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
// 遍历每个 BD 进行结算
for (Long bdUserId : bdGroupMap.keySet()) {
try {
processSingleBdSettlement(bdUserId, billBelong, billTitle);
processSingleBdSettlement(bdUserId, billBelong, billTitle, adminUserIds);
successCount++;
} catch (Exception e) {
log.error("BD {} 工资结算失败", bdUserId, e);
@ -115,7 +115,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
@Override
@Transactional(rollbackFor = Exception.class)
public BdSalarySettlementCO processSingleBdSettlement(Long bdUserId, Integer billBelong, String billTitle) {
public BdSalarySettlementCO processSingleBdSettlement(Long bdUserId, Integer billBelong, String billTitle, Set<Long> adminUserIds) {
log.info("开始处理 BD {} 的工资结算", bdUserId);
// 1. 生成幂等业务号
@ -139,10 +139,13 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
record.setMemberDetails(memberDetails);
// 6. 保存结算记录
record.setIsAdmin(adminUserIds != null && adminUserIds.contains(bdUserId));
bdSalarySettlementRecordService.create(record);
// 7. 如果工资大于 0则发放工资
if (record.getSettlementSalary() != null && record.getSettlementSalary().compareTo(BigDecimal.ZERO) > 0) {
if (record.getSettlementSalary() != null &&
record.getSettlementSalary().compareTo(BigDecimal.ZERO) > 0 &&
!Boolean.TRUE.equals(record.getIsAdmin())) {
try {
// 调用钱包服务发放工资
issueSalary(bdUserId, record);

View File

@ -2,6 +2,8 @@ package com.red.circle.other.app.service;
import com.red.circle.other.app.dto.clientobject.BdSalarySettlementCO;
import java.util.Set;
/**
* BD 工资结算服务.
*
@ -26,5 +28,5 @@ public interface BdSalarySettlementService {
* @param billTitle 结算周期标题
* @return 结算结果
*/
BdSalarySettlementCO processSingleBdSettlement(Long bdUserId, Integer billBelong, String billTitle);
BdSalarySettlementCO processSingleBdSettlement(Long bdUserId, Integer billBelong, String billTitle, Set<Long> adminUserIds);
}

View File

@ -53,6 +53,11 @@ public class BdSalarySettlementRecord implements Serializable {
@JsonSerialize(using = ToStringSerializer.class)
private Long bdUserId;
/**
* 是否是管理员
*/
private Boolean isAdmin;
/**
* 结算周期格式202501 表示2025年1月上半月202502 表示2025年1月下半月.
*/