From 15e588eb6a7549ecd2aaffb45e67f11e68354eb6 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 05 二月 2024 18:22:19 +0800
Subject: [PATCH] 111

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |  242 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 154 insertions(+), 88 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 d1c2c30..8aba30d 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
@@ -171,6 +171,7 @@
         update.setStatus(Constants.ApplyChangeStatus.APPROVE.getKey());
         update.setCheckDate(update.getEditDate());
         update.setCheckInfo(param.getCheckInfo());
+        update.setApplyId(model.getApplyId());
         update.setCheckUserId(user.getId());
         update.setId(model.getId());
         update.setValidCode(param.getValidCode());
@@ -194,6 +195,9 @@
             dealDetailsDUdata(update);
         }
 
+//        if(1==1){
+//            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+//        }
 
         Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_APPROVE;
         String info = "";
@@ -344,6 +348,17 @@
 
             MemberInsurance memberInsurance = new MemberInsurance(applyDetail,update.getId());
             memberInsuranceJoinMapper.insert(memberInsurance);
+
+            Member member = memberMapper.selectById(detail.getMemberId());
+            if(Objects.isNull(member)){
+                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍛樺伐鏁版嵁");
+            }
+            member.setApplyId(update.getApplyId());
+            member.setDuId(detail.getDuId());
+            member.setWorktypeId(detail.getWorktypeId());
+            member.setStartTime(detail.getStartTime());
+            member.setEndTime(detail.getEndTime());
+            memberMapper.updateById(member);
         }
     }
     /**
@@ -361,7 +376,6 @@
                         .leftJoin(ApplyChange.class, ApplyChange::getId, ApplyChagneDetail::getApplyChangeId)
                         .leftJoin(InsuranceApply.class, InsuranceApply::getId, ApplyChange::getApplyId)
                         .leftJoin(Solutions.class, Solutions::getId, InsuranceApply::getSolutionId)
-                        .leftJoin(Solutions.class, Solutions::getId, ApplyChange::getSolutionsId)
                         .leftJoin(Worktype.class, Worktype::getId, ApplyChagneDetail::getWorktypeId)
                         .leftJoin(DispatchUnit.class, DispatchUnit::getId, ApplyChagneDetail::getDuId)
                         .eq(ApplyChagneDetail::getApplyChangeId, update.getId())
@@ -380,20 +394,17 @@
         //鍔犱繚涓氬姟 浣跨敤鐨勫姞淇濋噾棰�
         ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_add = new ApplyChangeCyclePriceDTO();
         applyChangeCyclePriceDTO_add.setApplyId(update.getApplyId());
-        applyChangeCyclePriceDTO_add.setValidTime(DateUtil.getMontageDate(update.getStartTime(), 1));
+        applyChangeCyclePriceDTO_add.setValidTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
         //鍔犱繚 娣诲姞鐨勯噾棰�
         CountCyclePriceVO countCyclePriceVO_add = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_add);
 
 
-        //鍑忎繚涓氬姟 浣跨敤鐨勫噺淇濋噾棰�
-        ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_reduce = new ApplyChangeCyclePriceDTO();
-        applyChangeCyclePriceDTO_reduce.setApplyId(update.getApplyId());
-        applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(update.getStartTime(), 3));
-        //鍑忎繚 闇�瑕佸噺灏戠殑閲戦
-        CountCyclePriceVO countCyclePriceVO_reduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
-
 
         for (ApplyChagneDetail detail : detailList) {
+            Member member = memberMapper.selectById(detail.getMemberId());
+            if(Objects.isNull(member)){
+                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍛樺伐鏁版嵁");
+            }
             if (Constants.equalsInteger(detail.getType(), Constants.ZERO)) {
                 //鍔犱繚
                 ApplyDetail add = new ApplyDetail();
@@ -409,26 +420,24 @@
                 add.setDuId(detail.getDuId());
                 add.setStartTime(update.getApplyStartTime());
                 add.setEndTime(detail.getEndTime());
-                add.setFee(new BigDecimal(0));
-//                add.setFee(Constants.countDetailFee(detail.getSolutionTimeUnit(),detail.getSolutionPrice(), add.getStartTime(),add.getEndTime()));
-                if (DateUtil.daysBetweenDates(add.getStartTime(), new Date()) >= 0) {
-                    add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
-                    add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
+                add.setStartTime(DateUtil.getMontageDate(update.getApplyStartTime(), 1));
+                add.setEndTime(DateUtil.getMontageDate(detail.getEndTime(), 2));
+                add.setFee(countCyclePriceVO_add.getCyclePrice());
 
-                    add.setFee(countCyclePriceVO_add.getCyclePrice());
-                    if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(add.getStartTime(), 2), new Date()) >= 0) {
-                        Integer days = DateUtil.daysBetweenDates(new Date(), DateUtil.getMontageDate(add.getStartTime(), 2)) + 1;
-                        //濡傛灉宸蹭骇鐢熻垂鐢紝璁$畻宸蹭骇鐢熻垂鐢�
-                        add.setCurrentFee(this.getApplyPrice(update.getApplyId(), days));
-                    }
-//                addList.add(add);
-                    applyDetailJoinMapper.insert(add);
-                    totalFee.add(add.getFee());
-                    currentFee.add(add.getCurrentFee());
+                if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(detail.getStartTime(), 2), new Date()) >= 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);
+                }
+                applyDetailJoinMapper.insert(add);
+                totalFee = totalFee.add(add.getFee());
+                currentFee = currentFee.add(add.getCurrentFee());
 
-                    MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId());
-                    memberInsuranceList.add(memberInsurance);
-                } else {
+                MemberInsurance memberInsurance = new MemberInsurance(detail, update, update.getEditor(), add.getId());
+                memberInsuranceList.add(memberInsurance);
+            } else {
                     //鍑忎繚鎿嶄綔
                     //鏌ヨ鍛樺伐鏄湪涓诲崟涓� 鏄惁瀛樺湪鐢熸晥涓殑鏁版嵁
                     ApplyDetail oldModel = applyDetailJoinMapper.selectOne(new QueryWrapper<ApplyDetail>().lambda()
@@ -439,32 +448,31 @@
                     if (oldModel == null || oldModel.getStartTime() == null || oldModel.getStartTime().getTime() > update.getApplyStartTime().getTime()) {
                         throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鐢ㄦ埛銆�" + detail.getMemberName() + "銆戝師淇濆崟淇℃伅鏈夎锛屽綋鍓嶇敵璇蜂笉鏀寔鍑忎繚澶勭悊锛�");
                     }
-                    //閫�淇濋渶瑕侀��鍥炵殑璐圭敤
+                    //鍑忎繚涓氬姟 浣跨敤鐨勫噺淇濋噾棰�
+                    ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO_reduce = new ApplyChangeCyclePriceDTO();
+                    applyChangeCyclePriceDTO_reduce.setApplyId(update.getApplyId());
+                    applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(update.getApplyStartTime(), 2));
+                    //鍑忎繚 闇�瑕佸噺灏戠殑閲戦 鍗� 閫�淇濋渶瑕侀��鍥炵殑璐圭敤
+                    CountCyclePriceVO countCyclePriceVO_reduce = this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO_reduce);
                     BigDecimal updateFee = countCyclePriceVO_reduce.getCyclePrice().multiply(new BigDecimal(-1));
-                    BigDecimal updateCurrentFee = oldModel.getFee().subtract(updateFee);
-
-//                BigDecimal updateCurrentFee = new BigDecimal(0);
-//                if(DateUtil.daysBetweenDates(update.getApplyStartTime(),new Date() )>0){
-//                    //濡傛灉鐢熸晥鏃堕棿 鏄粖澶╀箣鍓嶏紝閫�鍥炲凡浜х敓璐圭敤锛岃绠楀凡浜х敓璐圭敤(鎬昏垂鐢�-宸蹭骇鐢熻垂鐢�)
-//                    updateCurrentFee = updateFee.subtract(oldModel.getCurrentFee());
-//                }
-
-//                    BigDecimal updateFee = (Constants.countDetailFee(detail.getSolutionTimeUnit(), detail.getSolutionPrice(), oldModel.getStartTime(), update.getApplyStartTime()));
-//                    BigDecimal updateCurrentFee = new BigDecimal(0);
-                    if (DateUtil.daysBetweenDates(update.getApplyStartTime(), new Date()) > 0) {
-                        //濡傛灉鐢熸晥鏃堕棿 鏄粖澶╀箣鍓嶏紝閫�鍥炲凡浜х敓璐圭敤锛岃绠楀凡浜х敓璐圭敤(鎬昏垂鐢�-宸蹭骇鐢熻垂鐢�)
-                        updateCurrentFee = updateFee.subtract(Constants.formatBigdecimal(oldModel.getCurrentFee()));
+                    //褰撳鎵规椂闂� 澶т簬 鐢宠鐨勬椂闂存椂 璁$畻瀹為檯鍑忓皯閲戦 鍥犱负宸叉墸閲戦浼氬ぇ浜� 搴旀墸閲戦
+                    BigDecimal updateCurrentFee = BigDecimal.ZERO;
+                    if (DateUtil.daysBetweenDates(DateUtil.getMontageDate(new Date(), 2),update.getApplyStartTime()) > 0) {
+                        applyChangeCyclePriceDTO_reduce.setValidTime(DateUtil.getMontageDate(new Date(), 2));
+                        //鑾峰彇 澶т簬瀹℃壒鏃ユ湡瀵艰嚧 澶氬噺鐨勯噾棰�
+                        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, update.getApplyStartTime())
+                            .set(ApplyDetail::getEndTime, DateUtil.getMontageDate(update.getApplyStartTime(), 3))
                             .set(ApplyDetail::getEditor, update.getEditor())
                             .set(ApplyDetail::getEditDate, update.getEditDate())
-                            .eq(ApplyDetail::getId, oldModel.getApplyId())
+                            .eq(ApplyDetail::getId, oldModel.getId())
                     );
-                    totalFee.add(updateFee);
-                    currentFee.add(updateCurrentFee);
+                    totalFee = totalFee.add(updateFee);
+                    currentFee = currentFee.add(updateCurrentFee);
 
                     //淇敼 鍛樺伐鎶曚繚鏄庣粏璁板綍 鍘嗗彶鏁版嵁
                     memberInsuranceJoinMapper.update(null, new UpdateWrapper<MemberInsurance>().lambda()
@@ -472,26 +480,28 @@
                             .set(MemberInsurance::getEndTime, update.getApplyStartTime())
                             .eq(MemberInsurance::getRelationId, oldModel.getId())
                     );
-
-                }
             }
+
+            member.setApplyId(update.getApplyId());
+            member.setDuId(detail.getDuId());
+            member.setWorktypeId(detail.getWorktypeId());
+            member.setStartTime(detail.getStartTime());
+            member.setEndTime(detail.getEndTime());
+            memberMapper.updateById(member);
 
             if (memberInsuranceList != null && memberInsuranceList.size() > 0) {
-//            applyDetailJoinMapper.insertBatchSomeColumn(addList);
                 memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
             }
-            if (totalFee.compareTo(new BigDecimal(0)) != 0) {
-                //濡傛灉淇濆崟閲戦鍙戠敓缂栫爜锛屾洿鏂版�讳繚鍗曢噾棰�
-                insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
-                        .setSql(" fee = ifnull(fee,0)+" + totalFee)
-                        .setSql(" current_fee = ifnull(current_fee,0)+" + currentFee)
-                        .set(InsuranceApply::getEditor, update.getEditor())
-                        .set(InsuranceApply::getEditDate, update.getEditDate())
-                        .eq(InsuranceApply::getId, update.getApplyId())
-                );
-
-            }
-
+        }
+        if (totalFee.compareTo(new BigDecimal(0)) != 0) {
+            //濡傛灉淇濆崟閲戦鍙戠敓缂栫爜锛屾洿鏂版�讳繚鍗曢噾棰�
+            insuranceApplyMapper.update(null, new UpdateWrapper<InsuranceApply>().lambda()
+                    .setSql(" fee = ifnull(fee,0)+" + totalFee)
+                    .setSql(" current_fee = ifnull(current_fee,0)+" + currentFee)
+                    .set(InsuranceApply::getEditor, update.getEditor())
+                    .set(InsuranceApply::getEditDate, update.getEditDate())
+                    .eq(InsuranceApply::getId, update.getApplyId())
+            );
         }
     }
 
@@ -624,6 +634,8 @@
         }
         applyChange.setCreateDate(new Date());
         applyChange.setCreator(loginUserInfo.getId());
+        applyChange.setEditor(loginUserInfo.getId());
+        applyChange.setEditDate(new Date());
         applyChange.setIsdeleted(Constants.ZERO);
         applyChange.setApplyStartTime(applyChange.getValidTime());
         applyChange.setStatus(Constants.ZERO);
@@ -636,8 +648,19 @@
         applyChangeFee.setFee(fee);
         applyChangeMapper.updateById(applyChangeFee);
 
+//        if(1==1){
+//            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+//        }
 
-        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
+
+
+        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);
+        applyLogMapper.insert(log);
+        
+
         return applyChange.getId();
     }
 
@@ -710,7 +733,15 @@
         BigDecimal fee = this.dealApplyChangeData(applyChange,insuranceApply,companySolution,solutions,loginUserInfo,BigDecimal.ZERO);
         applyChange.setFee(fee);
         applyChangeMapper.updateById(applyChange);
-        this.saveApplyLog(applyChange,Constants.ApplyChangeLogStatus.UPLOAD,null);
+
+
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_UPLOAD_AGAIN;
+        String info =applyLogType.getInfo();
+        info = info.replace("${param}", "");
+        ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),info,applyChange.getId(),applyLogType.getKey(), null, null);
+        applyLogMapper.insert(log);
+
+
         return applyChange.getId();
     }
 
@@ -767,7 +798,7 @@
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "璇ヤ紒涓氬垎閰嶄繚闄╂柟妗堟棤娉曡繘琛屽噺淇�");
             }
             //鍑忎繚鏄庣粏鏁版嵁 璁$畻閲戦  鏍规嵁鎵瑰崟鏃堕棿 鍓嶄竴澶� 璁$畻
-            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),3));
+            applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(applyChange.getValidTime(),2));
             CountCyclePriceVO countCyclePriceVO =  this.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO);
             BigDecimal detailFee = countCyclePriceVO.getCyclePrice();
             this.delChangeDetail(applyChange,delDetailList,insuranceApply,solutions,loginUserInfo,detailFee);
@@ -783,23 +814,18 @@
     }
 
 
-
-
-
-    public void saveApplyLog(ApplyChange applyChange,Constants.ApplyChangeLogStatus applyChangeLogStatus,String content){
+    public void saveApplyLog(ApplyChange applyChange,Constants.ApplyLogType applyLogType,String content){
         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         ApplyLog applyLog = new ApplyLog();
         applyLog.setCreateDate(new Date());
         applyLog.setCreator(loginUserInfo.getId());
         applyLog.setIsdeleted(Constants.ZERO);
         applyLog.setApplyId(applyChange.getApplyId());
-        applyLog.setTitle(applyChangeLogStatus.getName());
+        applyLog.setTitle(applyLogType.getName());
         if(StringUtils.isNotBlank(content)){
-            applyLog.setContent(applyChangeLogStatus.getInfo().replace("${param}",content));
-        }else{
-            applyLog.setContent(applyChangeLogStatus.getInfo());
+            applyLog.setContent(applyLogType.getInfo().replace("${param}",content));
         }
-        applyLog.setObjType(applyChangeLogStatus.getKey());
+        applyLog.setObjType(applyLogType.getKey());
         applyLog.setObjId( applyChange.getId());
         applyLog.setStatus(applyChange.getStatus());
         applyLogMapper.insert(applyLog);
@@ -812,7 +838,8 @@
      * @param delDetailList
      * @param loginUserInfo
      */
