Commit 9c9a984c by jianan

出账检核-增加币种55

parent 804404af
...@@ -197,9 +197,6 @@ public class ApiFortuneController { ...@@ -197,9 +197,6 @@ public class ApiFortuneController {
if (CollectionUtils.isEmpty(fortuneDownloadRequest.getFortuneBizIdList())) { if (CollectionUtils.isEmpty(fortuneDownloadRequest.getFortuneBizIdList())) {
return Result.fail(ErrorCode.PARAMS_ERROR.getCode(), "请选择要出账的发佣数据"); return Result.fail(ErrorCode.PARAMS_ERROR.getCode(), "请选择要出账的发佣数据");
} }
if (StringUtils.isBlank(fortuneDownloadRequest.getActualPayoutDate())) {
return Result.fail(ErrorCode.PARAMS_ERROR.getCode(), "请输入出账年月(实)");
}
fortuneService.downloadAccount(fortuneDownloadRequest, response); fortuneService.downloadAccount(fortuneDownloadRequest, response);
...@@ -449,6 +446,25 @@ public class ApiFortuneController { ...@@ -449,6 +446,25 @@ public class ApiFortuneController {
return Result.success(fortuneService.editActualPayoutDate(editActualPayoutDateRequest)); return Result.success(fortuneService.editActualPayoutDate(editActualPayoutDateRequest));
} }
/**
* 批量设置出账年月(实)),已设置的跳过
*
* @param editBatchActualPayoutDateRequest
* @return
*/
@PostMapping("/edit/actual_payout_date/batch")
@Operation(summary = "批量设置出账年月(实),已设置的跳过")
public Result<String> batchEditActualPayoutDate(@RequestBody BatchEditActualPayoutDateRequest editBatchActualPayoutDateRequest) {
if (editBatchActualPayoutDateRequest == null || CollectionUtils.isEmpty(editBatchActualPayoutDateRequest.getFortuneBizIdList())) {
return Result.fail(ErrorCode.PARAMS_ERROR.getCode(), "fortuneBizIdList 不能为空");
}
if (StringUtils.isBlank(editBatchActualPayoutDateRequest.getActualPayoutDate())) {
return Result.fail(ErrorCode.PARAMS_ERROR.getCode(), "actualPayoutDate 不能为空");
}
return Result.success(fortuneService.batchEditActualPayoutDate(editBatchActualPayoutDateRequest));
}
/** /**
* 修改结算汇率,设置完成后,更新到应付款管理明细中 * 修改结算汇率,设置完成后,更新到应付款管理明细中
* *
......
package com.yd.csf.service.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Data
public class BatchEditActualPayoutDateRequest {
@Schema(description = "出账业务ID列表", requiredMode = Schema.RequiredMode.REQUIRED)
private List<String> fortuneBizIdList;
@Schema(description = "实际出账年月(实)", requiredMode = Schema.RequiredMode.REQUIRED)
private String actualPayoutDate;
}
...@@ -11,6 +11,4 @@ public class FortuneDownloadRequest { ...@@ -11,6 +11,4 @@ public class FortuneDownloadRequest {
@Schema(description = "发佣数据业务Id列表", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "发佣数据业务Id列表", requiredMode = Schema.RequiredMode.REQUIRED)
private List<String> fortuneBizIdList; private List<String> fortuneBizIdList;
@Schema(description = "出账年月(实),格式:yyyy-MM,例如:2026-04", requiredMode = Schema.RequiredMode.REQUIRED)
private String actualPayoutDate;
} }
...@@ -22,7 +22,7 @@ public interface FortuneAccountService extends IService<FortuneAccount> { ...@@ -22,7 +22,7 @@ public interface FortuneAccountService extends IService<FortuneAccount> {
Page<FortuneAccountVO> getFortuneAccountVOPage(Page<FortuneAccount> fortunePage); Page<FortuneAccountVO> getFortuneAccountVOPage(Page<FortuneAccount> fortunePage);
void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList, LocalDate actualPayoutDate); void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList);
FortuneAccount getByFortuneAccountBizId(String fortuneAccountBizId); FortuneAccount getByFortuneAccountBizId(String fortuneAccountBizId);
......
...@@ -47,4 +47,5 @@ public interface FortuneService extends IService<Fortune> { ...@@ -47,4 +47,5 @@ public interface FortuneService extends IService<Fortune> {
Boolean editExchangeRate(EditExchangeRateRequest editExchangeRateRequest); Boolean editExchangeRate(EditExchangeRateRequest editExchangeRateRequest);
String batchEditActualPayoutDate(BatchEditActualPayoutDateRequest editBatchActualPayoutDateRequest);
} }
...@@ -109,7 +109,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper, ...@@ -109,7 +109,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
@Override @Override
@Transactional(rollbackFor = BusinessException.class) @Transactional(rollbackFor = BusinessException.class)
public void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList, LocalDate actualPayoutDate) { public void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList) {
if (CollectionUtils.isEmpty(accountExportDTOList)) { if (CollectionUtils.isEmpty(accountExportDTOList)) {
return; return;
} }
...@@ -142,7 +142,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper, ...@@ -142,7 +142,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
fortuneAccount.setTeamBizId(accountExportDTO.getTeamBizId()); fortuneAccount.setTeamBizId(accountExportDTO.getTeamBizId());
fortuneAccount.setCurrency(accountExportDTO.getCurrency()); fortuneAccount.setCurrency(accountExportDTO.getCurrency());
fortuneAccount.setHkdAmount(accountExportDTO.getAmount()); fortuneAccount.setHkdAmount(accountExportDTO.getAmount());
fortuneAccount.setFortuneAccountDate(this.getActualPayoutDate(actualPayoutDate)); fortuneAccount.setFortuneAccountDate(this.getActualPayoutDate(accountExportDTO.getActualPayoutDate()));
// 出账状态默认待出账 // 出账状态默认待出账
fortuneAccount.setStatus(FortuneStatusEnum.CHECKED.getItemValue()); fortuneAccount.setStatus(FortuneStatusEnum.CHECKED.getItemValue());
...@@ -187,7 +187,6 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper, ...@@ -187,7 +187,6 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.divide(item.getHkdAmount(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100))); .divide(item.getHkdAmount(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
} }
updateFortune.setReconciliationOperator(currentLoginUser.getUsername()); updateFortune.setReconciliationOperator(currentLoginUser.getUsername());
updateFortune.setActualPayoutDate(actualPayoutDate);
updateFortuneList.add(updateFortune); updateFortuneList.add(updateFortune);
// 处理关联预计发佣记录 // 处理关联预计发佣记录
expectedFortuneBizIdList.add(item.getExpectedFortuneBizId()); expectedFortuneBizIdList.add(item.getExpectedFortuneBizId());
...@@ -211,7 +210,6 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper, ...@@ -211,7 +210,6 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
ExpectedFortune updateExpectedFortune = new ExpectedFortune(); ExpectedFortune updateExpectedFortune = new ExpectedFortune();
updateExpectedFortune.setId(expectedFortune.getId()); updateExpectedFortune.setId(expectedFortune.getId());
updateExpectedFortune.setStatus(FortuneStatusEnum.CHECKED.getItemValue()); updateExpectedFortune.setStatus(FortuneStatusEnum.CHECKED.getItemValue());
updateExpectedFortune.setActualPayoutDate(actualPayoutDate);
updateExpectedFortuneList.add(updateExpectedFortune); updateExpectedFortuneList.add(updateExpectedFortune);
} }
expectedFortuneService.updateBatchById(updateExpectedFortuneList); expectedFortuneService.updateBatchById(updateExpectedFortuneList);
......
...@@ -393,26 +393,33 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -393,26 +393,33 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
if (StringUtils.equals(fortune.getStatus(), FortuneStatusEnum.SENT.getItemValue())) { if (StringUtils.equals(fortune.getStatus(), FortuneStatusEnum.SENT.getItemValue())) {
validateMsg.append(fortune.getPolicyNo()).append("-").append(fortune.getBroker()).append("已完成出账,不能生成出账记录; "); validateMsg.append(fortune.getPolicyNo()).append("-").append(fortune.getBroker()).append("已完成出账,不能生成出账记录; ");
} }
if (fortune.getActualPayoutDate() == null) {
validateMsg.append(fortune.getPolicyNo()).append("-").append(fortune.getBroker()).append("未设置出账年月(实),不能生成出账记录; ");
}
if (ObjectUtils.isEmpty(fortune.getPayoutCurrency())) {
validateMsg.append(fortune.getPolicyNo()).append("-").append(fortune.getBroker()).append("未设置发放币种,不能生成出账记录; ");
}
if (ObjectUtils.isEmpty(fortune.getPayoutAmount())) {
validateMsg.append(fortune.getPolicyNo()).append("-").append(fortune.getBroker()).append("未设置发放币种金额,不能生成出账记录; ");
}
} }
if (StringUtils.isNotBlank(validateMsg.toString())) { if (StringUtils.isNotBlank(validateMsg.toString())) {
throw new BusinessException(ResultCode.FAIL.getCode(), validateMsg.toString()); throw new BusinessException(ResultCode.FAIL.getCode(), validateMsg.toString());
} }
if (CollUtil.isNotEmpty(fortuneList)) { if (CollUtil.isNotEmpty(fortuneList)) {
// 按人和发放币种分组 // 按人和实际出账年月(实)和发放币种分组
Map<String, List<Fortune>> fortuneMap = fortuneList.stream().collect(Collectors.groupingBy(fortune -> fortune.getBroker() + "_" + fortune.getPayoutCurrency())); Map<String, List<Fortune>> fortuneMap = fortuneList.stream()
.collect(Collectors.groupingBy(fortune -> fortune.getBroker() + "_" + fortune.getActualPayoutDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "_" + fortune.getPayoutCurrency()));
// 创建按人分组的导出DTO列表 // 创建按人分组的导出DTO列表
List<FortuneAccountExportDTO> accountExportDTOList = new ArrayList<>(); List<FortuneAccountExportDTO> accountExportDTOList = new ArrayList<>();
// 设置出账年月(实)
LocalDate actualPayoutDate = LocalDate.parse(fortuneDownloadRequest.getActualPayoutDate() + "-01");
fortuneList.forEach(fortune -> fortune.setActualPayoutDate(actualPayoutDate));
// 处理每个分组的数据 // 处理每个分组的数据
for (Map.Entry<String, List<Fortune>> entry : fortuneMap.entrySet()) { for (Map.Entry<String, List<Fortune>> entry : fortuneMap.entrySet()) {
String broker = entry.getKey().split("_")[0]; String broker = entry.getKey().split("_")[0];
String currency = entry.getKey().split("_")[1]; String actualPayoutDate = entry.getKey().split("_")[1];
String currency = entry.getKey().split("_")[2];
List<Fortune> brokerFortunes = entry.getValue(); List<Fortune> brokerFortunes = entry.getValue();
FortuneAccountExportDTO accountDTO = new FortuneAccountExportDTO(); FortuneAccountExportDTO accountDTO = new FortuneAccountExportDTO();
...@@ -425,7 +432,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -425,7 +432,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
accountDTO.setTeam(brokerFortunes.get(0).getTeam()); accountDTO.setTeam(brokerFortunes.get(0).getTeam());
accountDTO.setTeamBizId(brokerFortunes.get(0).getTeamBizId()); accountDTO.setTeamBizId(brokerFortunes.get(0).getTeamBizId());
accountDTO.setCurrency(currency); accountDTO.setCurrency(currency);
accountDTO.setActualPayoutDate(brokerFortunes.get(0).getActualPayoutDate()); accountDTO.setActualPayoutDate(LocalDate.parse(actualPayoutDate));
} }
// 计算出账总额 // 计算出账总额
...@@ -480,7 +487,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -480,7 +487,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// } // }
// 写入数据库 // 写入数据库
fortuneAccountService.saveFortuneAccount(accountExportDTOList, actualPayoutDate); fortuneAccountService.saveFortuneAccount(accountExportDTOList);
// // 使用try-with-resources确保流正确关闭 // // 使用try-with-resources确保流正确关闭
// try (ServletOutputStream outputStream = response.getOutputStream()) { // try (ServletOutputStream outputStream = response.getOutputStream()) {
...@@ -1162,6 +1169,38 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -1162,6 +1169,38 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return true; return true;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public String batchEditActualPayoutDate(BatchEditActualPayoutDateRequest editBatchActualPayoutDateRequest) {
List<Fortune> fortuneList = this.lambdaQuery()
.in(Fortune::getFortuneBizId, editBatchActualPayoutDateRequest.getFortuneBizIdList())
.list();
if (CollectionUtils.isEmpty(fortuneList)) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), "出账记录不存在");
}
// 处理实际出账年月(实)
LocalDate actualPayoutDate = LocalDate.parse(editBatchActualPayoutDateRequest.getActualPayoutDate() + "-01");
// 更新 fortune 的字段, 已设置的不更新,记录更新成功及跳过的条数
int updateCount = 0;
int skipCount = 0;
for (Fortune fortune : fortuneList) {
if (ObjectUtils.isEmpty(fortune.getActualPayoutDate())) {
updateCount++;
} else {
skipCount++;
continue;
}
this.lambdaUpdate()
.set(Fortune::getActualPayoutDate, actualPayoutDate)
.eq(Fortune::getId, fortune.getId())
.update();
}
return String.format("设置成功。已更新 %d 条数据,跳过 %d 条(已有实际出账年月)", updateCount, skipCount);
}
private void validEditExchangeRate(EditExchangeRateRequest editExchangeRateRequest) { private void validEditExchangeRate(EditExchangeRateRequest editExchangeRateRequest) {
if (ObjectUtils.isEmpty(editExchangeRateRequest.getOriginalCurrency())) { if (ObjectUtils.isEmpty(editExchangeRateRequest.getOriginalCurrency())) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), "原币种不能为空"); throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), "原币种不能为空");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment