增加管理员的bd工资结算逻辑
This commit is contained in:
parent
665d76fa71
commit
39c7b45b4b
@ -1,5 +1,6 @@
|
|||||||
package com.red.circle.other.app.service;
|
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.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.framework.dto.ResultResponse;
|
||||||
@ -84,7 +85,6 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
|||||||
Set<Long> adminUserIds = getAdminUserIds();
|
Set<Long> adminUserIds = getAdminUserIds();
|
||||||
// 按 BD 用户 ID 分组(去重)
|
// 按 BD 用户 ID 分组(去重)
|
||||||
Map<Long, List<BusinessDevelopmentTeam>> bdGroupMap = allBdTeams.stream()
|
Map<Long, List<BusinessDevelopmentTeam>> bdGroupMap = allBdTeams.stream()
|
||||||
.filter(info -> !adminUserIds.contains(info.getUserId()))
|
|
||||||
.collect(Collectors.groupingBy(BusinessDevelopmentTeam::getUserId));
|
.collect(Collectors.groupingBy(BusinessDevelopmentTeam::getUserId));
|
||||||
|
|
||||||
log.warn("共找到 {} 个 BD", bdGroupMap.size());
|
log.warn("共找到 {} 个 BD", bdGroupMap.size());
|
||||||
@ -95,7 +95,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
|||||||
// 遍历每个 BD 进行结算
|
// 遍历每个 BD 进行结算
|
||||||
for (Long bdUserId : bdGroupMap.keySet()) {
|
for (Long bdUserId : bdGroupMap.keySet()) {
|
||||||
try {
|
try {
|
||||||
processSingleBdSettlement(bdUserId, billBelong, billTitle);
|
processSingleBdSettlement(bdUserId, billBelong, billTitle, adminUserIds);
|
||||||
successCount++;
|
successCount++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("BD {} 工资结算失败", bdUserId, e);
|
log.error("BD {} 工资结算失败", bdUserId, e);
|
||||||
@ -115,7 +115,7 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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);
|
log.info("开始处理 BD {} 的工资结算", bdUserId);
|
||||||
|
|
||||||
// 1. 生成幂等业务号
|
// 1. 生成幂等业务号
|
||||||
@ -139,10 +139,13 @@ public class BdSalarySettlementServiceImpl implements BdSalarySettlementService
|
|||||||
record.setMemberDetails(memberDetails);
|
record.setMemberDetails(memberDetails);
|
||||||
|
|
||||||
// 6. 保存结算记录
|
// 6. 保存结算记录
|
||||||
|
record.setIsAdmin(adminUserIds != null && adminUserIds.contains(bdUserId));
|
||||||
bdSalarySettlementRecordService.create(record);
|
bdSalarySettlementRecordService.create(record);
|
||||||
|
|
||||||
// 7. 如果工资大于 0,则发放工资
|
// 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 {
|
try {
|
||||||
// 调用钱包服务发放工资
|
// 调用钱包服务发放工资
|
||||||
issueSalary(bdUserId, record);
|
issueSalary(bdUserId, record);
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package com.red.circle.other.app.service;
|
|||||||
|
|
||||||
import com.red.circle.other.app.dto.clientobject.BdSalarySettlementCO;
|
import com.red.circle.other.app.dto.clientobject.BdSalarySettlementCO;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BD 工资结算服务.
|
* BD 工资结算服务.
|
||||||
*
|
*
|
||||||
@ -26,5 +28,5 @@ public interface BdSalarySettlementService {
|
|||||||
* @param billTitle 结算周期标题
|
* @param billTitle 结算周期标题
|
||||||
* @return 结算结果
|
* @return 结算结果
|
||||||
*/
|
*/
|
||||||
BdSalarySettlementCO processSingleBdSettlement(Long bdUserId, Integer billBelong, String billTitle);
|
BdSalarySettlementCO processSingleBdSettlement(Long bdUserId, Integer billBelong, String billTitle, Set<Long> adminUserIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,11 @@ public class BdSalarySettlementRecord implements Serializable {
|
|||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long bdUserId;
|
private Long bdUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是管理员
|
||||||
|
*/
|
||||||
|
private Boolean isAdmin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结算周期(格式:202501 表示2025年1月上半月,202502 表示2025年1月下半月).
|
* 结算周期(格式:202501 表示2025年1月上半月,202502 表示2025年1月下半月).
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user