-    public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal detailFee){
+    public void delChangeDetail(ApplyChange applyChange ,List<ApplyChagneDetail> delDetailList,InsuranceApply insuranceApply,Solutions solutions,
+                                LoginUserInfo loginUserInfo,BigDecimal detailFee){
         for (ApplyChagneDetail applyChagneDetail : delDetailList) {
             if (Objects.isNull(applyChagneDetail.getMemberId())) {
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍑忎繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝繀濉」缂哄け");
@@ -849,8 +876,15 @@
             applyChagneDetail.setApplyChangeId(applyChange.getId());
             applyChagneDetail.setType(Constants.ONE);
 
-            applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyDetail.getStartTime(),1));
+            applyChagneDetail.setStartTime(applyDetail.getStartTime());
             applyChagneDetail.setEndTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),3));
+
+            member.setApplyId(insuranceApply.getId());
+            member.setDuId(applyChagneDetail.getDuId());
+            member.setWorktypeId(applyChagneDetail.getWorktypeId());
+            member.setStartTime(applyChagneDetail.getStartTime());
+            member.setEndTime(applyChagneDetail.getEndTime());
+            memberMapper.updateById(member);
 
             applyChagneDetail.setFee( detailFee.multiply(new BigDecimal(-1)));
             applyChagneDetailJoinMapper.insert(applyChagneDetail);
