From 2a0d7762b0113bba17bd50203360ec669aa20b18 Mon Sep 17 00:00:00 2001
From: renkang <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 04 十二月 2024 19:44:10 +0800
Subject: [PATCH] 客户资料 巡检任务业务

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java |  154 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 109 insertions(+), 45 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 4c5bb96..94da9a9 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
@@ -33,6 +33,7 @@
 import java.math.BigDecimal;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 杩愮淮鍚堝悓淇℃伅琛⊿ervice瀹炵幇
@@ -86,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();
@@ -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){
@@ -148,7 +189,7 @@
             if(!(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()==null) && (
                     (model.getZlFreeEndDate()!=null &&  model.getZlFreeStartDate()==null)
                             ||(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()!=null)
-                            ||model.getZlFreeEndDate().getTime()<= model.getZlFreeStartDate().getTime())
+                            ||model.getZlFreeEndDate().getTime()< model.getZlFreeStartDate().getTime())
             ){
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勭璧佹潯娆惧厤绉熸湡淇℃伅锛�");
             }
@@ -193,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
@@ -201,7 +242,7 @@
                 ){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋寜椤甸潰瑕佹眰濉啓鐗╀笟鏉℃淇℃伅!");
                 }
-                if(d.getEndDate().getTime()<= d.getStartDate().getTime()){
+                if(d.getEndDate().getTime()< d.getStartDate().getTime()){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鐗╀笟鏉℃鏈夋晥鏈熺粨鏉熸椂闂翠笉寰楁棭浜庡紑濮嬫椂闂达紒");
                 }
                 if(!Constants.equalsInteger(model.getWyPayType(),Constants.ZERO) &&
@@ -236,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;
         }
@@ -252,19 +293,20 @@
                 .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) {
         BigDecimal fee = Constants.formatBigdecimal(model.getBtFee());
         String str = "閫�绉熸憳瑕侊細鍓╀綑鏈粨娓呰处鍗晎param1}浠斤紝鍏抽棴璐﹀崟{param2}浠姐�愰��绉熸棩{param3}锛岄��绉熻垂鐢ㄥ悎璁¢渶{param4}{param5}鍏冦�傘��";
         str = str.replace("{param1}",model.getBtWaitBill()+"")
-                .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate()))
-                .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"鏀�":"浠�")
-                .replace("{param4}",(fee.compareTo(new BigDecimal(0)) >=0?
+                .replace("{param2}",Integer.toString(model.getBtCLoseBill()))
+                .replace("{param3}",DateUtil.getDateLongSlash(model.getBtDate()))
+                .replace("{param4}",fee.compareTo(new BigDecimal(0)) >=0?"鏀�":"浠�")
+                .replace("{param5}",(fee.compareTo(new BigDecimal(0)) >=0?
                         Constants.formatBigdecimal(model.getBtFee()).intValue()
                         :(Constants.formatBigdecimal(model.getBtFee()).intValue() * -1))+"" );
         return  str;
@@ -348,7 +390,7 @@
         List<YwContractBill> canBills = new ArrayList<>();//鍙��绉熶慨鏀规暟鎹�
         List<YwContractBill> allBills = ywContractBillMapper.selectList(new QueryWrapper<YwContractBill>().
                 select("*," +
-                        "( select ifnull(sum(yw.ACT_RECEIVABLE_FEE),0) from  yw_contract_revenue yw where yw.bill_id = yw_contract_bill.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee " )
+                        "( 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 = yw_contract_bill.id and yw.status = 0 and yw.isdeleted = 0 ) as  actReceivableFee " )
                 .lambda().
                 eq(YwContractBill::getIsdeleted,Constants.ZERO)
                 .eq(YwContractBill::getContractId,param.getId()));
@@ -365,15 +407,23 @@
                 }
                 if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO)
                         ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){
-                    if(bill.getStartDate().getTime()>param.getEditDate().getTime()){
+                    if(bill.getStartDate().getTime()<param.getBtDate().getTime()){
+                        canBills.add(bill);
+                    }else{
                         //濡傛灉杩樻病寮�濮嬶紝璐﹀崟鐩存帴鍏抽棴
                         closeBills.add(bill);
                         noBills.add(bill);
-                    }else{
-                        canBills.add(bill);
                     }
+//                    if(bill.getStartDate().getTime()>param.getEditDate().getTime()){
+//                        //濡傛灉杩樻病寮�濮嬶紝璐﹀崟鐩存帴鍏抽棴
+//                        closeBills.add(bill);
+//                        noBills.add(bill);
+//                    }else{
+//                        canBills.add(bill);
+//                    }
                 }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
-                    if(bill.getEndDate().getTime()<param.getEditDate().getTime()){
+                    if(bill.getStartDate().getTime()>param.getBtDate().getTime()){
+//                    if(bill.getEndDate().getTime()<param.getEditDate().getTime()){
                         //濡傛灉宸茬粨娓咃紝璐﹀崟鐩存帴鍏抽棴
                         noBills.add(bill);
                     }else{
@@ -415,6 +465,7 @@
                         //濡傛灉璐﹀崟杩樻湁娆惧緟鏀讹紝鍒欎繚鎸佺姸鎬佷笉鍙�
                     }
                 }
+                b.setReceivableFee(editBill.getReceivableFee());
                 b.setEditDate(param.getEditDate());
                 b.setEditor(param.getEditor());
                 b.setBtActDate(param.getBtActDate());
@@ -429,12 +480,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());
@@ -450,6 +506,8 @@
                     addBill.setBtFee(Constants.formatBigdecimal(addBill.getActReceivableFee()).multiply(new BigDecimal(-1)));
                 }
                 totalBackFee = totalBackFee.add(Constants.formatBigdecimal(addBill.getBtFee()));
