From bd57081dc1bcd94e1e4043a9e0a7c6953d4bb9d4 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期一, 01 四月 2024 19:19:01 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/1.0.1' into 1.0.1

---
 server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java                     |   13 ++
 server/service/src/main/java/com/doumee/core/utils/Constants.java                            |   28 ++++-
 server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java |  109 +++++++++++++++++----
 server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java    |   40 ++++++-
 server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java                 |    7 
 server/service/src/main/java/com/doumee/service/business/UnionChangeService.java             |    5 
 server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java             |   14 +-
 server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java     |   25 +++-
 8 files changed, 188 insertions(+), 53 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
index b5bf545..ad906fc 100644
--- a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
+++ b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
@@ -1139,13 +1139,13 @@
                 sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 )?16:8) * 2 * 256);
             }
             sheet.createFreezePane(0, 1);
-            sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,6));
+            sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,5));
             Row title = sheet.createRow(0);
             title.setHeight((short) 2000);
             Cell c = title.createCell(0);
             c.setCellValue(sheetName);
             configFirstCell(sxssfWorkbook,c);
-            for (int i = 0; i < 8; i++) {
+            for (int i = 0; i < 6; i++) {
                 if(i>0){
                     title.createCell(i).setCellValue("");
                 }
@@ -1154,7 +1154,7 @@
             Row header1 = sheet.createRow(1);
             header1.createCell(0).setCellValue("鎶曚繚浜�");
             header1.createCell(1).setCellValue("鎶ヤ繚闄╀汉");
-            header1.createCell(2).setCellValue("鎶曚繚浜烘暟");
+            header1.createCell(2).setCellValue("");
             header1.createCell(3).setCellValue("淇濋櫓鏂规");
             header1.createCell(4).setCellValue("淇濋櫓鐢熸晥璧锋湡");
             header1.createCell(5).setCellValue("淇濋櫓鐢熸晥姝㈡湡");
@@ -1192,8 +1192,8 @@
                 header5.createCell(1).setCellValue(StringUtils.defaultString(addModel.getMemberName(),""));
                 header5.createCell(2).setCellValue(Constants.equalsInteger(addModel.getSex(),0)?"鐢�":(Constants.equalsInteger(addModel.getSex(),1)?"濂�":"-"));
                 header5.createCell(3).setCellValue(StringUtils.defaultString(addModel.getIdcardNo(),""));
-                header5.createCell(6).setCellValue(StringUtils.defaultString(addModel.getDuName(),""));
-                header5.createCell(7).setCellValue(StringUtils.defaultString(addModel.getWorkTypeName(),""));
+                header5.createCell(4).setCellValue(StringUtils.defaultString(addModel.getDuName(),""));
+                header5.createCell(5).setCellValue(StringUtils.defaultString(addModel.getWorkTypeName(),""));
                 for (int i = 0; i < 6; i++) {
                     configDataCell(sxssfWorkbook,header5.getCell(i));
                 }
@@ -1214,7 +1214,7 @@
                 configInfoCell(sxssfWorkbook,header6.getCell(i),HorizontalAlignment.LEFT);
             }
             header6.setHeight((short) 2000);
-            sheet.addMergedRegion(new CellRangeAddress(rowIndex ,rowIndex,0,7));
+            sheet.addMergedRegion(new CellRangeAddress(rowIndex ,rowIndex,0,5));
             Row header7= sheet.createRow(rowIndex+1);
             header7.setHeight((short) 3000);
             header7.createCell(0).setCellValue("鎶曚繚浼佷笟绛剧珷 锛�                            \n \n \n" +"鏃ユ湡锛�     骞�     鏈�     鏃�    ");
@@ -1224,7 +1224,7 @@
                 }
                 configInfoCell(sxssfWorkbook,header7.getCell(i),HorizontalAlignment.RIGHT);
             }
-            sheet.addMergedRegion(new CellRangeAddress(rowIndex+1 ,rowIndex+1,0,7));
+            sheet.addMergedRegion(new CellRangeAddress(rowIndex+1 ,rowIndex+1,0,5));
 
             //涓存椂缂撳啿鍖�
             ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/server/service/src/main/java/com/doumee/core/utils/Constants.java b/server/service/src/main/java/com/doumee/core/utils/Constants.java