@@ -876,6 +910,13 @@
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍔犱繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝繀濉」缂哄け");
             }
 
+            applyChagneDetail.setCreateDate(new Date());
+            applyChagneDetail.setCreator(loginUserInfo.getId());
+            applyChagneDetail.setIsdeleted(Constants.ZERO);
+            applyChagneDetail.setApplyChangeId(applyChange.getId());
+            applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyChange.getApplyStartTime(),1));
+            applyChagneDetail.setEndTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2));
+            applyChagneDetail.setType(Constants.ZERO);
             Member member = new Member();
             if(Objects.isNull(applyChagneDetail.getMemberId())){
                 //鏌ヨ鏄惁瀛樺湪璇ョ敤鎴�
@@ -897,11 +938,15 @@
                     member.setApplyId(insuranceApply.getId());
                     member.setDuId(applyChagneDetail.getDuId());
                     member.setWorktypeId(applyChagneDetail.getWorktypeId());
+                    member.setStartTime(applyChagneDetail.getStartTime());
+                    member.setEndTime(applyChagneDetail.getEndTime());
                     memberMapper.insert(member);
                 }else{
                     member.setApplyId(insuranceApply.getId());
                     member.setDuId(applyChagneDetail.getDuId());
                     member.setWorktypeId(applyChagneDetail.getWorktypeId());
+                    member.setStartTime(applyChagneDetail.getStartTime());
+                    member.setEndTime(applyChagneDetail.getEndTime());
                     memberMapper.updateById(member);
                 }
             }else{
@@ -912,8 +957,19 @@
                 member.setApplyId(insuranceApply.getId());
                 member.setDuId(applyChagneDetail.getDuId());
                 member.setWorktypeId(applyChagneDetail.getWorktypeId());
+                member.setStartTime(applyChagneDetail.getStartTime());
+                member.setEndTime(applyChagneDetail.getEndTime());
                 memberMapper.updateById(member);
             }