+                addBill.setCreator(param.getEditor());
+                addBill.setCreateDate(param.getEditDate());
                 addBill.setEditDate(param.getEditDate());
                 addBill.setEditor(param.getEditor());
                 addBill.setBtActDate(param.getBtActDate());
@@ -458,6 +516,7 @@
                 addBill.setBtUserId(param.getBtUserId());
                 addBill.setBtSignDate(param.getBtSignDate());
                 addBill.setBtType(param.getBtType());
+                addBill.setSortnum(sortNum );
                 newBills.add(addBill);
             }
             ywContractBillMapper.insert(param.getAddBillList());//鎵归噺鎻掑叆鏁版嵁
@@ -467,26 +526,27 @@
         if(yjBills.size()>0){
             // 濡傛灉鏄娂閲戞垨鑰呬繚璇侀噾锛屼笉鏀寔閫�娆撅紝淇濇寔鍘熸潵鐨勭姸鎬侊紝 0=绉熻祦璐癸紱1=鐗╀笟璐癸紱2=绉熻祦鎶奸噾锛�3=鐗╀笟鎶奸噾锛�4=姘寸數璐癸紱5=鏉傞」璐癸紱6=鍏朵粬;7=淇濊瘉閲�
             for(YwContractBill bill : yjBills){
-                if(!Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
-//                    YwContractBill b = new YwContractBill();
-//                    //浠樻鐘舵�侊細0=寰呮敹娆撅紱1=宸茬粨娓咃紱2=閮ㄥ垎缁撴竻锛�3=寰呬粯娆撅紱4=寰呴��娆撅紱5=宸插叧闂�
-//                    //濡傛灉璐﹀崟淇℃伅鍋氫簡缂栬緫锛岄噾棰濊绠� 瀹炴敹閲戦 鍜� 淇敼鍚庡簲鏀堕噾棰濅綔瀵规瘮锛屽垽鏂槸鍚﹀簲璇ラ��娆�
-//                    BigDecimal fee = Constants.formatBigdecimal(bill.getActReceivableFee()).subtract(bill.getReceivableFee());
-//                    if(fee.compareTo(new BigDecimal(0))== 0){
-//                        //濡傛灉璐圭敤姝eソ锛屽垯淇敼璐﹀崟淇℃伅涓哄凡缁撴竻
-//                        b.setPayStatus(Constants.ONE);
-//                    }else if(fee.compareTo(new BigDecimal(0))> 0){
-//                        //濡傛灉闇�瑕佽繘琛岄��娆撅紝鏇存柊璐﹀崟淇℃伅涓哄緟閫�娆�
-//                        b.setPayStatus(Constants.FOUR);
-//                    }
-//                    b.setId(bill.getId());
-//                    b.setEditDate(param.getEditDate());
-//                    b.setEditor(param.getEditor());
-//                    b.setReceivableFee(BigDecimal.ZERO);
-//                    ywContractBillMapper.updateById(b);
-                    //濡傛灉鏄湭缁撴竻鎶奸噾
-                    yjNoBills ++;
+                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(param.getCanBackRentBills())){
+                    List<YwContractBill> optional = param.getCanBackRentBills().stream().filter(i->Constants.equalsInteger(bill.getId(),i.getId())).collect(Collectors.toList());
+                    if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(optional)){
+                        YwContractBill canBill = optional.get(Constants.ZERO);
+                        YwContractBill yjBill = new YwContractBill();
+                        yjBill.setId(bill.getId());
+                        yjBill.setEditDate(param.getEditDate());
+                        yjBill.setEditor(param.getEditor());
+                        yjBill.setReceivableFee(BigDecimal.ZERO);
+                        if(bill.getActReceivableFee().compareTo(BigDecimal.ZERO)==Constants.ZERO){
+                            yjBill.setPayStatus(Constants.FIVE);
+                            yjBill.setStatus(Constants.ONE);
+                        }else{
+                            yjBill.setPayStatus(Constants.FOUR);
+                            yjNoBills ++;
+                        }
+                        yjBill.setPlanPayDate(canBill.getPlanPayDate());
+                        ywContractBillMapper.updateById(yjBill);
+                    }
                 }
+
             }
         }
         param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//鏈竻绠楃殑璐﹀崟鏁伴噺
