From 22271e641e4505ba906c3770905b7e84e3ad8d85 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 02 四月 2024 17:05:57 +0800
Subject: [PATCH] mrshi

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |  154 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 125 insertions(+), 29 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 427eb00..2c1cacf 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
@@ -122,8 +122,24 @@
         if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
             throw  new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        if(Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())
-                ||Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.APPROVE.getKey())){
+
+        InsuranceApply insuranceApply = insuranceApplyMapper.selectById(model.getApplyId());
+        if(Objects.isNull(insuranceApply)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if(insuranceApply.getIsdeleted().equals(Constants.ONE)){
+            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"鏁版嵁宸插垹闄�,鏃犳硶杩涜璇ユ搷浣�");
+        }
+        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
+        if(Objects.isNull(solutions)){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏈煡璇㈠埌鏂规淇℃伅");
+        }
+
+        if(
+//                Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())
+//                ||Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.SIGNATURE.getKey())
+//                ||
+                Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.APPROVE.getKey())){
             //宸叉彁浜ゅ拰宸插畬鎴愮姸鎬佷笉鏀寔瀹℃牳涓嶉�氳繃
             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ョ敵璇风姸鎬佸凡娴佽浆锛屽綋鍓嶄笉鏀寔璇ユ搷浣渵");
         }
@@ -137,6 +153,17 @@
         update.setCheckUserId(user.getId());
         update.setId(model.getId());
         applyChangeMapper.updateById(update);
+
+        //瀛樺偍寰呭姙淇℃伅
+        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.APPLY_CHANGE;
+        if(model.getType().equals(Constants.ONE)){
+            noticeObjectType = Constants.NoticeObjectType.CHANGE_FACTORY;
+        }
+        //鍒犻櫎鍏朵粬寰呭姙
+        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId()));
+        Notices notices = new Notices(noticeObjectType,Constants.ONE,model.getId(),solutions.getName(),
+                insuranceApply.getCompanyId(), Constants.NoticeType.FOUR);
+        noticesMapper.insert(notices);
 
         Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_CHECK_PASS_NO;
         String info =applyLogType.getInfo();
@@ -193,16 +220,15 @@
         param.getPidanFile().setObjType(Constants.MultiFile.CA_PD_PDF.getKey());
         param.getPidanFile().setType(Constants.TWO);
         multifileMapper.insert(param.getPidanFile());
-
         update.setApplyId(model.getApplyId());
 
 
         if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
             //濡傛灉鏄姞鍑忎繚鐢宠 澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
-            dealDetailsValidTime(update);
+            dealDetailsValidTime(update,insuranceApply);
         }else{
             //濡傛灉鏄崲鍘傜敵璇� 澶勭悊鏄庣粏鏁版嵁
-            dealDetailsDUdata(update);
+            dealDetailsDUdata(update,insuranceApply);
         }
 
         applyChangeMapper.updateById(update);
@@ -255,6 +281,15 @@
         update.setId(model.getId());
         update.setValidCode(param.getValidCode());
         applyChangeMapper.updateById(update);