+
+            //鏍规嵁鍛樺伐韬唤璇佽繘琛屽垽鏂勾榫�
+            long age = Constants.getAgeByIdCard(member.getIdcardNo());
+            if(Objects.isNull(age)
+                    || age > solutions.getMaxAge()
+                    || age < solutions.getMinAge()){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+applyChagneDetail.getMemberName()+"銆戝憳宸ュ勾榫勮秴鍑烘柟妗堥厤缃� 鏂规閰嶇疆銆�"+solutions.getMinAge()+" - "+solutions.getMaxAge()+"銆戝瓨鍦ㄥ紓甯告暟鎹紒");
+            }
+
             //鏌ヨ鍛樺伐鏄惁瀛樺湪  0寰呯缃� 1宸茬绔� 鐨勬绫讳笟鍔′繚鏁版嵁 鍚屼竴涓诲崟涓�
             if (applyChagneDetailJoinMapper.selectJoinCount(
                     new MPJLambdaWrapper<ApplyChagneDetail>()
@@ -924,6 +980,8 @@
             ) > Constants.ZERO) {
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍔犱繚浜哄憳銆�" + applyChagneDetail.getMemberName() + "銆戝瓨鍦ㄧ敵璇蜂腑鐨勫姞鍑忎繚/鎹㈠巶鍗曟嵁");
             }
