Commit 4680d228 by jianan

新单跟进同步预约信息16-保单币种默认结算汇率

parent 72c73c8d
...@@ -287,10 +287,6 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -287,10 +287,6 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
commissionExpected.setPaidRatio(BigDecimal.ZERO); commissionExpected.setPaidRatio(BigDecimal.ZERO);
// 校验参数 // 校验参数
validCommissionExpected(commissionExpected, true); validCommissionExpected(commissionExpected, true);
// 结算汇率初始值为 1
commissionExpected.setDefaultExchangeRate(BigDecimal.valueOf(1));
// 查询默认结算汇率
commissionExpected.setDefaultExchangeRate(queryDefaultExchangeRate(addDto.getCurrency()));
// 预计总金额 // 预计总金额
if ("R".equals(addDto.getCommissionBizType())) { if ("R".equals(addDto.getCommissionBizType())) {
...@@ -298,9 +294,17 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -298,9 +294,17 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
if (ObjectUtils.isEmpty(policy)) { if (ObjectUtils.isEmpty(policy)) {
throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "保单号为" + addDto.getPolicyNo() + "的保单不存在"); throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "保单号为" + addDto.getPolicyNo() + "的保单不存在");
} }
// 结算汇率初始值为 1
commissionExpected.setDefaultExchangeRate(BigDecimal.valueOf(1));
// 查询默认结算汇率
commissionExpected.setDefaultExchangeRate(queryExchangeRateByFeign(policy.getCurrency(), addDto.getCurrency()));
// 查询港币汇率
BigDecimal exchangeRateHkd = queryExchangeRateByFeign(addDto.getCurrency(), "HKD");
// 转换为港币金额
BigDecimal expectedAmount = policy.getPaymentPremium() BigDecimal expectedAmount = policy.getPaymentPremium()
.multiply(commissionExpected.getCommissionRatio()) .multiply(commissionExpected.getCommissionRatio())
.multiply(commissionExpected.getDefaultExchangeRate()) .multiply(commissionExpected.getDefaultExchangeRate())
.multiply(exchangeRateHkd)
.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); .divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP);
commissionExpected.setExpectedAmount(expectedAmount); commissionExpected.setExpectedAmount(expectedAmount);
...@@ -368,21 +372,6 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -368,21 +372,6 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
} }
} }
private BigDecimal queryDefaultExchangeRate(String currency) {
if ("HKD".equalsIgnoreCase(currency)) {
return BigDecimal.valueOf(1);
}
Result<List<GetDictItemListByDictTypeResponse>> result = apiSysDictFeignClient.getDictItemListByDictType("csf_exchange_rate_hkd");
if (CollectionUtils.isNotEmpty(result.getData())) {
for (GetDictItemListByDictTypeResponse dictItem : result.getData()) {
if (StringUtils.equalsIgnoreCase(dictItem.getItemLabel(), currency)) {
return new BigDecimal(dictItem.getItemValue());
}
}
}
return BigDecimal.ONE;
}
@Override @Override
public Boolean deleteCommissionExpected(String commissionExpectedBizId) { public Boolean deleteCommissionExpected(String commissionExpectedBizId) {
if (StringUtils.isBlank(commissionExpectedBizId)) { if (StringUtils.isBlank(commissionExpectedBizId)) {
...@@ -408,8 +397,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -408,8 +397,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
validCommissionExpected(commissionExpected, false); validCommissionExpected(commissionExpected, false);
// 转换为实体类 // 转换为实体类
BeanUtils.copyProperties(commissionExpectedUpdateRequest, commissionExpected, "id", "commissionBizId"); BeanUtils.copyProperties(commissionExpectedUpdateRequest, commissionExpected, "id", "commissionBizId");
// 更新默认结算汇率
commissionExpected.setDefaultExchangeRate(queryDefaultExchangeRate(commissionExpectedUpdateRequest.getCurrency()));
// 更新预计入账金额 // 更新预计入账金额
if ("R".equals(commissionExpectedUpdateRequest.getCommissionBizType())) { if ("R".equals(commissionExpectedUpdateRequest.getCommissionBizType())) {
// 查询保单 // 查询保单
...@@ -417,10 +405,16 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -417,10 +405,16 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
if (policy == null) { if (policy == null) {
throw new BusinessException(ResultCode.NULL_ERROR.getCode(), "保单不存在"); throw new BusinessException(ResultCode.NULL_ERROR.getCode(), "保单不存在");
} }
// 更新默认结算汇率
commissionExpected.setDefaultExchangeRate(queryExchangeRateByFeign(policy.getCurrency(), commissionExpectedUpdateRequest.getCurrency()));
// 查询港币汇率
BigDecimal exchangeRateHkd = queryExchangeRateByFeign(commissionExpectedUpdateRequest.getCurrency(), "HKD");
// 转换为港币金额
commissionExpected.setExpectedAmount( commissionExpected.setExpectedAmount(
policy.getPaymentPremium() policy.getPaymentPremium()
.multiply(commissionExpectedUpdateRequest.getCommissionRatio()) .multiply(commissionExpectedUpdateRequest.getCommissionRatio())
.multiply(commissionExpected.getDefaultExchangeRate()) .multiply(commissionExpected.getDefaultExchangeRate())
.multiply(exchangeRateHkd)
.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP) .divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)
); );
commissionExpected.setPremium(policy.getPaymentPremium()); commissionExpected.setPremium(policy.getPaymentPremium());
...@@ -751,7 +745,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -751,7 +745,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
if ("R".equals(commissionBizType)) { if ("R".equals(commissionBizType)) {
// 关联保单应收单:保费 × 佣金比例 × 默认结算汇率 ÷ 100 // 关联保单应收单:保费 × 佣金比例 × 默认结算汇率 ÷ 100
BigDecimal exchangeRate = defaultExchangeRate; BigDecimal exchangeRate = defaultExchangeRate;
BigDecimal exchangeRateHkd = queryDefaultExchangeRate(currency); BigDecimal exchangeRateHkd = queryExchangeRateByFeign(currency, "HKD");
if (exchangeRate == null) { if (exchangeRate == null) {
// 这里获取保单币种对预计来佣的结算币种的默认汇率 // 这里获取保单币种对预计来佣的结算币种的默认汇率
exchangeRate = queryExchangeRateByFeign(policyCurrency, currency); exchangeRate = queryExchangeRateByFeign(policyCurrency, currency);
...@@ -765,7 +759,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -765,7 +759,7 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
// 非关联保单应收单:金额 × 默认结算汇率 // 非关联保单应收单:金额 × 默认结算汇率
BigDecimal exchangeRate = defaultExchangeRate; BigDecimal exchangeRate = defaultExchangeRate;
if (exchangeRate == null) { if (exchangeRate == null) {
exchangeRate = queryDefaultExchangeRate(currency); exchangeRate = queryExchangeRateByFeign(policyCurrency, currency);
} }
return amount.multiply(exchangeRate); return amount.multiply(exchangeRate);
} }
...@@ -778,6 +772,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -778,6 +772,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
* @return 汇率 * @return 汇率
*/ */
private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) { private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) {
if (policyCurrency.equalsIgnoreCase(currency)) {
return BigDecimal.valueOf(1);
}
// 调用Feign客户端查询汇率 // 调用Feign客户端查询汇率
Result<BigDecimal> result = apiExchangeRateFeignClient.getExchangeRate(policyCurrency, currency, ""); Result<BigDecimal> result = apiExchangeRateFeignClient.getExchangeRate(policyCurrency, currency, "");
if (result != null && result.getData() != null) { if (result != null && result.getData() != null) {
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
then round((ifnull(sum(ce.expected_amount), 0) - ifnull(sum(ce.paid_amount), 0)) / ifnull(sum(ce.expected_amount), 0) * 100, 2) then round((ifnull(sum(ce.expected_amount), 0) - ifnull(sum(ce.paid_amount), 0)) / ifnull(sum(ce.expected_amount), 0) * 100, 2)
else 0 else 0
end as unpaidRatio, end as unpaidRatio,
ifnull(avg(ce.default_exchange_rate), 0) as exchangeRate, MAX(ce.default_exchange_rate) as exchangeRate,
MAX(p.insurance_company) as insuranceCompany, MAX(p.insurance_company) as insuranceCompany,
MAX(p.product_name) as productName, MAX(p.product_name) as productName,
ifnull(avg(ce.premium), 0) as premium, ifnull(avg(ce.premium), 0) as premium,
......
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