From 626630050b7a66288872ccba387f56dbaa6b5f09 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期日, 07 四月 2024 09:24:54 +0800
Subject: [PATCH] 提交一把

---
 server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java |   90 +++++++++++++++++++++++++++++++++------------
 1 files changed, 66 insertions(+), 24 deletions(-)

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 59baf20..d491222 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
@@ -154,7 +154,7 @@
                 .selectAs(Company::getName,UnionChange::getShopName)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 0  )",UnionChange::getAddNum)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 1  )",UnionChange::getDelNum)
-                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 2  )",UnionChange::getChangeNum)
+                .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 2  )",UnionChange::getChangeNum).select("( select ifnull(sum(ac.FEE),0) from apply_change ac where t.id = ac.UNION_CHANGE_ID  )",UnionChange::getFee)
                 .leftJoin(UnionApply.class,UnionApply::getId,UnionChange::getUnionApplyId)
                 .leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId)
                 .leftJoin(Company.class,Company::getId,UnionChange::getShopId)
@@ -172,15 +172,40 @@
                             .selectAs(SystemUser::getType,ApplyLog::getCreatorType)
                             .leftJoin(SystemUser.class,SystemUser::getId,ApplyLog::getCreator)
                             .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId)
-                            .in(ApplyLog::getObjType,Constants.ApplyLogType.getTypeList(Constants.THREE))
+                            .in(ApplyLog::getObjType,Constants.ApplyLogType.getTypeList(Constants.FOUR))
                             .eq(ApplyLog::getApplyId,unionChange.getId())
                             .orderByAsc(ApplyLog::getCreateDate)
             );
             unionChange.setApplyLogList(applyLogList);
         }
+        initFiles(unionChange);
         return unionChange;
     }
 
+    private void initFiles(UnionChange unionChange) {
+        List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
+                .eq(Multifile::getObjId, unionChange.getId() )
+                .in(Multifile::getObjType, Arrays.asList(new Integer[]{Constants.MultiFile.WTB_CA_TBD_PDF.getKey(),Constants.MultiFile.WTB_CA_DONE_PDF.getKey()}))
+                .eq(Multifile::getIsdeleted,Constants.ZERO));
+        if(multifiles!=null){
+            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
+                    +systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
+            for(Multifile f : multifiles){
+                if(StringUtils.isBlank(f.getFileurl())){
+                    continue;
+                }
+                f.setFileurlFull(path+f.getFileurl());
+                if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.WTB_CA_TBD_PDF.getKey())){
+                    //绛剧讲鍚庣敵璇峰崟
+                    unionChange.setApplyFile(f);
+                }
+                if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.WTB_CA_DONE_PDF.getKey())){
+                    //绛剧讲鍚庣敵璇峰崟
+                    unionChange.setPidanFile(f);
+                }
+            }
+        }
+    }
 
 
     @Override
@@ -200,6 +225,7 @@
         IPage<UnionChange> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
         MPJLambdaWrapper<UnionChange> queryWrapper = new MPJLambdaWrapper<>();
         queryWrapper.selectAll(UnionChange.class);
+        pageWrap.getModel().setIsdeleted(Constants.ZERO);
         queryWrapper.selectAs(UnionApply::getCode,UnionChange::getApplyCode);
         queryWrapper.selectAs(Solutions::getName,UnionChange::getSolutionsName)
         .select("( select count(1) from apply_chagne_detail ad where t.id = ad.UNION_CHANGE_ID and ad.TYPE = 0  )",UnionChange::getAddNum)