+
+
             //鏌ヨ鍛樺伐鏄湪涓诲崟涓� 鏄惁瀛樺湪鐢熸晥涓殑鏁版嵁
             if(!Objects.isNull(applyChagneDetail.getMemberId())){
                 if (applyDetailJoinMapper.selectCount(new QueryWrapper<ApplyDetail>().lambda()
@@ -944,13 +1002,6 @@
                 throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "銆�" + applyChagneDetail.getMemberName() + "銆戝憳宸ュ伐绉嶄俊鎭湭鏌ヨ鍒帮紒");
             }
             applyChagneDetail.setMemberId(member.getId());
-            applyChagneDetail.setCreateDate(new Date());
-            applyChagneDetail.setCreator(loginUserInfo.getId());
-            applyChagneDetail.setIsdeleted(Constants.ZERO);
-            applyChagneDetail.setApplyChangeId(applyChange.getId());
-            applyChagneDetail.setStartTime(DateUtil.getMontageDate(applyChange.getStartTime(),1));
-            applyChagneDetail.setEndTime(DateUtil.getMontageDate(insuranceApply.getEndTime(),2));
-            applyChagneDetail.setType(Constants.ZERO);
             applyChagneDetail.setFee(detailFee);
             applyChagneDetailJoinMapper.insert(applyChagneDetail);
         }
