From 16217be9c85f95cb236e639da6e546bb38cdc53d Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 05 十二月 2024 14:45:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 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 4683542..f9be5d2 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
@@ -91,6 +91,7 @@
     }
 
     private void dealRoomsForContract(YwContract model) {
+        this.dealRoomsValid(model);
         List<YwContractRoom> list = new ArrayList<>();
         for(YwRoom room :model.getRoomList()){
             YwContractRoom t = new YwContractRoom();
@@ -106,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.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' " +
+                            " and t.BT_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){
@@ -1228,6 +1269,8 @@
                             ,Constants.YwLogType.CONTRACT_UPDATE.getKey())
                     .orderByAsc(YwWorkorderLog::getCreateDate)));
 
+            //鏌ヨ璐﹀崟闆嗗悎
+
             queryBillListByModel(model,new Date());
         }
         return model;
@@ -1242,7 +1285,8 @@
         //鏌ヨ璐﹀崟闆嗗悎
         model.setBillList(ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>()
                 .selectAll(YwContractBill.class )
-                .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE  else  -yw.ACT_RECEIVABLE_FEE end),0) from  yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee  ")
+                //.select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE  else  -yw.ACT_RECEIVABLE_FEE end),0) from  yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee  ")
+                .select(" ( select ifnull( sum( CASE WHEN t.bill_type = 0 and yw.REVENUE_TYPE = 0 THEN yw.ACT_RECEIVABLE_FEE when  t.bill_type = 0 and yw.REVENUE_TYPE = 1 then -yw.ACT_RECEIVABLE_FEE  when t.bill_type = 1 and yw.REVENUE_TYPE = 0 then -yw.ACT_RECEIVABLE_FEE else  yw.ACT_RECEIVABLE_FEE END),0) from  yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee  ")
                 .eq(  YwContractBill::getContractId,model.getId())
                 .eq(YwContractBill::getIsdeleted,Constants.ZERO)
                 .orderByAsc(YwContractBill::getSortnum,YwContractBill::getCreateDate)));

--
Gitblit v1.9.3