Commit e3578e94 by jianan

新单跟进保单重复提示

parent e6c3561e
...@@ -54,6 +54,7 @@ import org.slf4j.Logger; ...@@ -54,6 +54,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -63,6 +64,7 @@ import javax.servlet.ServletOutputStream; ...@@ -63,6 +64,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.SQLIntegrityConstraintViolationException;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -577,7 +579,21 @@ public class ApiPolicyFollowController { ...@@ -577,7 +579,21 @@ public class ApiPolicyFollowController {
} }
// 修改逻辑 // 修改逻辑
try {
policyFollowService.changePolicyFollowStatus(changePolicyFollowStatusRequest, policyFollow); 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("修改跟进状态失败");
}
// 修改为生效时需要同步预计发佣 // 修改为生效时需要同步预计发佣
if (PolicyFollowStatusEnum.EFFECTIVE.equals(currentStatusEnum)) { if (PolicyFollowStatusEnum.EFFECTIVE.equals(currentStatusEnum)) {
......
...@@ -205,20 +205,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -205,20 +205,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
totalFortune(fortune, expectedFortune, loginUserId, fortuneUpdateRequest); totalFortune(fortune, expectedFortune, loginUserId, fortuneUpdateRequest);
} }
// 同步 expected_fortune // 更新 expected_fortune 出账状态
// 统一使用港币金额
BigDecimal newPaid = calculateExpectedFortunePaidAmount(expectedFortune);
BigDecimal newUnpaid = expectedFortune.getHkdAmount().subtract(newPaid);
String newStatus = newUnpaid.compareTo(BigDecimal.ZERO) == 0 ? "6" : "3";
expectedFortuneService.lambdaUpdate() expectedFortuneService.lambdaUpdate()
.set(ExpectedFortune::getPaidAmount, newPaid) .set(ExpectedFortune::getStatus, fortuneUpdateRequest.getStatus())
.set(ExpectedFortune::getUnpaidAmount, newUnpaid)
.set(ExpectedFortune::getPaidRatio,
newPaid.divide(expectedFortune.getHkdAmount(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)))
.set(ExpectedFortune::getUnpaidRatio,
newUnpaid.divide(expectedFortune.getHkdAmount(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)))
.set(ExpectedFortune::getStatus, newStatus)
.eq(ExpectedFortune::getId, expectedFortune.getId()) .eq(ExpectedFortune::getId, expectedFortune.getId())
.update(); .update();
......
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