Commit d9a5b15c by jianan

新单跟进修改保单号重复提示

parent c7f5d6e0
......@@ -579,21 +579,7 @@ public class ApiPolicyFollowController {
}
// 修改逻辑
try {
policyFollowService.changePolicyFollowStatus(changePolicyFollowStatusRequest, policyFollow);
} catch (DataIntegrityViolationException e) {
log.info("修改跟进状态失败:{}", e.getMessage());
// 判断是否为唯一索引冲突
String message = e.getMessage();
if (StringUtils.isNotBlank(message) && message.contains("idx_policy_no")) {
return Result.fail("保单号已存在,请勿重复添加");
} else {
return Result.fail("修改跟进状态失败");
}
} catch (Exception e) {
log.info("修改跟进状态失败:{}", e.getMessage());
return Result.fail("修改跟进状态失败");
}
policyFollowService.changePolicyFollowStatus(changePolicyFollowStatusRequest, policyFollow);
// 修改为生效时需要同步预计发佣
if (PolicyFollowStatusEnum.EFFECTIVE.equals(currentStatusEnum)) {
......
......@@ -40,6 +40,7 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -194,12 +195,12 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
public Boolean updatePolicyFollowDto(PolicyFollowDto policyFollowDto) {
// 校验参数
if (StringUtils.isBlank(policyFollowDto.getPolicyBizId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), "policyBizId不能为空");
throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "policyBizId不能为空");
}
String policyBizId = policyFollowDto.getPolicyBizId();
PolicyFollow policyFollow = getByPolicyBizId(policyBizId);
if (policyFollow == null) {
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR.getCode(), "新单跟进记录不存在");
throw new BusinessException(ResultCode.NULL_ERROR.getCode(), "新单跟进记录不存在");
}
// 复制属性,排除系统字段
......@@ -224,17 +225,31 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
policyFollow.setUpdaterId(loginUserId);
policyFollow.setUpdateTime(new Date());
boolean result = updateById(policyFollow);
try {
boolean result = updateById(policyFollow);
} catch (DataIntegrityViolationException e) {
log.info("修改跟进信息失败:{}", e.getMessage());
// 判断是否为唯一索引冲突
String message = e.getMessage();
if (StringUtils.isNotBlank(message) && message.contains("idx_policy_no")) {
throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "保单号已存在,请勿重复添加");
} else {
throw new BusinessException(ResultCode.FAIL.getCode(), "修改跟进信息失败");
}
} catch (Exception e) {
log.info("修改跟进信息失败:{}", e.getMessage());
throw new BusinessException(ResultCode.FAIL.getCode(), "修改跟进信息失败");
}
// 如果保单号从空变为有值,更新关联的FNA状态为"签单完成"
if (isPolicyNoUpdated && result) {
if (isPolicyNoUpdated) {
fnaService.lambdaUpdate()
.eq(Fna::getFnaBizId, policyFollow.getFnaBizId())
.set(Fna::getStatus, FnaStatusEnum.SIGNED_COMPLETED.getItemValue())
.update();
}
return result;
return true;
}
private void setPolicyMailing(PolicyFollow policyFollow, PolicyMailing policyMailing) {
......
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