From 45a8fb5db1b0aa6d5cd39198ffc30dba5ec8b2d9 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 10 四月 2024 18:24:15 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java       |   18 +++++++-
 server/service/src/main/java/com/doumee/core/utils/Constants.java                               |    2 
 server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java    |   17 +++++---
 server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java       |   18 ++++++++
 server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java             |   16 ++++----
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChagneDetailServiceImpl.java |    1 
 server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java        |   14 +++++-
 7 files changed, 62 insertions(+), 24 deletions(-)

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 f6929c8..ada5761 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
@@ -791,6 +791,7 @@
         CA_JIAJIAN_APPLY_SIGN(23, "鍔犲噺淇濈敵璇蜂紒涓氱绔�","",1),
         CA_CHANGUNIT_APPLY_SIGN(24, "鎹㈠巶鐢宠浼佷笟绛剧珷","",1),
         CA_UPLOAD_AGAIN(25, "鍐嶆鎶曚繚","",1),
+        CA_HBD_AUDIT(42, "瀹℃壒閫氳繃","鍘熷洜锛�${param}",1),
 
         WTB_FINISH_FAQRS(26, "濮旀墭淇� - 浼佷笟瀹屾垚绛剧讲鏂规纭涔�","",0),
         WTB_FINISH_MEMBER_LIST(27, "濮旀墭淇� - 浼佷笟瀹屾垚绛剧讲浜哄憳鍚嶅崟","",0),
@@ -819,7 +820,6 @@
         CA_HBD_SIGNATURE_TBD(38, "鍟嗘埛绛剧珷","",4),
         CA_HBD_UPLOAD_INSURANCE(39, "鎶曚繚瀹屾垚","",4),
         CA_HBD_CLOSE(40, "閫�鍥炵敵璇�","鍘熷洜锛�${param}",4),
-        CA_HBD_AUDIT(41, "瀹℃壒閫氳繃","鍘熷洜锛�${param}",4),
 
 
 
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChagneDetailServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChagneDetailServiceImpl.java
index c266424..f74e0a9 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChagneDetailServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChagneDetailServiceImpl.java
@@ -266,7 +266,6 @@
         List<ApplyChagneDetail> list = applyChangeDetailJoinMapper.selectJoinList(ApplyChagneDetail.class, queryWrapper);
         for (ApplyChagneDetail applyChagneDetail:list) {
             applyChagneDetail.setAge(Constants.getAgeByIdCard(applyChagneDetail.getMemberIdcardNo()));
-
         }
         return list;
     }
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 02f12dd..65345a0 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
@@ -882,7 +882,9 @@
         if (Objects.isNull(insuranceApply)) {
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        if (!Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())) {
+        if (!(Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())
+        ||Constants.equalsInteger(insuranceApply.getStatus(),Constants.InsuranceApplyStatus.WTB_DONE.getKey())
+        )) {
             throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(), "淇濆崟鐘舵�侀敊璇�");
         }
         if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO
@@ -1020,6 +1022,13 @@
         //鎹㈠巶涓氬姟
         List<ApplyChagneDetail> changeDetailList = applyChange.getChangeDetailList();
         if (CollectionUtils.isNotEmpty(changeDetailList)) {
+            //楠岃瘉鏄惁瀛樺湪閲嶅鏁版嵁
+            List<String> idcarNo = changeDetailList.stream().map(m->m.getIdcardNo()).collect(Collectors.toList());
+            Set<String> set = new HashSet<>(idcarNo);
+            if(idcarNo.size() != set.size()){
+                throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝浜哄憳褰曞叆鏁版嵁瀛樺湪鐩稿悓鏁版嵁锛�");
+            }
+
             this.changeDetail(applyChange,changeDetailList,duWorktypeList,duSolutionList,loginUserInfo);
         }
         return fee;
@@ -2030,7 +2039,7 @@
         CountCyclePriceVO returnCountCyclePriceVO = new CountCyclePriceVO();
         //鍔犲噺淇濋噾棰�
 //        returnCountCyclePriceVO.setCyclePrice(sumPrice.multiply(new BigDecimal(optDays)).divide(new BigDecimal(sumDays),2, RoundingMode.HALF_UP));
-        returnCountCyclePriceVO.setCyclePrice(applyDetail.getPrice().multiply(new BigDecimal(optDays)));
+        returnCountCyclePriceVO.setCyclePrice(applyDetail.getPrice().multiply(new BigDecimal(optDays)).setScale(2, RoundingMode.HALF_UP));
         return returnCountCyclePriceVO;
     }
 
@@ -2171,6 +2180,9 @@
         }
         if(applyChange.getId() == null){
             throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        } 
