支持手动工资按月度账期发放
This commit is contained in:
parent
973f76a438
commit
e3be12cd8b
@ -33,6 +33,11 @@ public class TeamManualSalaryPaymentCmd extends Command {
|
||||
*/
|
||||
private List<Long> userIds;
|
||||
|
||||
/**
|
||||
* 月度账期,格式 yyyyMM. 为空时使用当前月.
|
||||
*/
|
||||
private Integer billBelong;
|
||||
|
||||
/**
|
||||
* 后台操作人.
|
||||
*/
|
||||
|
||||
@ -32,6 +32,11 @@ public class TeamManualSalaryPaymentQryCmd extends PageCommand {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 月度账期,格式 yyyyMM. 为空时使用当前月.
|
||||
*/
|
||||
private Integer billBelong;
|
||||
|
||||
/**
|
||||
* 排序字段.
|
||||
*/
|
||||
|
||||
@ -826,8 +826,10 @@ public class TeamMemberTargetServiceImpl implements TeamMemberTargetService {
|
||||
public List<TeamMemberTarget> listManualSalaryTargets(String sysOrigin, String countryCode,
|
||||
Collection<Long> userIds, Integer billBelong) {
|
||||
Criteria criteria = Criteria.where("sysOrigin").is(sysOrigin)
|
||||
.and("history").is(Boolean.FALSE)
|
||||
.and("billBelong").is(billBelong);
|
||||
if (Objects.equals(billBelong, getCalcBillBelong())) {
|
||||
criteria.and("history").is(Boolean.FALSE);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(countryCode)) {
|
||||
criteria.and("countryCode").in(countryCodeAliasSupport.getMatchCodes(countryCode));
|
||||
|
||||
@ -86,8 +86,9 @@ public class TeamManualSalaryPaymentClientServiceImpl implements
|
||||
public PageResult<TeamManualSalaryPaymentDTO> page(TeamManualSalaryPaymentQryCmd cmd) {
|
||||
validatePage(cmd);
|
||||
|
||||
Integer billBelong = resolveBillBelong(cmd.getBillBelong());
|
||||
List<ManualSalaryRow> rows = buildRows(cmd.getSysOrigin(), cmd.getCountryCode(),
|
||||
singletonUserId(cmd.getUserId()), TeamBillCycleUtils.getCalcBillBelong());
|
||||
singletonUserId(cmd.getUserId()), billBelong);
|
||||
rows = sortRows(rows, cmd.getSortField(), cmd.getSortOrder());
|
||||
|
||||
int cursor = 1;
|
||||
@ -115,7 +116,7 @@ public class TeamManualSalaryPaymentClientServiceImpl implements
|
||||
public List<TeamManualSalaryPaymentResultDTO> pay(TeamManualSalaryPaymentCmd cmd) {
|
||||
validatePay(cmd);
|
||||
|
||||
Integer billBelong = TeamBillCycleUtils.getCalcBillBelong();
|
||||
Integer billBelong = resolveBillBelong(cmd.getBillBelong());
|
||||
String lockKey = MANUAL_SALARY_LOCK_PREFIX + cmd.getSysOrigin() + ":" + cmd.getCountryCode()
|
||||
+ ":" + billBelong;
|
||||
ResponseAssert.isTrue(CommonErrorCode.OPERATION_CONFLICT,
|
||||
@ -746,6 +747,16 @@ public class TeamManualSalaryPaymentClientServiceImpl implements
|
||||
ResponseAssert.notBlank(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getCountryCode());
|
||||
}
|
||||
|
||||
private Integer resolveBillBelong(Integer billBelong) {
|
||||
if (Objects.isNull(billBelong)) {
|
||||
return TeamBillCycleUtils.getCalcBillBelong();
|
||||
}
|
||||
int month = billBelong % 100;
|
||||
ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR,
|
||||
billBelong >= 200001 && billBelong <= 209912 && month >= 1 && month <= 12);
|
||||
return billBelong;
|
||||
}
|
||||
|
||||
private String paymentId(Long userId, Integer billBelong) {
|
||||
return userId + "_" + billBelong;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ class TeamManualSalaryPaymentClientServiceImplTest {
|
||||
String region = "2046067717605224449";
|
||||
Long userId = 2054591808909930498L;
|
||||
Long teamId = 2054614353419759617L;
|
||||
Integer billBelong = TeamBillCycleUtils.getCalcBillBelong();
|
||||
Integer billBelong = 202605;
|
||||
String paymentId = userId + "_" + billBelong;
|
||||
TeamMemberTarget target = new TeamMemberTarget()
|
||||
.setId("target-id")
|
||||
@ -202,6 +202,7 @@ class TeamManualSalaryPaymentClientServiceImplTest {
|
||||
List<TeamManualSalaryPaymentResultDTO> results = service.pay(new TeamManualSalaryPaymentCmd()
|
||||
.setSysOrigin(sysOrigin)
|
||||
.setCountryCode(countryCode)
|
||||
.setBillBelong(billBelong)
|
||||
.setUserIds(List.of(userId)));
|
||||
|
||||
assertEquals(1, results.size());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user