Commit 7463f806 authored by 李灿灿's avatar 李灿灿

【商险-投保-替换】替换逻辑变更

parent 45129435
......@@ -248,6 +248,7 @@ public class TInsuranceDetail extends BaseEntity {
* 是否有效 0有效 1无效
*/
@Schema(description = "是否有效 0有效 1无效")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Integer isEffect;
/**
......
......@@ -403,6 +403,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.failed(InsurancesConstants.DATA_IS_NOT_EXIST);
}
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);
......@@ -554,7 +556,55 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
byId.setUpdateBy(user.getId());
byId.setUpdateTime(LocalDateTime.now());
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);
}
//操作记录
......@@ -680,6 +730,27 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
listVO.setErrorMessage(InsurancesConstants.REDUCE_ROLLBACK_REDUCE_IS_NOT_ALLOW);
errorList.add(listVO);
}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.setUpdateBy(user.getId());
......
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