From bbcade0aa73354bf775fe91f88dd618bab6ea4a4 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 03 十二月 2024 19:14:15 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/funingyunwei

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java |   67 +++++++++++++++++++++++++++------
 1 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
index 4795aa6..2e5a8ff 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
@@ -87,11 +87,11 @@
         dealMultifileBiz(model);//澶勭悊闄勪欢淇℃伅
         dealRoomsForContract(model);//澶勭悊鎴挎簮鍏宠仈琛�
         dealLogBiz(model,Constants.YwLogType.CONTRACT_CREATE,model.getLoginUserInfo().getRealname(),"銆�"+model.getRemark().replace("鍚堝悓鎽樿锛�","")+"銆�");//璁板綍鏂板缓鏃ュ織
-
         return model.getId();
     }
 
     private void dealRoomsForContract(YwContract model) {
+        this.dealRoomsValid(model);
         List<YwContractRoom> list = new ArrayList<>();
         for(YwRoom room :model.getRoomList()){
             YwContractRoom t = new YwContractRoom();
@@ -107,6 +107,46 @@
         }
         ywContractRoomMapper.insert(list);
     }
+
+    private void dealRoomsValid(YwContract model){
+        List<Integer> roomIds = model.getRoomList().stream().map(i->i.getId()).collect(Collectors.toList());
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(roomIds)){
+            if(ywContractMapper.selectJoinCount(new MPJLambdaWrapper<YwContract>()
+                    .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId)
+                    .eq(YwContractRoom::getType,Constants.ZERO)
+                    .in(YwContractRoom::getRoomId,roomIds)
+                    .in(YwContract::getStatus,Constants.ZERO,Constants.ONE,Constants.TWO)
+                    .apply(" (" +
+                            " ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"'  and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " +
+                            "or " +
+                            " ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"'  and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " +
+                            " ) ")
+
+            )>Constants.ZERO){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎴挎簮宸茶鍗犵敤璇峰埛鏂伴噸璇�");
+            };
+
+            if(ywContractMapper.selectJoinCount(new MPJLambdaWrapper<YwContract>()
+                    .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId)
+                    .eq(YwContractRoom::getType,Constants.ZERO)
+                    .in(YwContractRoom::getRoomId,roomIds)
+                    .in(YwContract::getStatus,Constants.THREE)
+                    .apply(" ( t.START_DATE < '"+DateUtil.getFomartDate(model.getBtDate(),"yyyy-MM-dd HH:mm:ss")+"' " +
+                            " and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " )
+            )>Constants.ZERO){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎴挎簮宸茶鍗犵敤璇峰埛鏂伴噸璇�");
+            };
+
+
+
+        }
+
+
+
+
+
+    }
+
 
     @Override
     public   List<YwContractBill> getBillList(YwContract model){
@@ -194,7 +234,7 @@
             }
             for(YwContractDetail d :model.getWyDetailList()){
                 if(  d.getStartDate() == null
-                        ||d.getEditDate() == null
+                        ||d.getEndDate() == null
                         ||d.getPrice() == null
                         ||d.getCircleType() == null
                         || d.getCircleType()>6
@@ -237,9 +277,9 @@
 
         String str = "";
         //璧风鏃�2024/06/01锛岀璧佹暟涓�500銕°�傞鏈熺璧佷笁鏈堜竴浠橈紝绉熼噾鍗曚环35鍏�/銕÷锋湀銆傞鏈熺墿涓氫笁鏈堜竴浠橈紝鐗╀笟鍗曚环4.3鍏�/銕÷锋湀
-        String str0 = "鍚堝悓鎽樿锛氳捣绉熸棩{param1}锛岀璧佹暟涓簕param2}銕°�傞鏈熺璧亄param3}锛岀閲戝崟浠穥param4}鍏儃param5}銆傞鏈熺墿涓歿param6}锛岀墿涓氬崟浠穥param7}{param8}";
-        String str1 = "鍚堝悓鎽樿锛氳捣绉熸棩{param1}锛岀璧佹暟涓簕param2}銕°�傞鏈熺璧亄param3}锛岀閲戝崟浠穥param4}鍏儃param5}銆�";
-        String str2 = "鍚堝悓鎽樿锛氳捣绉熸棩{param1}锛岄鏈熺墿涓歿param6}锛岀墿涓氬崟浠穥param7}鍏儃param8}";
+        String str0 = "鍚堝悓鎽樿锛氳捣绉熸棩{param1}锛岀璧佹暟涓簕param2}銕°�傞鏈熺璧亄param3}锛岀閲戝崟浠穥param4}{param5}銆傞鏈熺墿涓歿param6}锛岀墿涓氬崟浠穥param7}{param8}";
+        String str1 = "鍚堝悓鎽樿锛氳捣绉熸棩{param1}锛岀璧佹暟涓簕param2}銕°�傞鏈熺璧亄param3}锛岀閲戝崟浠穥param4}{param5}銆�";
+        String str2 = "鍚堝悓鎽樿锛氳捣绉熸棩{param1}锛岄鏈熺墿涓歿param6}锛岀墿涓氬崟浠穥param7}{param8}";
         if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
             str= str0;
         }
@@ -253,10 +293,10 @@
                 .replace("{param2}",model.getTotalArea().intValue()+"")
                 .replace("{param3}",Constants.getPayTypeByNum(model.getZlPayType()))
                 .replace("{param4}",Constants.formatBigdecimal(model.getZlFirstPrice()).intValue()+"")
-                .replace("{param5}",Constants.getUnitTypeByNum(model.getZlFirstCircle())
+                .replace("{param5}",Constants.getUnitTypeByNum(model.getZlFirstCircle()))
                 .replace("{param6}",Constants.getPayTypeByNum(model.getWyPayType()))
                 .replace("{param7}",Constants.formatBigdecimal(model.getWyFirstPrice()).intValue()+"")
-                .replace("{param8}",Constants.getUnitTypeByNum(model.getWyFirstCircle())));
+                .replace("{param8}",Constants.getUnitTypeByNum(model.getWyFirstCircle()));
         return  str;
     }
     private String getbackRentRemarkByParam(YwContract model) {
@@ -312,9 +352,6 @@
         update.setBtFee(param.getBtFee());
         update.setBtRemark(getbackRentRemarkByParam(param));
         ywContractMapper.updateById(update);
-//        if(1==1){
-//            throw new BusinessException(ResponseStatus.NOT_ALLOWED);
-//        }
         dealLogBiz(param,Constants.YwLogType.CONTRACT_BACK, param.getLoginUserInfo().getRealname(),getbackRentLogByParam(param));
         return param.getId();
     }
