Commit 8e3d44b1 by zhangxingmin

push

parent c1719ae5
...@@ -198,10 +198,38 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy> ...@@ -198,10 +198,38 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy>
return true; return true;
} }
private BigDecimal calculateTotalPaymentPremium(ApiProductPlanMainInfoDto apiProductPlanMainInfoDto) { private BigDecimal calculateTotalPaymentPremium(ApiProductPlanMainInfoDto dto) {
// 计算总保费 // 校验每期保费(必填)
return apiProductPlanMainInfoDto.getEachIssuePremium() BigDecimal eachIssuePremium = dto.getEachIssuePremium();
.multiply(new BigDecimal(apiProductPlanMainInfoDto.getPaymentFrequency())) if (eachIssuePremium == null) {
throw new BusinessException("每期保费不能为空");
}
String issueNumberStr = dto.getIssueNumber();
BigDecimal issueNumber;
// 供款期数为空时,默认按 1 期处理
if (StringUtils.isBlank(issueNumberStr)) {
issueNumber = BigDecimal.ONE;
} else {
// 安全转换为 BigDecimal
try {
issueNumber = new BigDecimal(issueNumberStr.trim());
} catch (NumberFormatException e) {
throw new BusinessException("供款期数格式不正确,请填写数字");
}
// 业务逻辑校验:期数必须为正整数
if (issueNumber.compareTo(BigDecimal.ZERO) <= 0) {
throw new BusinessException("供款期数必须大于0");
}
// 检查是否为整数(去除小数部分后与原值比较)
if (issueNumber.stripTrailingZeros().scale() > 0) {
throw new BusinessException("供款期数必须为整数");
}
}
// 计算总保费并保留4位小数
return eachIssuePremium.multiply(issueNumber)
.setScale(4, RoundingMode.HALF_UP); .setScale(4, RoundingMode.HALF_UP);
} }
......
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