+        if(Objects.isNull(applyChange)){
+            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
         }
         ApplyChange model = applyChangeJoinMapper.selectJoinOne(ApplyChange.class,
                 new MPJLambdaWrapper<ApplyChange>()
@@ -2219,7 +2231,7 @@
         }else{
             info = info.replace("${param}", "");
         }
-        ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(),info,applyChange.getId(),applyLogType.getKey(), null, null);
+        ApplyLog log = new ApplyLog(update,applyLogType.getName(),info,update.getId(),applyLogType.getKey(), null, null);
         applyLogMapper.insert(log);
 
 
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 4caeb81..88d918f 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
@@ -1822,7 +1822,7 @@
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鎶曚繚淇℃伅寮傚父锛氭�诲ぉ鏁颁笌鎬婚噾棰濋敊璇�");
                 }
                 applyDetail.setPrice(
-                        applyDetail.getFee().divide(new BigDecimal(maxDays),2,RoundingMode.HALF_UP)
+                        applyDetail.getFee().divide(new BigDecimal(maxDays),7,RoundingMode.HALF_UP)
                 );
                 //楠岃瘉娲鹃仯鍗曚綅淇℃伅鏄惁瀛樺湪
                 if(duSolutionList.stream().filter(d->d.getDispatchUnitId().equals(applyDetail.getDuId())).collect(Collectors.toList()).size()<=Constants.ZERO){
@@ -1894,18 +1894,21 @@
             return  new ArrayList<>();
         }
         List<Integer> statusList = Constants.InsuranceApplyStatus.getKesByStatus(collectStatus);
-        if(collectStatus.equals(Constants.ApplyCollectStatus.DCD.getKey())){
+        if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.DCD.getKey())){
             statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBDCD.getKey()));
-        }else if(collectStatus.equals(Constants.ApplyCollectStatus.DSP.getKey())){
+        }else if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.DSP.getKey())){
             statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBDSH.getKey()));
-        }else if(collectStatus.equals(Constants.ApplyCollectStatus.BZZ.getKey())){
+        }else if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.BZZ.getKey())){
             statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBBZZ.getKey()));
-        }else if(collectStatus.equals(Constants.ApplyCollectStatus.YTH.getKey())){
+        }else if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.YTH.getKey())){
             statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBYTH.getKey()));
-        }else if(collectStatus.equals(Constants.ApplyCollectStatus.YGB.getKey())){
+        }else if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.YGB.getKey())){
             statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBYGB.getKey()));
-        }else if(collectStatus.equals(Constants.ApplyCollectStatus.DQYQZ.getKey())){
+        }else if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.DQYQZ.getKey())){
             statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBDQS.getKey()));
+        }else if(Constants.equalsInteger(collectStatus,Constants.ApplyCollectStatus.YGQ.getKey())){
+            statusList.addAll(Constants.InsuranceApplyStatus.getKesByStatus(Constants.ApplyCollectStatus.WTBBZZ.getKey()));
+            statusList.add(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey());
         }
 
         return statusList;
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
index 6b9923c..70b0ee5 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
@@ -474,20 +474,20 @@
             ){
                 throw new BusinessException(ResponseStatus.BAD_REQUEST);
             }
-            //鏌ヨ姣忎釜淇濆崟涓嬪彲浠ユ姇淇濈殑閲戦
+            //鏌ヨ姣忎釜淇濆崟涓嬪彲浠ユ姤閿�鐨勯噾棰�
             InsuranceApply insuranceApply = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,new MPJLambdaWrapper<InsuranceApply>()
                     .selectAll(InsuranceApply.class)
 //                    .select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status  = 1 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney")
                     .select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney ")
                     .eq(InsuranceApply::getId,taxDetial.getInsuranceApplyId())
             );
-//            if(Objects.isNull(insuranceApply)){
-//                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"淇濆崟鍙枫��"+taxDetial.getApplyCode()+"銆戞湭鏌ヨ鍒颁繚鍗曚俊鎭�");
-//            }
-//            if(insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney()).compareTo(taxDetial.getFee())!=Constants.ZERO){
-//                //throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"淇濆崟鍙枫��"+taxDetial.getApplyCode()+"銆戝彲鎶ラ攢閲戦閿欒銆�"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"銆�");
-//                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"淇濆崟鍙枫��"+taxDetial.getApplyCode()+"銆戝彲鎶ラ攢閲戦閿欒");
-//            }
+            if(Objects.isNull(insuranceApply)){
+                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"淇濆崟鍙枫��"+taxDetial.getApplyCode()+"銆戞湭鏌ヨ鍒颁繚鍗曚俊鎭�");
+            }
+            if(insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney()).compareTo(taxDetial.getFee())!=Constants.ZERO){
+                //throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"淇濆崟鍙枫��"+taxDetial.getApplyCode()+"銆戝彲鎶ラ攢閲戦閿欒銆�"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"銆�");
+                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"淇濆崟鍙枫��"+taxDetial.getApplyCode()+"銆戜笉婊¤冻寮�绁ㄦ潯浠�");
+            }
             taxDetial.setCreator(user.getId());
             taxDetial.setCreateDate(new Date());
             taxDetial.setIsdeleted(Constants.ZERO);
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 90eb09a..ba9b444 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
@@ -380,7 +380,6 @@
                 }
             }
         }
