From d798c557fd8df9a7d5f43455455fb30658259d6e Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 28 十一月 2024 14:53:37 +0800
Subject: [PATCH] 开发更新

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java |   81 +++++++++++++++++++++++++++++-----------
 1 files changed, 59 insertions(+), 22 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 51efed1..d2da52a 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
@@ -294,11 +294,16 @@
         //澶勭悊
         dealBackRentBillBiz(param);
         YwContract update = new YwContract();
+        update.setId(param.getId());
         update.setEditDate(new Date());
         update.setEditor(param.getLoginUserInfo().getId());
         update.setBtActDate(update.getEditDate());
         update.setBtActUserId(update.getEditor());
-        update.setStatus(Constants.THREE);
+        if(Objects.nonNull(param.getBtWaitBill()) && param.getBtWaitBill() > Constants.ZERO){
+            update.setStatus(Constants.THREE);
+        }else{
+            update.setStatus(Constants.FOUR);
+        }
         update.setBtInfo(param.getBtInfo());
         update.setBtDate(param.getBtDate());
         update.setBtType(param.getBtType());
@@ -308,6 +313,30 @@
         ywContractMapper.updateById(update);
         dealLogBiz(param,Constants.YwLogType.CONTRACT_BACK, param.getLoginUserInfo().getRealname(),getbackRentLogByParam(param));
         return param.getId();
+    }
+
+
+    @Override
+    public  void dealTimeOut(){
+        //瀹氭椂澶勭悊鍚堝悓鎵ц涓�
+        ywContractMapper.update(new UpdateWrapper<YwContract>()
+                .lambda()
+                .set(YwContract::getStatus,Constants.ONE)
+                .set(YwContract::getEditDate,DateUtil.getCurrDateTime())
+                .eq(YwContract::getIsdeleted,Constants.ZERO)
+                .in(YwContract::getStatus,Constants.ZERO)
+                .apply(" START_DATE < NOW()  AND END_DATE > NOW() ")
+        );
+        //瀹氭椂澶勭悊鍚堝悓宸茶繃鏈�
+        ywContractMapper.update(new UpdateWrapper<YwContract>()
+                        .lambda()
+                .set(YwContract::getStatus,Constants.TWO)
+                .set(YwContract::getEditDate,DateUtil.getCurrDateTime())
+                .eq(YwContract::getIsdeleted,Constants.ZERO)
+                .in(YwContract::getStatus,Constants.ONE,Constants.ZERO)
+                .apply(" END_DATE < NOW() ")
+        );
+
     }
 
     private void dealBackRentBillBiz(YwContract param) {
@@ -328,7 +357,7 @@
                 //浠樻鐘舵�侊細0=寰呮敹娆撅紱1=宸茬粨娓咃紱2=閮ㄥ垎缁撴竻锛�3=寰呬粯娆撅紱4=寰呴��娆撅紱5=宸插叧闂�
                 // 濡傛灉鏄娂閲戞垨鑰呬繚璇侀噾锛屼笉鏀寔閫�娆撅紝淇濇寔鍘熸潵鐨勭姸鎬侊紝 0=绉熻祦璐癸紱1=鐗╀笟璐癸紱2=绉熻祦鎶奸噾锛�3=鐗╀笟鎶奸噾锛�4=姘寸數璐癸紱5=鏉傞」璐癸紱6=鍏朵粬;7=淇濊瘉閲�
                 if(Constants.equalsInteger(Constants.THREE,bill.getCostType())
-                        ||  Constants.equalsInteger(Constants.FOUR,bill.getCostType())
+                        ||  Constants.equalsInteger(Constants.TWO,bill.getCostType())
                         ||Constants.equalsInteger(Constants.SEVEN,bill.getCostType())){
                     //鎶奸噾鍜屼繚璇侀噾
                     yjBills.add(bill);
@@ -466,7 +495,7 @@
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝鍚堝悓淇℃伅涓嶅瓨鍦紝璇疯繑鍥炲垪琛ㄥ埛鏂伴噸璇曪紒");
         }
 
-        SystemUser user = systemUserMapper.selectById(param.getUserId());
+        SystemUser user = systemUserMapper.selectById(param.getBtUserId());
         if(user ==null ||  (user.getDeleted()!=null&& user.getDeleted() )){
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝缁忓姙浜轰俊鎭笉瀛樺湪锛�");
         }
@@ -489,7 +518,8 @@
     }
 
     private void dealDetailListBiz(YwContract model) {
-        List<YwContractDetail> details = new ArrayList<>();
+        List<YwContractDetail> details1 = new ArrayList<>();
+        List<YwContractDetail> details2 = new ArrayList<>();
         int num = 0;
         if(Constants.equalsInteger(model.getType(),Constants.ZERO )
                 || Constants.equalsInteger(model.getType(),Constants.TWO)){
@@ -501,7 +531,7 @@
                d.setType(Constants.ZERO);
                d.setSortnum(num++);
                d.setStatus(Constants.ZERO);
-               details.add(d);
+               details1.add(d);
             }
         }
         num = 0;
@@ -515,22 +545,28 @@
                 d.setContractId(model.getId());
                 d.setSortnum(num++);
                 d.setStatus(Constants.ZERO);
-                details.add(d);
+                details2.add(d);
             }
         }
         if(model.getId()!=null){
-            ywContractDetailMapper.insert(details);//鎵归噺鎻掑叆鏉℃淇℃伅淇℃伅
+            if(details1.size()>0){
+                ywContractDetailMapper.insert(details1);//鎵归噺鎻掑叆鏉℃淇℃伅淇℃伅
+            }
+            if(details2.size()>0){
+                ywContractDetailMapper.insert(details2);//鎵归噺鎻掑叆鏉℃淇℃伅淇℃伅
+            }
         }
         //澶勭悊璐﹀崟淇℃伅