index ee63490..cce057f 100644
--- a/server/service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -158,11 +158,16 @@
         int birthYear = Integer.parseInt(idCard.substring(6, 10));
         int birthMonth = Integer.parseInt(idCard.substring(10, 12));
         int birthDay = Integer.parseInt(idCard.substring(12, 14));
+        try{
+            LocalDate birthDate = LocalDate.of(birthYear, birthMonth, birthDay);
+            LocalDate currentDate = LocalDate.now();
+            long age = ChronoUnit.YEARS.between(birthDate, currentDate);
+            return age;
+        }catch (Exception e){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"韬唤璇佸彿鐮侀敊璇細"+idCard);
+        }
 
-        LocalDate birthDate = LocalDate.of(birthYear, birthMonth, birthDay);
-        LocalDate currentDate = LocalDate.now();
-        long age = ChronoUnit.YEARS.between(birthDate, currentDate);
-        return age;
+
     }
 
 
@@ -450,6 +455,7 @@
         COMPANY_TBD_SIGNED_PDF(22, "鍚堝苟鍗�-鎶曚繚鍗�-鍟嗘埛鎻愪氦锛堜紒涓氱缃诧級PDF", "鍚堝苟鍗�-鎶曚繚鍗�-鍟嗘埛鎻愪氦锛堜紒涓氱缃诧級PDF"),
         WTB_CA_DONE_PDF(23, "濮旀墭鍔犲噺淇�/鎹㈠巶涓氬姟 - 鍚堝苟鍗曟渶缁堜繚鍗�", "濮旀墭鍔犲噺淇�/鎹㈠巶涓氬姟 - 鍚堝苟鍗曟渶缁堜繚鍗�"),
         WTB_CONFIRMATION_LATTER(24, "濮旀墭淇� - 鎶曚繚鏂规纭涔�", "濮旀墭淇� - 鎶曚繚鏂规纭涔�"),
+        WTB_CA_TBD_PDF(25, "濮旀墭鍔犲噺淇�/鎹㈠巶涓氬姟 -鎶曚繚鍗曪紙浼佷笟绛剧讲鍚嶱DF锛�", "濮旀墭鍔犲噺淇�/鎹㈠巶涓氬姟 -鎶曚繚鍗曪紙浼佷笟绛剧讲鍚嶱DF锛�"),
         ;
         // 鎴愬憳鍙橀噺
         private String name;
@@ -793,16 +799,24 @@
 
 
         /**
-         * 濮旀墭淇濆悎骞跺崟
+         * 濮旀墭淇� 鎶曚繚鍗曞悎骞跺崟鏃ュ織
          */
         IA_HBD_UPLOAD(32, "鎻愪氦鐢宠","",3),
         IA_HBD_UPLOAD_TBD(33, "涓婁紶鎶曚繚鍗�","",3),
-        IA_HBD_SIGNATURE_TBD(34, "绛剧讲鎶曚繚鍗�","",3),
-        IA_HBD_UPLOAD_INSURANCE(35, "涓婁紶淇濋櫓鍗�","淇濋櫓鐢熸晥璧锋湡锛�${param1}鍙樻洿涓�${param2}",3),
+        IA_HBD_SIGNATURE_TBD(34, "鍟嗘埛绛剧珷","",3),
+        IA_HBD_UPLOAD_INSURANCE(35, "鎶曚繚瀹屾垚","淇濋櫓鐢熸晥璧锋湡锛�${param1}鍙樻洿涓�${param2}",3),
         IA_HBD_CLOSE(36, "閫�鍥炵敵璇�","鍘熷洜锛�${param}",3),
 
 
 
+        /**
+         * 濮旀墭淇� 鍔犲噺淇�/鎹㈠巶 鍚堝苟鍗�
+         */
+        CA_HBD_UPLOAD(37, "鎻愪氦鐢宠","",4),
+        CA_HBD_SIGNATURE_TBD(38, "鍟嗘埛绛剧珷","",4),
+        CA_HBD_UPLOAD_INSURANCE(39, "鎶曚繚瀹屾垚","",4),
+        CA_HBD_CLOSE(40, "閫�鍥炵敵璇�","鍘熷洜锛�${param}",4),
+
 
 
 
diff --git a/server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java b/server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java
index 5b0f624..087b3ae 100644
--- a/server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java
+++ b/server/service/src/main/java/com/doumee/dao/business/model/ApplyLog.java
@@ -63,6 +63,19 @@
         this.afterContent=after;
     }
 
