Commit 71f6df76 by jianan

出账检核-1/2/4

parent f77007ba
......@@ -194,7 +194,10 @@ public class ApiFortuneController {
@PostMapping("/download/account")
public Result<Boolean> downloadAccount(@RequestBody FortuneDownloadRequest fortuneDownloadRequest, HttpServletResponse response) throws IOException {
if (CollectionUtils.isEmpty(fortuneDownloadRequest.getFortuneBizIdList())) {
throw new BusinessException(ResultCode.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);
......
......@@ -10,4 +10,7 @@ public class FortuneDownloadRequest {
@Schema(description = "发佣数据业务Id列表", requiredMode = Schema.RequiredMode.REQUIRED)
private List<String> fortuneBizIdList;
@Schema(description = "出账年月(实),格式:yyyy-MM,例如:2026-04", requiredMode = Schema.RequiredMode.REQUIRED)
private String actualPayoutDate;
}
......@@ -28,6 +28,11 @@ public class Fortune implements Serializable {
private String expectedFortuneBizId;
/**
* 应付账款编号
*/
private String payableNo;
/**
* 检核年月
*/
private String reconciliationYearMonth;
......
......@@ -7,6 +7,7 @@ import com.yd.csf.service.model.FortuneAccount;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yd.csf.service.vo.FortuneAccountVO;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
......@@ -21,7 +22,7 @@ public interface FortuneAccountService extends IService<FortuneAccount> {
Page<FortuneAccountVO> getFortuneAccountVOPage(Page<FortuneAccount> fortunePage);
void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList);
void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList, LocalDate actualPayoutDate);
FortuneAccount getByFortuneAccountBizId(String fortuneAccountBizId);
......
......@@ -107,7 +107,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
@Override
@Transactional(rollbackFor = BusinessException.class)
public void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList) {
public void saveFortuneAccount(List<FortuneAccountExportDTO> accountExportDTOList, LocalDate actualPayoutDate) {
if (CollectionUtils.isEmpty(accountExportDTOList)) {
return;
}
......@@ -126,7 +126,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
fortuneAccount.setTeamBizId(accountExportDTO.getTeamBizId());
fortuneAccount.setCurrency(accountExportDTO.getCurrency());
fortuneAccount.setHkdAmount(accountExportDTO.getAmount());
fortuneAccount.setFortuneAccountDate(this.getActualPayoutDate(accountExportDTO));
fortuneAccount.setFortuneAccountDate(this.getActualPayoutDate(actualPayoutDate));
// 出账状态默认待出账
fortuneAccount.setStatus(FortuneStatusEnum.CHECKED.getItemValue());
......@@ -184,13 +184,25 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
}
// 更新预计发佣记录的出账状态
if (CollectionUtils.isNotEmpty(expectedFortuneBizIdList)) {
expectedFortuneService.updateBatchByBizId(expectedFortuneBizIdList, FortuneStatusEnum.CHECKED.getItemValue());
// 查询预计发佣记录
List<ExpectedFortune> expectedFortuneList = expectedFortuneService.list(new QueryWrapper<ExpectedFortune>()
.in("expected_fortune_biz_id", expectedFortuneBizIdList));
List<ExpectedFortune> updateExpectedFortuneList = new ArrayList<>();
for (ExpectedFortune expectedFortune : expectedFortuneList) {
ExpectedFortune updateExpectedFortune = new ExpectedFortune();
updateExpectedFortune.setId(expectedFortune.getId());
updateExpectedFortune.setStatus(FortuneStatusEnum.CHECKED.getItemValue());
updateExpectedFortune.setActualPayoutDate(actualPayoutDate);
updateExpectedFortuneList.add(updateExpectedFortune);
}
expectedFortuneService.updateBatchById(updateExpectedFortuneList);
}
}
private Date getActualPayoutDate(FortuneAccountExportDTO accountExportDTO) {
LocalDate actualPayoutDate = accountExportDTO.getActualPayoutDate();
private Date getActualPayoutDate(LocalDate actualPayoutDate) {
if (actualPayoutDate == null) {
return null;
}
......
......@@ -367,11 +367,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// 创建按人分组的导出DTO列表
List<FortuneAccountExportDTO> accountExportDTOList = new ArrayList<>();
// 收集所有不同的fortune项目名称
Set<String> allFortuneNames = fortuneList.stream()
.map(Fortune::getFortuneName)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
// 设置出账年月(实)
LocalDate actualPayoutDate = LocalDate.parse(fortuneDownloadRequest.getActualPayoutDate());
fortuneList.forEach(fortune -> fortune.setActualPayoutDate(actualPayoutDate));
// 处理每个分组的数据
for (Map.Entry<String, List<Fortune>> entry : fortuneMap.entrySet()) {
......@@ -444,7 +442,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// }
// 写入数据库
fortuneAccountService.saveFortuneAccount(accountExportDTOList);
fortuneAccountService.saveFortuneAccount(accountExportDTOList, actualPayoutDate);
// // 使用try-with-resources确保流正确关闭
// try (ServletOutputStream outputStream = response.getOutputStream()) {
......
......@@ -48,6 +48,12 @@ public class FortuneVO implements Serializable {
private String expectedFortuneBizId;
/**
* 应付账款编号
*/
@Schema(description = "应付账款编号")
private String payableNo;
/**
* 保单号
*/
@Schema(description = "保单号")
......
......@@ -8,6 +8,7 @@
<id property="id" column="id" />
<result property="fortuneBizId" column="fortune_biz_id" />
<result property="expectedFortuneBizId" column="expected_fortune_biz_id" />
<result property="payableNo" column="payable_no" />
<result property="reconciliationYearMonth" column="reconciliation_year_month" />
<result property="fortuneBizType" column="fortune_biz_type" />
<result property="isPart" column="is_part" />
......@@ -51,7 +52,7 @@
</resultMap>
<sql id="Base_Column_List">
id,fortune_biz_id,expected_fortune_biz_id,reconciliation_year_month,fortune_biz_type,batch_biz_id,
id,fortune_biz_id,expected_fortune_biz_id,payable_no,reconciliation_year_month,fortune_biz_type,batch_biz_id,
commission_biz_id,commission_expected_biz_id,policy_no,policy_currency,fortune_period,fortune_total_period,broker_biz_id,
team_biz_id,grade_commission_rate,share_rate,fortune_name,fortune_type,is_part,
amount,currency,exchange_rate,hkd_amount,current_payment_amount,current_payment_hkd_amount,current_payment_ratio,status,payout_date,actual_payout_date,is_tax,
......
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