@@ -1015,7 +1066,18 @@
             applyChagneDetail.setIsdeleted(Constants.ZERO);
             applyChagneDetail.setApplyChangeId(applyChange.getId());
             applyChagneDetail.setType(Constants.TWO);
+            applyChagneDetail.setStartTime(applyDetail.getStartTime());
+            applyChagneDetail.setEndTime(applyDetail.getEndTime());
+
             applyChagneDetailJoinMapper.insert(applyChagneDetail);
+
+            member.setApplyId(applyChange.getApplyId());
+            member.setDuId(applyChagneDetail.getDuId());
+            member.setWorktypeId(applyChagneDetail.getWorktypeId());
+            member.setStartTime(applyChagneDetail.getStartTime());
+            member.setEndTime(applyChagneDetail.getEndTime());
+            memberMapper.updateById(member);
+
         }
     }
 
@@ -1124,12 +1186,14 @@
                 .selectAll(ApplyChange.class)
                 .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
                 .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
+                .selectAs(Company::getName,ApplyChange::getCompanyName)
                 .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)
                 .select("( select ifnull(sum(ad.FEE),0) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID  )",ApplyChange::getChangeMoney)
                 .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
                 .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
+                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                 .eq(!Objects.isNull(model.getType()),ApplyChange::getType,model.getType())
                 .eq(!Objects.isNull(model.getStatus())&&!model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,model.getStatus())
                 .in(!Objects.isNull(model.getStatus())&&model.getStatus().equals(Constants.ApplyChangeStatus.RETURN_APPLY_UPLOAD.getKey()),ApplyChange::getStatus,
@@ -1190,7 +1254,7 @@
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈡柟妗堜俊鎭�");
         }
 
