Xiaojh 4 years ago
parent
commit
593fa78f5c

+ 28 - 8
smart-city-platform/src/main/resources/mapper/pay/PayReportMapper.xml

@@ -205,8 +205,8 @@
             ifnull(count(distinct a.payseriesno),0) "frequency",
             ifnull(round(sum(a.transamount),3),'0.000') as "receivedamount",
             ifnull(FLOOR(sum(a.transamount)/p.totalprice_l1),0) as "amount",
-            round(ifnull((FLOOR(sum(a.transamount)/p.totalprice_l1))*(max(case when e.feetype = 1 then e.price end )),0 ),3)as "sfee",
-            round(ifnull((FLOOR(sum(a.transamount)/p.totalprice_l1))*(max(case when e.feetype = 4 then e.price end )),0 ),3) as "wsfee",
+            round(ifnull((FLOOR(sum(a.transamount)/p.totalprice_l1))*(max(tab.p1 )),0 ),3)as "sfee",
+            round(ifnull((FLOOR(sum(a.transamount)/p.totalprice_l1))*(max(tab.p4 )),0 ),3) as "wsfee",
             '0.000' as "ysfee",
             '0.000' as "fjfee"
         FROM
@@ -215,8 +215,18 @@
         left join pay_base_customerandmeterrela c on c.account_id = a.account_id
         left join pay_base_waterproperty p on p.id = c.waterproperty_id
         left join pay_base_watercategory w on w.id = p.category_id
-        left join pay_base_priceofwaterproperty b on p.id = b.waterproperty_id
-        left join pay_base_waterprice e on b.waterprice_id = e.id and e.ladderlevel = 1
+        left join
+        (
+            select
+                w.id,
+                max(case when e.feetype = 1 then e.price end) as "p1",
+                max(case when e.feetype = 4 then e.price end) as "p4"
+            from pay_base_waterproperty w
+            left join pay_base_priceofwaterproperty p on p.waterproperty_id = w.id
+            left join pay_base_waterprice e on e.id = p.waterprice_id
+            where e.ladderlevel = '1'
+            GROUP BY w.id
+        )tab on tab.id = p.id
         left join sc_organization o on o.id = c.office_id
         left join sc_user u on u.id = a.create_by
         <where>
@@ -256,16 +266,26 @@
             ifnull(count(distinct a.payseriesno),0) "frequency",
             ifnull(round(sum(a.receivedamount),3),'0.000') as "receivedamount",
             ifnull(FLOOR(sum(a.receivedamount)/p.totalprice_l1),0) as "amount",
-            round(ifnull((FLOOR(sum(a.receivedamount)/p.totalprice_l1))*(max(case when e.feetype = 1 then e.price end )),0 ),3)as "sfee",
-            round(ifnull((FLOOR(sum(a.receivedamount)/p.totalprice_l1))*(max(case when e.feetype = 4 then e.price end )),0 ),3) as "wsfee",
+            round(ifnull((FLOOR(sum(a.receivedamount)/p.totalprice_l1))*(max(tab.p1 )),0 ),3)as "sfee",
+            round(ifnull((FLOOR(sum(a.receivedamount)/p.totalprice_l1))*(max(tab.p4 )),0 ),3) as "wsfee",
             '0.000' as "ysfee",
             '0.000' as "fjfee"
         from pay_pay_received a
         left join pay_base_customerandmeterrela c on c.account_id = a.account_id
         left join pay_base_waterproperty p on p.id = c.waterproperty_id
         left join pay_base_watercategory w on w.id = p.category_id
-        left join pay_base_priceofwaterproperty b on p.id = b.waterproperty_id
-        left join pay_base_waterprice e on b.waterprice_id = e.id and e.ladderlevel = 1
+        left join
+        (
+            select
+            w.id,
+            max(case when e.feetype = 1 then e.price end) as "p1",
+            max(case when e.feetype = 4 then e.price end) as "p4"
+            from pay_base_waterproperty w
+            left join pay_base_priceofwaterproperty p on p.waterproperty_id = w.id
+            left join pay_base_waterprice e on e.id = p.waterprice_id
+            where e.ladderlevel = '1'
+            GROUP BY w.id
+        )tab on tab.id = p.id
         left join sc_organization o on o.id = c.office_id
         left join sc_user u on u.id = a.create_by
         <where>