From a7d11031939ddb31a11f62e4a48b4a068b6e7db4 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 01 四月 2024 19:38:50 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java |  196 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 162 insertions(+), 34 deletions(-)

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..59661ba 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()));
         }
     }
 
@@ -1863,9 +1932,13 @@
         queryWrapper.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId);
         queryWrapper.leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId);
         queryWrapper.eq(InsuranceApply::getIsdeleted,Constants.ZERO);
+        queryWrapper.eq(model.getUnionApplyId()!=null,InsuranceApply::getUnionApplyId, model.getUnionApplyId());
         //浼佷笟浜哄憳鏌ョ湅鏈紒涓氭暟鎹�
         if(loginUserInfo.getType().equals(Constants.ONE)){
             queryWrapper.eq(InsuranceApply::getCompanyId, loginUserInfo.getCompanyId());
+        }else if(loginUserInfo.getType().equals(Constants.TWO)){
+            //濡傛灉鏄晢瀹舵煡鐪�
+            queryWrapper.eq(Solutions::getShopId, loginUserInfo.getCompanyId());
         }else{
             if(loginUserInfo.getCompanyIdList()!=null && loginUserInfo.getCompanyIdList().size()>0){
                 queryWrapper.in(InsuranceApply::getCompanyId, loginUserInfo.getCompanyIdList());
@@ -1916,7 +1989,62 @@
             queryWrapper.ge(InsuranceApply::getEndTime,DateUtil.DateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
         }
         List<InsuranceApply> list = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class, queryWrapper);
+        if(Constants.equalsObject(model.getGetFiles(),Constants.ONE)){
+            //濡傛灉鏄悎骞跺崟,闇�瑕佹煡璇㈤檮浠朵俊鎭�
+            initFileForList(list);
+        }
         return list;
+    }
+
+    private void initFileForList(List<InsuranceApply> list) {
+        List<Integer> objList =  new ArrayList<>();
+        if(list!=null && list.size()>0){
+            for(InsuranceApply param : list){
+                objList.get(param.getId());
+            }
+        }else{
+            return;
+        }
+        List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
+                .in(Multifile::getObjId,objList)
+                .in(Multifile::getObjType,Arrays.asList(new Integer[]{Constants.MultiFile.BD_APPLY_PDF.getKey()
+                        ,Constants.MultiFile.BD_SIGNED_PDF.getKey()
+                        ,Constants.MultiFile.WTB_CONFIRMATION_LATTER.getKey()
+                        ,Constants.MultiFile.MEMBER_LIST_LATTER.getKey()
+                        ,Constants.MultiFile.BD_DONE_PDF.getKey()}))
+                .eq(Multifile::getIsdeleted,Constants.ZERO)
+                .orderByAsc(Multifile::getId));
+        if(multifiles!=null && multifiles.size()>0){
+            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
+                    +systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
+                for(InsuranceApply model : list){
+                    for(Multifile f : multifiles) {
+                        if (StringUtils.isBlank(f.getFileurl())) {
+                            continue;
+                        }
+                        f.setFileurlFull(path+f.getFileurl());
+                        if(Constants.equalsInteger(f.getObjId(), model.getId()) ){
+                            if (Constants.equalsInteger(f.getObjType(), Constants.MultiFile.BD_APPLY_PDF.getKey())) {
+                                //绛剧讲鍓嶇殑鎶曚繚鍗�
+                                model.setToubaodanFile(f);
+                            } else if (Constants.equalsInteger(f.getObjType(), Constants.MultiFile.BD_SIGNED_PDF.getKey())) {
+                                //绛剧讲鍚庣殑鎶曚繚鍗�
+                                model.setToubaodanSignedFile(f);
+                            } else if (Constants.equalsInteger(f.getObjType(), Constants.MultiFile.BD_DONE_PDF.getKey())) {
+                                //鏈�绲備繚闄╁崟
+                                model.setBaoxiandanFile(f);
+                            } else if (Constants.equalsInteger(f.getObjType(), Constants.MultiFile.MEMBER_LIST_LATTER.getKey())) {
+                                //鐢宠鍗�
+                                model.setShenqingdanFile(f);
+                            } else if (Constants.equalsInteger(f.getObjType(), Constants.MultiFile.WTB_CONFIRMATION_LATTER.getKey())) {
+                                //绛剧讲鍚庣‘璁や功
+                                model.setFanganFile(f);
+                            }
+                        }
+                    }
+                }
+        }
+
     }
 
 