-
     }
 
 
@@ -443,13 +442,22 @@
 
         Integer maxDays = DateUtil.calculateBetween(saveUnionApplyDTO.getStartDate(),saveUnionApplyDTO.getEndDate(),0);
 
-        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda().select(ApplyDetail::getId,ApplyDetail::getPrice)
+        List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectList(new QueryWrapper<ApplyDetail>().lambda()
+                .select(ApplyDetail::getId,ApplyDetail::getPrice,ApplyDetail::getStartTime,ApplyDetail::getEndTime,ApplyDetail::getFee)
                 .in(ApplyDetail::getApplyId,saveUnionApplyDTO.getApplyIds())
                 .eq(ApplyDetail::getIsdeleted,Constants.ZERO));
         if(applyDetailList.size()==0){
             throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝瀛樺湪濮旀墭鎶曚繚鐢宠璁板綍淇℃伅鏈夎锛岃杩斿洖鏌ョ湅鐢宠浜哄憳鏄惁涓虹┖锛�");
         }
-        unionApply.setFee(applyDetailList.stream().map(i->Constants.formatBigdecimal(i.getPrice()).multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
+        BigDecimal fee = BigDecimal.ZERO;
+        for (ApplyDetail applyDetail:applyDetailList) {
+            Integer oldDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0);
+            fee =fee.add(new BigDecimal(maxDays).multiply( applyDetail.getFee()).divide(new BigDecimal(oldDays),2,RoundingMode.HALF_UP));
+        }
+        unionApply.setFee(fee);
+
+//        unionApply.setFee(applyDetailList.stream()
+//                .map(i->Constants.formatBigdecimal(i.getPrice()).multiply(new BigDecimal(maxDays))).reduce(BigDecimal.ZERO,BigDecimal::add));
 
         unionApplyMapper.insert(unionApply);
 
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 a05336f..79b5655 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
@@ -36,6 +36,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -187,7 +188,7 @@
                     fee = fee.subtract(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice())).add(applyChagneDetail.getFee());
                 }
             }
-            unionChange.setFee(fee);
+            unionChange.setFee(fee.setScale(2, RoundingMode.HALF_UP));
             //鏌ヨ鎿嶄綔璁板綍
             List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
                     new MPJLambdaWrapper<ApplyLog>()
@@ -389,6 +390,8 @@
         UnionChange unionChange = new UnionChange();
         unionChange.setCreateDate(new Date());
         unionChange.setCreator(user.getId());
+        unionChange.setEditDate(new Date());
+        unionChange.setEditor(user.getId());
         unionChange.setShopId(user.getCompanyId());
         unionChange.setIsdeleted(Constants.ZERO);
         unionChange.setUnionApplyId(saveUnionChangeDTO.getUnionApplyId());
@@ -699,6 +702,7 @@
         }
         if(CollectionUtils.isNotEmpty(applyChangeList)){
             for (ApplyChange applyChange:applyChangeList) {
+                ApplyChange oldModel = applyChange;
                 applyChange.setApplyStartTime(unionChangeBXDDTO.getApplyDate());
                 applyChange.setValidTime(unionChangeBXDDTO.getApplyDate());
                 applyChange.setEditDate(new Date());
@@ -727,6 +731,18 @@
                                 .eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
                 this.dealApplyChangeDetail(applyChange,allList);
                 applyChangeJoinMapper.updateById(applyChange);
+
+                //瀛樺偍鎵瑰崟瀹屾垚淇℃伅
+                Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_APPROVE;
+                String info = "";
+                if(applyChange.getValidTime()!=null && applyChange.getValidTime().getTime()/1000!= applyChange.getApplyStartTime().getTime()/1000){
+                    info =applyLogType.getInfo();
+                    info = info.replace("${param1}",DateUtil.getPlusTime2(applyChange.getValidTime()));
+                    info = info.replace("${param2}",DateUtil.getPlusTime2(applyChange.getApplyStartTime()));
+                }
+                ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(), info,applyChange.getId(),applyLogType.getKey(),JSONObject.toJSONString(oldModel), JSONObject.toJSONString(applyChange));
+                applyLogMapper.insert(log);
+
             }
         }
         unionChangeMapper.update(null,new UpdateWrapper<UnionChange>().lambda()

--
Gitblit v1.9.3