From 39fb77e70bae8aa3289df71bcb04b78dc9f2ba8f Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期五, 29 三月 2024 10:15:30 +0800
Subject: [PATCH] 提交一把

---
 server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java |   81 ++++++++++++++++++++++++++++++----------
 1 files changed, 61 insertions(+), 20 deletions(-)

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 379f7bc..75b8f44 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
@@ -141,6 +141,12 @@
         IPage<UnionApply> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
         QueryWrapper<UnionApply> queryWrapper = new QueryWrapper<>();
         Utils.MP.blankToNull(pageWrap.getModel());
+
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if(user.getType().equals(Constants.TWO)){
+            queryWrapper.lambda().eq(UnionApply::getCompanyId, pageWrap.getModel().getCompanyId());
+        }
+
         if (pageWrap.getModel().getId() != null) {
             queryWrapper.lambda().eq(UnionApply::getId, pageWrap.getModel().getId());
         }
@@ -220,16 +226,35 @@
     }
 
 
+
     @Override
-    public void merge(SaveUnionApplyDTO saveUnionApplyDTO){
+    public UnionApply detail(Integer applyId){
+        UnionApply unionApply = unionApplyJoinMapper.selectJoinOne(UnionApply.class,
+                new MPJLambdaWrapper<UnionApply>()
+                        .selectAll(UnionApply.class)
+                        .selectAs(Solutions::getName,UnionApply::getSolutionName)
+                        .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.UNION_APPLY_ID = t.id ) as insureNum")
+                        .leftJoin(Solutions.class,Solutions::getId,UnionApply::getSolutionId)
+                        .eq(UnionApply::getId,applyId)
+                        .last(" limit 1 ")
+        );
+        return unionApply;
+    }
+
+
+
+
+    @Override
+    public Integer merge(SaveUnionApplyDTO saveUnionApplyDTO){
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-        if(user.getType().equals(Constants.TWO)){
+        if(!user.getType().equals(Constants.TWO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣�");
         }
         if(Objects.isNull(saveUnionApplyDTO)
             || Objects.isNull(saveUnionApplyDTO.getApplyIds())
             || Objects.isNull(saveUnionApplyDTO.getStartDate())
             || Objects.isNull(saveUnionApplyDTO.getEndDate())
+            || Objects.isNull(saveUnionApplyDTO.getBaseSolutionId())
         ){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
@@ -239,7 +264,7 @@
                         .selectAs(InsuranceApply::getSolutionBaseId,Solutions::getBaseId)
                         .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                         .eq(InsuranceApply::getIsdeleted, Constants.ZERO)
-                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey())
+                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.COMPANY_MEMBER_LIST_SIGNATURE.getKey())
                         .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId())
                         .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds())
                         .isNull(InsuranceApply::getUnionApplyId)
@@ -263,7 +288,6 @@
         Integer maxDays = DateUtil.calculateBetween(saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate(),0);
         List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getPrice)
                 .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds()));
-        //unionApply.setFee(insuranceApplyList.stream().map(i->i.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add));
         unionApply.setFee(applyDetailList.stream().map(i->i.getPrice().multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
         unionApplyMapper.insert(unionApply);
 
@@ -277,6 +301,8 @@
                 .set(ApplyDetail::getUnionApplyId,unionApply.getId())
                 .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds()));
 
+        return unionApply.getId();
+
     }
 
 
