Commit e6856d4f by jianan

出账检核-增加币种46

parent 786306b1
...@@ -269,8 +269,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -269,8 +269,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
/** /**
* 保单币种对预计来佣的结算币种的默认汇率 * 保单币种对预计来佣的结算币种的默认汇率
*
* @param policyCurrency 保单币种 * @param policyCurrency 保单币种
* @param currency 预计来佣的结算币种 * @param currency 预计来佣的结算币种
* @return 汇率 * @return 汇率
*/ */
private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) { private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) {
...@@ -838,7 +839,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -838,7 +839,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
private ExpectedFortune createExpectedFortune(FortuneAddRequest fortuneAddRequest, Policy policy, String fortuneName) { private ExpectedFortune createExpectedFortune(FortuneAddRequest fortuneAddRequest, Policy policy, String fortuneName) {
// 创建 expectedFortune // 创建 expectedFortune
ExpectedFortune expectedFortune = new ExpectedFortune(); ExpectedFortune expectedFortune = new ExpectedFortune();
BeanUtil.copyProperties(fortuneAddRequest, expectedFortune); BeanUtil.copyProperties(fortuneAddRequest, expectedFortune, "payoutDate", "actualPayoutDate");
// 设置 policy 关联字段 // 设置 policy 关联字段
expectedFortune.setInsuranceCompanyBizId(policy.getInsuranceCompanyBizId()); expectedFortune.setInsuranceCompanyBizId(policy.getInsuranceCompanyBizId());
...@@ -856,6 +857,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -856,6 +857,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
expectedFortune.setIsPart(0); expectedFortune.setIsPart(0);
// 默认保单币种汇率 // 默认保单币种汇率
expectedFortune.setDefaultExchangeRate(fortuneAddRequest.getExchangeRate()); expectedFortune.setDefaultExchangeRate(fortuneAddRequest.getExchangeRate());
// 预计出账年月
expectedFortune.setPayoutDate(LocalDate.parse(fortuneAddRequest.getPayoutDate() + "-01"));
// 实际出账年月
expectedFortune.setActualPayoutDate(LocalDate.parse(fortuneAddRequest.getActualPayoutDate() + "-01"));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例 // 已出帐金额、待出帐金额、已出帐比例、待出帐比例
expectedFortune.setPaidAmount(BigDecimal.ZERO); expectedFortune.setPaidAmount(BigDecimal.ZERO);
...@@ -900,26 +905,26 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -900,26 +905,26 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
List<FortuneSplitDto> splitList = fortuneSplitRequest.getFortuneSplitDtoList(); List<FortuneSplitDto> splitList = fortuneSplitRequest.getFortuneSplitDtoList();
// 3. 金额验证 // 3. 金额验证
BigDecimal totalSplitOriginalAmount = splitList.stream() BigDecimal totalSplitOriginalAmount = splitList.stream()
.map(FortuneSplitDto::getOriginalAmount) .map(FortuneSplitDto::getOriginalAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalSplitRatio = splitList.stream() BigDecimal totalSplitRatio = splitList.stream()
.map(FortuneSplitDto::getSplitRatio) .map(FortuneSplitDto::getSplitRatio)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal tolerance = new BigDecimal("0.01"); BigDecimal tolerance = new BigDecimal("0.01");
BigDecimal originalDifference = originalFortune.getOriginalAmount().subtract(totalSplitOriginalAmount).abs(); BigDecimal originalDifference = originalFortune.getOriginalAmount().subtract(totalSplitOriginalAmount).abs();
if (originalDifference.compareTo(tolerance) > 0) { if (originalDifference.compareTo(tolerance) > 0) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(),
String.format("分期原始金额总和(%s)与原记录原始金额(%s)不匹配", totalSplitOriginalAmount, originalFortune.getOriginalAmount())); String.format("分期原始金额总和(%s)与原记录原始金额(%s)不匹配", totalSplitOriginalAmount, originalFortune.getOriginalAmount()));
} }
if (totalSplitRatio.compareTo(BigDecimal.ZERO) > 0) { if (totalSplitRatio.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal ratioDifference = new BigDecimal("100").subtract(totalSplitRatio).abs(); BigDecimal ratioDifference = new BigDecimal("100").subtract(totalSplitRatio).abs();
if (ratioDifference.compareTo(new BigDecimal("0.1")) > 0) { if (ratioDifference.compareTo(new BigDecimal("0.1")) > 0) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(),
String.format("分期比例总和(%s%%)应为100%%", totalSplitRatio)); String.format("分期比例总和(%s%%)应为100%%", totalSplitRatio));
} }
} }
...@@ -941,9 +946,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -941,9 +946,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
ExpectedFortune newExpectedFortune = new ExpectedFortune(); ExpectedFortune newExpectedFortune = new ExpectedFortune();
BeanUtils.copyProperties(originalExpectedFortune, newExpectedFortune, BeanUtils.copyProperties(originalExpectedFortune, newExpectedFortune,
"id", "expectedFortuneBizId", "amount", "hkdAmount", "id", "expectedFortuneBizId", "amount", "hkdAmount",
"paidAmount", "unpaidAmount", "paidRatio", "unpaidRatio", "paidAmount", "unpaidAmount", "paidRatio", "unpaidRatio",
"status", "payoutDate", "actualPayoutDate", "remark"); "status", "payoutDate", "actualPayoutDate", "remark");
String newExpectedFortuneBizId = RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_EXPECTED_FORTUNE.getCode()); String newExpectedFortuneBizId = RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_EXPECTED_FORTUNE.getCode());
newExpectedFortune.setExpectedFortuneBizId(newExpectedFortuneBizId); newExpectedFortune.setExpectedFortuneBizId(newExpectedFortuneBizId);
...@@ -987,10 +992,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -987,10 +992,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
Fortune newFortune = new Fortune(); Fortune newFortune = new Fortune();
BeanUtils.copyProperties(originalFortune, newFortune, BeanUtils.copyProperties(originalFortune, newFortune,
"id", "fortuneBizId", "expectedFortuneBizId", "id", "fortuneBizId", "expectedFortuneBizId",
"amount", "hkdAmount", "currentPaymentAmount", "currentPaymentHkdAmount", "amount", "hkdAmount", "currentPaymentAmount", "currentPaymentHkdAmount",
"currentPaymentRatio", "status", "isPart", "currentPaymentRatio", "status", "isPart",
"payoutDate", "actualPayoutDate", "remark"); "payoutDate", "actualPayoutDate", "remark");
newFortune.setFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_FORTUNE.getCode())); newFortune.setFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_FORTUNE.getCode()));
...@@ -1011,8 +1016,8 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -1011,8 +1016,8 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
String fortuneRemark = StringUtils.isBlank(splitDto.getRemark()) ? "" : splitDto.getRemark(); String fortuneRemark = StringUtils.isBlank(splitDto.getRemark()) ? "" : splitDto.getRemark();
if (StringUtils.isNotBlank(originalFortune.getRemark())) { if (StringUtils.isNotBlank(originalFortune.getRemark())) {
fortuneRemark = StringUtils.isBlank(fortuneRemark) ? fortuneRemark = StringUtils.isBlank(fortuneRemark) ?
originalFortune.getRemark() : originalFortune.getRemark() :
originalFortune.getRemark() + "; " + fortuneRemark; originalFortune.getRemark() + "; " + fortuneRemark;
} }
newFortune.setRemark(fortuneRemark); newFortune.setRemark(fortuneRemark);
...@@ -1199,15 +1204,15 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -1199,15 +1204,15 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
FortuneSplitDto dto = splitList.get(i); FortuneSplitDto dto = splitList.get(i);
if (dto.getHkdAmount() == null || dto.getHkdAmount().compareTo(BigDecimal.ZERO) <= 0) { if (dto.getHkdAmount() == null || dto.getHkdAmount().compareTo(BigDecimal.ZERO) <= 0) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(),
"第" + (i + 1) + "期:港币金额必须大于0"); "第" + (i + 1) + "期:港币金额必须大于0");
} }
if (dto.getExchangeRate() == null || dto.getExchangeRate().compareTo(BigDecimal.ZERO) <= 0) { if (dto.getExchangeRate() == null || dto.getExchangeRate().compareTo(BigDecimal.ZERO) <= 0) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(),
"第" + (i + 1) + "期:汇率必须大于0"); "第" + (i + 1) + "期:汇率必须大于0");
} }
if (StringUtils.isBlank(dto.getPayoutYearMonth())) { if (StringUtils.isBlank(dto.getPayoutYearMonth())) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(),
"第" + (i + 1) + "期:出账年月不能为空"); "第" + (i + 1) + "期:出账年月不能为空");
} }
} }
} }
......
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