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/YwContractBillServiceImpl.java |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
index 0c3e1dc..471d18f 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
@@ -189,7 +189,8 @@
     public YwContractBill getDetail(Integer id) {
         YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(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  ")
                         .selectAs(YwContract::getCode,YwContractBill::getContractCode)
                         .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
                         .selectAs(Company::getName,YwContractBill::getCompanyName)
@@ -279,7 +280,8 @@
         YwContractBill model = pageWrap.getModel();
         IPage<YwContractBill> iPage = ywContractBillMapper.selectJoinPage(page,YwContractBill.class,
             queryWrapper.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  ")
                     .selectAs(YwContract::getCode,YwContractBill::getContractCode)
                     .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
                     .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
@@ -300,8 +302,9 @@
                     .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getContractCode()),
                             YwContract::getCode,model.getContractCode())
                 .ge(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateStart()),YwContractBill::getPlanPayDate, Utils.Date.getStart(model.getPlanPayDateStart()))
-                .le(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),YwContractBill::getPlanPayDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) )
-        ;
+                .le(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),YwContractBill::getPlanPayDate, Utils.Date.getEnd(model.getPlanPayDateEnd()))
+                    .orderByDesc(YwContractBill::getId));
+
         this.dealRoomDetail(iPage.getRecords());
         for (YwContractBill ywContractBill:iPage.getRecords()) {
             //闇�鏀堕噾棰�
@@ -460,7 +463,8 @@
     public List<YwContractBill> getCanBackBill(YwContractBill model) {
         List<YwContractBill> list = 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  ")
                         .selectAs(YwContract::getCode,YwContractBill::getContractCode)
                         .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
                         .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
@@ -469,7 +473,9 @@
                         .in(YwContractBill::getCostType,Constants.ZERO,Constants.ONE,Constants.FOUR,Constants.FIVE,7)
                         .eq(Objects.nonNull(model)&&Objects.nonNull(model.getContractId()),
                                 YwContractBill::getContractId,model.getContractId())
-                        .le(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),YwContractBill::getStartDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) )
+                        .and(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),
+                                i->i.le(YwContractBill::getStartDate, Utils.Date.getEnd(model.getPlanPayDateEnd())).or()
+                        .in(YwContractBill::getPayStatus,Constants.ONE,Constants.TWO) ))
                 ;
 
         for (YwContractBill ywContractBill:list) {

--
Gitblit v1.9.3