Commit f259c352 by jianan

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

parent 96da5a90
......@@ -719,6 +719,10 @@ public class ApiAppointmentServiceImpl implements ApiAppointmentService {
follow.setInsuranceCompany(apiProductPlanMainInfoDto.getCompanyName());
// 保险公司业务ID(从产品计划获取的公司ID)
follow.setInsuranceCompanyBizId(apiProductPlanMainInfoDto.getCompanyId());
// 对账公司
follow.setReconciliationCompany(apiProductPlanMainInfoDto.getReconciliationCompanyName());
// 对账公司业务ID(从产品计划获取的对账公司ID)
follow.setReconciliationCompanyBizId(apiProductPlanMainInfoDto.getReconciliationCompanyId());
// 币种
follow.setPolicyCurrency(apiProductPlanMainInfoDto.getPolicyCurrency());
// 供款年期
......
......@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yd.auth.core.dto.AuthUserDto;
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.enums.*;
import com.yd.common.exception.BusinessException;
......@@ -34,6 +35,7 @@ import com.yd.csf.service.service.*;
import com.yd.csf.service.vo.ExpectedFortuneExportDTO;
import com.yd.csf.service.vo.ExpectedFortuneStatisticsVO;
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.sysdict.ApiSysDictFeignClient;
import com.yd.user.feign.response.sysdict.GetDictItemListByDictTypeResponse;
......@@ -91,6 +93,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
private ApiSysDictFeignClient apiSysDictFeignClient;
@Resource
private PolicyFollowService policyFollowService;
@Resource
private ApiExchangeRateFeignClient apiExchangeRateFeignClient;
@Resource
private CommissionExpectedService commissionExpectedService;
/**
* 生成预计发佣
......@@ -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缓存
redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo);
......@@ -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
public Result executeSync(List<QueryPolicyAndBrokerDto> queryPolicyAndBrokerDtoList, List<CommissionRuleBinding> commissionRuleBindingList, String policyNo) {
return null;
......@@ -425,7 +457,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
return commissionRuleBindingList;
}
private void updatePayableNoBatch(String policyNo) {
private List<ExpectedFortune> updatePayableNoBatch(String policyNo) {
// 查询最新一条有 payableNo 记录
ExpectedFortune latest = iExpectedFortuneService.getOne(
new QueryWrapper<ExpectedFortune>().isNotNull("payable_no").orderByDesc("id").last("LIMIT 1"),
......@@ -452,6 +484,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
"csf_fortune_type", expectedFortune.getFortuneName()));
}
iExpectedFortuneService.updateBatchById(expectedFortuneList);
return expectedFortuneList;
}
/**
......@@ -629,8 +663,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
fortune.setExpectedFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_EXPECTED_FORTUNE.getCode()));
//基本法项目配置表唯一业务ID
fortune.setRuleItemBizId(algorithmResDto.getRuleItemBizId());
//发佣币种
fortune.setCurrency(fortuneDto.getCurrency());
//保单币种
fortune.setPolicyCurrency(fortuneDto.getCurrency());
//发佣期数
fortune.setFortunePeriod(fortuneDto.getFortunePeriod());
//发佣总期数
......@@ -639,8 +673,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
fortune.setPolicyNo(fortuneDto.getPolicyNo());
//预计发佣日期
fortune.setPayoutDate(fortuneDto.getPayoutDate());
//默认结算汇率
fortune.setDefaultExchangeRate(queryDefaultExchangeRate(fortune.getCurrency()));
// 标准发佣金额 -> 计算值
BigDecimal standardAmount = algorithmResDto.getCalculatedValue();
......@@ -659,8 +691,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
// 计算实际预计发佣金额 = 标准发佣金额 × decimalRatio
BigDecimal actualAmount = standardAmount.multiply(decimalRatio);
fortune.setAmount(actualAmount);
// 计算港币金额
fortune.setHkdAmount(actualAmount.multiply(fortune.getDefaultExchangeRate()));
} catch (NumberFormatException e) {
// 如果比例不是有效的数字,使用标准金额
......@@ -755,7 +785,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
// 应付款编号(序号递增)
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()));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
......@@ -790,27 +821,22 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
return null;
}
private BigDecimal queryDefaultExchangeRate(String currency) {
if ("HKD".equalsIgnoreCase(currency)) {
return BigDecimal.valueOf(1);
}
//查询redis缓存的字典列表信息
List<GetDictItemListByDictTypeResponse> dictTypeResponses = redisUtil.getCacheObject(RedisConstants.DICT_LIST);
String defaultExchangeRaye = GetDictItemListByDictTypeResponse.getItemLabel(dictTypeResponses,
"csf_exchange_rate_hkd", currency);
if (ObjectUtils.isNotEmpty(defaultExchangeRaye)) {
return new BigDecimal(defaultExchangeRaye);
/**
* 保单币种对预计来佣的结算币种的默认汇率
* @param policyCurrency 保单币种
* @param currency 预计来佣的结算币种
* @return 汇率
*/
private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) {
if (policyCurrency.equalsIgnoreCase(currency)) {
return BigDecimal.ONE;
}
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) {
......@@ -1057,7 +1083,11 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
updateExpectedFortune.setId(expectedFortune.getId());
// 默认结算汇率
if (updateExpectedFortune.getDefaultExchangeRate() == null) {
updateExpectedFortune.setDefaultExchangeRate(queryDefaultExchangeRate(updateExpectedFortune.getCurrency()));
updateExpectedFortune.setDefaultExchangeRate(
queryExchangeRateByFeign(
updateExpectedFortune.getPolicyCurrency(),
updateExpectedFortune.getCurrency()
));
}
// 计算港币金额
updateExpectedFortune.setHkdAmount(updateExpectedFortune.getAmount().multiply(updateExpectedFortune.getDefaultExchangeRate()));
......
......@@ -120,7 +120,7 @@ public class PolicyFollowVO implements Serializable {
* 缴费年期
*/
@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