Commit 70f7ffd1 authored by 李灿灿's avatar 李灿灿

商险编辑接口

parent 32a26c2d
...@@ -27,6 +27,10 @@ public class InsurancesConstants { ...@@ -27,6 +27,10 @@ public class InsurancesConstants {
* 非投保退回状态,无法删除 * 非投保退回状态,无法删除
*/ */
public static final String DELETE_ERROR = "非投保退回状态,无法删除"; public static final String DELETE_ERROR = "非投保退回状态,无法删除";
/**
* 不允许编辑
*/
public static final String EDIT_NOT_ALLOW = "不允许编辑";
/** /**
* 投保信息已存在 * 投保信息已存在
*/ */
......
package com.yifu.cloud.plus.v1.yifu.insurances.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* @author licancan
* @description 投保编辑入参
* @date 2022-07-21 11:33:30
*/
@Data
@Schema(description = "投保编辑入参")
public class InsuranceEditParam implements Serializable {
private static final long serialVersionUID = -7742645628926325904L;
/**
* 主键
*/
@Schema(description = "主键")
@NotBlank(message = "主键不能为空")
private String id;
/**
* 员工姓名
*/
@Schema(description = "员工姓名")
@Size(max = 20, message = "员工姓名不可超过20位")
@NotBlank(message = "员工姓名不能为空")
private String empName;
/**
* 员工身份证号
*/
@Schema(description = "员工身份证号")
@NotBlank(message = "员工身份证号不能为空")
private String empIdcardNo;
/**
* 保单开始时间
*/
@Schema(description = "保单开始时间")
@NotBlank(message = "保单开始时间不能为空")
private String policyStart;
/**
* 保单结束时间
*/
@Schema(description = "保单结束时间")
@NotBlank(message = "保单结束时间不能为空")
private String policyEnd;
/**
* 岗位
*/
@Schema(description = "岗位")
@NotBlank(message = "岗位不能为空")
private String post;
/**
* 险种名称
*/
@Schema(description = "险种名称")
@NotBlank(message = "险种名称不能为空")
private String insuranceTypeName;
/**
* 保险公司名称
*/
@Schema(description = "保险公司名称")
@NotBlank(message = "保险公司名称不能为空")
private String insuranceCompanyName;
/**
* 购买标准
*/
@Schema(description = "购买标准")
@NotBlank(message = "购买标准不能为空")
private String buyStandard;
/**
* 商险购买地省code
*/
@Schema(description = "商险购买地省code")
@NotNull(message = "商险购买地省ID不能为空")
private Integer insuranceProvince;
/**
* 商险购买地省
*/
@Schema(description = "商险购买地省")
@NotBlank(message = "商险购买地省不能为空")
private String insuranceProvinceName;
/**
* 商险购买地市code
*/
@Schema(description = "商险购买地市code")
@NotNull(message = "商险购买地市ID不能为空")
private Integer insuranceCity;
/**
* 商险购买地市
*/
@Schema(description = "商险购买地市")
@NotBlank(message = "商险购买地市不能为空")
private String insuranceCityName;
/**
* 商险办理省code
*/
@Schema(description = "商险办理省code")
@NotNull(message = "商险办理省ID不能为空")
private Integer insuranceHandleProvince;
/**
* 商险办理省
*/
@Schema(description = "商险办理省")
@NotBlank(message = "商险办理省不能为空")
private String insuranceHandleProvinceName;
/**
* 商险办理城市code
*/
@Schema(description = "商险办理城市code")
@NotNull(message = "商险办理城市ID不能为空")
private Integer insuranceHandleCity;
/**
* 商险办理城市
*/
@Schema(description = "商险办理城市")
@NotBlank(message = "商险办理城市不能为空")
private String insuranceHandleCityName;
/***********************************以下字段由系统算出,前端不用传,是为了方便入库***********************************/
/**
* 医疗额度
*/
private String medicalQuota;
/**
* 身故或残疾额度
*/
private String dieDisableQuota;
/**
* 险种主键
*/
private Long insuranceTypeId;
}
...@@ -111,11 +111,25 @@ public class TInsuranceDetailController { ...@@ -111,11 +111,25 @@ public class TInsuranceDetailController {
*/ */
@GetMapping("/deleteInsurance") @GetMapping("/deleteInsurance")
@Operation(summary = "通过id删除", description = "通过id删除") @Operation(summary = "通过id删除", description = "通过id删除")
//@PreAuthorize("@pms.hasPermission('temployeeinfo_del')") //@PreAuthorize("@pms.hasPermission('insurance_del')")
public R<String> deleteInsurance(@RequestParam String id) { public R<String> deleteInsurance(@RequestParam String id) {
return tInsuranceDetailService.deleteInsurance(id); return tInsuranceDetailService.deleteInsurance(id);
} }
/**
* 编辑
*
* @author licancan
* @param param
* @return {@link R<String>}
*/
@PostMapping("/editInsurance")
@Operation(summary = "编辑", description = "编辑")
//@PreAuthorize("@pms.hasPermission('insurance_edit')")
public R<String> editInsurance(@RequestBody @Valid InsuranceEditParam param) {
return tInsuranceDetailService.editInsurance(param);
}
/** /**
* 通过id查询 * 通过id查询
* *
......
...@@ -73,6 +73,15 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> { ...@@ -73,6 +73,15 @@ public interface TInsuranceDetailService extends IService<TInsuranceDetail> {
*/ */
R<String> deleteInsurance(String id); R<String> deleteInsurance(String id);
/**
* 编辑
*
* @author licancan
* @param param
* @return {@link R<String>}
*/
R<String> editInsurance(InsuranceEditParam param);
/** /**
* 通过id查询 * 通过id查询
* *
......
...@@ -186,7 +186,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -186,7 +186,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
BeanCopyUtils.copyProperties(success,detail); BeanCopyUtils.copyProperties(success,detail);
//购买类型,默认为「批增」 //购买类型,默认为「批增」
detail.setBuyType(CommonConstants.THREE_INT); detail.setBuyType(CommonConstants.THREE_INT);
//投保状态:待投保??? //投保状态:待投保
detail.setBuyHandleStatus(CommonConstants.ONE_INT); detail.setBuyHandleStatus(CommonConstants.ONE_INT);
detail.setCreateBy(user.getId()); detail.setCreateBy(user.getId());
detail.setCreateName(user.getNickname()); detail.setCreateName(user.getNickname());
...@@ -296,6 +296,102 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap ...@@ -296,6 +296,102 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
return R.ok(InsurancesConstants.OPERATE_SUCCESS); return R.ok(InsurancesConstants.OPERATE_SUCCESS);
} }
/**
* 编辑
*
* @param param
* @return {@link R<String>}
* @author licancan
*/
@Override
public R<String> editInsurance(InsuranceEditParam param) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
TInsuranceDetail byId = this.getById(param.getId());
if (null == byId){
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);
}
// 保单开始日期 > 当前派单日期
if(!LocalDateUtil.isDate(param.getPolicyStart(),LocalDateUtil.NORM_DATE_PATTERN)){
return R.failed(InsurancesConstants.POLICY_START_PARSE_ERROR);
}
if(!LocalDateUtil.isDate(param.getPolicyEnd(),LocalDateUtil.NORM_DATE_PATTERN)){
return R.failed(InsurancesConstants.POLICY_END_PARSE_ERROR);
}
if(!LocalDateUtil.isFutureDate(param.getPolicyStart())){
return R.failed(InsurancesConstants.POLICY_START_SHOULD_IS_FUTURE);
}
// 保险公司-险种-购买标准 是否存在
TInsuranceCompany insuranceCompany = tInsuranceCompanyService.getOne(Wrappers.<TInsuranceCompany>query().lambda()
.eq(TInsuranceCompany::getCompanyName, param.getInsuranceCompanyName())
.eq(TInsuranceCompany::getDeleteFlag, CommonConstants.ZERO_INT)
);
if (!Optional.ofNullable(insuranceCompany).isPresent()){
return R.failed(InsurancesConstants.INSURANCE_COMPANY_NAME_NOT_EXIST);
}else {
TInsuranceType insuranceType = tInsuranceTypeService.getOne(Wrappers.<TInsuranceType>query().lambda()
.eq(TInsuranceType::getName, param.getInsuranceTypeName())
.eq(TInsuranceType::getInsuranceCompanyId, insuranceCompany.getId())
.eq(TInsuranceType::getDeleteFlag, CommonConstants.ZERO_INT)
);
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())
.eq(TInsuranceTypeStandard::getDeleteFlag, CommonConstants.ZERO_INT)
);
if (!Optional.ofNullable(typeStandard).isPresent()){
return R.failed(InsurancesConstants.BUY_STANDARD_NOT_EXIST);
}else {
// "医疗额度" 和 "身故或残疾",由系统根据 保险公司+险种+ 购买标准 关联查询,并补全
// 这里计算好赋值,是为了方便入库
param.setMedicalQuota(typeStandard.getMedicalQuota());
param.setDieDisableQuota(typeStandard.getDieDisableQuota());
param.setInsuranceTypeId(typeStandard.getInsuranceTypeId());
}
}
}
//记录查重校验:姓名 + 身份证号 + 保险公司 + 险种 + 保单开始日期~保单结束日期区间 是唯一(剔除退回、过期状态的记录)
//todo 时间区间
Set<Integer> setRStatus = Sets.newHashSet();
setRStatus.add(CommonConstants.FOUR_INT);
TInsuranceDetail insuranceDetail = this.baseMapper.selectOne(Wrappers.<TInsuranceDetail>query().lambda()
.eq(TInsuranceDetail::getEmpName, param.getEmpName())
.eq(TInsuranceDetail::getEmpIdcardNo, param.getEmpIdcardNo())
.eq(TInsuranceDetail::getInsuranceCompanyName, param.getInsuranceCompanyName())
.eq(TInsuranceDetail::getInsuranceTypeName, param.getInsuranceTypeName())
.eq(TInsuranceDetail::getPolicyStart, param.getPolicyStart())
.eq(TInsuranceDetail::getPolicyEnd, param.getPolicyEnd())
.notIn(TInsuranceDetail::getBuyHandleStatus, setRStatus)
.eq(TInsuranceDetail::getIsOverdue, CommonConstants.ZERO_INT)
.eq(TInsuranceDetail::getDeleteFlag, CommonConstants.ZERO_INT)
);
if (Optional.ofNullable(insuranceDetail).isPresent()){
return R.failed(InsurancesConstants.DATA_IS_EXIST);
}
BeanCopyUtils.copyProperties(param,byId);
//投保状态:待投保
byId.setBuyHandleStatus(CommonConstants.ONE_INT);
byId.setPolicyStart(LocalDateUtil.parseLocalDate(param.getPolicyStart()));
byId.setPolicyEnd(LocalDateUtil.parseLocalDate(param.getPolicyEnd()));
byId.setUpdateBy(user.getId());
byId.setUpdateTime(LocalDateTime.now());
this.updateById(byId);
}else {
return R.failed(InsurancesConstants.EDIT_NOT_ALLOW);
}
return R.ok(InsurancesConstants.OPERATE_SUCCESS);
}
/** /**
* 通过id查询 * 通过id查询
* *
......
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