+
+        //淇敼鍛樺伐淇濆崟璁板綍
+        memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>()
+                .lambda()
+                .set(MemberInsurance::getPdCode,param.getValidCode())
+                .eq(MemberInsurance::getRelationType,Constants.ONE)
+                .eq(MemberInsurance::getApplyChangeId,model.getId())
+        );
+
         //鍒犻櫎鍘熸湁鐨勪繚鍗曚俊鎭�
         multifileMapper.delete(new UpdateWrapper<Multifile>().lambda()
                 .set(Multifile::getIsdeleted,Constants.ZERO)
@@ -284,12 +319,13 @@
      * 澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
      * @param update
      */
-    private void dealDetailsDUdata(ApplyChange update ) {
+    private void dealDetailsDUdata(ApplyChange update,InsuranceApply insuranceApply) {
         List<ApplyChagneDetail> detailList = applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,
                 new MPJLambdaWrapper<ApplyChagneDetail>()
                         .selectAll(ApplyChagneDetail.class)
                         .selectAs(Solutions::getTimeUnit,ApplyChagneDetail::getSolutionTimeUnit)
                         .selectAs(Solutions::getPrice,ApplyChagneDetail::getSolutionPrice)
+                        .selectAs(Solutions::getId,ApplyChagneDetail::getSolutionId)
                         .selectAs(Solutions::getName,ApplyChagneDetail::getSolutionsName)
                         .selectAs(Worktype::getName,ApplyChagneDetail::getWorkTypeName)
                         .selectAs(DispatchUnit::getName,ApplyChagneDetail::getDuName)
@@ -387,9 +423,16 @@
                 applyDetailJoinMapper.insert(applyDetail);
 
                 MemberInsurance memberInsurance = new MemberInsurance(applyDetail,update.getId());
+                memberInsurance.setSolutionId(detail.getSolutionId());
+                memberInsurance.setWorktypeName(detail.getWorkTypeName());
+                memberInsurance.setDuName(detail.getDuName());
+                memberInsurance.setApplyChangeId(detail.getApplyChangeId());
+                memberInsurance.setSolutionName(detail.getSolutionsName());
+                memberInsurance.setPdCode(update.getValidCode());
+                memberInsurance.setBdCode(insuranceApply.getCode());
+                memberInsurance.setRelationType(Constants.ONE);
                 memberInsuranceJoinMapper.insert(memberInsurance);
             }else{
-
                 applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                         .set(ApplyDetail::getEditor,update.getEditor())
                         .set(ApplyDetail::getEditDate,update.getEditDate())
@@ -397,7 +440,6 @@
                         .set(ApplyDetail::getWorktypeId,detail.getWorktypeId())
                         .eq(ApplyDetail::getId,oldModel.getId())
                 );
-
                 //鍛樺伐鎶曚繚鏄庣粏璁板綍 鍘嗗彶鏁版嵁
                 memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
                         .set(MemberInsurance::getDuId,detail.getDuId())
@@ -429,7 +471,7 @@
      * 澶勭悊鍔犲噺淇濇槑缁嗘暟鎹�
      * @param update
      */
-    private void dealDetailsValidTime(ApplyChange update) {
+    private void dealDetailsValidTime(ApplyChange update,InsuranceApply insuranceApply) {
         List<ApplyChagneDetail> detailList = applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,
                 new MPJLambdaWrapper<ApplyChagneDetail>()
                         .selectAll(ApplyChagneDetail.class)
@@ -466,6 +508,16 @@
         //鍔犱繚 娣诲姞鐨勯噾棰�
         CountCyclePriceVO countCyclePriceVO_add = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_add);
 
+        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
+        if(Objects.isNull(solutions)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
+        }
+        if(solutions.getDataType().equals(Constants.ONE)){
+            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
+            if(Objects.isNull(solutions)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鏂规鏈�鏂扮増鏈俊鎭�");
+            }
+        }
 
 
         for (ApplyChagneDetail detail : detailList) {
@@ -481,7 +533,7 @@
                         .eq(ApplyDetail::getApplyId,update.getApplyId())
                         .eq(ApplyDetail::getIdcardNo,detail.getIdcardNo())
                         .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(update.getApplyStartTime(),1))
-                        .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(),3))
+                        .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(detail.getEndTime(),2))
                 )>Constants.ZERO){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠淇濆崟涓嬶紝鍔犱繚浜哄憳銆�" + detail.getMemberName() + "銆戝瓨鍦ㄦ棩鏈熷啿绐佺殑鏁版嵁");
                 }
@@ -511,7 +563,7 @@
 
                 if(new Date().compareTo(DateUtil.getMontageDate(detail.getStartTime(), 2))>=0){
                     Integer days = DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2), detail.getStartTime()) + 1;