+    public ApplyLog(UnionChange apply,String title,String content,Integer objId,Integer objType, String before,String after){
+        this.title =title;
+        this.content=content;
+        this.applyId = apply.getId();
+        this.createDate =apply.getEditDate();
+        this.creator =apply.getEditor();
+        this.status = apply.getStatus();
+        this.objId=objId;
+        this.objType = objType;
+        this.beforeContent=before;
+        this.afterContent=after;
+    }
+
 
     @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "涓婚敭", example = "1")
diff --git a/server/service/src/main/java/com/doumee/service/business/UnionChangeService.java b/server/service/src/main/java/com/doumee/service/business/UnionChangeService.java
index ed1c9e3..8cb039d 100644
--- a/server/service/src/main/java/com/doumee/service/business/UnionChangeService.java
+++ b/server/service/src/main/java/com/doumee/service/business/UnionChangeService.java
@@ -2,6 +2,7 @@
 
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.dao.business.dto.CloseDTO;
 import com.doumee.dao.business.dto.SaveUnionChangeDTO;
 import com.doumee.dao.business.dto.SmsCheckDTO;
 import com.doumee.dao.business.dto.UnionChangeBXDDTO;
@@ -107,9 +108,9 @@
 
     /**
      * 鍏抽棴 鍚堝苟鍗曪紙鍔犲噺淇�/鎹㈠巶鍗曪級
-     * @param id
+     * @param closeDTO
      */
-    void cancelMerge(Integer id);
+    void cancelMerge(CloseDTO closeDTO);
 
 
     /**
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
index 7ab518f..4cfc6f0 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -103,6 +103,8 @@
     private NoticesMapper noticesMapper;
     @Autowired
     private UnionApplyJoinMapper unionApplyJoinMapper;
+    @Autowired
+    private UnionChangeJoinMapper unionChangeJoinMapper;
 
     @Override
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
@@ -751,15 +753,6 @@
         update.setId(model.getId());
         unionApplyJoinMapper.updateById(update);
 
-        //瀛樺偍寰呭姙淇℃伅
-//        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
-//        //鍒犻櫎鍏朵粬寰呭姙
-//        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey())
-//                .ne(Notices::getType,Constants.NoticeType.SIX.getStatus())
-//                .eq(Notices::getObjId,model.getId()));
-//        Notices notices = new Notices(noticeObjectType,Constants.ZERO,model.getId(),model.getSolutionsName(),model.getCompanyId(),Constants.NoticeType.TWO);
-//        noticesMapper.insert(notices);
-
         Multifile f = new Multifile();
         f.setIsdeleted(Constants.ZERO);
         f.setCreator(model.getCreator());
@@ -772,14 +765,45 @@
         f.setInfo("鍟嗘埛绛剧讲鎶曚繚鍗�");
         f.setName("鍟嗘埛绛剧讲鎶曚繚鍗�.pdf");
         multifileMapper.insert(f);
-//        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.SIGNATURE;
-//        ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
-//        applyLogMapper.insert(log);
-//
-//        startSendEmail(f, model.getCompanyName(),model.getSolutionsName(),model.getSolutionEmail());
-
 
         Constants.ApplyLogType applyLogType = Constants.ApplyLogType.IA_HBD_SIGNATURE_TBD;
+        ApplyLog log = new ApplyLog(model,applyLogType.getName(), null
+                ,model.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(model));
+        applyLogMapper.insert(log);
+
+        return  f;
+    }
+
+
+    /**
+     * 鍟嗘埛鍚堝苟鍗�(鍔犲噺淇�/鎹㈠巶) 鍟嗘埛绛剧讲鎶曚繚鐢宠鍗�
+     * @param model
+     * @param fileurl
+     * @param fullUrl
+     * @return
+     */
+    public Multifile   uploadUnionChangeSignedFileDo(UnionChange model,String fileurl,String fullUrl) {
+        UnionChange update = new UnionChange();
+        update.setEditDate(new Date());
+        update.setEditor(model.getCreator());
+        update.setStatus(Constants.UnionChangeStatus.UPLOAD_INSURANCE_POLICY.getKey());
+        update.setId(model.getId());
+        unionChangeJoinMapper.updateById(update);
+
+        Multifile f = new Multifile();
+        f.setIsdeleted(Constants.ZERO);
+        f.setCreator(model.getCreator());
+        f.setObjId(update.getId());
+        f.setCreateDate(update.getEditDate());
+        f.setObjType(Constants.MultiFile.WTB_CA_TBD_PDF.getKey());
+        f.setType(Constants.TWO);
+        f.setFileurl(fileurl);
+        f.setFileurlFull(fullUrl);
+        f.setInfo("濮旀墭鍔犲噺淇�/鎹㈠巶涓氬姟 -鎶曚繚鍗�");
+        f.setName("濮旀墭鍔犲噺淇�/鎹㈠巶涓氬姟 -鎶曚繚鍗�.pdf");
+        multifileMapper.insert(f);
+
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_SIGNATURE_TBD;
         ApplyLog log = new ApplyLog(model,applyLogType.getName(), null
                 ,model.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(model));
         applyLogMapper.insert(log);
@@ -1012,11 +1036,32 @@
                     continue;
                 }
                 uploadUnionApplySignedFileDo(model,fileUrl,path+fileUrl);