-        Constants.ApplyChangeLogStatus applyChangeLogStatus = Constants.ApplyChangeLogStatus.RETURN_APPLY;
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_CHECK_PASS_NO;
 
         Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.APPLY_CHANGE;
         if(applyChange.getType().equals(Constants.ONE)){
@@ -1221,7 +1285,7 @@
 
 
         }else if(applyChangeOptDTO.getOptType().equals(4)){
-            applyChangeLogStatus = Constants.ApplyChangeLogStatus.PLATFORM_AGREE;
+            applyLogType = Constants.ApplyLogType.CA_PLATFORM_AGREE_BACK_APPLY;
             //骞冲彴鍚屾剰閫�鍥�
             if(loginUserInfo.getType().equals(Constants.ZERO)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲钩鍙扮鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
@@ -1232,7 +1296,7 @@
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘琛岃鎿嶄綔!");
             }
         }else if(applyChangeOptDTO.getOptType().equals(5)){
-            applyChangeLogStatus = Constants.ApplyChangeLogStatus.PLATFORM_UN_AGREE;
+            applyLogType = Constants.ApplyLogType.CA_PALTFORM_REFUSE_APPLY;
             //骞冲彴椹冲洖閫�鍥�
             if(loginUserInfo.getType().equals(Constants.ZERO)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲钩鍙扮鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
@@ -1249,7 +1313,7 @@
             }
         }else if(applyChangeOptDTO.getOptType().equals(6)){
             //浼佷笟鍏抽棴
-            applyChangeLogStatus = Constants.ApplyChangeLogStatus.CLOSE;
+            applyLogType = Constants.ApplyLogType.CA_COMPANY_CLOSE;
             if(!loginUserInfo.getType().equals(Constants.ONE)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
             }
@@ -1257,7 +1321,6 @@
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏁版嵁鐘舵�侀敊璇棤娉曡繘琛岃鎿嶄綔!");
             }
             applyChange.setStatus(Constants.ApplyChangeStatus.CLOSE.getKey());
-
 
             //瀛樺偍寰呭姙淇℃伅
             //鍒犻櫎鍏朵粬寰呭姙
@@ -1270,8 +1333,10 @@
         applyChange.setEditDate(new Date());
         applyChangeMapper.updateById(applyChange);
 
-        //瀛樺偍鏃ュ織鏁版嵁
-        this.saveApplyLog(applyChange,applyChangeLogStatus,applyChangeOptDTO.getOptIllustration());
+        String info = applyLogType.getInfo();
+        info = info.replace("${param}", applyChangeOptDTO.getOptIllustration());
+        ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),info,applyChange.getId(),applyLogType.getKey(), null, null);
+        applyLogMapper.insert(log);
     }
 
 
@@ -1302,6 +1367,7 @@
                         .selectAs(Company::getName,ApplyLog::getCompanyName)
                         .leftJoin(SystemUser.class,SystemUser::getId,ApplyLog::getCreator)
                         .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId)
+                        .in(ApplyLog::getObjType,Constants.ApplyLogType.getTypeList(Constants.ONE))
                         .eq(ApplyLog::getObjId,applyChange.getId())
                         .orderByAsc(ApplyLog::getCreateDate)
         );

--
Gitblit v1.9.3