-                    //濡傛灉宸蹭骇鐢熻垂鐢紝璁$畻宸蹭骇鐢熻垂鐢�
+                    //濡傛灉宸插凡浜х敓璐圭敤锛岃绠楀凡宸蹭骇鐢熻垂鐢�
                     add.setCurrentFee(this.getApplyPrice(update.getApplyId(), days));
                 }else{
                     add.setCurrentFee(BigDecimal.ZERO);
@@ -520,7 +572,10 @@
                 totalFee = totalFee.add(add.getFee());
                 currentFee = currentFee.add(add.getCurrentFee());
 
-                MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId());
+                MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId(),solutions.getId());
+                memberInsurance.setStartTime(add.getStartTime());
+                memberInsurance.setEndTime(add.getEndTime());
+                memberInsurance.setRelationType(Constants.ONE);
                 memberInsuranceList.add(memberInsurance);
 
                 applyChangeDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
@@ -555,10 +610,13 @@
                         CountCyclePriceVO timeoutCountCyclePriceVOReduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
                         updateCurrentFee = timeoutCountCyclePriceVOReduce.getCyclePrice().subtract(countCyclePriceVO_reduce.getCyclePrice());
                     }
+
+
                     applyDetailJoinMapper.update(null, new UpdateWrapper<ApplyDetail>().lambda()
                             .setSql(" fee = ifnull(fee,0)+" + updateFee)
                             .setSql(" current_fee = " + updateCurrentFee)
-                            .set(ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 3))
+                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())!=0,ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 3))
+                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())==0,ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 2))
                             .set(ApplyDetail::getEditor, update.getEditor())
                             .set(ApplyDetail::getEditDate, update.getEditDate())
                             .eq(ApplyDetail::getId, oldModel.getId())
@@ -569,7 +627,9 @@
                     //淇敼 鍛樺伐鎶曚繚鏄庣粏璁板綍 鍘嗗彶鏁版嵁
                     memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
                             .setSql(" fee = ifnull(fee,0)+" + updateFee)
-                            .set(MemberInsurance::getEndTime, update.getApplyStartTime())
+                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())!=0,MemberInsurance::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 3))
+                            .set(insuranceApply.getStartTime().compareTo(update.getApplyStartTime())==0,MemberInsurance::getEndTime,DateUtil.getMontageDate(update.getApplyStartTime(), 2))
+                            .set(MemberInsurance::getStartTime, update.getApplyStartTime())
                             .eq(MemberInsurance::getRelationId, oldModel.getId())
                     );
 
@@ -644,13 +704,20 @@
         Constants.NoticeType noticeType = Constants.NoticeType.FOUR;
         if(param.getDealBackApply() ==1){
             //濡傛灉鏄┏鍥�,鍙兘鍙┏鍥炲凡绛剧珷鐘舵�佷笅鐨勯��鍥炵敵璇风姸鎬佽繘琛屾搷浣�
-            if(!Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey())){
+            if(!(Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey())
+                    ||Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()))
+            ){
                 throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ョ敵璇风姸鎬佸凡娴佽浆锛屽綋鍓嶄笉鏀寔璇ユ搷浣渵");
+            }
+            if(Constants.equalsInteger(model.getStatus(),Constants.ApplyChangeStatus.RETURN_APPLY_SIGNATURE.getKey())){
+                update.setStatus(Constants.ApplyChangeStatus.SIGNATURE.getKey());
+            }else {
+                update.setStatus(Constants.ApplyChangeStatus.UPLOAD.getKey());
             }
             applyLogType = Constants.ApplyLogType.CA_PALTFORM_REFUSE_APPLY;
             info = applyLogType.getInfo();
             info = info.replace("${param}", param.getCheckInfo());