@@ -209,7 +235,7 @@
         queryWrapper.leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId);
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         if(Constants.equalsInteger(user.getType(),Constants.TWO)){
-            queryWrapper.eq(UnionChange::getShopId, pageWrap.getModel().getShopId());
+            queryWrapper.eq(UnionChange::getShopId, user.getCompanyId());
         }
         Utils.MP.blankToNull(pageWrap.getModel());
         if (pageWrap.getModel().getId() != null) {
@@ -292,6 +318,7 @@
 
 
     @Override
+    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     public Integer merge(SaveUnionChangeDTO saveUnionChangeDTO){
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         if(!user.getType().equals(Constants.TWO)){
@@ -312,7 +339,7 @@
                         .eq(ApplyChange::getIsdeleted, Constants.ZERO)
                         .eq(InsuranceApply::getUnionApplyId,saveUnionChangeDTO.getUnionApplyId())
                         .eq(ApplyChange::getStatus,Constants.ApplyChangeStatus.CHECHED_PASSED.getKey())
-                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())
+                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey())
                         .eq(ApplyChange::getType,saveUnionChangeDTO.getBusinessType())
                         .in(ApplyChange::getId,saveUnionChangeDTO.getApplyIds())
                         .isNull(ApplyChange::getUnionChangeId)
@@ -326,6 +353,7 @@
         unionChange.setCreateDate(new Date());
         unionChange.setCreator(user.getId());
         unionChange.setShopId(user.getCompanyId());
+        unionChange.setIsdeleted(Constants.ZERO);
         unionChange.setUnionApplyId(saveUnionChangeDTO.getUnionApplyId());
         unionChange.setApplyStartTime(saveUnionChangeDTO.getApplyDate());
         unionChange.setType(saveUnionChangeDTO.getBusinessType());
@@ -342,7 +370,7 @@
 
         applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                 .set(ApplyChagneDetail::getUnionChangeId,unionChange.getId())
-                .in(ApplyChagneDetail::getApplyId,saveUnionChangeDTO.getApplyIds()));
+                .in(ApplyChagneDetail::getApplyChangeId,saveUnionChangeDTO.getApplyIds()));
 
 
         Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
@@ -371,13 +399,16 @@
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-        if(user.getType().equals(Constants.TWO)){
+        user.setType(Constants.formatIntegerNum(user.getType()));
+        if(!user.getType().equals(Constants.TWO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
         }
         UnionChange unionChange = unionChangeMapper.selectById(closeDTO.getId());
         if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
+        unionChange.setStatus(Constants.formatIntegerNum(unionChange.getStatus()));
+        unionChange.setShopId(Constants.formatIntegerNum(unionChange.getShopId()));
         if(!unionChange.getShopId().equals(user.getCompanyId())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧烽潪鎮ㄧ殑鍚堝苟鍗曪紝鎮ㄦ棤娉曡繘琛屾搷浣滐紒");
         }
@@ -398,14 +429,14 @@
 
         applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                 .set(ApplyChagneDetail::getUnionChangeId,null)
-                .in(ApplyChagneDetail::getApplyId,unionChange.getId()));
+                .eq(ApplyChagneDetail::getUnionChangeId,unionChange.getId()));
 
         unionChangeMapper.update(null,new UpdateWrapper<UnionChange>().lambda()
-                .set(UnionChange::getStatus,Constants.UnionApplyStatus.CLOSE.getKey())
+                .set(UnionChange::getStatus,Constants.UnionChangeStatus.CLOSE.getKey())
                 .eq(UnionChange::getId,unionChange.getId())
         );
 
-        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
+        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_CLOSE;
         String info =applyLogType.getInfo();
         info = info.replace("${param}", closeDTO.getReason());
         ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), info
@@ -415,8 +446,11 @@
     }
 
 
+    @Override
     public UnionChange unionChangeDetail(Integer unionChangeId){
-
+        if(Objects.isNull(unionChangeId)){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
         UnionChange unionChange = unionChangeJoinMapper.selectJoinOne(UnionChange.class,
                 new MPJLambdaWrapper<UnionChange>()
                         .selectAll(UnionChange.class)
@@ -433,8 +467,10 @@
         );
         //浼佷笟鍚嶇О
         List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,new MPJLambdaWrapper<ApplyChange>()
+                .selectAll(ApplyChange.class)
                 .selectAs(Company::getName,ApplyChange::getCompanyName)
-                .leftJoin(Company.class,Company::getId,ApplyChange::getCompanyId)
+                .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId)
+                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                 .eq(ApplyChange::getUnionChangeId,unionChangeId)
         );
 
@@ -486,6 +522,7 @@
         }
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         UnionChange unionChange = this.unionChangeDetail(smsCheckDTO.getBusinessId());
+        unionChange.setStatus(Constants.formatIntegerNum(unionChange.getStatus()));
         if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
