Commit 6c3ff802 by jianan

来佣率分隔符拆分读取佣率2

parent 47748a80
...@@ -396,4 +396,15 @@ public class ApiCommissionExpectedController { ...@@ -396,4 +396,15 @@ public class ApiCommissionExpectedController {
} }
return Collections.emptyList(); return Collections.emptyList();
} }
@GetMapping("/test_expected_commission")
@Operation(summary = "测试佣金匹配")
public Result<Boolean> testExpectedCommission(@RequestParam("policyNo") String policyNo) {
if (StringUtils.isBlank(policyNo)) {
return Result.fail(ResultCode.NULL_ERROR.getCode(), "policyNo不能为空");
}
commissionExpectedService.testExpectedCommission(policyNo);
return Result.success(true);
}
} }
...@@ -78,4 +78,6 @@ public interface CommissionExpectedService extends IService<CommissionExpected> ...@@ -78,4 +78,6 @@ public interface CommissionExpectedService extends IService<CommissionExpected>
* @return 应收款报表VO分页列表 * @return 应收款报表VO分页列表
*/ */
IPage<ReceivableReportVO> receivableReportPage(Page<ReceivableReportVO> page, List<Long> expectedIds); IPage<ReceivableReportVO> receivableReportPage(Page<ReceivableReportVO> page, List<Long> expectedIds);
void testExpectedCommission(String policyNo);
} }
...@@ -128,7 +128,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -128,7 +128,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
commissionExpectedVO.setReconciliationCompany(policy.getReconciliationCompany()); commissionExpectedVO.setReconciliationCompany(policy.getReconciliationCompany());
commissionExpectedVO.setPolicyCurrency(policy.getCurrency()); commissionExpectedVO.setPolicyCurrency(policy.getCurrency());
} }
PolicyFollow policyFollow= policyFollowMap.get(commissionExpected.getPolicyNo()); PolicyFollow policyFollow = policyFollowMap.get(commissionExpected.getPolicyNo());
if (policyFollow != null) { if (policyFollow != null) {
commissionExpectedVO.setProductName(policyFollow.getProductName()); commissionExpectedVO.setProductName(policyFollow.getProductName());
commissionExpectedVO.setProductLaunchBizId(policyFollow.getProductLaunchBizId()); commissionExpectedVO.setProductLaunchBizId(policyFollow.getProductLaunchBizId());
...@@ -194,7 +194,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -194,7 +194,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
Object data = result.getData(); Object data = result.getData();
try { try {
// 将 data 转为 JSON 字符串再解析为 Map,以便提取 records // 将 data 转为 JSON 字符串再解析为 Map,以便提取 records
Map<String, Object> dataMap = JSON.parseObject(JSON.toJSONString(data), new com.alibaba.fastjson.TypeReference<Map<String, Object>>() {}); Map<String, Object> dataMap = JSON.parseObject(JSON.toJSONString(data), new com.alibaba.fastjson.TypeReference<Map<String, Object>>() {
});
Object recordsObj = dataMap.get("records"); Object recordsObj = dataMap.get("records");
if (recordsObj instanceof List) { if (recordsObj instanceof List) {
List<?> recordsList = (List<?>) recordsObj; List<?> recordsList = (List<?>) recordsObj;
...@@ -609,7 +610,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -609,7 +610,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
throw new BusinessException("保單持有人年齡不能为空"); throw new BusinessException("保單持有人年齡不能为空");
} }
Date effectiveDate = policy.getEffectiveDate(); Date effectiveDate = policy.getEffectiveDate();
log.info("getExpectedCommissionByProductlaunchId的effectiveDate生效日期:{}",effectiveDate); log.info("getExpectedCommissionByProductlaunchId的effectiveDate生效日期:{}", effectiveDate);
if (effectiveDate == null) { if (effectiveDate == null) {
throw new BusinessException("保单生效日期不能为空"); throw new BusinessException("保单生效日期不能为空");
} }
...@@ -722,8 +723,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -722,8 +723,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
/** /**
* 匹配预计规格并返回不匹配的条件 * 匹配预计规格并返回不匹配的条件
* *
* @param expectedSpeciesList 预计规格列表 * @param expectedSpeciesList 预计规格列表
* @param policy 保单对象 * @param policy 保单对象
* @return 匹配结果 * @return 匹配结果
*/ */
private MatchResult matchExpectedSpecies( private MatchResult matchExpectedSpecies(
...@@ -797,7 +798,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -797,7 +798,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
} }
try { try {
return objectMapper.readValue(speciesJson, return objectMapper.readValue(speciesJson,
new TypeReference<List<SpeciesCondition>>() {}); new TypeReference<List<SpeciesCondition>>() {
});
} catch (IOException e) { } catch (IOException e) {
log.error("解析speciesJson失败: {}", speciesJson, e); log.error("解析speciesJson失败: {}", speciesJson, e);
return Collections.emptyList(); return Collections.emptyList();
...@@ -836,7 +838,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -836,7 +838,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
return conditions.stream() return conditions.stream()
.anyMatch(c -> typeCode.equals(c.getTypeCode()) .anyMatch(c -> typeCode.equals(c.getTypeCode())
&& SpeciesConditionMatcher.matches( && SpeciesConditionMatcher.matches(
typeCode, c.getValue(), actualValue)); typeCode, c.getValue(), actualValue));
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -854,10 +856,10 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -854,10 +856,10 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
/** /**
* 过滤列表并检查是否为空 * 过滤列表并检查是否为空
* *
* @param list 待过滤的列表 * @param list 待过滤的列表
* @param predicate 过滤条件 * @param predicate 过滤条件
* @param unmatchedConditions 不匹配条件列表 * @param unmatchedConditions 不匹配条件列表
* @param conditionDesc 条件描述 * @param conditionDesc 条件描述
* @return 过滤后的列表 * @return 过滤后的列表
*/ */
private List<ApiExpectedSpeciesListResponse> filterAndCheck( private List<ApiExpectedSpeciesListResponse> filterAndCheck(
...@@ -898,17 +900,18 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -898,17 +900,18 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
/** /**
* 计算预计来佣港币金额 * 计算预计来佣港币金额
* @param premium 保费 *
* @param commissionRatio 佣金比例 * @param premium 保费
* @param commissionBizType 佣金业务类型 * @param commissionRatio 佣金比例
* @param amount 金额 * @param commissionBizType 佣金业务类型
* @param currency 预计来佣的结算币种=产品绑定的来佣结算币种 * @param amount 金额
* @param policyCurrency 保单币种 * @param currency 预计来佣的结算币种=产品绑定的来佣结算币种
* @param policyCurrency 保单币种
* @param defaultExchangeRate 默认结算汇率 * @param defaultExchangeRate 默认结算汇率
* @return 预计来佣金额 * @return 预计来佣金额
*/ */
private BigDecimal calculateExpectedAmount(BigDecimal premium, BigDecimal commissionRatio, String commissionBizType, private BigDecimal calculateExpectedAmount(BigDecimal premium, BigDecimal commissionRatio, String commissionBizType,
BigDecimal amount, String currency, String policyCurrency, BigDecimal defaultExchangeRate) { BigDecimal amount, String currency, String policyCurrency, BigDecimal defaultExchangeRate) {
if ("R".equals(commissionBizType)) { if ("R".equals(commissionBizType)) {
// 关联保单应收单:保费 × 佣金比例 × 默认结算汇率 ÷ 100 // 关联保单应收单:保费 × 佣金比例 × 默认结算汇率 ÷ 100
BigDecimal exchangeRate = defaultExchangeRate; BigDecimal exchangeRate = defaultExchangeRate;
...@@ -934,8 +937,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -934,8 +937,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
/** /**
* 保单币种对预计来佣的结算币种的默认汇率 * 保单币种对预计来佣的结算币种的默认汇率
*
* @param policyCurrency 保单币种 * @param policyCurrency 保单币种
* @param currency 预计来佣的结算币种 * @param currency 预计来佣的结算币种
* @return 汇率 * @return 汇率
*/ */
private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) { private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) {
...@@ -952,7 +956,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -952,7 +956,8 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
/** /**
* 根据保单生效日和佣金期数计算预计来佣日期,首期为生效日的1个月,后续期数为首期的次年 * 根据保单生效日和佣金期数计算预计来佣日期,首期为生效日的1个月,后续期数为首期的次年
* @param endPeriod 佣金期数 *
* @param endPeriod 佣金期数
* @param effectiveDate 保单生效日 * @param effectiveDate 保单生效日
* @return 预计来佣日期 * @return 预计来佣日期
*/ */
...@@ -983,6 +988,34 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -983,6 +988,34 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
return baseMapper.receivableReportPage(page, expectedIds); return baseMapper.receivableReportPage(page, expectedIds);
} }
@Override
public void testExpectedCommission(String policyNo) {
Policy policy = policyService.queryOne(policyNo);
String productLaunchBizId = policy.getProductLaunchBizId();
if (StringUtils.isNotBlank(productLaunchBizId)) {
PolicyFollow policyFollow = policyFollowService.queryOneByPolicyNo(policyNo);
String professionalInvestor = policyFollow.getProfessionalInvestor();
List<ApiExpectedSpeciesListResponse> expectedSpeciesList = queryExpectedSpeciesByFeign(productLaunchBizId);
if (CollUtil.isNotEmpty(expectedSpeciesList)) {
// 匹配规格并获取不匹配的条件
CommissionExpectedServiceImpl.MatchResult matchResult = matchExpectedSpecies(expectedSpeciesList, policy, professionalInvestor);
if (matchResult.getMatchedList().isEmpty()) {
String errorMsg = matchResult.getUnmatchedConditions().isEmpty()
? "未查询到预计来佣规格"
: "未查询到预计来佣规格,不匹配条件:" + String.join("、", matchResult.getUnmatchedConditions());
log.info("未查询到预计来佣规格,当前规格:{}", JSONUtil.toJsonStr(expectedSpeciesList));
throw new BusinessException(ResultCode.FAIL.getCode(), errorMsg);
}
}
}
}
} }
......
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