-//                return;
             }
         }
 
-
+        /**
+         *鍚堝苟鍔犲噺淇濇崲鍘� 绛剧讲涓氬姟
+         */
+        List<UnionChange> unionChangeList = unionChangeJoinMapper.selectJoinList(UnionChange.class,
+                new MPJLambdaWrapper<UnionChange>()
+                        .selectAll(UnionChange.class)
+                        .eq(UnionChange::getStatus,Constants.UnionChangeStatus.MERGE.getKey())
+                        .isNotNull(UnionChange::getSignApplyNo));
+        if(unionChangeList !=null && unionChangeList.size()>0 ){
+            for(UnionChange model : unionChangeList){
+                String status = signService.linkFileStatus(model.getSignApplyNo());
+                if(!StringUtils.equals(status,"3")){
+                    continue;
+                }
+                String link = signService.linkFile(model.getSignApplyNo());
+                String fileUrl = uploadSignFile(link);
+                if(StringUtils.isBlank(fileUrl)){
+                    //濡傛灉涓嬭浇澶辫触锛屾竻闄ゅ悎鍚岋紝涓嬫绛剧珷閲嶆柊鐢熸垚鏂板悎鍚�
+                    continue;
+                }
+                uploadUnionChangeSignedFileDo(model,fileUrl,path+fileUrl);
+            }
+        }
 
 
 
@@ -1187,6 +1232,27 @@
                 }
                 uploadUnionApplySignedFileDo(unionApply,fileUrl,path+fileUrl);
             }
+
+
+            /**
+             *鍚堝苟鍔犲噺淇濇崲鍘� 绛剧讲涓氬姟
+             */
+            UnionChange unionChange = unionChangeJoinMapper.selectOne(
+                    new MPJLambdaWrapper<UnionChange>()
+                            .selectAll(UnionChange.class)
+                            .eq(UnionChange::getSignApplyNo,data.getApplyNo())
+                            .last(" limit 1 "));
+            if(unionChange != null &&Constants.equalsInteger(unionChange.getStatus(),Constants.UnionChangeStatus.MERGE.getKey())){
+                String link = signService.linkFile(model.getSignApplyNo());
+                String fileUrl = uploadSignFile(link);
+                if(StringUtils.isBlank(fileUrl)){
+                    //濡傛灉涓嬭浇澶辫触锛屾竻闄ゅ悎鍚岋紝涓嬫绛剧珷閲嶆柊鐢熸垚鏂板悎鍚�
+                    return;
+                }
+                uploadUnionChangeSignedFileDo(unionChange,fileUrl,path+fileUrl);
+            }
+
+
         }else if(Constants.equalsInteger(data.getSignStatus(), Constants.TWO )){
             //濡傛灉宸叉嫆绛撅紝娓呴櫎鍚堝悓锛屼笅娆$绔犻噸鏂扮敓鎴愭柊鍚堝悓
             insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
@@ -1207,6 +1273,9 @@
             applyChangeMapper.update(null,new UpdateWrapper<ApplyChange>().lambda()
                     .set(ApplyChange::getSignMemberListNo,null)
                     .eq(ApplyChange::getSignMemberListNo,data.getApplyNo()));
+            unionChangeJoinMapper.update(null,new UpdateWrapper<UnionChange>().lambda()
+                    .set(UnionChange::getSignApplyNo,null)
+                    .eq(UnionChange::getSignApplyNo,data.getApplyNo()));
         }
     }
 