@@ -2185,11 +2313,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;
@@ -2202,11 +2330,12 @@
      * 鏇存柊淇濆崟瀹為檯閲戦
      */
     @Override
-    @Transactional(rollbackFor = {Exception.class})
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
     public void updateApplyCurrentFee(Integer id){
-        List<InsuranceApply> insuranceApplyList = insuranceApplyMapper.selectList(new QueryWrapper<InsuranceApply>().lambda()
+        List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class,new MPJLambdaWrapper<InsuranceApply>()
+                .selectAll(InsuranceApply.class)
                 .eq(InsuranceApply::getIsdeleted,Constants.ZERO)
-                .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())
+                .in(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey(),Constants.InsuranceApplyStatus.WTB_TOUBAOING.getKey())
                 .eq(!Objects.isNull(id),InsuranceApply::getId,id)
                 .le(InsuranceApply::getStartTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 00:00:00")
                 .ge(InsuranceApply::getEndTime,DateUtil.getDate(new Date(),"yyyy-MM-dd") + " 23:59:59")
@@ -2214,20 +2343,23 @@
 
         if(CollectionUtils.isNotEmpty(insuranceApplyList)){
             for (InsuranceApply insuranceApply:insuranceApplyList) {
-                Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
-                if(Objects.isNull(solutions)){
-                    continue;
-                }
+//                Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
+//                if(Objects.isNull(solutions)){
+//                    continue;
+//                }
                 BigDecimal sumAmount = BigDecimal.ZERO;
-                List<ApplyDetail> applyDetailList = applyDetailMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId()));
+                List<ApplyDetail> applyDetailList = applyDetailMapper
+                        .selectList(new QueryWrapper<ApplyDetail>().lambda()
+                                .eq(ApplyDetail::getApplyId,insuranceApply.getId()));
                 if(CollectionUtils.isNotEmpty(applyDetailList)){
                     for (ApplyDetail applyDetail: applyDetailList) {
                         //2024-1-30 10:04:24 淇敼 鏍规嵁瀹為檯澶╂暟杩涜璁$畻 褰撳墠璐圭敤  鎬婚噾棰�/鎬诲ぉ鏁�*瀹為檯澶╂暟
-                        Integer maxDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0);
+//                        Integer maxDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0);
                         BigDecimal fee = applyDetail.getFee();
                         if(applyDetail.getStartTime().compareTo(new Date()) <= 0 && applyDetail.getEndTime().compareTo(new Date()) >= 0 ){
                             Integer days =  DateUtil.calculateBetween(applyDetail.getStartTime(),new Date(),0);
-                            applyDetail.setCurrentFee(fee.divide(BigDecimal.valueOf(maxDays),2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(days)));
+                            applyDetail.setCurrentFee(new BigDecimal(days).multiply(applyDetail.getPrice()));
+                            //applyDetail.setCurrentFee(fee.divide(BigDecimal.valueOf(maxDays),2, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(days)));
                             applyDetailMapper.updateById(applyDetail);
                         }else if(applyDetail.getStartTime().compareTo(new Date()) <= 0&&applyDetail.getEndTime().compareTo(new Date()) <= 0){
                             applyDetail.setCurrentFee(fee);
@@ -2240,10 +2372,6 @@
                 insuranceApplyMapper.updateById(insuranceApply);
             }
         }
-//        if(1==1){
-//            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
-//        }
-
     }
 
 
@@ -2378,7 +2506,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;

--
Gitblit v1.9.3