From ba5210dc8c6c537cacc59c18d58baa9744cd2b9d Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 10 五月 2022 11:14:39 +0800
Subject: [PATCH] 优化报修单推送bug

---
 java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
index e6f6c24..9dc8aad 100755
--- a/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -692,7 +692,7 @@
             and pfc.start_time &lt;= #{endTime}
         </if>
         <if test="yearMonth !=null and yearMonth != ''">
-            and concat(t.fee_year,t.fee_month) = #{yearMonth}
+            and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
         </if>
 
         group by t.config_id,t.fee_name,pfc.start_time
@@ -762,7 +762,7 @@
             and pfc.start_time &lt;= #{endTime}
         </if>
         <if test="yearMonth !=null and yearMonth != ''">
-            and concat(t.fee_year,t.fee_month) = #{yearMonth}
+            and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
         </if>
         group by t.config_id,t.fee_name,pfc.start_time
         order by t.create_time desc
@@ -831,7 +831,7 @@
             and pfc.start_time &lt;= #{endTime}
         </if>
         <if test="yearMonth !=null and yearMonth != ''">
-            and concat(t.fee_year,t.fee_month) = #{yearMonth}
+            and concat(t.fee_year,lpad(t.fee_month,2,0)) = #{yearMonth}
         </if>
         order by t.create_time desc
     </select>
@@ -894,8 +894,12 @@
     <select id="queryFeeDetail" parameterType="Map" resultType="Map">
         select t.obj_name objName,t.fee_name feeName,t.fee_create_time feeCreateTime,pfa.`value`
         ownerName,br.built_up_area builtUpArea ,max(t.deadline_time)
-        deadlineTime,t.create_time createTime,SUM(t.receivable_amount) receivableAmount,SUM(t.received_amount)
-        receivedAmount,SUM(t.owe_amount) oweAmount,max(t.update_time) updateTime
+        deadlineTime,t.create_time createTime,max(t.update_time) updateTime,SUM(t.his_owe_amount)
+        hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
+        SUM(t.cur_received_amount) curReceivedAmount,SUM(t.his_owe_received_amount)
+        hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
+        sum(t.his_owe_amount+t.cur_receivable_amount) receivableAmount,
+        sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount
         from report_fee_month_statistics t
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
         left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
@@ -903,7 +907,7 @@
         left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
         inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
         left join pay_fee_attrs pfa on pf.fee_id = pfa.fee_id and pfa.spec_cd = '390008' and pfa.status_cd ='0'
-        where t.status_cd = '0' and t.receivable_amount >=0 and t.receivable_amount >= 0
+        where t.status_cd = '0'
         <if test="roomNum !=null and roomNum != ''">
             and br.room_num= #{roomNum}
         </if>
@@ -944,6 +948,7 @@
             and t.create_time &lt;= #{endTime}
         </if>
         group by t.config_id,t.fee_name,t.fee_create_time,t.obj_id,t.obj_name,pfa.`value`,br.built_up_area
+        order by pfa.`value`
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>
@@ -951,8 +956,14 @@
 
     <!-- 鏌ヨ璐圭敤鏈堢粺璁′俊鎭� add by wuxw 2018-07-03 -->
     <select id="queryAllFeeDetail" parameterType="Map" resultType="Map">
-        select SUM(t.receivable_amount) allReceivableAmount,SUM(t.received_amount) allReceivedAmount,
-        SUM(t.owe_amount) allOweAmount from report_fee_month_statistics t
+        select
+        SUM(t.his_owe_amount + t.cur_receivable_amount) allReceivableAmount,
+        SUM(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) allReceivedAmount,
+        if(SUM(t.his_owe_amount + t.cur_receivable_amount - t.cur_received_amount - t.his_owe_received_amount) &lt; 0,0,
+        SUM(t.his_owe_amount + t.cur_receivable_amount - t.cur_received_amount - t.his_owe_received_amount))
+        allOweAmount,
+        SUM(t.his_owe_received_amount) allHisOweReceivedAmount
+        from report_fee_month_statistics t
         inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
         left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
         left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
@@ -1098,6 +1109,7 @@
         </if>
         group by t.fee_name,t.payer_obj_id,t.payer_obj_name,pfa.`value`,br.built_up_area
         HAVING oweAmount > 0
+        order by pfa.`value`
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>
@@ -1931,7 +1943,7 @@
         select 1 from pay_fee pf where t.room_id = pf.payer_obj_id and pf.status_cd = '0' and pf.state = '2008001'
         )
         and t.community_id = #{communityId}
-        order by t.create_time desc
+        order by bo.name
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>
@@ -2559,13 +2571,13 @@
         and t.create_time &lt; #{endTime}
         and t.fee_id = #{feeId}
         <if test="flag == 1">
-            and concat(t.detail_year,t.detail_month) = #{yearMonth}
+            and concat(t.detail_year,lpad(t.detail_month,2,0)) = #{yearMonth}
         </if>
         <if test="flag == 2">
-            and concat(t.detail_year,t.detail_month) &lt; #{yearMonth}
+            and concat(t.detail_year,lpad(t.detail_month,2,0)) &lt; #{yearMonth}
         </if>
         <if test="flag == 3">
-            and concat(t.detail_year,t.detail_month) &gt; #{yearMonth}
+            and concat(t.detail_year,lpad(t.detail_month,2,0)) &gt; #{yearMonth}
         </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}

--
Gitblit v1.8.0