From 5bce819f4a418f9ae352eb105e33707de1e0c1ce Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 31 一月 2024 14:07:44 +0800
Subject: [PATCH] 111

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |  112 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 97 insertions(+), 15 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
index 3370231..832c861 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -454,11 +454,12 @@
         if (!loginUserInfo.getType().equals(Constants.ONE)) {
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢ㄦ埛绫诲瀷閿欒锛氶潪浼佷笟鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
         }
+        BigDecimal fee = BigDecimal.ZERO;
+
         InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId());
         if (Objects.isNull(insuranceApply)) {
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        System.out.println(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey());
         if (!Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())) {
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "淇濆崟鐘舵�侀敊璇�");
         }
@@ -491,6 +492,90 @@
         applyChange.setStatus(Constants.ZERO);
         applyChangeMapper.insert(applyChange);
 
+        this.dealApplyChangeData(applyChange,insuranceApply,companySolution,solutions,loginUserInfo,fee);
+
+        ApplyChange applyChangeFee = new ApplyChange();
+        applyChangeFee.setId(applyChange.getId());
+        applyChangeFee.setFee(fee);
+        applyChangeMapper.updateById(applyChangeFee);
+
+        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
+        return applyChange.getId();
+    }
+
+
+
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+    public Integer update(ApplyChange applyChange) {
+        if (Objects.isNull(applyChange)
+                || Objects.isNull(applyChange.getId())
+                || Objects.isNull(applyChange.getApplyId())
+                || Objects.isNull(applyChange.getValidTime())
+                || Objects.isNull(applyChange.getType())
+                || !(applyChange.getType().equals(Constants.ZERO) || applyChange.getType().equals(Constants.ONE))
+        ) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if (!loginUserInfo.getType().equals(Constants.ONE)) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢ㄦ埛绫诲瀷閿欒锛氶潪浼佷笟鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
+        }
+        ApplyChange dbApplyChange = applyChangeMapper.selectById(applyChange.getId());
+        if(Objects.isNull(dbApplyChange)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if(!dbApplyChange.getStatus().equals(Constants.ApplyChangeStatus.PLATFORM_AGREE.getKey())){
+            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "涓氬姟淇濈敵璇峰崟鐘舵�侀敊璇�");
+        }
+
+        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyChange.getApplyId());
+        if (Objects.isNull(insuranceApply)) {
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if (!Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())) {
+            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "淇濆崟鐘舵�侀敊璇�");
+        }
+        if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO
+        ) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "淇濆崟宸茶繃淇濓紝鏃犳硶杩涜璇ユ搷浣�");
+        }
+        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
+        if(Objects.isNull(solutions)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
+        }
+        CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
+                .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
+                .eq(CompanySolution::getSolutionBaseId,solutions.getId())
+                .eq(CompanySolution::getIsdeleted,Constants.ZERO)
+                .last(" limit 1 ")
+        );
+        if(Objects.isNull(companySolution)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌浼佷笟鍒嗛厤淇濋櫓鏂规淇℃伅");
+        }
+        //鐢宠鏃堕棿蹇呴』澶勪簬淇濆崟鐨勬椂闂磋寖鍥村唴
+        if (!(DateUtil.compareDate( insuranceApply.getStartTime(),applyChange.getValidTime()) >= Constants.ZERO
+                && DateUtil.compareDate( applyChange.getValidTime(),insuranceApply.getEndTime()) >= Constants.ZERO)) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢宠鏃ユ湡鏈浜庝繚鍗曟棩鏈熷唴锛屾棤娉曡繘琛岃鎿嶄綔");
+        }
+
+
+        applyChange.setEditDate(new Date());
+        applyChange.setEditor(loginUserInfo.getId());
+        applyChange.setStatus(Constants.ZERO);
+        BigDecimal fee = BigDecimal.ZERO;
+        this.dealApplyChangeData(applyChange,insuranceApply,companySolution,solutions,loginUserInfo,fee);
+        applyChange.setFee(fee);
+        applyChangeMapper.updateById(applyChange);
+        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
+        return applyChange.getId();
+    }
+
+
+    public void dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){
+
+
         //鏌ヨ淇濋櫓鏂规涓嬬殑鎵�鏈夋淳閬e崟浣�
         List<DuSolution>  duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class,new MPJLambdaWrapper<DuSolution>()
                 .selectAll(DuSolution.class)
@@ -514,17 +599,16 @@
         if (!CollectionUtils.isNotEmpty(duWorktypeList)) {
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鏁版嵁寮傚父锛氫繚闄╂柟妗堜笅鏈煡璇㈠埌宸ョ淇℃伅");
         }
-        BigDecimal fee = BigDecimal.ZERO;
+
         //鍔犱繚鏁版嵁
         List<ApplyChagneDetail> addDetailList = applyChange.getAddDetailList();
         if (CollectionUtils.isNotEmpty(addDetailList)) {
-           if(companySolution.getCanAdd().equals(Constants.ZERO)){
-               throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
-           }
+            if(companySolution.getCanAdd().equals(Constants.ZERO)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
+            }
             this.addChangeDetail(applyChange,addDetailList,duWorktypeList,duSolutionList,insuranceApply,solutions,loginUserInfo);
 
             fee = addDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add);
-
         }
 
         //鍑忎繚鏁版嵁
@@ -533,23 +617,19 @@
             if(companySolution.getCanReduce().equals(Constants.ZERO)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽噺淇�");
             }
-             this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
+            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo);
             fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
         }
-        ApplyChange applyChangeFee = new ApplyChange();
-        applyChangeFee.setId(applyChange.getId());
-        applyChangeFee.setFee(fee);
-        applyChangeMapper.updateById(applyChangeFee);
 
         //鎹㈠巶涓氬姟
         List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList();
         if (CollectionUtils.isNotEmpty(changeDetailList)) {
             this.changeDetail(applyChange,changeDetailList,duWorktypeList,duSolutionList,loginUserInfo);
         }
-
-        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
-        return applyChange.getId();
     }
+
+
+
 
 
     public void saveApplyLog(ApplyChange applyChange,Constants.ApplyChangeLogStatus applyChangeLogStatus,String content){
@@ -894,6 +974,7 @@
         queryWrapper
                 .selectAll(ApplyChange.class)
                 .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
+                .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0  )",ApplyChange::getAddNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1  )",ApplyChange::getDelNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 2  )",ApplyChange::getChangeNum)
@@ -906,7 +987,8 @@
                         Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey(),
                         Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey())
                 .eq(!Objects.isNull(model.getCompanyId()),InsuranceApply::getCompanyId,model.getCompanyId())
-                .eq(!Objects.isNull(model.getSolutionsId()),ApplyChange::getSolutionsId,model.getSolutionsId())
+//                .eq(!Objects.isNull(model.getSolutionsId()),ApplyChange::getSolutionsId,model.getSolutionsId())
+                .eq(!Objects.isNull(model.getBaseSolutionsId()),Solutions::getBaseId,model.getBaseSolutionsId())
                 .ge(StringUtils.isNotBlank(model.getCreateDateS()),ApplyChange::getCreateDate, model.getCreateDateS()+" 00:00:00" )
                 .le(StringUtils.isNotBlank(model.getCreateDateE()),ApplyChange::getCreateDate, model.getCreateDateE()+" 23:59:59" );
 

--
Gitblit v1.9.3