Commit 1ab9c9fc by zhangxingmin

Merge remote-tracking branch 'origin/dev' into dev_zxm

parents 32e6b8e4 cd66fe60
...@@ -492,7 +492,6 @@ public class ApiPolicyFollowController { ...@@ -492,7 +492,6 @@ public class ApiPolicyFollowController {
*/ */
@PostMapping("/change_status") @PostMapping("/change_status")
@Operation(summary = "修改跟进状态") @Operation(summary = "修改跟进状态")
@Transactional(rollbackFor = Exception.class)
public Result<Boolean> changePolicyFollowStatus(@RequestBody ChangePolicyFollowStatusRequest changePolicyFollowStatusRequest, public Result<Boolean> changePolicyFollowStatus(@RequestBody ChangePolicyFollowStatusRequest changePolicyFollowStatusRequest,
HttpServletRequest request) { HttpServletRequest request) {
if (changePolicyFollowStatusRequest == null || StringUtils.isBlank(changePolicyFollowStatusRequest.getPolicyBizId())) { if (changePolicyFollowStatusRequest == null || StringUtils.isBlank(changePolicyFollowStatusRequest.getPolicyBizId())) {
...@@ -504,6 +503,9 @@ public class ApiPolicyFollowController { ...@@ -504,6 +503,9 @@ public class ApiPolicyFollowController {
if (policyFollow == null) { if (policyFollow == null) {
return Result.fail(ResultCode.NULL_ERROR.getCode(), ResultCode.NULL_ERROR.getMessage()); return Result.fail(ResultCode.NULL_ERROR.getCode(), ResultCode.NULL_ERROR.getMessage());
} }
if (ObjectUtils.isEmpty(policyFollow.getReconciliationCompanyCode())) {
return Result.fail(ResultCode.NULL_ERROR.getCode(), "新单跟进记录中,reconciliationCompanyCode不能为空");
}
PolicyFollowStatusEnum currentStatusEnum = PolicyFollowStatusEnum.getEnumByValue(changePolicyFollowStatusRequest.getStatus()); PolicyFollowStatusEnum currentStatusEnum = PolicyFollowStatusEnum.getEnumByValue(changePolicyFollowStatusRequest.getStatus());
// 修改为生效时需要校验、同步预计发佣 // 修改为生效时需要校验、同步预计发佣
...@@ -712,15 +714,11 @@ public class ApiPolicyFollowController { ...@@ -712,15 +714,11 @@ public class ApiPolicyFollowController {
*/ */
@GetMapping("/product_plan") @GetMapping("/product_plan")
@Operation(summary = "查询产品计划信息") @Operation(summary = "查询产品计划信息")
public Result<Policy> getProductPlan(@RequestParam("policyBizId") String policyBizId) { public Result<PolicyDto> getProductPlan(@RequestParam("policyBizId") String policyBizId) {
if (StringUtils.isBlank(policyBizId)) { if (StringUtils.isBlank(policyBizId)) {
return Result.fail(ResultCode.NULL_ERROR.getCode(), "policyBizId不能为空"); return Result.fail(ResultCode.NULL_ERROR.getCode(), "policyBizId不能为空");
} }
Policy policy = policyFollowService.getProductPlan(policyBizId); return Result.success(policyFollowService.getProductPlan(policyBizId));
if (policy == null) {
return Result.fail(ResultCode.NULL_ERROR.getCode(), "产品计划信息不存在");
}
return Result.success(policy);
} }
/** /**
......
...@@ -364,7 +364,8 @@ public class ApiAppointmentServiceImpl implements ApiAppointmentService { ...@@ -364,7 +364,8 @@ public class ApiAppointmentServiceImpl implements ApiAppointmentService {
updateFnaBizIdAndNo(appointment.getFnaBizId(), appointment.getAppointmentBizId(), appointment.getAppointmentNo()); updateFnaBizIdAndNo(appointment.getFnaBizId(), appointment.getAppointmentBizId(), appointment.getAppointmentNo());
//新增健康问卷和预约对象关系绑定 //新增健康问卷和预约对象关系绑定
objectSaveJkQuestion(appointment.getAppointmentBizId(),request.getApiAnswerSaveRequest()); objectSaveJkQuestion(appointment.getAppointmentBizId(),request.getApiAnswerSaveRequest());
//新增对象材料关系信息
addRelObjectMaterialList(appointment.getAppointmentBizId(),request.getMaterialDtoList());
return Result.success(); return Result.success();
} }
......
...@@ -44,6 +44,11 @@ public class ApiAppointmentAddStorageRequest { ...@@ -44,6 +44,11 @@ public class ApiAppointmentAddStorageRequest {
private ApiSecondHolderInfoDto apiSecondHolderInfoDto; private ApiSecondHolderInfoDto apiSecondHolderInfoDto;
/** /**
* 附件信息
*/
private List<ApiAppointmentMaterialDto> materialDtoList;
/**
* 问卷-答题提交对象 * 问卷-答题提交对象
*/ */
private ApiAnswerSaveRequest apiAnswerSaveRequest; private ApiAnswerSaveRequest apiAnswerSaveRequest;
......
package com.yd.csf.service.dto; package com.yd.csf.service.dto;
import com.yd.csf.service.model.PolicyAdditional; import com.yd.csf.service.model.*;
import com.yd.csf.service.vo.PolicyVO; import com.yd.csf.service.vo.PolicyVO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -23,4 +24,19 @@ public class PolicyDto implements Serializable { ...@@ -23,4 +24,19 @@ public class PolicyDto implements Serializable {
*/ */
@Schema(description = "保单附加险列表") @Schema(description = "保单附加险列表")
private List<PolicyAdditional> apiProductPlanAdditionalInfoDtoList; private List<PolicyAdditional> apiProductPlanAdditionalInfoDtoList;
public static PolicyDto convertToDto(Policy policy, List<PolicyAdditional> policyAdditionals) {
PolicyDto dto = new PolicyDto();
if (ObjectUtils.isEmpty(policy)) {
return dto;
}
// 产品计划主信息
dto.setApiProductPlanMainInfoDto(PolicyVO.objToVo(policy));
// 附加险列表
dto.setApiProductPlanAdditionalInfoDtoList(policyAdditionals);
return dto;
}
} }
...@@ -150,7 +150,10 @@ public class PolicyFollowDto implements Serializable { ...@@ -150,7 +150,10 @@ public class PolicyFollowDto implements Serializable {
private String insuranceCompanyBizId; private String insuranceCompanyBizId;
@Schema(description = "对账公司") @Schema(description = "对账公司")
private String reconciliationCompany; private String reconciliationCompanyName;
@Schema(description = "对账公司编码")
private String reconciliationCode;
@Schema(description = "对账公司业务id") @Schema(description = "对账公司业务id")
private String reconciliationCompanyBizId; private String reconciliationCompanyBizId;
......
...@@ -83,6 +83,11 @@ public class Policy implements Serializable { ...@@ -83,6 +83,11 @@ public class Policy implements Serializable {
private String policyHolder; private String policyHolder;
/** /**
* 保單持有人年齡
*/
private Integer policyHolderAge;
/**
* 受保人 * 受保人
*/ */
private String insured; private String insured;
......
...@@ -241,6 +241,11 @@ public class PolicyFollow implements Serializable { ...@@ -241,6 +241,11 @@ public class PolicyFollow implements Serializable {
private String reconciliationCompany; private String reconciliationCompany;
/** /**
* 对账公司编码
*/
private String reconciliationCompanyCode;
/**
* 对账公司业务id * 对账公司业务id
*/ */
private String reconciliationCompanyBizId; private String reconciliationCompanyBizId;
......
...@@ -96,7 +96,7 @@ public interface PolicyFollowService extends IService<PolicyFollow> { ...@@ -96,7 +96,7 @@ public interface PolicyFollowService extends IService<PolicyFollow> {
* @param policyBizId 新单跟进业务ID * @param policyBizId 新单跟进业务ID
* @return 产品计划信息 * @return 产品计划信息
*/ */
Policy getProductPlan(String policyBizId); PolicyDto getProductPlan(String policyBizId);
/** /**
* 查询投保人信息 * 查询投保人信息
......
...@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient; import com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient;
import com.yd.common.constant.CommonConstant; import com.yd.common.constant.CommonConstant;
import com.yd.common.constant.RedisConstants; import com.yd.common.constant.RedisConstants;
...@@ -41,6 +43,7 @@ import org.springframework.stereotype.Service; ...@@ -41,6 +43,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -77,6 +80,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -77,6 +80,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
@Resource @Resource
private ApiExchangeRateFeignClient apiExchangeRateFeignClient; private ApiExchangeRateFeignClient apiExchangeRateFeignClient;
// 用于对象转换的ObjectMapper
private static final ObjectMapper objectMapper = new ObjectMapper();
@Override @Override
public Page<CommissionExpectedVO> getCommissionExpectedVOPage(Page<CommissionExpected> commissionExpectedPage) { public Page<CommissionExpectedVO> getCommissionExpectedVOPage(Page<CommissionExpected> commissionExpectedPage) {
...@@ -481,6 +487,10 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -481,6 +487,10 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
if (paymentPremium == null) { if (paymentPremium == null) {
throw new BusinessException("保费不能为空"); throw new BusinessException("保费不能为空");
} }
Integer policyHolderAge = policy.getPolicyHolderAge();
if (policyHolderAge == null) {
throw new BusinessException("保單持有人年齡不能为空");
}
Date effectiveDate = policy.getEffectiveDate(); Date effectiveDate = policy.getEffectiveDate();
if (effectiveDate == null) { if (effectiveDate == null) {
throw new BusinessException("保单生效日期不能为空"); throw new BusinessException("保单生效日期不能为空");
...@@ -501,22 +511,25 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -501,22 +511,25 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
List<CommissionExpected> commissionExpectedList = new ArrayList<>(); List<CommissionExpected> commissionExpectedList = new ArrayList<>();
if (CollUtil.isNotEmpty(expectedSpeciesList)) { if (CollUtil.isNotEmpty(expectedSpeciesList)) {
// 根据供款年期匹配规格 // 匹配规格并获取不匹配的条件
List<ApiExpectedSpeciesListResponse> collect = expectedSpeciesList.stream() MatchResult matchResult = matchExpectedSpecies(
.filter(i -> paymentTerm.equals(i.getPaymentTerm())) expectedSpeciesList, paymentTerm, reconciliationCompanyBizId,
.collect(Collectors.toList()); policyHolderAge, paymentPremium);
if (ObjectUtils.isEmpty(collect)) { if (matchResult.getMatchedList().isEmpty()) {
throw new BusinessException(ResultCode.FAIL.getCode(), "未查询到对应供款年期的佣金规格"); String errorMsg = matchResult.getUnmatchedConditions().isEmpty()
? "未查询到对应供款年期的佣金规格"
: "未查询到对应供款年期的佣金规格,不匹配条件:" + String.join("、", matchResult.getUnmatchedConditions());
throw new BusinessException(ResultCode.FAIL.getCode(), errorMsg);
} }
// 计算佣金总期数 list 中 endPeriod最大值 // 计算佣金总期数 list 中 endPeriod最大值
Integer maxEndPeriod = collect.stream() Integer maxEndPeriod = matchResult.getMatchedList().stream()
.map(item -> Convert.toInt(item.getEndPeriod())) .map(item -> Convert.toInt(item.getEndPeriod()))
.max(Integer::compareTo) .max(Integer::compareTo)
.orElse(0); .orElse(0);
for (ApiExpectedSpeciesListResponse item : collect) { for (ApiExpectedSpeciesListResponse item : matchResult.getMatchedList()) {
CommissionExpected commissionExpected = new CommissionExpected(); CommissionExpected commissionExpected = new CommissionExpected();
commissionExpected.setCommissionExpectedBizId(RandomStringGenerator.generateBizId16("commission_expected")); commissionExpected.setCommissionExpectedBizId(RandomStringGenerator.generateBizId16("commission_expected"));
commissionExpected.setReceivableNo(receivableService.generateReceivableNo("R", reconciliationCompanyCode, reconciliationCompany)); commissionExpected.setReceivableNo(receivableService.generateReceivableNo("R", reconciliationCompanyCode, reconciliationCompany));
...@@ -565,6 +578,140 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte ...@@ -565,6 +578,140 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
} }
} }
/**
* 匹配规格结果内部类
*/
private static class MatchResult {
private List<ApiExpectedSpeciesListResponse> matchedList;
private List<String> unmatchedConditions;
public MatchResult(List<ApiExpectedSpeciesListResponse> matchedList, List<String> unmatchedConditions) {
this.matchedList = matchedList;
this.unmatchedConditions = unmatchedConditions;
}
public List<ApiExpectedSpeciesListResponse> getMatchedList() {
return matchedList;
}
public List<String> getUnmatchedConditions() {
return unmatchedConditions;
}
}
/**
* 匹配预计规格并返回不匹配的条件
*
* @param expectedSpeciesList 预计规格列表
* @param paymentTerm 供款年期
* @param reconciliationCompanyId 对账公司ID
* @param policyHolderAge 保单持有人年龄
* @param paymentPremium 年缴保费
* @return 匹配结果
*/
private MatchResult matchExpectedSpecies(List<ApiExpectedSpeciesListResponse> expectedSpeciesList,
String paymentTerm, String reconciliationCompanyId,
Integer policyHolderAge, BigDecimal paymentPremium) {
List<String> unmatchedConditions = new ArrayList<>();
List<ApiExpectedSpeciesListResponse> currentList = expectedSpeciesList;
// 检查供款年期
currentList = filterAndCheck(currentList,
i -> paymentTerm.equals(i.getPaymentTerm()),
unmatchedConditions, "供款年期[" + paymentTerm + "]");
if (unmatchedConditions.size() > 0) {
return new MatchResult(Collections.emptyList(), unmatchedConditions);
}
// 检查对账公司
currentList = filterAndCheck(currentList,
i -> reconciliationCompanyId.equals(i.getReconciliationCompany()),
unmatchedConditions, "对账公司[" + reconciliationCompanyId + "]");
if (unmatchedConditions.size() > 0) {
return new MatchResult(Collections.emptyList(), unmatchedConditions);
}
// 检查年龄
currentList = filterAndCheck(currentList,
i -> containsValue(i.getSpeciesJson(), "AGE", Convert.toStr(policyHolderAge)),
unmatchedConditions, "年龄[" + policyHolderAge + "]");
if (unmatchedConditions.size() > 0) {
return new MatchResult(Collections.emptyList(), unmatchedConditions);
}
// 检查保费
currentList = filterAndCheck(currentList,
i -> containsValue(i.getSpeciesJson(), "PREMIUM", Convert.toStr(paymentPremium)),
unmatchedConditions, "保费[" + paymentPremium + "]");
return new MatchResult(currentList, unmatchedConditions);
}
/**
* 过滤列表并检查是否为空
*
* @param list 待过滤的列表
* @param predicate 过滤条件
* @param unmatchedConditions 不匹配条件列表
* @param conditionDesc 条件描述
* @return 过滤后的列表
*/
private List<ApiExpectedSpeciesListResponse> filterAndCheck(
List<ApiExpectedSpeciesListResponse> list,
java.util.function.Predicate<ApiExpectedSpeciesListResponse> predicate,
List<String> unmatchedConditions, String conditionDesc) {
List<ApiExpectedSpeciesListResponse> filtered = list.stream()
.filter(predicate)
.collect(Collectors.toList());
if (filtered.isEmpty()) {
unmatchedConditions.add(conditionDesc);
}
return filtered;
}
private static boolean containsValue(String json, String targetKey, String targetValue) {
if (json == null || json.trim().isEmpty()) return false;
try {
List<Map<String, Object>> params = objectMapper.readValue(json, new TypeReference<List<Map<String, Object>>>() {});
// AGE 和 PREMIUM 使用最小值匹配(targetValue >= value)
if (targetKey.equals("AGE") || targetKey.equals("PREMIUM")) {
return params.stream().anyMatch(p -> {
Object value = p.get("value");
if (value == null) {
return false;
}
// 转换为 BigDecimal
BigDecimal threshold;
if (value instanceof BigDecimal) {
threshold = (BigDecimal) value;
} else if (value instanceof Number) {
threshold = BigDecimal.valueOf(((Number) value).doubleValue());
} else if (value instanceof String) {
try {
threshold = new BigDecimal((String) value);
} catch (NumberFormatException e) {
return false;
}
} else {
return false;
}
// 判断是否大于等于最小值
return new BigDecimal(targetValue).compareTo(threshold) >= 0;
});
}
// 其他字段使用等于匹配
else {
return params.stream().anyMatch(p -> targetValue.equals(p.get("value")));
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
@Override @Override
public List<ApiExpectedSpeciesListResponse> queryExpectedSpeciesByFeign(String productLaunchBizId) { public List<ApiExpectedSpeciesListResponse> queryExpectedSpeciesByFeign(String productLaunchBizId) {
ApiExpectedSpeciesListRequest apiExpectedSpeciesListRequest = new ApiExpectedSpeciesListRequest(); ApiExpectedSpeciesListRequest apiExpectedSpeciesListRequest = new ApiExpectedSpeciesListRequest();
......
...@@ -89,6 +89,8 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -89,6 +89,8 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
private FnaService fnaService; private FnaService fnaService;
@Resource @Resource
private ApiInsuranceReconciliationCompanyFeignClient apiInsuranceReconciliationCompanyFeignClient; private ApiInsuranceReconciliationCompanyFeignClient apiInsuranceReconciliationCompanyFeignClient;
@Resource
private CustomerService customerService;
@Override @Override
...@@ -199,6 +201,12 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -199,6 +201,12 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
// 复制属性,排除系统字段 // 复制属性,排除系统字段
BeanUtils.copyProperties(policyFollowDto, policyFollow, "id", "policyBizId", "brokerList"); BeanUtils.copyProperties(policyFollowDto, policyFollow, "id", "policyBizId", "brokerList");
if (StringUtils.isNotBlank(policyFollowDto.getReconciliationCode())) {
policyFollow.setReconciliationCompanyCode(policyFollowDto.getReconciliationCode());
}
if (StringUtils.isNotBlank(policyFollowDto.getReconciliationCompanyName())) {
policyFollow.setReconciliationCompany(policyFollowDto.getReconciliationCompanyName());
}
// 检查保单号是否从空变为有值 // 检查保单号是否从空变为有值
String oldPolicyNo = policyFollow.getPolicyNo(); String oldPolicyNo = policyFollow.getPolicyNo();
...@@ -484,8 +492,17 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -484,8 +492,17 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
// 如果是生效状态,同步保单、预计发佣、预计来佣 // 如果是生效状态,同步保单、预计发佣、预计来佣
if (PolicyFollowStatusEnum.EFFECTIVE.equals(policyFollowStatusEnum)) { if (PolicyFollowStatusEnum.EFFECTIVE.equals(policyFollowStatusEnum)) {
Policy policy = new Policy(); Policy policy = policyService.getOne(new QueryWrapper<Policy>().eq("policy_biz_id", policyBizId));
BeanUtils.copyProperties(policyFollow, policy, "id"); if (policy == null) {
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR.getCode(), "policy不存在");
}
policy.setPolicyNo(policyFollow.getPolicyNo());
policy.setPaymentPremium(policyFollow.getEachIssuePremium());
policy.setPolicyHolderAge(calculatePolicyHolderAge(policyFollow.getCustomerBizId()));
policy.setEffectiveDate(policyFollow.getEffectiveDate());
policy.setCoolingOffEndDate(policyFollow.getCoolingOffEndDate());
policy.setPaymentTerm(policyFollow.getIssueNumber());
// 更新保单状态为生效
policy.setStatus(PolicyStatusEnum.INFORCE.getItemValue()); policy.setStatus(PolicyStatusEnum.INFORCE.getItemValue());
// 手动映射不同名的字段 // 手动映射不同名的字段
policy.setPaymentPremium(policyFollow.getInitialPremium()); policy.setPaymentPremium(policyFollow.getInitialPremium());
...@@ -493,39 +510,37 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -493,39 +510,37 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
policy.setPaymentTerm(policyFollow.getIssueNumber()); policy.setPaymentTerm(policyFollow.getIssueNumber());
policy.setUnderwritingDate(changePolicyFollowStatusRequest.getUnderwritingDate()); policy.setUnderwritingDate(changePolicyFollowStatusRequest.getUnderwritingDate());
policy.setEffectiveDate(changePolicyFollowStatusRequest.getEffectiveDate()); policy.setEffectiveDate(changePolicyFollowStatusRequest.getEffectiveDate());
policy.setPolicyHolderAge(calculatePolicyHolderAge(policyFollow.getCustomerBizId()));
if (ObjectUtils.isEmpty(policy.getInsuranceCompany()) || ObjectUtils.isEmpty(policy.getReconciliationCompanyBizId())) { if (ObjectUtils.isEmpty(policy.getInsuranceCompany()) || ObjectUtils.isEmpty(policy.getInsuranceCompany())) {
// 获取保单产品信息,填充对账公司相关字段 // 获取保单产品信息,填充对账公司相关字段
PolicyProductInfo productInfo = getPolicyProductInfo(policyFollow.getProductLaunchBizId()); PolicyProductInfo productInfo = getPolicyProductInfo(policyFollow.getProductLaunchBizId());
if (productInfo != null) { if (productInfo != null) {
policy.setInsuranceCompany(productInfo.getInsuranceCompany()); policy.setInsuranceCompany(productInfo.getInsuranceCompany());
policy.setInsuranceCompanyBizId(productInfo.getInsuranceCompanyBizId()); policy.setInsuranceCompanyBizId(productInfo.getInsuranceCompanyBizId());
policy.setReconciliationCompany(productInfo.getReconciliationCompany()); if (ObjectUtils.isEmpty(policy.getReconciliationCompany())) {
policy.setReconciliationCompanyBizId(productInfo.getReconciliationCompanyBizId()); policy.setReconciliationCompany(productInfo.getReconciliationCompany());
}
// 调用对账公司 feignclient,查询对账公司编码 if (ObjectUtils.isEmpty(policy.getReconciliationCompanyBizId())) {
String reconciliationCompanyCode = queryReconciliationCompanyByFeign(policy.getReconciliationCompanyBizId()); policy.setReconciliationCompanyBizId(productInfo.getReconciliationCompanyBizId());
// 如果仍然没有获取到编码,抛异常
if (StringUtils.isBlank(reconciliationCompanyCode)) {
throw new BusinessException("未能从对账公司服务获取编码,请补充,当前对账公司:" + productInfo.getReconciliationCompany());
} }
policy.setReconciliationCompanyCode(reconciliationCompanyCode);
} }
} }
// 保存保单 // 保存保单
try { policyService.updateById(policy);
policyService.save(policy);
} catch (DuplicateKeyException e) {
// 保单号已存在
throw new BusinessException("保单号 " + policy.getPolicyNo() + " 已存在,请勿重复添加");
}
// 更新转介人保单号 // 更新转介人保单号
updatePolicyBrokerPolicyNo(policyBizId, policy.getPolicyNo()); updatePolicyBrokerPolicyNo(policyBizId, policy.getPolicyNo());
// 根据保单生成预计入账记录 // 根据保单生成预计入账记录
generateExpectedCommission(policyFollow, policy); generateExpectedCommission(policyFollow, policy);
// 更新FNA状态为 "签单完成"
fnaService.update(new UpdateWrapper<Fna>()
.set("status", FnaStatusEnum.SIGNED_COMPLETED.getItemValue())
.set("policy_no", policy.getPolicyNo())
.eq("fna_biz_id", policyFollow.getFnaBizId()));
} }
// 新增新单状态记录 // 新增新单状态记录
...@@ -541,6 +556,18 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -541,6 +556,18 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
return true; return true;
} }
private Integer calculatePolicyHolderAge(String customerBizId) {
Customer customer = customerService.getByCustomerBizId(customerBizId);
if (customer == null) {
throw new BusinessException("客户不存在");
}
if (customer.getBirthday() == null) {
throw new BusinessException("客户生日不能为空");
}
// 根据生日计算年龄
return DateUtil.ageOfNow(customer.getBirthday());
}
/** /**
* 调用对账公司 feignclient,查询对账公司编码 * 调用对账公司 feignclient,查询对账公司编码
*/ */
...@@ -963,8 +990,13 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -963,8 +990,13 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
} }
@Override @Override
public Policy getProductPlan(String policyBizId) { public PolicyDto getProductPlan(String policyBizId) {
return policyService.getOne(new QueryWrapper<Policy>().eq("policy_biz_id", policyBizId).eq("is_deleted", 0)); Policy policy = policyService.getOne(new QueryWrapper<Policy>().eq("policy_biz_id", policyBizId));
List<PolicyAdditional> policyAdditionalList = policyAdditionalService.lambdaQuery()
.eq(PolicyAdditional::getPolicyBizId, policyBizId)
.list();
// 转换为DTO
return PolicyDto.convertToDto(policy, policyAdditionalList);
} }
@Override @Override
......
...@@ -53,7 +53,6 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy> ...@@ -53,7 +53,6 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy>
@Resource @Resource
private PolicyAdditionalService policyAdditionalService; private PolicyAdditionalService policyAdditionalService;
@Resource @Resource
private ApiRelProjectProductLaunchFeignClient apiRelProjectProductLaunchFeignClient; private ApiRelProjectProductLaunchFeignClient apiRelProjectProductLaunchFeignClient;
...@@ -148,7 +147,6 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy> ...@@ -148,7 +147,6 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy>
policyAdditionalService.saveBatch(policyAdditionalList); policyAdditionalService.saveBatch(policyAdditionalList);
} }
policy.setUpdateTime(now);
return true; return true;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<result property="insuranceCompanyBizId" column="insurance_company_biz_id" /> <result property="insuranceCompanyBizId" column="insurance_company_biz_id" />
<result property="region" column="region" /> <result property="region" column="region" />
<result property="policyHolder" column="policy_holder" /> <result property="policyHolder" column="policy_holder" />
<result property="policyHolderAge" column="policy_holder_age" />
<result property="insured" column="insured" /> <result property="insured" column="insured" />
<result property="sumInsured" column="sum_insured" /> <result property="sumInsured" column="sum_insured" />
<result property="paymentTerm" column="payment_term" /> <result property="paymentTerm" column="payment_term" />
...@@ -55,7 +56,7 @@ ...@@ -55,7 +56,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,policy_biz_id,policy_no,user_biz_id,product_launch_biz_id,product_code, id,policy_biz_id,policy_no,user_biz_id,product_launch_biz_id,product_code,
product_name,product_cate,insurance_company,insurance_company_biz_id,region, product_name,product_cate,insurance_company,insurance_company_biz_id,region,
policy_holder,insured,sum_insured,payment_term,payment_frequency,payment_premium, policy_holder,policy_holder_age,insured,sum_insured,payment_term,payment_frequency,payment_premium,
status,currency,initial_premium,sign_date,issue_date, status,currency,initial_premium,sign_date,issue_date,
effective_date,cooling_off_end_date,cooling_off_days,renewal_date,is_prepaid,deductibles,prepaid_term, effective_date,cooling_off_end_date,cooling_off_days,renewal_date,is_prepaid,deductibles,prepaid_term,
initial_payment_method,renewal_payment_method,dividend_distribution_method,is_backtrack,is_join, initial_payment_method,renewal_payment_method,dividend_distribution_method,is_backtrack,is_join,
......
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