@@ -2185,11 +2254,11 @@
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱鐢ㄦ埛鏃犳硶杩涜璇ユ搷浣�");
         }
         MPJLambdaWrapper<ApplyDetail> lambdaWrapper = new MPJLambdaWrapper<ApplyDetail>();
-        lambdaWrapper.selectAll(Member.class)
+        lambdaWrapper.select(ApplyDetail::getId)
                 .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                 .and(i->i.eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()).or().eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey()))
                 .eq(InsuranceApply::getCompanyId,loginUserInfo.getCompanyId())
-                .apply(" now() betwwen t.START_TIME and t.END_TIME ");
+                .apply(" now() between t.START_TIME and t.END_TIME ");
 
          Integer count = applyDetailJoinMapper.selectJoinCount(lambdaWrapper);
         return count;
@@ -2378,7 +2447,7 @@
                 .leftJoin(Worktype.class,Worktype::getId,ApplyDetail::getWorktypeId)
                 .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId)
                 .isNull(ApplyDetail::getFromId)
-                .eq(ApplyDetail::getId,model.getId())
+                .eq(ApplyDetail::getApplyId,model.getId())
         );
         model.setApplyDetailList(applyDetailList);
         return model;
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
index b37246d..da340b8 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -414,6 +414,8 @@
         UnionApply unionApply = new UnionApply();
         unionApply.setCreateDate(new Date());
         unionApply.setCreator(user.getId());
+        unionApply.setEditor(user.getId());
+        unionApply.setEditDate(new Date());
         unionApply.setCompanyId(user.getCompanyId());
         unionApply.setStartTime(saveUnionApplyDTO.getStartDate());
         unionApply.setEndTime(saveUnionApplyDTO.getEndDate());
@@ -470,7 +472,9 @@
         if(!user.getType().equals(Constants.TWO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
         }
-        if(Objects.isNull(closeDTO)||Objects.isNull(closeDTO.getId())){
+        if(Objects.isNull(closeDTO)
+                ||Objects.isNull(closeDTO.getId())
+                ||StringUtils.isBlank(closeDTO.getReason())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         UnionApply unionApply = unionApplyMapper.selectById(closeDTO.getId());
@@ -489,15 +493,24 @@
         //鍚堝苟鍗曠姸鎬佸浜庡緟鎶曚繚
         if(unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())
         || unionApply.getStatus().equals(Constants.UnionApplyStatus.WAIT_SIGNATURE.getKey())){
-            //TODO 鍒犻櫎浼佷笟鎶曚繚鍗曠殑 绛剧讲鏁版嵁
-
+            multifileMapper.delete(new QueryWrapper<Multifile>()
+                    .lambda()
+                    .apply(" multifile.id in ( select i.id  from insurance_apply i where i.UNION_APPLY_ID = "+unionApply.getId()+" ) ")
+                    .eq(Multifile::getObjType,Constants.MultiFile.COMPANY_TBD_SIGNED.getKey()));
         }
         insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
                 .set(InsuranceApply::getUnionApplyId,null)
                 .set(InsuranceApply::getCheckDate,new Date())
+                .set(unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())
+                        || unionApply.getStatus().equals(Constants.UnionApplyStatus.WAIT_SIGNATURE.getKey()),
+                        InsuranceApply::getUnionApplyTbdStatus,Constants.ZERO)
+                .set(unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())
+                        || unionApply.getStatus().equals(Constants.UnionApplyStatus.WAIT_SIGNATURE.getKey()),
+                        InsuranceApply::getApplyTbdNo,null)
                 .set(InsuranceApply::getCheckUserId,user.getId())
                 .set(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_BUSINESS_CHECK_PASS.getKey())
-                .eq(InsuranceApply::getUnionApplyId,unionApply.getId()));
+                .eq(InsuranceApply::getUnionApplyId,unionApply.getId())
+        );
 
         applyDetailJoinMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda()
                 .set(ApplyDetail::getUnionApplyId,null)
@@ -516,8 +529,6 @@
         info = info.replace("${param}", closeDTO.getReason());
         ApplyLog log = new ApplyLog(unionApply,applyLogType.getName(), info
                 ,unionApply.getId(),applyLogType.getKey(),null, null);
-        applyLogMapper.insert(log);
-
         applyLogMapper.insert(log);
     }
 
@@ -799,7 +810,7 @@
                 .set(UnionApply::getCurrentFee,sumCurrFee)
                 .eq(UnionApply::getId,unionApply.getId())
         );
