Commit be982fc5 authored by 李灿灿's avatar 李灿灿

Merge branch 'feature-licancan' into 'develop'

Feature licancan

See merge request fangxinjiang/yifu!97
parents c282dc98 3e72c3a9
...@@ -248,6 +248,7 @@ public class TInsuranceDetail extends BaseEntity { ...@@ -248,6 +248,7 @@ public class TInsuranceDetail extends BaseEntity {
* 是否有效 0有效 1无效 * 是否有效 0有效 1无效
*/ */
@Schema(description = "是否有效 0有效 1无效") @Schema(description = "是否有效 0有效 1无效")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Integer isEffect; private Integer isEffect;
/** /**
......
...@@ -408,6 +408,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -408,6 +408,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.failed(InsurancesConstants.DATA_IS_NOT_EXIST); return R.failed(InsurancesConstants.DATA_IS_NOT_EXIST);
} }
if (byId.getBuyHandleStatus() == CommonConstants.FOUR_INT && byId.getBuyType() != CommonConstants.FOUR_INT){ if (byId.getBuyHandleStatus() == CommonConstants.FOUR_INT && byId.getBuyType() != CommonConstants.FOUR_INT){
//新增、批增的编辑逻辑
// 身份证号位数校验(18 位合法) // 身份证号位数校验(18 位合法)
if (!ValidityUtil.validateIDCard(param.getEmpIdcardNo())){ if (!ValidityUtil.validateIDCard(param.getEmpIdcardNo())){
return R.failed(InsurancesConstants.EMP_IDCARD_NO_NOT_LEGITIMATE); return R.failed(InsurancesConstants.EMP_IDCARD_NO_NOT_LEGITIMATE);
...@@ -559,7 +561,55 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -559,7 +561,55 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
byId.setUpdateBy(user.getId()); byId.setUpdateBy(user.getId());
byId.setUpdateTime(LocalDateTime.now()); byId.setUpdateTime(LocalDateTime.now());
this.updateById(byId); this.updateById(byId);
}else { }else if(byId.getBuyHandleStatus() == CommonConstants.FOUR_INT && byId.getBuyType() == CommonConstants.FOUR_INT){
//替换的编辑逻辑
// 身份证号位数校验(18 位合法)
if (!ValidityUtil.validateIDCard(param.getEmpIdcardNo())){
return R.failed(InsurancesConstants.EMP_IDCARD_NO_NOT_LEGITIMATE);
}
//校验身份合法
/*TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(param.getEmpName());
checkIdCard.setIdCard(param.getEmpIdcardNo());
R<TCheckIdCard> tCheckIdCardR = checkDaprUtil.checkIdCardSingle(checkIdCard);
if (null != tCheckIdCardR && tCheckIdCardR.getCode() == CommonConstants.SUCCESS){
TCheckIdCard data = tCheckIdCardR.getData();
if (CommonConstants.ONE_INT != data.getIsTrue()){
return R.failed(InsurancesConstants.EMP_ID_CARD_NO_NOT_FIT);
}
}*/
TInsuranceReplace one = tInsuranceReplaceService.getOne(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getToInsuranceDetailId, byId.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Optional.ofNullable(one).isPresent()){
TInsuranceDetail insuranceDetail = this.getById(one.getFromInsuranceDetailId());
if (Optional.ofNullable(insuranceDetail).isPresent()){
if (insuranceDetail.getIsUse() == CommonConstants.ONE_INT){
return R.failed("员工"+insuranceDetail.getEmpName()+"的投保记录已出险,无法替换");
}
if (insuranceDetail.getIsEffect() == CommonConstants.ONE_INT){
return R.failed("员工"+insuranceDetail.getEmpName()+"的投保记录无效,无法替换");
}
//被替换者无效
insuranceDetail.setIsEffect(CommonConstants.ONE_INT);
this.updateById(insuranceDetail);
//替换记录成功
one.setReplaceStatus(CommonConstants.ONE_INT);
tInsuranceReplaceService.updateById(one);
//替换状态下目前只能编辑姓名、身份证号
//投保状态:待投保
byId.setBuyHandleStatus(CommonConstants.ONE_INT);
byId.setEmpName(param.getEmpName());
byId.setEmpIdcardNo(param.getEmpIdcardNo());
byId.setUpdateBy(user.getId());
byId.setUpdateTime(LocalDateTime.now());
this.updateById(byId);
}
}
} else {
return R.failed(InsurancesConstants.EDIT_NOT_ALLOW); return R.failed(InsurancesConstants.EDIT_NOT_ALLOW);
} }
//操作记录 //操作记录
...@@ -685,6 +735,27 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -685,6 +735,27 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listVO.setErrorMessage(InsurancesConstants.REDUCE_ROLLBACK_REDUCE_IS_NOT_ALLOW); listVO.setErrorMessage(InsurancesConstants.REDUCE_ROLLBACK_REDUCE_IS_NOT_ALLOW);
errorList.add(listVO); errorList.add(listVO);
}else{ }else{
//判断是否是替换类型的退回,如果是,需要将被替换者激活,替换者有效状态为空
if(detail.getBuyType() == CommonConstants.FOUR_INT){
//替换者有效状态为空
detail.setIsEffect(null);
TInsuranceReplace one = tInsuranceReplaceService.getOne(Wrappers.<TInsuranceReplace>query().lambda()
.eq(TInsuranceReplace::getToInsuranceDetailId, detail.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Optional.ofNullable(one).isPresent()){
//替换记录变为失败
one.setReplaceStatus(CommonConstants.ZERO_INT);
tInsuranceReplaceService.updateById(one);
TInsuranceDetail byId = this.getById(one.getFromInsuranceDetailId());
if (Optional.ofNullable(byId).isPresent()){
//被替换者激活
byId.setIsEffect(CommonConstants.ZERO_INT);
this.updateById(byId);
}
}
}
// 记录状态置为「退回」 // 记录状态置为「退回」
detail.setBuyHandleStatus(CommonConstants.FOUR_INT); detail.setBuyHandleStatus(CommonConstants.FOUR_INT);
detail.setUpdateBy(user.getId()); detail.setUpdateBy(user.getId());
...@@ -763,47 +834,87 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -763,47 +834,87 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listVO.setErrorMessage(InsurancesConstants.INSURANCE_BUY_STATUS_NOT_TWO); listVO.setErrorMessage(InsurancesConstants.INSURANCE_BUY_STATUS_NOT_TWO);
errorList.add(listVO); errorList.add(listVO);
}else { }else {
//根据结算类型判断是否需要计算预估保费 //替换类型不参与结算
//预估 if(detail.getBuyType() == CommonConstants.FOUR_INT){
if (detail.getSettleType() == CommonConstants.ZERO_INT){ //记录状态均置为「已投保」
if (CommonConstants.ONE_INT == detail.getBillingType()){ detail.setBuyHandleStatus(CommonConstants.THREE_INT);
// 按月查费率 detail.setSignFlag(CommonConstants.ONE_INT);
// 预估保费 = 费率 * 购买标准 //记录的有效状态,置为「有效」
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).multiply(detail.getRate()).setScale(2,BigDecimal.ROUND_HALF_UP); detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setEstimatePremium(estimatePremium); detail.setIsOverdue(CommonConstants.ZERO_INT);
if (detail.getBuyType() == CommonConstants.THREE_INT){ detail.setIsUse(CommonConstants.ZERO_INT);
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT)); successList.add(detail);
}else{
//根据结算类型判断是否需要计算预估保费
//预估
if (detail.getSettleType() == CommonConstants.ZERO_INT){
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 {
//按天
//计算起止时间的天数
long day = LocalDateUtil.betweenDay(detail.getPolicyStart().toString(), detail.getPolicyEnd().toString());
//预估保费 = (购买标准 / 365) * 天数
BigDecimal estimatePremium = new BigDecimal(detail.getBuyStandard()).multiply(new BigDecimal(day)).divide(new BigDecimal("365"),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);
} }
//记录状态均置为「已投保」 }
detail.setBuyHandleStatus(CommonConstants.THREE_INT); //实缴
detail.setSignFlag(CommonConstants.ONE_INT); if(detail.getSettleType() == 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()).multiply(new BigDecimal(day)).divide(new BigDecimal("365"),CommonConstants.TWO_INT,BigDecimal.ROUND_HALF_UP);
detail.setEstimatePremium(estimatePremium);
if (detail.getBuyType() == CommonConstants.THREE_INT){ if (detail.getBuyType() == CommonConstants.THREE_INT){
detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT)); detail.setPolicyEffect(LocalDate.now().plusDays(CommonConstants.ONE_INT));
} }
...@@ -814,37 +925,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -814,37 +925,9 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setIsEffect(CommonConstants.ZERO_INT); detail.setIsEffect(CommonConstants.ZERO_INT);
detail.setIsOverdue(CommonConstants.ZERO_INT); detail.setIsOverdue(CommonConstants.ZERO_INT);
detail.setIsUse(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); successList.add(detail);
} }
} }
//实缴
if(detail.getSettleType() == CommonConstants.ONE_INT){
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);
successList.add(detail);
}
} }
} }
} }
......
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