@@ -498,7 +535,7 @@
         if(unionChange.getStatus().equals(Constants.UnionChangeStatus.CLOSE.getKey())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝鍚堝苟鍗曚笟鍔″凡鍏抽棴");
         }
-        if(unionChange.getStatus().equals(Constants.UnionChangeStatus.MERGE.getKey())){
+        if(!unionChange.getStatus().equals(Constants.UnionChangeStatus.MERGE.getKey())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝鍚堝苟鍗曠姸鎬佸凡娴佽浆");
         }
         Company company =  companyMapper.selectById(user.getCompanyId());
@@ -551,6 +588,8 @@
         if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
+        unionChange.setStatus(Constants.formatIntegerNum(unionChange.getStatus()));
+        unionChange.setShopId(Constants.formatIntegerNum(unionChange.getShopId()));
         if(!unionChange.getShopId().equals(user.getCompanyId())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧烽潪鎮ㄧ殑鍚堝苟鍗曪紝鎮ㄦ棤娉曡繘琛屾搷浣滐紒");
         }
@@ -560,7 +599,7 @@
         if(unionChange.getStatus().equals(Constants.UnionChangeStatus.CLOSE.getKey())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝鍚堝苟鍗曚笟鍔″凡鍏抽棴");
         }
-        if(unionChange.getStatus().equals(Constants.UnionChangeStatus.UPLOAD_INSURANCE_POLICY.getKey())){
+        if(!unionChange.getStatus().equals(Constants.UnionChangeStatus.UPLOAD_INSURANCE_POLICY.getKey())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝鍚堝苟鍗曠姸鎬佸凡娴佽浆");
         }
 
@@ -600,19 +639,17 @@
                         ||StringUtils.isBlank(m.getFileurl())
                         ||StringUtils.isBlank(m.getName())
                 ){
-                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍔犲噺淇�/鎹㈠巶涓氬姟鎵瑰崟鏂囦欢淇℃伅缂哄け");
+                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎵瑰崟鏂囦欢淇℃伅缂哄け");
                 }
-                multifile.setIsdeleted(Constants.ZERO);
-                multifile.setCreator(user.getId());
-                multifile.setCreateDate(new Date());
-                multifile.setCreateDate(new Date());
-                multifile.setObjType(Constants.MultiFile.CA_PD_PDF.getKey());
-                multifile.setType(Constants.TWO);
-                multifileMapper.insert(multifile);
+                m.setId(null);
+                m.setIsdeleted(Constants.ZERO);
+                m.setCreator(user.getId());
+                m.setCreateDate(new Date());
+                m.setObjType(Constants.MultiFile.CA_PD_PDF.getKey());
+                m.setType(Constants.TWO);
+                multifileMapper.insert(m);
             }
         }
-
-
         if(CollectionUtils.isNotEmpty(applyChangeList)){
             for (ApplyChange applyChange:applyChangeList) {
                 applyChange.setApplyStartTime(unionChangeBXDDTO.getApplyDate());
@@ -620,7 +657,12 @@
                 applyChange.setEditDate(new Date());
                 applyChange.setEditor(user.getId());
                 applyChange.setStatus(Constants.ApplyChangeStatus.APPROVE.getKey());
-                List<ApplyChagneDetail> allList = applyChagneDetailJoinMapper.selectList(new QueryWrapper<ApplyChagneDetail>().lambda().eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
+                List<ApplyChagneDetail> allList = applyChagneDetailJoinMapper.selectJoinList(ApplyChagneDetail.class,
+                        new MPJLambdaWrapper<ApplyChagneDetail>().selectAll(ApplyChagneDetail.class)
+                                .selectAs(Member::getName,ApplyChagneDetail::getMemberName )
+                                .selectAs(Member::getIdcardNo,ApplyChagneDetail::getIdcardNo )
+                                .leftJoin(Member.class,Member::getId,ApplyChagneDetail::getMemberId)
+                                .eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
                 this.dealApplyChangeDetail(applyChange,allList);
                 applyChange.setCode(unionChangeBXDDTO.getCode());
                 applyChange.setCheckUserId(user.getId());

--
Gitblit v1.9.3