-            update.setStatus(Constants.ApplyChangeStatus.SIGNATURE.getKey());
+
             noticeType = Constants.NoticeType.FIVE;
         }else{
             //濡傛灉鏄悓鎰�,涓ょ鐢宠閫�鍥炵姸鎬侀兘鍙搷浣�
@@ -679,8 +746,8 @@
         }
         //鍒犻櫎鍏朵粬寰呭姙
         noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId()));
-        Notices notices = new Notices(noticeObjectType,Constants.ZERO,model.getId(),solutions.getName(),
-                model.getCompanyId(), noticeType);
+        Notices notices = new Notices(noticeObjectType,Constants.ONE,model.getId(),solutions.getName(),
+                insuranceApply.getCompanyId(), noticeType);
         noticesMapper.insert(notices);
 
         ApplyLog log = new ApplyLog(update,applyLogType.getName(),info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
@@ -721,9 +788,17 @@
         if(Objects.isNull(solutions)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
         }
+        if(solutions.getDataType().equals(Constants.ONE)){
+            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
+            if(Objects.isNull(solutions)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鏂规鏈�鏂扮増鏈俊鎭�");
+            }
+        }
+
+
         CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
                 .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
-                .eq(CompanySolution::getSolutionId,solutions.getId())
+                .eq(CompanySolution::getSolutionBaseId,solutions.getBaseId())
                 .eq(CompanySolution::getIsdeleted,Constants.ZERO)
                 .last(" limit 1 ")
         );
@@ -762,9 +837,7 @@
         applyChangeMapper.updateById(applyChangeFee);
 
         Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_COMPANY_COMMIT;
-        String info =applyLogType.getInfo();
-        info = info.replace("${param}", "");
-        ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),info,applyChange.getId(),applyLogType.getKey(), null, null);
+        ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),"",applyChange.getId(),applyLogType.getKey(), null, null);
         applyLogMapper.insert(log);
         
 
@@ -815,9 +888,15 @@
         if(Objects.isNull(solutions)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规");
         }
+        if(solutions.getDataType().equals(Constants.ONE)){
+            solutions = solutionsMapper.selectOne(new QueryWrapper<Solutions>().lambda().eq(Solutions::getBaseId,solutions.getBaseId()).eq(Solutions::getDataType,Constants.TWO).last("limit 1"));
+            if(Objects.isNull(solutions)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鏂规鏈�鏂扮増鏈俊鎭�");
+            }
+        }
         CompanySolution companySolution = companySolutionMapper.selectOne(new QueryWrapper<CompanySolution>().lambda()
                 .eq(CompanySolution::getCompanyId,loginUserInfo.getCompanyId())
-                .eq(CompanySolution::getSolutionBaseId,solutions.getId())
+                .eq(CompanySolution::getSolutionBaseId,solutions.getBaseId())
                 .eq(CompanySolution::getIsdeleted,Constants.ZERO)
                 .last(" limit 1 ")
         );
@@ -871,7 +950,7 @@
                 .eq(DispatchUnit::getUnitStatus,Constants.ONE)
                 .eq(DuSolution::getIsdeleted,Constants.ZERO)
                 .eq(DuSolution::getStatus,Constants.ONE)
-                .eq(DuSolution::getSolutionId,insuranceApply.getSolutionId()));
+                .eq(DuSolution::getSolutionId,companySolution.getSolutionId()));
         if(!CollectionUtils.isNotEmpty(duSolutionList)){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏁版嵁寮傚父锛氫繚闄╂柟妗堜笅鏈煡璇㈠埌娲鹃仯鍗曚綅");
         }
@@ -894,6 +973,13 @@
             if(companySolution.getCanAdd().equals(Constants.ZERO)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽姞淇�");
             }
+            //楠岃瘉鏄惁瀛樺湪閲嶅鏁版嵁
+            List<String> idcarNo = addDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
+            Set<String> set = new HashSet<>(idcarNo);
+            if(idcarNo.size() != set.size()){
+                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝浜哄憳褰曞叆鏁版嵁瀛樺湪鐩稿悓鏁版嵁锛�");
+            }
+
             //鍔犱繚鏄庣粏鏁版嵁 璁$畻閲戦  鏍规嵁鎵瑰崟鏃堕棿 璁$畻
             applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),1));
             CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