-        //鍚堝苟鍗� 鎬讳繚鍗�
+        //鍚堝苟鍗� 鏂囦欢
         if(StringUtils.isNotBlank(unionApplyBXDDTO.getFileUrl())){
             Multifile multifile = new Multifile();
             multifile.setIsdeleted(Constants.ZERO);
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
index d113bb0..6f9436a 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -1,5 +1,6 @@
 package com.doumee.service.business.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.annotation.excel.ExcelExporter;
 import com.doumee.core.constants.ResponseStatus;
@@ -11,10 +12,7 @@
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.*;
-import com.doumee.dao.business.dto.SaveUnionApplyDTO;
-import com.doumee.dao.business.dto.SaveUnionChangeDTO;
-import com.doumee.dao.business.dto.SmsCheckDTO;
-import com.doumee.dao.business.dto.UnionChangeBXDDTO;
+import com.doumee.dao.business.dto.*;
 import com.doumee.dao.business.join.*;
 import com.doumee.dao.business.model.*;
 import com.doumee.dao.business.vo.CountCyclePriceVO;
@@ -92,6 +90,8 @@
     @Autowired
     private MultifileMapper multifileMapper;
 
+    @Autowired
+    private ApplyLogMapper applyLogMapper;
     @Override
     public Integer create(UnionChange unionChange) {
         unionChangeMapper.insert(unionChange);
@@ -320,6 +320,13 @@
         applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                 .set(ApplyChagneDetail::getUnionChangeId,unionChange.getId())
                 .in(ApplyChagneDetail::getApplyId,saveUnionChangeDTO.getApplyIds()));
+
+
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
+        ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), null
+                ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
+        applyLogMapper.insert(log);
+
         return unionChange.getId();
     }
 
@@ -330,16 +337,21 @@
 
     /**
      * 鍙栨秷淇濆崟鍚堝苟
-     * @param id
+     * @param closeDTO
      */
     @Override
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
-    public void cancelMerge(Integer id){
+    public void cancelMerge(CloseDTO closeDTO){
+        if(Objects.isNull(closeDTO)
+                ||Objects.isNull(closeDTO.getId())
+                ||StringUtils.isBlank(closeDTO.getReason())){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         if(user.getType().equals(Constants.TWO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
         }
-        UnionChange unionChange = unionChangeMapper.selectById(id);
+        UnionChange unionChange = unionChangeMapper.selectById(closeDTO.getId());
         if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
@@ -368,6 +380,14 @@
                 .set(UnionChange::getStatus,Constants.UnionApplyStatus.CLOSE.getKey())
                 .eq(UnionChange::getId,unionChange.getId())
         );
+
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
+        String info =applyLogType.getInfo();
+        info = info.replace("${param}", closeDTO.getReason());
+        ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), info
+                ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
+        applyLogMapper.insert(log);
+
     }
 
 
@@ -589,6 +609,12 @@
                 .set(UnionChange::getEditor,user.getId())
                 .eq(UnionChange::getId,unionChangeBXDDTO.getId())
         );
+
+
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD_INSURANCE;
+        ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), null
+                ,unionChange.getId(),applyLogType.getKey(),null, JSONObject.toJSONString(unionChange));
+        applyLogMapper.insert(log);
     }
 
 
diff --git a/server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java b/server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java
index 01480f7..53c3996 100644
--- a/server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java
+++ b/server/shop/src/main/java/com/doumee/api/business/UnionChangeController.java
@@ -6,6 +6,7 @@
 import com.doumee.core.model.ApiResponse;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.dao.business.dto.CloseDTO;
 import com.doumee.dao.business.dto.SaveUnionChangeDTO;
 import com.doumee.dao.business.dto.SmsCheckDTO;
 import com.doumee.dao.business.dto.UnionChangeBXDDTO;
@@ -101,10 +102,10 @@
 
 
     @ApiOperation("鍏抽棴鍚堝苟鍗�")
-    @GetMapping("/close")
+    @PostMapping("/close")
     @RequiresPermissions("business:unionchange:close")
-    public ApiResponse close(@RequestParam Integer id) {
-        unionChangeService.cancelMerge(id);
+    public ApiResponse close(@RequestBody CloseDTO closeDTO) {
+        unionChangeService.cancelMerge(closeDTO);
         return ApiResponse.success(null);
     }
 

--
Gitblit v1.9.3