From c40579692637afaecbd4b63422efa66f3fa9de42 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 05 十二月 2024 18:44:36 +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 |  126 +++++++++++++++++++----------------------
 1 files changed, 59 insertions(+), 67 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 94da9a9..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
@@ -189,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‘鐨勭璧佹潯娆惧厤绉熸湡淇℃伅锛�");
             }
@@ -242,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) &&
@@ -303,10 +303,9 @@
         BigDecimal fee = Constants.formatBigdecimal(model.getBtFee());
         String str = "閫�绉熸憳瑕侊細鍓╀綑鏈粨娓呰处鍗晎param1}浠斤紝鍏抽棴璐﹀崟{param2}浠姐�愰��绉熸棩{param3}锛岄��绉熻垂鐢ㄥ悎璁¢渶{param4}{param5}鍏冦�傘��";
         str = str.replace("{param1}",model.getBtWaitBill()+"")
-                .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?
+                .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate()))
+                .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"鏀�":"浠�")
+                .replace("{param4}",(fee.compareTo(new BigDecimal(0)) >=0?
                         Constants.formatBigdecimal(model.getBtFee()).intValue()
                         :(Constants.formatBigdecimal(model.getBtFee()).intValue() * -1))+"" );
         return  str;
@@ -353,6 +352,9 @@
         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();
     }
@@ -480,17 +482,12 @@
                 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());
@@ -506,8 +503,6 @@
                     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());
@@ -516,7 +511,6 @@
                 addBill.setBtUserId(param.getBtUserId());
                 addBill.setBtSignDate(param.getBtSignDate());
                 addBill.setBtType(param.getBtType());
-                addBill.setSortnum(sortNum );
                 newBills.add(addBill);
             }
             ywContractBillMapper.insert(param.getAddBillList());//鎵归噺鎻掑叆鏁版嵁
@@ -535,18 +529,12 @@
                         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.setPayStatus(Constants.FOUR);
                         yjBill.setPlanPayDate(canBill.getPlanPayDate());
                         ywContractBillMapper.updateById(yjBill);
                     }
                 }
-
+                yjNoBills ++;
             }
         }
         param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//鏈竻绠楃殑璐﹀崟鏁伴噺
@@ -701,15 +689,12 @@
         }
         int num =1;
         for(int i=0;i<billList1.size();i++){
-            if(Constants.equalsInteger( billList1.get(i).getCostType(),Constants.ZERO)){
-                billList1.get(i).setSortnum(num++);
-            }
+            billList1.get(i).setSortnum(num);
+            num++;
         }
-        num =1;
         for(int i=0;i<billList2.size();i++){
-            if(Constants.equalsInteger( billList2.get(i).getCostType(),Constants.ONE)){
-                billList2.get(i).setSortnum(num++);
-            }
+            billList2.get(i).setSortnum(num);
+            num++;
         }
         if(model.getId()!=null){
             ywContractBillMapper.insert(billList1);
@@ -926,7 +911,6 @@
             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;
@@ -1046,7 +1030,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‘鐨勭璧佹潯娆惧厤绉熸湡淇℃伅锛�");
             }
@@ -1075,7 +1059,7 @@
                         Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绉熻祦鏉℃鍙湁閫夋嫨涓�娆℃�т粯娆炬椂锛屾墠鑳介�夋嫨璇ユ寜姣忓満鏀惰垂锛�");
                 }
-                if(model.getZlFirstPrice() == null){//棣栨湡淇℃伅
+                if(model.getZlFirstCircle() == null){//棣栨湡淇℃伅
                     model.setZlFirstPrice(d.getPrice());
                     model.setZlFirstCircle(d.getCircleType());
                 }
@@ -1124,7 +1108,7 @@
                         Constants.equalsInteger(d.getCircleType(),Constants.SIX)){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鐗╀笟鏉℃鍙湁閫夋嫨涓�娆℃�т粯娆炬椂锛屾墠鑳介�夋嫨璇ユ寜姣忓満鏀惰垂锛�");
                 }
-                if(model.getWyFirstPrice() == null){
+                if(model.getWyFirstCircle() == null){
                     //棣栨湡淇℃伅
                     model.setWyFirstPrice(d.getPrice());
                     model.setWyFirstCircle(d.getCircleType());
@@ -1286,47 +1270,55 @@
                     .orderByAsc(YwWorkorderLog::getCreateDate)));
 
             //鏌ヨ璐﹀崟闆嗗悎
-            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()));
-            }
+            queryBillListByModel(model,new Date());
+        }
+        return model;
+    }
+    @Override
+    public YwContract findForBills(YwContract model) {
+        queryBillListByModel(model,model.getBtDate());
+        return model;
 
-            model.setCanBackRentBills(new ArrayList<>());
-            long nowStart = Utils.Date.getStart(new Date()).getTime();
-            long nowEnd = Utils.Date.getEnd(new Date()).getTime();
-            if(model.getBillList()!=null && model.getBillList().size()>0){
-                for(YwContractBill bill: model.getBillList()){
-                    //浠樻鐘舵�侊細0=寰呮敹娆撅紱1=宸茬粨娓咃紱2=閮ㄥ垎缁撴竻锛�3=寰呬粯娆撅紱4=寰呴��娆撅紱5=宸插叧闂�
-                    if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO)
-                            ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){
-                        if(bill.getStartDate().getTime()>nowEnd){
-                            //濡傛灉杩樻病寮�濮嬶紝璐﹀崟鐩存帴鍏抽棴
-                            continue;
-                        }
-                        model.getCanBackRentBills().add(bill);
+    }
+    private void queryBillListByModel(YwContract model,Date date) {
+        //鏌ヨ璐﹀崟闆嗗悎
+        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)));
 
-                    }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
-                        if(bill.getEndDate().getTime()<nowStart){
-                            //濡傛灉宸茬粨娓咃紝璐﹀崟鐩存帴鍏抽棴
-                            continue;
-                        }
-                        model.getCanBackRentBills().add(bill);
-                    }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.TWO) ){
-                        model.getCanBackRentBills().add(bill);
+        for (YwContractBill ywContractBill:model.getBillList()) {
+            ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
+        }
+        model.setCanBackRentBills(new ArrayList<>());
+        long nowStart = Utils.Date.getStart(date).getTime();
+        long nowEnd = Utils.Date.getEnd(date).getTime();
+        if(model.getBillList()!=null && model.getBillList().size()>0){
+            for(YwContractBill bill: model.getBillList()){
+                //浠樻鐘舵�侊細0=寰呮敹娆撅紱1=宸茬粨娓咃紱2=閮ㄥ垎缁撴竻锛�3=寰呬粯娆撅紱4=寰呴��娆撅紱5=宸插叧闂�
+                if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO)
+                        ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){
+                    if(bill.getStartDate().getTime()>nowEnd){
+                        //濡傛灉杩樻病寮�濮嬶紝璐﹀崟鐩存帴鍏抽棴
+                        continue;
                     }
+                    model.getCanBackRentBills().add(bill);
+
+                }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
+                    if(bill.getEndDate().getTime()<nowStart){
+                        //濡傛灉宸茬粨娓咃紝璐﹀崟鐩存帴鍏抽棴
+                        continue;
+                    }
+                    model.getCanBackRentBills().add(bill);
+                }else  if(Constants.equalsInteger(bill.getPayStatus(),Constants.TWO) ){
+                    model.getCanBackRentBills().add(bill);
                 }
             }
-
         }
-
-        return model;
     }
 
     @Override

--
Gitblit v1.9.3