@@ -645,7 +705,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++);
@@ -787,17 +847,13 @@
             bill.setTotleFee(totalFee);
             bill.setReceivableFee(totalFee);
             bill.setBillType(Constants.ZERO);
-
-
             bill.setCompanyId(model.getCompanyId());
             list.add(bill);
         }
     }
-
-
     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() ;
@@ -870,6 +926,7 @@
             bill.setTotleFee(getTotalFeeByStartEnd(model,d,bill,freeStart,freeEnd));
             bill.setReceivableFee(bill.getTotleFee());
             bill.setBillType(Constants.ZERO);
+            bill.setCompanyId(model.getCompanyId());
             list.add(bill);
         }
         return list;
@@ -989,7 +1046,7 @@
             if(!(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()==null) && (
                         (model.getZlFreeEndDate()!=null &&  model.getZlFreeStartDate()==null)
                         ||(model.getZlFreeEndDate()==null &&  model.getZlFreeStartDate()!=null)
-                        ||model.getZlFreeEndDate().getTime()<= model.getZlFreeStartDate().getTime())
+                        ||model.getZlFreeEndDate().getTime()< model.getZlFreeStartDate().getTime())
                   ){
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勭璧佹潯娆惧厤绉熸湡淇℃伅锛�");
             }
@@ -1018,7 +1075,7 @@
                         Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绉熻祦鏉℃鍙湁閫夋嫨涓�娆℃�т粯娆炬椂锛屾墠鑳介�夋嫨璇ユ寜姣忓満鏀惰垂锛�");
                 }
-                if(model.getZlFirstCircle() == null){//棣栨湡淇℃伅
+                if(model.getZlFirstPrice() == null){//棣栨湡淇℃伅
                     model.setZlFirstPrice(d.getPrice());
                     model.setZlFirstCircle(d.getCircleType());
                 }
@@ -1067,7 +1124,7 @@
                         Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鐗╀笟鏉℃鍙湁閫夋嫨涓�娆℃�т粯娆炬椂锛屾墠鑳介�夋嫨璇ユ寜姣忓満鏀惰垂锛�");
                 }
-                if(model.getWyFirstCircle() == null){
+                if(model.getWyFirstPrice() == null){
                     //棣栨湡淇℃伅
                     model.setWyFirstPrice(d.getPrice());
                     model.setWyFirstCircle(d.getCircleType());
@@ -1231,9 +1288,16 @@
             //鏌ヨ璐﹀崟闆嗗悎
             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 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)));
+
+            for (YwContractBill ywContractBill:model.getBillList()) {
+                ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
+            }
+
             model.setCanBackRentBills(new ArrayList<>());
             long nowStart = Utils.Date.getStart(new Date()).getTime();
             long nowEnd = Utils.Date.getEnd(new Date()).getTime();

--
Gitblit v1.9.3