Commit f259c352 by jianan

新单跟进-缴费年期、对账公司

parent 96da5a90
...@@ -719,6 +719,10 @@ public class ApiAppointmentServiceImpl implements ApiAppointmentService { ...@@ -719,6 +719,10 @@ public class ApiAppointmentServiceImpl implements ApiAppointmentService {
follow.setInsuranceCompany(apiProductPlanMainInfoDto.getCompanyName()); follow.setInsuranceCompany(apiProductPlanMainInfoDto.getCompanyName());
// 保险公司业务ID(从产品计划获取的公司ID) // 保险公司业务ID(从产品计划获取的公司ID)
follow.setInsuranceCompanyBizId(apiProductPlanMainInfoDto.getCompanyId()); follow.setInsuranceCompanyBizId(apiProductPlanMainInfoDto.getCompanyId());
// 对账公司
follow.setReconciliationCompany(apiProductPlanMainInfoDto.getReconciliationCompanyName());
// 对账公司业务ID(从产品计划获取的对账公司ID)
follow.setReconciliationCompanyBizId(apiProductPlanMainInfoDto.getReconciliationCompanyId());
// 币种 // 币种
follow.setPolicyCurrency(apiProductPlanMainInfoDto.getPolicyCurrency()); follow.setPolicyCurrency(apiProductPlanMainInfoDto.getPolicyCurrency());
// 供款年期 // 供款年期
......
...@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yd.auth.core.dto.AuthUserDto; import com.yd.auth.core.dto.AuthUserDto;
import com.yd.auth.core.utils.SecurityUtil; import com.yd.auth.core.utils.SecurityUtil;
import com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient;
import com.yd.common.constant.RedisConstants; import com.yd.common.constant.RedisConstants;
import com.yd.common.enums.*; import com.yd.common.enums.*;
import com.yd.common.exception.BusinessException; import com.yd.common.exception.BusinessException;
...@@ -34,6 +35,7 @@ import com.yd.csf.service.service.*; ...@@ -34,6 +35,7 @@ import com.yd.csf.service.service.*;
import com.yd.csf.service.vo.ExpectedFortuneExportDTO; import com.yd.csf.service.vo.ExpectedFortuneExportDTO;
import com.yd.csf.service.vo.ExpectedFortuneStatisticsVO; import com.yd.csf.service.vo.ExpectedFortuneStatisticsVO;
import com.yd.csf.service.vo.PayableReportVO; import com.yd.csf.service.vo.PayableReportVO;
import com.yd.product.feign.response.expectedspecies.ApiExpectedSpeciesListResponse;
import com.yd.user.feign.client.clientuser.ApiClientUserFeignClient; import com.yd.user.feign.client.clientuser.ApiClientUserFeignClient;
import com.yd.user.feign.client.sysdict.ApiSysDictFeignClient; import com.yd.user.feign.client.sysdict.ApiSysDictFeignClient;
import com.yd.user.feign.response.sysdict.GetDictItemListByDictTypeResponse; import com.yd.user.feign.response.sysdict.GetDictItemListByDictTypeResponse;
...@@ -91,6 +93,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -91,6 +93,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
private ApiSysDictFeignClient apiSysDictFeignClient; private ApiSysDictFeignClient apiSysDictFeignClient;
@Resource @Resource
private PolicyFollowService policyFollowService; private PolicyFollowService policyFollowService;
@Resource
private ApiExchangeRateFeignClient apiExchangeRateFeignClient;
@Resource
private CommissionExpectedService commissionExpectedService;
/** /**
* 生成预计发佣 * 生成预计发佣
...@@ -304,7 +310,13 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -304,7 +310,13 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
} }
} }
//批量设置应付款编号、发佣类型 //批量设置应付款编号、发佣类型
updatePayableNoBatch(policyNo); List<ExpectedFortune> expectedFortuneList = updatePayableNoBatch(policyNo);
//默认结算汇率、港币金额
if (ObjectUtils.isNotEmpty(queryPolicyAndBrokerDtoList)) {
String productLaunchBizId = queryPolicyAndBrokerDtoList.get(0).getPlanBizId();
updateHkdAmountBatch(expectedFortuneList, productLaunchBizId);
}
//执行成功完毕,也要销毁redis缓存 //执行成功完毕,也要销毁redis缓存
redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo); redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo);
...@@ -333,6 +345,26 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -333,6 +345,26 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}); });
} }
private void updateHkdAmountBatch(List<ExpectedFortune> expectedFortuneList, String productLaunchBizId) {
if (ObjectUtils.isNotEmpty(expectedFortuneList)) {
//查询结算币种
List<ApiExpectedSpeciesListResponse> expectedSpeciesList = commissionExpectedService.queryExpectedSpeciesByFeign(productLaunchBizId);
// queryExchangeRateByFeign()
//设置默认结算汇率
// expectedFortune.setDefaultExchangeRate(defaultExchangeRate);
//设置港币金额(标准发佣金额 * 默认结算汇率)
// expectedFortune.setHkdAmount(expectedFortune.getAmount().multiply(defaultExchangeRate));
//设置转介人职级比例
//设置发佣率 = 基础公告佣率 * 转介人职级比例
}
}
@Override @Override
public Result executeSync(List<QueryPolicyAndBrokerDto> queryPolicyAndBrokerDtoList, List<CommissionRuleBinding> commissionRuleBindingList, String policyNo) { public Result executeSync(List<QueryPolicyAndBrokerDto> queryPolicyAndBrokerDtoList, List<CommissionRuleBinding> commissionRuleBindingList, String policyNo) {
return null; return null;
...@@ -425,7 +457,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -425,7 +457,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
return commissionRuleBindingList; return commissionRuleBindingList;
} }
private void updatePayableNoBatch(String policyNo) { private List<ExpectedFortune> updatePayableNoBatch(String policyNo) {
// 查询最新一条有 payableNo 记录 // 查询最新一条有 payableNo 记录
ExpectedFortune latest = iExpectedFortuneService.getOne( ExpectedFortune latest = iExpectedFortuneService.getOne(
new QueryWrapper<ExpectedFortune>().isNotNull("payable_no").orderByDesc("id").last("LIMIT 1"), new QueryWrapper<ExpectedFortune>().isNotNull("payable_no").orderByDesc("id").last("LIMIT 1"),
...@@ -452,6 +484,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -452,6 +484,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
"csf_fortune_type", expectedFortune.getFortuneName())); "csf_fortune_type", expectedFortune.getFortuneName()));
} }
iExpectedFortuneService.updateBatchById(expectedFortuneList); iExpectedFortuneService.updateBatchById(expectedFortuneList);
return expectedFortuneList;
} }
/** /**
...@@ -629,8 +663,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -629,8 +663,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
fortune.setExpectedFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_EXPECTED_FORTUNE.getCode())); fortune.setExpectedFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_EXPECTED_FORTUNE.getCode()));
//基本法项目配置表唯一业务ID //基本法项目配置表唯一业务ID
fortune.setRuleItemBizId(algorithmResDto.getRuleItemBizId()); fortune.setRuleItemBizId(algorithmResDto.getRuleItemBizId());
//发佣币种 //保单币种
fortune.setCurrency(fortuneDto.getCurrency()); fortune.setPolicyCurrency(fortuneDto.getCurrency());
//发佣期数 //发佣期数
fortune.setFortunePeriod(fortuneDto.getFortunePeriod()); fortune.setFortunePeriod(fortuneDto.getFortunePeriod());
//发佣总期数 //发佣总期数
...@@ -639,8 +673,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -639,8 +673,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
fortune.setPolicyNo(fortuneDto.getPolicyNo()); fortune.setPolicyNo(fortuneDto.getPolicyNo());
//预计发佣日期 //预计发佣日期
fortune.setPayoutDate(fortuneDto.getPayoutDate()); fortune.setPayoutDate(fortuneDto.getPayoutDate());
//默认结算汇率
fortune.setDefaultExchangeRate(queryDefaultExchangeRate(fortune.getCurrency()));
// 标准发佣金额 -> 计算值 // 标准发佣金额 -> 计算值
BigDecimal standardAmount = algorithmResDto.getCalculatedValue(); BigDecimal standardAmount = algorithmResDto.getCalculatedValue();
...@@ -659,8 +691,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -659,8 +691,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
// 计算实际预计发佣金额 = 标准发佣金额 × decimalRatio // 计算实际预计发佣金额 = 标准发佣金额 × decimalRatio
BigDecimal actualAmount = standardAmount.multiply(decimalRatio); BigDecimal actualAmount = standardAmount.multiply(decimalRatio);
fortune.setAmount(actualAmount); fortune.setAmount(actualAmount);
// 计算港币金额
fortune.setHkdAmount(actualAmount.multiply(fortune.getDefaultExchangeRate()));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// 如果比例不是有效的数字,使用标准金额 // 如果比例不是有效的数字,使用标准金额
...@@ -755,7 +785,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -755,7 +785,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
// 应付款编号(序号递增) // 应付款编号(序号递增)
expectedFortune.setPayableNo(this.createPayableNo(expectedFortune.getFortuneBizType(), ++currentSeq)); expectedFortune.setPayableNo(this.createPayableNo(expectedFortune.getFortuneBizType(), ++currentSeq));
// 默认结算汇率 // 默认结算汇率
expectedFortune.setDefaultExchangeRate(queryDefaultExchangeRate(expectedFortune.getCurrency())); expectedFortune.setDefaultExchangeRate(
queryExchangeRateByFeign(expectedFortune.getPolicyCurrency(), expectedFortune.getCurrency()));
// 计算港币金额 // 计算港币金额
expectedFortune.setHkdAmount(expectedFortune.getAmount().multiply(expectedFortune.getDefaultExchangeRate())); expectedFortune.setHkdAmount(expectedFortune.getAmount().multiply(expectedFortune.getDefaultExchangeRate()));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例 // 已出帐金额、待出帐金额、已出帐比例、待出帐比例
...@@ -790,27 +821,22 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -790,27 +821,22 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
return null; return null;
} }
private BigDecimal queryDefaultExchangeRate(String currency) { /**
if ("HKD".equalsIgnoreCase(currency)) { * 保单币种对预计来佣的结算币种的默认汇率
return BigDecimal.valueOf(1); * @param policyCurrency 保单币种
} * @param currency 预计来佣的结算币种
//查询redis缓存的字典列表信息 * @return 汇率
List<GetDictItemListByDictTypeResponse> dictTypeResponses = redisUtil.getCacheObject(RedisConstants.DICT_LIST); */
String defaultExchangeRaye = GetDictItemListByDictTypeResponse.getItemLabel(dictTypeResponses, private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) {
"csf_exchange_rate_hkd", currency); if (policyCurrency.equalsIgnoreCase(currency)) {
if (ObjectUtils.isNotEmpty(defaultExchangeRaye)) { return BigDecimal.ONE;
return new BigDecimal(defaultExchangeRaye);
}
Result<List<GetDictItemListByDictTypeResponse>> result = apiSysDictFeignClient.getDictItemListByDictType("csf_exchange_rate_hkd");
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(result.getData())) {
for (GetDictItemListByDictTypeResponse dictItem : result.getData()) {
if (StringUtils.equalsIgnoreCase(dictItem.getItemLabel(), currency)) {
return new BigDecimal(dictItem.getItemValue());
}
} }
// 调用Feign客户端查询汇率
Result<BigDecimal> result = apiExchangeRateFeignClient.getExchangeRate(policyCurrency, currency, "");
if (result != null && result.getData() != null) {
return result.getData();
} }
return BigDecimal.ONE; return null;
} }
private void validateAdd(List<ExpectedFortuneAddRequest> fortuneAddRequestList) { private void validateAdd(List<ExpectedFortuneAddRequest> fortuneAddRequestList) {
...@@ -1057,7 +1083,11 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1057,7 +1083,11 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
updateExpectedFortune.setId(expectedFortune.getId()); updateExpectedFortune.setId(expectedFortune.getId());
// 默认结算汇率 // 默认结算汇率
if (updateExpectedFortune.getDefaultExchangeRate() == null) { if (updateExpectedFortune.getDefaultExchangeRate() == null) {
updateExpectedFortune.setDefaultExchangeRate(queryDefaultExchangeRate(updateExpectedFortune.getCurrency())); updateExpectedFortune.setDefaultExchangeRate(
queryExchangeRateByFeign(
updateExpectedFortune.getPolicyCurrency(),
updateExpectedFortune.getCurrency()
));
} }
// 计算港币金额 // 计算港币金额
updateExpectedFortune.setHkdAmount(updateExpectedFortune.getAmount().multiply(updateExpectedFortune.getDefaultExchangeRate())); updateExpectedFortune.setHkdAmount(updateExpectedFortune.getAmount().multiply(updateExpectedFortune.getDefaultExchangeRate()));
......
...@@ -120,7 +120,7 @@ public class PolicyFollowVO implements Serializable { ...@@ -120,7 +120,7 @@ public class PolicyFollowVO implements Serializable {
* 缴费年期 * 缴费年期
*/ */
@Schema(description = "缴费年期") @Schema(description = "缴费年期")
private Integer issueNumber; private Object issueNumber;
/** /**
* 保险公司 * 保险公司
......
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