@@ -288,7 +314,7 @@
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
     public void cancelMerge(Integer id){
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-        if(user.getType().equals(Constants.TWO)){
+        if(!user.getType().equals(Constants.TWO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
         }
         UnionApply unionApply = unionApplyMapper.selectById(id);
@@ -300,6 +326,9 @@
         }
         if(unionApply.getStatus().equals(Constants.UnionApplyStatus.FINISH.getKey())){
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝鍚堝苟鍗曚笟鍔″凡瀹岀粨锛屾偍鏃犳硶杩涜璇ユ搷浣滐紒");
+        }
+        if(unionApply.getStatus().equals(Constants.UnionApplyStatus.CLOSE.getKey())){
+            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝鍚堝苟鍗曚笟鍔″凡鍏抽棴");
         }
         //鍚堝苟鍗曠姸鎬佸浜庡緟鎶曚繚
         if(unionApply.getStatus().equals(Constants.UnionApplyStatus.UPLOAD_INSURANCE_POLICY.getKey())
@@ -313,11 +342,9 @@
                 .set(InsuranceApply::getCheckUserId,user.getId())
                 .eq(InsuranceApply::getUnionApplyId,unionApply.getId()));
 
-
         applyDetailJoinMapper.update(null,new UpdateWrapper<ApplyDetail>().lambda()
                 .set(ApplyDetail::getUnionApplyId,null)
                 .eq(ApplyDetail::getUnionApplyId,unionApply.getId()));
-
 
         unionApplyMapper.update(null,new UpdateWrapper<UnionApply>().lambda()
                 .set(UnionApply::getCheckDate,new Date())
@@ -337,6 +364,9 @@
             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(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
+        }
         UnionApply unionApply = unionApplyMapper.selectById(uploadMultifileDTO.getBusinessId());
         if(Objects.isNull(unionApply)||!Constants.equalsInteger(unionApply.getIsdeleted(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -385,6 +415,9 @@
             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(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
+        }
         UnionApply unionApply = unionApplyJoinMapper.selectById(id);
         if(unionApply == null ||!Constants.equalsInteger(unionApply.getIsdeleted(),Constants.ZERO)){
             throw  new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -448,6 +481,9 @@
             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(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣滐紒");
+        }
         UnionApply unionApply = unionApplyJoinMapper.selectById(unionApplyBXDDTO.getId());
         if(unionApply == null ||!Constants.equalsInteger(unionApply.getIsdeleted(),Constants.ZERO)){
             throw  new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -497,6 +533,22 @@
             }else if(useDays>0){
                 currentFee =  new BigDecimal(useDays).multiply(price);
             }
+            //涓婁紶淇濆崟淇℃伅
+            if(StringUtils.isNotBlank(unionApplyBXDDDetailTO.getFileUrl())){
+                Multifile multifile = new Multifile();
+                multifile.setIsdeleted(Constants.ZERO);
+                multifile.setCreator(user.getId());
+                multifile.setCreateDate(new Date());
+                multifile.setObjId(insuranceApply.getId());
+                multifile.setObjType(Constants.MultiFile.COMPANY_TBD_SIGNED_PDF.getKey());
+                multifile.setType(Constants.TWO);
+                multifile.setFileurl(unionApplyBXDDDetailTO.getFileUrl());
+                multifile.setName(unionApplyBXDDDetailTO.getFileName());
+                multifileMapper.insert(multifile);
+                insuranceApply.setUnionApplyTbdStatus(Constants.ONE);
+            }else{
+                insuranceApply.setUnionApplyTbdStatus(Constants.ZERO);
+            }
             //鏇存柊鎶曚繚鐢宠鍗�
             insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
                     .set(InsuranceApply::getFee,
@@ -508,6 +560,7 @@
                     .set(InsuranceApply::getCurrentFee,currentFee.multiply(new BigDecimal(applyDetails.size())))
                     .set(InsuranceApply::getStartTime,unionApplyBXDDTO.getStartTime())
                     .set(InsuranceApply::getEndTime,unionApplyBXDDTO.getEndTime())
+                    .set(InsuranceApply::getUnionApplyTbdStatus,insuranceApply.getUnionApplyTbdStatus())
                     .set(InsuranceApply::getEditDate,new Date())
                     .set(InsuranceApply::getEditor,user.getId())
                     .eq(InsuranceApply::getId,insuranceApply.getId()));
@@ -522,19 +575,7 @@
                     .set(ApplyDetail::getEndTime,unionApplyBXDDTO.getEndTime())
                     .in(ApplyDetail::getId,applyDetails.stream().map(m->m.getId()).collect(Collectors.toList()))
             );
-            //涓婁紶淇濆崟淇℃伅
-            if(StringUtils.isNotBlank(unionApplyBXDDDetailTO.getFileUrl())){
-                Multifile multifile = new Multifile();
-                multifile.setIsdeleted(Constants.ZERO);
-                multifile.setCreator(user.getId());
-                multifile.setCreateDate(new Date());
-                multifile.setObjId(insuranceApply.getId());
-                multifile.setObjType(Constants.MultiFile.BD_APPLY_PDF.getKey());
-                multifile.setType(Constants.TWO);
-                multifile.setFileurl(unionApplyBXDDDetailTO.getFileUrl());
-                multifile.setName(unionApplyBXDDDetailTO.getFileName());
-                multifileMapper.insert(multifile);
-            }
+
             sumFee = sumFee.add(price.multiply(new BigDecimal(applyDetails.size())).multiply(new BigDecimal(maxDays)));
             sumCurrFee = sumCurrFee.add(currentFee.multiply(new BigDecimal(applyDetails.size())));
         }

--
Gitblit v1.9.3