-        dealBillListBiz(model,details);
+        dealBillListBiz(model,details1,details2);
     }
 
     /**
      * 鏀粯鏂瑰紡 0=涓�娆℃�т粯娆撅紱1=姣忎笁涓湀涓�浠橈紱2=鍏釜鏈堜竴浠橈紱3=涓�骞翠竴浠�
      * @param model
-     * @param details
+     * @param details1 绉熻祦鏉℃
+     * @param details2 鐗╀笟鏉℃
      */
-    private void dealBillListBiz(YwContract model, List<YwContractDetail> details) {
+    private void dealBillListBiz(YwContract model, List<YwContractDetail> details1, List<YwContractDetail> details2) {
         List<YwContractBill> billList1 = new ArrayList<>();
         List<YwContractBill> billList2 = new ArrayList<>();
         if(Constants.equalsInteger(model.getType(),Constants.ZERO )
@@ -538,20 +574,20 @@
             //濡傛灉鏈夌璧佹潯娆�
             if(Constants.formatBigdecimal(model.getZlDeposit()).compareTo(new BigDecimal(0))>0){
                     //濡傛灉鏈夌璧佹娂閲�
-                billList1.add(initDepoistBill(Constants.THREE,model,details));
+                billList1.add(initDepoistBill(Constants.TWO,model));
             }
             if(Constants.equalsInteger(model.getZlPayType(), Constants.ZERO)){
                 //濡傛灉鏄竴娆℃�т粯娓�
-                billList1.addAll(getBillsByParamOnce(model,details,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
+                billList1.addAll(getBillsByParamOnce(model,details1,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
             }else if(Constants.equalsInteger(model.getZlPayType(), Constants.ONE)){
                 //濡傛灉姣忎笁涓湀涓�浠�
-                billList1.addAll(getBillsByParam3Months(model,details,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
+                billList1.addAll(getBillsByParam3Months(model,details1,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
             }else if(Constants.equalsInteger(model.getZlPayType(), Constants.TWO)){
                 //濡傛灉鍏釜鏈堜竴浠�
-                billList1.addAll(getBillsByParam6Months(model,details,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
+                billList1.addAll(getBillsByParam6Months(model,details1,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
             }else if(Constants.equalsInteger(model.getZlPayType(), Constants.THREE)){
                 //濡傛灉涓�骞翠竴浠�
-                billList1.addAll(getBillsByParam1Year(model,details,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
+                billList1.addAll(getBillsByParam1Year(model,details1,model.getZlFreeStartDate(),model.getZlFreeEndDate()));
             }
         }
         if(Constants.equalsInteger(model.getType(),Constants.ZERO )
@@ -559,26 +595,26 @@
             //濡傛灉鐗╀笟鏉℃
             if(Constants.formatBigdecimal(model.getWyDeposit()).compareTo(new BigDecimal(0))>0){
                 //濡傛灉鏈夌璧佹娂閲�
-                billList2.add(initDepoistBill(Constants.FOUR,model,details));
+                billList2.add(initDepoistBill(Constants.THREE,model));
             }
             if(Constants.equalsInteger(model.getWyPayType(), Constants.ZERO)){
                 //濡傛灉鏄竴娆℃�т粯娓�
-                billList2.addAll(getBillsByParamOnce(model,details,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
+                billList2.addAll(getBillsByParamOnce(model,details2,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
             }else if(Constants.equalsInteger(model.getWyPayType(), Constants.ONE)){
                 //濡傛灉姣忎笁涓湀涓�浠�
-                billList2.addAll(getBillsByParam3Months(model,details,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
+                billList2.addAll(getBillsByParam3Months(model,details2,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
             }else if(Constants.equalsInteger(model.getWyPayType(), Constants.TWO)){
                 //濡傛灉鍏釜鏈堜竴浠�
-                billList2.addAll(getBillsByParam6Months(model,details,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
+                billList2.addAll(getBillsByParam6Months(model,details2,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
             }else if(Constants.equalsInteger(model.getWyPayType(), Constants.THREE)){
                 //濡傛灉涓�骞翠竴浠�
-                billList2.addAll(getBillsByParam1Year(model,details,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
+                billList2.addAll(getBillsByParam1Year(model,details2,model.getWyFreeStartDate(),model.getWyFreeEndDate()));
             }
         }
 
         if(model.getBillType() == 0){
             model.setBillList(billList1);
-        }else  if(model.getBillType() == 0){
+        }else  if(model.getBillType() == 1){
             model.setBillList(billList2);
         }
         int num =1;
@@ -599,7 +635,7 @@
         }
     }
 
-    private YwContractBill initDepoistBill(int type,  YwContract model, List<YwContractDetail> details) {
+    private YwContractBill initDepoistBill(int type,  YwContract model ) {
         YwContractBill bill  = new YwContractBill();
         bill.setCreateDate(model.getEditDate());
         bill.setCreator(model.getEditor());
@@ -1114,6 +1150,7 @@
                 .selectAs(YwCustomer::getName,YwContract::getRenterName )
                 .selectAs(YwProject::getName,YwContract::getProjectName )
                 .select("t3.realname",YwContract::getCreatorName )
+                .select("(select sum(r.area) from yw_contract_room cr left join yw_room r on r.id = cr.room_id where r.isdeleted=0 and cr.contract_id =t.id)",YwContract::getTotalArea )
                 .leftJoin(Company.class,Company::getId,YwContract::getCompanyId)
                 .leftJoin(SystemUser.class,SystemUser::getId,YwContract::getUserId)
                 .leftJoin(SystemUser.class,SystemUser::getId,YwContract::getCreator)

--
Gitblit v1.9.3