Commit 5cf7bde6 authored by 李灿灿's avatar 李灿灿

Merge branch 'feature-licancan' into 'develop'

Feature licancan

See merge request fangxinjiang/yifu!79
parents 47ee39d2 1bbdfcce
......@@ -75,6 +75,18 @@ public class TInsuranceDetail extends BaseEntity {
@Schema(description = "购买标准")
private String buyStandard;
/**
* 费率
*/
@Schema(description = "费率")
private BigDecimal rate;
/**
* 计费方式
*/
@Schema(description = "计费方式(0:按天,1:按月)")
private Integer billingType;
/**
* 医疗额度
*/
......
......@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author licancan
......@@ -134,6 +135,18 @@ public class InsuranceAddParam implements Serializable {
@JsonIgnore
private Long insuranceTypeId;
/**
* 费率
*/
@JsonIgnore
private BigDecimal rate;
/**
* 计费方式
*/
@JsonIgnore
private Integer billingType;
/**
* 商险购买地省code
*/
......
......@@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
......@@ -130,6 +131,18 @@ public class InsuranceBatchParam implements Serializable {
@JsonIgnore
private Long insuranceTypeId;
/**
* 费率
*/
@JsonIgnore
private BigDecimal rate;
/**
* 计费方式
*/
@JsonIgnore
private Integer billingType;
/**
* 商险购买地省code
*/
......
......@@ -421,6 +421,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (!Optional.ofNullable(insuranceCompany).isPresent()){
return R.failed(InsurancesConstants.INSURANCE_COMPANY_NAME_NOT_EXIST);
}else {
//冗余保险公司计费方式
byId.setBillingType(Integer.valueOf(insuranceCompany.getBillingType()));
TInsuranceType insuranceType = tInsuranceTypeService.getOne(Wrappers.<TInsuranceType>query().lambda()
.eq(TInsuranceType::getName, param.getInsuranceTypeName())
.eq(TInsuranceType::getInsuranceCompanyId, insuranceCompany.getId())
......@@ -429,6 +432,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (!Optional.ofNullable(insuranceType).isPresent()){
return R.failed(InsurancesConstants.INSURANCE_TYPE_NAME_NOT_EXIST);
}else {
//购买标准
TInsuranceTypeStandard typeStandard = tInsuranceTypeStandardService.getOne(Wrappers.<TInsuranceTypeStandard>query().lambda()
.eq(TInsuranceTypeStandard::getBuyStandard, param.getBuyStandard())
.eq(TInsuranceTypeStandard::getInsuranceTypeId, insuranceType.getId())
......@@ -443,6 +447,24 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
param.setDieDisableQuota(typeStandard.getDieDisableQuota());
param.setInsuranceTypeId(Long.parseLong(typeStandard.getInsuranceTypeId()));
}
//按月查费率
if (CommonConstants.ONE_STRING.equals(insuranceCompany.getBillingType())){
//计算起止时间的月数
long month = LocalDateUtil.betweenMonth(param.getPolicyStart(), param.getPolicyEnd());
TInsuranceTypeRate typeRate = tInsuranceTypeRateService.getOne(Wrappers.<TInsuranceTypeRate>query().lambda()
.eq(TInsuranceTypeRate::getInsuranceTypeId, insuranceType.getId())
.eq(TInsuranceTypeRate::getMonth, month)
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(typeRate).isPresent()){
return R.failed(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
}else {
//冗余费率
byId.setRate(new BigDecimal(typeRate.getRate()));
}
}
}
}
//记录查重校验:姓名 + 身份证号 + 保险公司 + 险种 + 保单开始日期~保单结束日期区间 是唯一(剔除退回、过期状态的记录)
......@@ -718,102 +740,69 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//根据结算类型判断是否需要计算预估保费
//预估
if (detail.getSettleType() == CommonConstants.ZERO_INT){
//根据险种获取费率,没费率返回错误
TInsuranceType insuranceType = tInsuranceTypeService.getById(detail.getInsuranceTypeId());
//险种存不存在
if (!Optional.ofNullable(insuranceType).isPresent()){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_NAME_NOT_EXIST);
errorList.add(listVO);
if (CommonConstants.ONE_INT == detail.getBillingType()){
// 按月查费率
// 预估保费 = 费率 * 购买标准
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).multiply(detail.getRate()).setScale(2,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
}
//记录状态均置为「已投保」
detail.setBuyHandleStatus(CommonConstants.THREE_INT);
detail.setSignFlag(CommonConstants.ONE_INT);
//记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setEstimatePremium(estimatePremium);
//调完ekp接口才会是1
settle.setIsEstimatePush(CommonConstants.ONE_INT);
settle.setEstimatePushTime(LocalDateTime.now());
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
}else {
TInsuranceCompany insuranceCompany = tInsuranceCompanyService.getById(insuranceType.getInsuranceCompanyId());
//保险公司存不存在
if (!Optional.ofNullable(insuranceCompany).isPresent()){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.INSURANCE_COMPANY_NAME_NOT_EXIST);
errorList.add(listVO);
}else {
if (CommonConstants.ONE_STRING.equals(insuranceCompany.getBillingType())){
//按月查费率
//计算起止时间的月数
long month = LocalDateUtil.betweenMonth(detail.getPolicyStart().toString(), detail.getPolicyEnd().toString());
TInsuranceTypeRate typeRate = tInsuranceTypeRateService.getOne(Wrappers.<TInsuranceTypeRate>query().lambda()
.eq(TInsuranceTypeRate::getInsuranceTypeId, detail.getInsuranceTypeId())
.eq(TInsuranceTypeRate::getMonth, month)
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(typeRate).isPresent()){
InsuranceListVO listVO = new InsuranceListVO();
BeanCopyUtils.copyProperties(detail,listVO);
listVO.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
errorList.add(listVO);
}else {
// 预估保费 = 费率 * 购买标准
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).multiply(new BigDecimal(typeRate.getRate())).setScale(2,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
}
//记录状态均置为「已投保」
detail.setBuyHandleStatus(CommonConstants.THREE_INT);
detail.setSignFlag(CommonConstants.ONE_INT);
//记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setEstimatePremium(estimatePremium);
//调完ekp接口才会是1
settle.setIsEstimatePush(CommonConstants.ONE_INT);
settle.setEstimatePushTime(LocalDateTime.now());
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
}
}else {
//按天
//计算起止时间的天数
long day = LocalDateUtil.betweenDay(detail.getPolicyStart().toString(), detail.getPolicyEnd().toString());
//预估保费 = (购买标准 / 365) * 天数
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).divide(new BigDecimal("365"),CommonConstants.TWO_INT,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(day)).setScale(CommonConstants.TWO_INT,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
}
//记录状态均置为「已投保」
detail.setBuyHandleStatus(CommonConstants.THREE_INT);
detail.setSignFlag(CommonConstants.ONE_INT);
//记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setEstimatePremium(estimatePremium);
//调完ekp接口才会是1
settle.setIsEstimatePush(CommonConstants.ONE_INT);
settle.setEstimatePushTime(LocalDateTime.now());
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
}
//按天
//计算起止时间的天数
long day = LocalDateUtil.betweenDay(detail.getPolicyStart().toString(), detail.getPolicyEnd().toString());
//预估保费 = (购买标准 / 365) * 天数
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).divide(new BigDecimal("365"),CommonConstants.TWO_INT,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(day)).setScale(CommonConstants.TWO_INT,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
}
//记录状态均置为「已投保」
detail.setBuyHandleStatus(CommonConstants.THREE_INT);
detail.setSignFlag(CommonConstants.ONE_INT);
//记录的有效状态,置为「有效」
detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(CommonConstants.ZERO_INT);
//保费存储
TInsuranceSettle settle = new TInsuranceSettle();
settle.setInsDetailId(detail.getId());
settle.setSettleType(detail.getSettleType());
settle.setSettleHandleStatus(CommonConstants.ONE_STRING);
settle.setEstimatePremium(estimatePremium);
//调完ekp接口才会是1
settle.setIsEstimatePush(CommonConstants.ONE_INT);
settle.setEstimatePushTime(LocalDateTime.now());
settle.setCreateTime(LocalDateTime.now());
tInsuranceSettleService.save(settle);
detail.setDefaultSettleId(settle.getId());
successList.add(detail);
}
}
//实缴
......@@ -1151,6 +1140,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}else {
//冗余保险公司计费方式
param.setBillingType(Integer.valueOf(insuranceCompany.getBillingType()));
TInsuranceType insuranceType = tInsuranceTypeService.getOne(Wrappers.<TInsuranceType>query().lambda()
.eq(TInsuranceType::getName, param.getInsuranceTypeName())
.eq(TInsuranceType::getInsuranceCompanyId, insuranceCompany.getId())
......@@ -1161,6 +1153,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}else {
//购买标准
TInsuranceTypeStandard typeStandard = tInsuranceTypeStandardService.getOne(Wrappers.<TInsuranceTypeStandard>query().lambda()
.eq(TInsuranceTypeStandard::getBuyStandard, param.getBuyStandard())
.eq(TInsuranceTypeStandard::getInsuranceTypeId, insuranceType.getId())
......@@ -1177,6 +1170,26 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
param.setDieDisableQuota(typeStandard.getDieDisableQuota());
param.setInsuranceTypeId(Long.parseLong(typeStandard.getInsuranceTypeId()));
}
//按月查费率
if (CommonConstants.ONE_STRING.equals(insuranceCompany.getBillingType())){
//计算起止时间的月数
long month = LocalDateUtil.betweenMonth(param.getPolicyStart(), param.getPolicyEnd());
TInsuranceTypeRate typeRate = tInsuranceTypeRateService.getOne(Wrappers.<TInsuranceTypeRate>query().lambda()
.eq(TInsuranceTypeRate::getInsuranceTypeId, insuranceType.getId())
.eq(TInsuranceTypeRate::getMonth, month)
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(typeRate).isPresent()){
param.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
listResult.add(param);
continue;
}else {
//冗余费率
param.setRate(new BigDecimal(typeRate.getRate()));
}
}
}
}
......@@ -1440,6 +1453,32 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
param.setInsuranceHandleCity(Integer.parseInt(redisHandleCityName));
}
//保单开始日期、结束日期,由系统根据保单号关联查询投保状态为 "已投保" 的商险记录的任意一条
TInsuranceDetail limitOne = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getPolicyNo, param.getPolicyNo())
.eq(TInsuranceDetail::getBuyHandleStatus, CommonConstants.THREE_INT)
//有效
.and(
wrapper -> wrapper.eq(TInsuranceDetail::getIsEffect,CommonConstants.ZERO_INT)
.or().isNull(TInsuranceDetail::getIsEffect)
)
//未过期
.and(
wrapper -> wrapper.eq(TInsuranceDetail::getIsOverdue,CommonConstants.ZERO_INT)
.or().isNull(TInsuranceDetail::getIsOverdue)
)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(limitOne).isPresent()){
param.setErrorMessage(InsurancesConstants.POLICY_NO_EXIST);
listResult.add(param);
continue;
}else {
param.setPolicyStart(limitOne.getPolicyStart());
param.setPolicyEnd(limitOne.getPolicyEnd());
}
// 保险公司-险种-购买标准 是否存在
TInsuranceCompany insuranceCompany = tInsuranceCompanyService.getOne(Wrappers.<TInsuranceCompany>query().lambda()
.eq(TInsuranceCompany::getCompanyName, param.getInsuranceCompanyName())
......@@ -1450,6 +1489,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}else {
//冗余保险公司计费方式
param.setBillingType(Integer.valueOf(insuranceCompany.getBillingType()));
TInsuranceType insuranceType = tInsuranceTypeService.getOne(Wrappers.<TInsuranceType>query().lambda()
.eq(TInsuranceType::getName, param.getInsuranceTypeName())
.eq(TInsuranceType::getInsuranceCompanyId, insuranceCompany.getId())
......@@ -1460,6 +1502,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}else {
//购买标准
TInsuranceTypeStandard typeStandard = tInsuranceTypeStandardService.getOne(Wrappers.<TInsuranceTypeStandard>query().lambda()
.eq(TInsuranceTypeStandard::getBuyStandard, param.getBuyStandard())
.eq(TInsuranceTypeStandard::getInsuranceTypeId, insuranceType.getId())
......@@ -1476,9 +1519,41 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
param.setDieDisableQuota(typeStandard.getDieDisableQuota());
param.setInsuranceTypeId(Long.parseLong(typeStandard.getInsuranceTypeId()));
}
//按月查费率
if (CommonConstants.ONE_STRING.equals(insuranceCompany.getBillingType())){
//计算起止时间的月数
long month = LocalDateUtil.betweenMonth(param.getPolicyStart().toString(), param.getPolicyEnd().toString());
TInsuranceTypeRate typeRate = tInsuranceTypeRateService.getOne(Wrappers.<TInsuranceTypeRate>query().lambda()
.eq(TInsuranceTypeRate::getInsuranceTypeId, insuranceType.getId())
.eq(TInsuranceTypeRate::getMonth, month)
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(typeRate).isPresent()){
param.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
listResult.add(param);
continue;
}else {
//冗余费率
param.setRate(new BigDecimal(typeRate.getRate()));
}
}
}
}
if(!limitOne.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
listResult.add(param);
continue;
}
if (!limitOne.getInsuranceTypeName().equals(param.getInsuranceTypeName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
listResult.add(param);
continue;
}
// 结算月份 >= 派单月份(结算月 < 派单月份的记录予以拦截,并提示)
if(!LocalDateUtil.isDate(param.getSettleMonth(),LocalDateUtil.NORM_MONTH_PATTERN)){
param.setErrorMessage(InsurancesConstants.SETTLE_MONTH_PARSE_ERROR);
......@@ -1520,41 +1595,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listResult.add(param);
continue;
}
//保单开始日期、结束日期,由系统根据保单号关联查询投保状态为 "已投保" 的商险记录的任意一条
TInsuranceDetail limitOne = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getPolicyNo, param.getPolicyNo())
.eq(TInsuranceDetail::getBuyHandleStatus, CommonConstants.THREE_INT)
//有效
.and(
wrapper -> wrapper.eq(TInsuranceDetail::getIsEffect,CommonConstants.ZERO_INT)
.or().isNull(TInsuranceDetail::getIsEffect)
)
//未过期
.and(
wrapper -> wrapper.eq(TInsuranceDetail::getIsOverdue,CommonConstants.ZERO_INT)
.or().isNull(TInsuranceDetail::getIsOverdue)
)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
if (!Optional.ofNullable(limitOne).isPresent()){
param.setErrorMessage(InsurancesConstants.POLICY_NO_EXIST);
listResult.add(param);
continue;
}else {
if(!limitOne.getInsuranceCompanyName().equals(param.getInsuranceCompanyName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_COMPANY_NAME_NOT_SAME);
listResult.add(param);
continue;
}else if (!limitOne.getInsuranceTypeName().equals(param.getInsuranceTypeName())){
param.setErrorMessage(InsurancesConstants.POLICY_NO_TYPE_NAME_NOT_SAME);
listResult.add(param);
continue;
}else {
param.setPolicyStart(limitOne.getPolicyStart());
param.setPolicyEnd(limitOne.getPolicyEnd());
}
}
listSuccess.add(param);
}
map.put("listResult",listResult);
......
......@@ -14,6 +14,8 @@
<result property="insuranceTypeName" column="INSURANCE_TYPE_NAME" jdbcType="VARCHAR"/>
<result property="insuranceTypeId" column="INSURANCE_TYPE_ID" jdbcType="BIGINT"/>
<result property="buyStandard" column="BUY_STANDARD" jdbcType="VARCHAR"/>
<result property="rate" column="RATE" jdbcType="DECIMAL"/>
<result property="billingType" column="BILLING_TYPE" jdbcType="TINYINT"/>
<result property="medicalQuota" column="MEDICAL_QUOTA" jdbcType="VARCHAR"/>
<result property="dieDisableQuota" column="DIE_DISABLE_QUOTA" jdbcType="VARCHAR"/>
<result property="policyNo" column="POLICY_NO" jdbcType="VARCHAR"/>
......@@ -54,7 +56,7 @@
<sql id="Base_Column_List">
ID,EMP_NAME,
EMP_IDCARD_NO,DEPT_NO,POST,INSURANCE_COMPANY_NAME,INSURANCE_TYPE_NAME,
INSURANCE_TYPE_ID,BUY_STANDARD,MEDICAL_QUOTA,DIE_DISABLE_QUOTA,POLICY_NO,
INSURANCE_TYPE_ID,BUY_STANDARD,RATE,BILLING_TYPE,MEDICAL_QUOTA,DIE_DISABLE_QUOTA,POLICY_NO,
POLICY_START,POLICY_END,POLICY_EFFECT,
BATCH_DATE,SETTLE_MONTH,INVOICE_NO,
BUY_TYPE,INSURANCE_PROVINCE,INSURANCE_PROVINCE_NAME,INSURANCE_CITY,INSURANCE_CITY_NAME,
......
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