@@ -442,12 +479,17 @@
                 totalBackFee = totalBackFee.add(fee);//绱閫�娆鹃噾棰�
             }
         }
+        List<YwContractBill> ywContractBillList = ywContractBillMapper.selectList(new QueryWrapper<YwContractBill>()
+                .lambda().eq(YwContractBill::getContractId,param.getId()).orderByDesc(YwContractBill::getId));
+        Integer sortNum = ywContractBillList.size();
         if(param.getAddBillList()!=null && param.getAddBillList().size()>0){
             for(YwContractBill addBill : param.getAddBillList()){
+                sortNum = sortNum + 1 ;
                 addBill.setIsdeleted(Constants.ZERO);
                 addBill.setContractId(param.getId());
                 addBill.setType(Constants.ONE);
                 addBill.setStatus(Constants.ZERO);
+                addBill.setTotleFee(addBill.getReceivableFee());
                 if(Constants.equalsInteger(addBill.getFeeType(),Constants.ONE)){
                     addBill.setStartDate(addBill.getPlanPayDate());
                     addBill.setEndDate(addBill.getPlanPayDate());
@@ -471,6 +513,7 @@
                 addBill.setBtUserId(param.getBtUserId());
                 addBill.setBtSignDate(param.getBtSignDate());
                 addBill.setBtType(param.getBtType());
+                addBill.setSortnum(sortNum );
                 newBills.add(addBill);
             }
             ywContractBillMapper.insert(param.getAddBillList());//鎵归噺鎻掑叆鏁版嵁
@@ -653,7 +696,7 @@
                 billList1.get(i).setSortnum(num++);
             }
         }
-          num =1;
+        num =1;
         for(int i=0;i<billList2.size();i++){
             if(Constants.equalsInteger( billList2.get(i).getCostType(),Constants.ONE)){
                 billList2.get(i).setSortnum(num++);
@@ -801,7 +844,7 @@
     }
     private BigDecimal getTotalFeeByStartEnd(YwContract model, YwContractDetail d, YwContractBill bill,Date freeStart,Date freeEnd) {
         BigDecimal totalFee = new BigDecimal(0);
-        DateCompare dateCompare =   DateCompare.dayCompare(bill.getStartDate(),DateUtil.addDaysToDate(bill.getEndDate(),1),freeStart,DateUtil.addDaysToDate(freeEnd,1));
+        DateCompare dateCompare =   DateCompare.dayCompare(bill.getStartDate(),bill.getEndDate(),freeStart, freeEnd);
         if(Constants.equalsInteger(d.getCircleType(),Constants.ZERO)){
             //0=鍏冩瘡骞崇背澶�
             int days = dateCompare.getDay() ;

--
Gitblit v1.9.3