Commit 070e3f87 by jianan

出账检核-增加币种84

parent d790d8c2
...@@ -94,6 +94,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -94,6 +94,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
private ApiExpectedFortuneService getSelf() { private ApiExpectedFortuneService getSelf() {
return applicationContext.getBean(ApiExpectedFortuneService.class); return applicationContext.getBean(ApiExpectedFortuneService.class);
} }
@Autowired @Autowired
private TransactionTemplate transactionTemplate; private TransactionTemplate transactionTemplate;
@Autowired @Autowired
...@@ -480,28 +481,36 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -480,28 +481,36 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
ApiAnnouncementCommissionRatioListResponse announcementRatio = announcementRatioList.get(0); ApiAnnouncementCommissionRatioListResponse announcementRatio = announcementRatioList.get(0);
String currency = announcementRatio.getCurrency(); String currency = announcementRatio.getCurrency();
log.info("结算币种:{}", currency); log.info("结算币种(发放币种):{}", currency);
BigDecimal exchangeRate = queryExchangeRateByFeign(policyCurrency, currency); BigDecimal originalToHkdRate = queryExchangeRateByFeign(policyCurrency, "HKD");
log.info("结算汇率(原币种 -> 港币汇率):{}", originalToHkdRate);
log.info("结算汇率:{}", exchangeRate); BigDecimal hkdToPayoutRate = queryExchangeRateByFeign("HKD", currency);
log.info("港币 -> 发放币种汇率:{}", hkdToPayoutRate);
for (ExpectedFortune expectedFortune : expectedFortuneList) { for (ExpectedFortune expectedFortune : expectedFortuneList) {
ExpectedFortune updateObj = new ExpectedFortune(); ExpectedFortune updateObj = new ExpectedFortune();
updateObj.setId(expectedFortune.getId()); updateObj.setId(expectedFortune.getId());
//原币种 //原币种
updateObj.setOriginalCurrency(currency); updateObj.setOriginalCurrency(policyCurrency);
//原币种金额 //原币种金额
updateObj.setOriginalAmount(expectedFortune.getRuleAmount()); updateObj.setOriginalAmount(expectedFortune.getRuleAmount());
//原币种 -> 港币汇率 //原币种 -> 港币汇率
updateObj.setOriginalToHkdRate(exchangeRate); updateObj.setOriginalToHkdRate(originalToHkdRate);
//保单币种 //保单币种
updateObj.setRuleCurrency(currency); updateObj.setRuleCurrency(currency);
//默认保单币种 -> 港币汇率 //默认保单币种 -> 港币汇率
updateObj.setDefaultExchangeRate(exchangeRate); updateObj.setDefaultExchangeRate(originalToHkdRate);
//港币金额(标准发佣金额 * 默认保单币种 -> 港币汇率) //港币金额(标准发佣金额 * 默认保单币种 -> 港币汇率)
updateObj.setHkdAmount(expectedFortune.getRuleAmount().multiply(exchangeRate)); updateObj.setHkdAmount(expectedFortune.getRuleAmount().multiply(originalToHkdRate));
//发放币种
updateObj.setPayoutCurrency(currency);
//发放币种金额
updateObj.setPayoutAmount(expectedFortune.getHkdAmount().multiply(hkdToPayoutRate));
//港币 -> 发放币种汇率
updateObj.setHkdToPayoutRate(hkdToPayoutRate);
//默认值 //默认值
updateObj.setPaidAmount(BigDecimal.ZERO); updateObj.setPaidAmount(BigDecimal.ZERO);
updateObj.setPaidRatio(BigDecimal.ZERO); updateObj.setPaidRatio(BigDecimal.ZERO);
...@@ -621,7 +630,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -621,7 +630,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//默认结算汇率、港币金额 //默认结算汇率、港币金额
String policyCurrency = queryPolicyAndBrokerDtoList.get(0).getCurrency(); String policyCurrency = queryPolicyAndBrokerDtoList.get(0).getCurrency();
updateHkdAmountBatch(expectedFortuneList, policyCurrency, announcementRatioList); updateHkdAmountBatch(expectedFortuneList, policyCurrency, announcementRatioList);
;
//执行成功完毕,也要销毁redis缓存 //执行成功完毕,也要销毁redis缓存
redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo); redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo);
...@@ -633,11 +641,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -633,11 +641,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
.policyNo(policyNo) .policyNo(policyNo)
.status(0) .status(0)
.build()); .build());
//异步处理-构建冷静期定时任务
// log.info("异步处理-构建冷静期定时任务=>请求前入参:{}",JSON.toJSONString(collectResDtos));
// apiExpectedFortuneAsyncService.buildCalmDateTask(collectResDtos,policyNo,exchangeRate);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
//抛出异常,销毁redis缓存 //抛出异常,销毁redis缓存
...@@ -706,7 +709,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -706,7 +709,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<List<AlgorithmResDto>> executeReward(ExecuteBillingDto dto) { public Result executeReward(ExecuteBillingDto dto) {
QueryPolicyAndBrokerDto brokerDto = dto.getPolicyAndBrokerDto(); QueryPolicyAndBrokerDto brokerDto = dto.getPolicyAndBrokerDto();
//构造销售佣金基本法项目的顺序下标值执行 //构造销售佣金基本法项目的顺序下标值执行
List<Integer> executionOrderList = new ArrayList<>(); List<Integer> executionOrderList = new ArrayList<>();
...@@ -765,11 +768,9 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -765,11 +768,9 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//保险公司业务id //保险公司业务id
.insuranceCompanyBizId(brokerDto.getInsuranceCompanyBizId()) .insuranceCompanyBizId(brokerDto.getInsuranceCompanyBizId())
.source(2) .source(2)
//转介人的介绍费占比
.brokerRatio(dto.getBrokerRatio())
.build()); .build());
return Result.success(result.getData()); return Result.success();
} }
private static LocalDate calculateExpectedPayoutDate(LocalDate effectiveDate, Integer issueNumber) { private static LocalDate calculateExpectedPayoutDate(LocalDate effectiveDate, Integer issueNumber) {
...@@ -783,7 +784,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -783,7 +784,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<List<AlgorithmResDto>> executeBilling(ExecuteBillingDto dto) { public Result executeBilling(ExecuteBillingDto dto) {
log.info("执行 - 销售佣金(销售佣金基本法)——>入参:{}", JSON.toJSONString(dto)); log.info("执行 - 销售佣金(销售佣金基本法)——>入参:{}", JSON.toJSONString(dto));
QueryPolicyAndBrokerDto brokerDto = dto.getPolicyAndBrokerDto(); QueryPolicyAndBrokerDto brokerDto = dto.getPolicyAndBrokerDto();
//构造销售佣金基本法项目的顺序下标值执行 //构造销售佣金基本法项目的顺序下标值执行
...@@ -843,10 +844,9 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -843,10 +844,9 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//保险公司业务id //保险公司业务id
.insuranceCompanyBizId(brokerDto.getInsuranceCompanyBizId()) .insuranceCompanyBizId(brokerDto.getInsuranceCompanyBizId())
.source(1) .source(1)
.brokerRatio(dto.getBrokerRatio())
.build()); .build());
return Result.success(result.getData()); return Result.success();
} }
/** /**
...@@ -868,10 +868,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -868,10 +868,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
continue; continue;
} }
log.info("生成保单预计发佣表记录——>入参algorithmResDto:{}", JSON.toJSONString(algorithmResDto)); log.info("生成保单预计发佣表记录——>入参algorithmResDto:{}", JSON.toJSONString(algorithmResDto));
// PolicyBroker policyBroker = policyBrokerService.queryOne(QueryPolicyBrokerDto.builder() PolicyBroker policyBroker = policyBrokerService.queryOne(QueryPolicyBrokerDto.builder()
// .policyNo(fortuneDto.getPolicyNo()) .policyNo(fortuneDto.getPolicyNo())
// .brokerBizId(fortuneDto.getBrokerBizId()) .brokerBizId(fortuneDto.getBrokerBizId())
// .build()); .build());
ExpectedFortune fortune = new ExpectedFortune(); ExpectedFortune fortune = new ExpectedFortune();
//发佣金额 -> 计算值 - sqlAlgorithmResultDtoList集合里面的计算值和值 //发佣金额 -> 计算值 - sqlAlgorithmResultDtoList集合里面的计算值和值
// fortune.setAmount(algorithmResDto.getCalculatedValue()); // fortune.setAmount(algorithmResDto.getCalculatedValue());
...@@ -915,8 +915,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -915,8 +915,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
fortune.setStandardAmount(standardAmount); fortune.setStandardAmount(standardAmount);
// 转介人介绍费占比 // 转介人介绍费占比
// String brokerRatioStr = !Objects.isNull(policyBroker) ? policyBroker.getBrokerRatio() : "100"; String brokerRatioStr = !Objects.isNull(policyBroker) ? policyBroker.getBrokerRatio() : "100";
String brokerRatioStr = StringUtils.isNotBlank(fortuneDto.getBrokerRatio()) ? fortuneDto.getBrokerRatio() : "100";
fortune.setBrokerRatio(brokerRatioStr); fortune.setBrokerRatio(brokerRatioStr);
try { try {
...@@ -1154,26 +1153,26 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1154,26 +1153,26 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
} }
/** /**
* 保单币种对预计来佣的结算币种的默认汇率 * 查询币对的默认汇率
* *
* @param policyCurrency 保单币种 * @param sourceCurrency 源币种
* @param currency 预计来佣的结算币种 * @param targetCurrency 目标币种
* @return 汇率 * @return 汇率
*/ */
private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) { private BigDecimal queryExchangeRateByFeign(String sourceCurrency, String targetCurrency) {
HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token2 = request2.getHeader("Authorization"); String token2 = request2.getHeader("Authorization");
log.info("保单币种对预计来佣的结算币种的默认汇率 token==============,{}", token2); log.info("查询币对的默认汇率 token==============,{}", token2);
if (policyCurrency.equalsIgnoreCase(currency)) { if (sourceCurrency.equalsIgnoreCase(targetCurrency)) {
return BigDecimal.ONE; return BigDecimal.ONE;
} }
// 调用Feign客户端查询汇率 // 调用Feign客户端查询汇率
Result<BigDecimal> result = apiExchangeRateFeignClient.getExchangeRate(policyCurrency, currency, ""); Result<BigDecimal> result = apiExchangeRateFeignClient.getExchangeRate(sourceCurrency, targetCurrency, "");
if (result != null && result.getData() != null) { if (result != null && result.getData() != null) {
return result.getData(); return result.getData();
} else {
throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "查询币对的默认汇率失败, 币种:" + sourceCurrency + " -> " + targetCurrency);
} }
log.info("调用Feign客户端查询汇率=>,{}",JSON.toJSONString(result));
return null;
} }
private void validateAdd(List<ExpectedFortuneAddRequest> fortuneAddRequestList) { private void validateAdd(List<ExpectedFortuneAddRequest> fortuneAddRequestList) {
...@@ -1228,11 +1227,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1228,11 +1227,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
@Override @Override
public Result<PayableReportResponse> payableReport(ApiExpectedFortunePageRequest request) { public Result<PayableReportResponse> payableReport(ApiExpectedFortunePageRequest request) {
//保單持有人(中/英)、签单人、转介人名称(主)查询保单号列表
List<String> queryPolicyNoList = policyFollowService.queryPolicyNoList(request.getPolicyHolder(),"","","");
// 构建查询条件 // 构建查询条件
request.setPolicyNoList(queryPolicyNoList);
QueryWrapper<ExpectedFortune> queryWrapper = this.getQueryWrapper(request); QueryWrapper<ExpectedFortune> queryWrapper = this.getQueryWrapper(request);
// 先查询所有符合条件的记录ID(用于统计) // 先查询所有符合条件的记录ID(用于统计)
...@@ -1268,8 +1263,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1268,8 +1263,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
Map<String, PolicyFollow> policyFollowMap = policyFollowService.queryPolicyFollowMap(policyNoList); Map<String, PolicyFollow> policyFollowMap = policyFollowService.queryPolicyFollowMap(policyNoList);
List<PayableReportVO> voList = payableReportPage.getRecords().stream().map(vo -> { List<PayableReportVO> voList = payableReportPage.getRecords().stream().map(vo -> {
PolicyFollow policyFollow= policyFollowMap.get(vo.getPolicyNo()); PolicyFollow policyFollow = policyFollowMap.get(vo.getPolicyNo());
UserGradeDto userGradeDto= userGradeMap.get(vo.getBrokerBizId()); UserGradeDto userGradeDto = userGradeMap.get(vo.getBrokerBizId());
vo.setCurrency(CurrencyEnum.toLabel(vo.getCurrency())); vo.setCurrency(CurrencyEnum.toLabel(vo.getCurrency()));
if (userGradeDto != null) { if (userGradeDto != null) {
...@@ -1365,7 +1360,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1365,7 +1360,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
policyHolder); policyHolder);
} }
queryWrapper.in(ObjectUtils.isNotEmpty(request.getPolicyNoList()), "policy_no", request.getPolicyNoList());
// 按id升序排序 // 按id升序排序
queryWrapper.orderByAsc("id"); queryWrapper.orderByAsc("id");
return queryWrapper; return queryWrapper;
......
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