Commit 2d35cbaf by jianan

预计来佣日期

parent b9cae7e0
......@@ -651,13 +651,17 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
throw new BusinessException(ResultCode.FAIL.getCode(), errorMsg);
}
List<ApiExpectedSpeciesListResponse> matchedList = matchResult.getMatchedList();
// 计算佣金总期数 list 中 endPeriod最大值
Integer maxEndPeriod = matchResult.getMatchedList().stream()
Integer maxEndPeriod = matchedList.stream()
.map(item -> Convert.toInt(item.getEndPeriod()))
.max(Integer::compareTo)
.orElse(0);
for (ApiExpectedSpeciesListResponse item : matchResult.getMatchedList()) {
int size = matchedList.size();
for (int i = 0; i < size; i++) {
ApiExpectedSpeciesListResponse item = matchedList.get(i);
CommissionExpected commissionExpected = new CommissionExpected();
commissionExpected.setCommissionExpectedBizId(RandomStringGenerator.generateBizId16("commission_expected"));
commissionExpected.setReceivableNo(receivableService.generateReceivableNo("R", reconciliationCompanyCode, reconciliationCompany));
......@@ -678,7 +682,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
commissionExpected.setCommissionRatio(item.getCommissionRate());
commissionExpected.setAmount(null);
commissionExpected.setCurrency(item.getCurrency());
commissionExpected.setCommissionDate(calculateCommissionDate(item.getEndPeriod(), coolingOffEndDate));
commissionExpected.setCommissionDate(calculateCommissionDate(i, coolingOffEndDate));
commissionExpected.setStatus(CommissionExpectedStatusEnum.PENDING.getItemValue());
commissionExpected.setStatusDesc(null);
commissionExpected.setDefaultExchangeRate(queryExchangeRateByFeign(policy.getCurrency(), item.getCurrency()));
......@@ -973,12 +977,12 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
/**
* 根据保单生效日和佣金期数计算预计来佣日期,首期为生效日的1个月,后续期数为首期的次年
*
* @param endPeriod 佣金期数
* @param currentPeriod 佣金期数
* @param effectiveDate 保单生效日
* @return 预计来佣日期
*/
private Date calculateCommissionDate(String endPeriod, Date effectiveDate) {
if (effectiveDate == null || StringUtils.isBlank(endPeriod)) {
private Date calculateCommissionDate(Integer currentPeriod, Date effectiveDate) {
if (effectiveDate == null || currentPeriod == null || currentPeriod <= 0) {
return null;
}
......@@ -987,14 +991,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
// 首期:保单生效日的1个月
cal.add(Calendar.MONTH, 1);
Integer period = Convert.toInt(endPeriod);
if (period == null || period <= 0) {
return cal.getTime();
}
// 后续期数:在首期基础上增加 (period - 1) 年
// 例如:第2期为首期次年,第3期为首期+2年
cal.add(Calendar.YEAR, period - 1);
// 后续期数
cal.add(Calendar.YEAR, currentPeriod);
return cal.getTime();
}
......
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