|
@@ -223,40 +223,50 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getPayfeeInfoPrint" resultType="com.bz.smart_city.dto.pay.payfee.PrintReceivedInfo">
|
|
|
- select * from (
|
|
|
select
|
|
|
- a.account_id as "accountId",
|
|
|
- re.feetypename,
|
|
|
- re.ladderlevel,
|
|
|
- (case when re.ladderlevel = 1 then '一阶'
|
|
|
- when re.ladderlevel = 2 then '二阶'
|
|
|
- when re.ladderlevel = 3 then '三阶'
|
|
|
- when re.ladderlevel = 4 then '四阶'
|
|
|
- else '' end) as "ladderlevelname",
|
|
|
- re.payamount,
|
|
|
- re.waterbasicprice,
|
|
|
- sum(case when payway != 4 then reced.receivedamount else 0 end ) receivedamount,
|
|
|
- sum(case when payway = 4 then reced.receivedamount else 0 end ) autoReceivedamount
|
|
|
- from pay_amount_waterusedamount a
|
|
|
- left join pay_pay_receivable re on a.id=re.usedamount_id
|
|
|
- left join pay_pay_received reced on reced.receivable_id=re.id
|
|
|
- where re.feetype=1 and a.`year`*12+a.`month` >= #{minPeriod} and a.`year`*12+a.`month` <= #{maxPeriod} and a.account_id=#{accountId}
|
|
|
- group by a.account_id, re.feetypename,re.ladderlevel,re.payamount,re.waterbasicprice
|
|
|
- union all
|
|
|
- select
|
|
|
- a.account_id,
|
|
|
- re.feetypename,
|
|
|
- '' as "ladderlevel",
|
|
|
- '' as "ladderlevelname",
|
|
|
- sum(re.payamount) as "payamount",
|
|
|
- max(re.waterbasicprice) as "waterbasicprice",
|
|
|
- sum(case when payway != 4 then reced.receivedamount else 0 end ) receivedamount,
|
|
|
- sum(case when payway = 4 then reced.receivedamount else 0 end ) autoReceivedamount
|
|
|
- from pay_amount_waterusedamount a
|
|
|
- left join pay_pay_receivable re on a.id=re.usedamount_id
|
|
|
- left join pay_pay_received reced on reced.receivable_id=re.id
|
|
|
- where re.feetype !=1 and a.`year`*12+a.`month` >= #{minPeriod} and a.`year`*12+a.`month` <= #{maxPeriod} and a.account_id=#{accountId}
|
|
|
- group by a.account_id,re.feetypename
|
|
|
+ accountId ,
|
|
|
+ feetypename,
|
|
|
+ ladderlevel,
|
|
|
+ ladderlevelname,
|
|
|
+ feetypename+ladderlevelname as "itemname",
|
|
|
+ payamount,
|
|
|
+ waterbasicprice,
|
|
|
+ receivedamount,
|
|
|
+ autoReceivedamount
|
|
|
+ from (
|
|
|
+ select
|
|
|
+ a.account_id as "accountId",
|
|
|
+ re.feetypename,
|
|
|
+ re.ladderlevel,
|
|
|
+ (case when re.ladderlevel = 1 then '一阶'
|
|
|
+ when re.ladderlevel = 2 then '二阶'
|
|
|
+ when re.ladderlevel = 3 then '三阶'
|
|
|
+ when re.ladderlevel = 4 then '四阶'
|
|
|
+ else '' end) as "ladderlevelname",
|
|
|
+ re.payamount,
|
|
|
+ re.waterbasicprice,
|
|
|
+ sum(case when payway != 4 then reced.receivedamount else 0 end ) receivedamount,
|
|
|
+ sum(case when payway = 4 then reced.receivedamount else 0 end ) autoReceivedamount
|
|
|
+ from pay_amount_waterusedamount a
|
|
|
+ left join pay_pay_receivable re on a.id=re.usedamount_id
|
|
|
+ left join pay_pay_received reced on reced.receivable_id=re.id
|
|
|
+ where re.feetype=1 and a.`year`*12+a.`month` >= #{minPeriod} and a.`year`*12+a.`month` <= #{maxPeriod} and a.account_id=#{accountId}
|
|
|
+ group by a.account_id, re.feetypename,re.ladderlevel,re.payamount,re.waterbasicprice
|
|
|
+ union all
|
|
|
+ select
|
|
|
+ a.account_id,
|
|
|
+ re.feetypename,
|
|
|
+ '' as "ladderlevel",
|
|
|
+ '' as "ladderlevelname",
|
|
|
+ sum(re.payamount) as "payamount",
|
|
|
+ max(re.waterbasicprice) as "waterbasicprice",
|
|
|
+ sum(case when payway != 4 then reced.receivedamount else 0 end ) receivedamount,
|
|
|
+ sum(case when payway = 4 then reced.receivedamount else 0 end ) autoReceivedamount
|
|
|
+ from pay_amount_waterusedamount a
|
|
|
+ left join pay_pay_receivable re on a.id=re.usedamount_id
|
|
|
+ left join pay_pay_received reced on reced.receivable_id=re.id
|
|
|
+ where re.feetype !=1 and a.`year`*12+a.`month` >= #{minPeriod} and a.`year`*12+a.`month` <= #{maxPeriod} and a.account_id=#{accountId}
|
|
|
+ group by a.account_id,re.feetypename
|
|
|
)s
|
|
|
order by s.accountId,s.feetypename,s.ladderlevel
|
|
|
</select>
|