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 |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 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 b6d5a9f..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
@@ -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,9 +303,10 @@
         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;
@@ -505,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());
@@ -532,12 +535,18 @@
                         yjBill.setEditDate(param.getEditDate());
                         yjBill.setEditor(param.getEditor());
                         yjBill.setReceivableFee(BigDecimal.ZERO);
-                        yjBill.setPayStatus(Constants.FOUR);
+                        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);
                     }
                 }
-                yjNoBills ++;
+
             }
         }
         param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//鏈竻绠楃殑璐﹀崟鏁伴噺
@@ -917,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;
@@ -1036,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‘鐨勭璧佹潯娆惧厤绉熸湡淇℃伅锛�");
             }
@@ -1065,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());
                 }
@@ -1114,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());
@@ -1278,7 +1288,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