@@ -907,6 +993,13 @@
         //鍑忎繚鏁版嵁
         List<ApplyChagneDetail> delDetailList = applyChange.getDelDetailList();
         if (CollectionUtils.isNotEmpty(delDetailList)) {
+            //楠岃瘉鏄惁瀛樺湪閲嶅鏁版嵁
+            List<String> idcarNo = delDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
+            Set<String> set = new HashSet<>(idcarNo);
+            if(idcarNo.size() != set.size()){
+                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝浜哄憳褰曞叆鏁版嵁瀛樺湪鐩稿悓鏁版嵁锛�");
+            }
+
             if(companySolution.getCanReduce().equals(Constants.ZERO)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽噺淇�");
             }
@@ -914,7 +1007,7 @@
             applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),2));
             CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
             BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
-            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo,detailFee);
+            this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo,detailFee,applyChangeCyclePriceDTO.getValidTime());
             fee = fee.add(delDetailList.stream().map(ApplyChagneDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
         }
 
@@ -952,7 +1045,7 @@
      * @param loginUserInfo
      */
     public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,
-                                LoginUserInfo loginUserInfo,BigDecimal detailFee){
+                                LoginUserInfo loginUserInfo,BigDecimal detailFee,Date endTime){
         for (ApplyChagneDetail applyChagneDetail : delDetailList) {
             if (Objects.isNull(applyChagneDetail.getMemberId())) {
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍑忎繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝繀濉」缂哄け");
@@ -1004,7 +1097,7 @@
             applyChagneDetail.setType(Constants.ONE);
 
             applyChagneDetail.setStartTime(applyDetail.getStartTime());
-            applyChagneDetail.setEndTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),3));
+            applyChagneDetail.setEndTime(endTime);
 
             member.setApplyId(insuranceApply.getId());
             member.setDuId(applyChagneDetail.getDuId());
@@ -1044,7 +1137,8 @@
                     .eq(ApplyDetail::getApplyId,applyChange.getApplyId())
                     .eq(ApplyDetail::getIdcardNo,applyChagneDetail.getIdcardNo())
                     .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),1))
-                    .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3))
+                            .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(insuranceApply.getEndTime(),2))
+                    //.ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(applyChange.getApplyStartTime(),3))
             )>Constants.ZERO){
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠淇濆崟涓嬶紝鍔犱繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝瓨鍦ㄦ棩鏈熷啿绐佺殑鏁版嵁");
             }
@@ -1497,6 +1591,8 @@
         String info = applyLogType.getInfo();
         if(StringUtils.isNotBlank(applyChangeOptDTO.getOptIllustration())){
             info = info.replace("${param}", applyChangeOptDTO.getOptIllustration());
+        }else{
+            info = info.replace("${param}", "");
         }
         ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),info,applyChange.getId(),applyLogType.getKey(), null, null);
         applyLogMapper.insert(log);
@@ -1781,7 +1877,7 @@
         BigDecimal sumPrice = countCyclePriceVO.getCyclePrice();
         CountCyclePriceVO returnCountCyclePriceVO = new CountCyclePriceVO();
         //鍔犲噺淇濋噾棰�
-        returnCountCyclePriceVO.setCyclePrice(sumPrice.divide(new BigDecimal(sumDays),2, RoundingMode.HALF_UP).multiply(new BigDecimal(optDays)));
+        returnCountCyclePriceVO.setCyclePrice(sumPrice.multiply(new BigDecimal(optDays)).divide(new BigDecimal(sumDays),2, RoundingMode.HALF_UP));
         return returnCountCyclePriceVO;
     }
 

--
Gitblit v1.9.3