|
@@ -55,6 +55,7 @@
|
|
|
select
|
|
|
a.id,
|
|
|
a.invoiceno as "invoiceno",
|
|
|
+ a.account_id as "accountId",
|
|
|
a.accountnumber as "accountnumber",
|
|
|
a.accountname as "accountname",
|
|
|
a.invoiceamount as "invoiceamount",
|
|
@@ -72,6 +73,7 @@
|
|
|
select
|
|
|
a.id,
|
|
|
a.invoiceno as "invoiceno",
|
|
|
+ a.account_id as "accountId",
|
|
|
a.accountnumber as "accountnumber",
|
|
|
a.accountname as "accountname",
|
|
|
a.invoiceamount as "invoiceamount",
|
|
@@ -178,22 +180,29 @@
|
|
|
,account.accountnumber
|
|
|
,account.address
|
|
|
,u.name AS "createBy"
|
|
|
+ ,a.year
|
|
|
+ ,a.month
|
|
|
,(select customer_name from sc_customer where id=#{customerId}) as "customerName"
|
|
|
from pay_pay_transactiondetails a
|
|
|
left join pay_base_account account on account.id=a.account_id
|
|
|
left join sc_user u on u.id=a.create_by
|
|
|
where a.payseriesno =#{payseriesno} and a.site_id=#{siteId} and a.customer_id=#{customerId}
|
|
|
- and a.canceledrecord_id is null and a.iscanceled=0
|
|
|
+ and a.canceledrecord_id is null and a.iscanceled=0 and payway != 5
|
|
|
</select>
|
|
|
|
|
|
<select id="getPrintDataKailu" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
|
|
|
select
|
|
|
d.water_meter_no as eleno
|
|
|
+ ,account.id AS "accountId"
|
|
|
+ ,account.name AS "accountname"
|
|
|
+ ,account.accountnumber
|
|
|
+ ,account.address
|
|
|
,c.metercode
|
|
|
,p.name as waterPropertyName
|
|
|
,p.price1 as price1
|
|
|
,p.price4 as price4
|
|
|
from pay_base_customerandmeterrela c
|
|
|
+ left join pay_base_account account on account.id=c.account_id
|
|
|
left join sc_device d on c.watermeter_id=d.id
|
|
|
left join (
|
|
|
select
|
|
@@ -229,12 +238,13 @@
|
|
|
max(amount.reading) as "reading",
|
|
|
min(amount.lastreading) as "lastreading",
|
|
|
max(reced.create_date) as "createDate",
|
|
|
+ sum(amount.payamount) as "payamount",
|
|
|
(select name from sc_user where id=max(reced.create_by)) as "createBy",
|
|
|
- (select customer_name from sc_customer where id=#{customerId}) as "customerName"
|
|
|
+ (select customer_name from sc_customer where id=max(reced.customer_id)) as "customerName"
|
|
|
from pay_pay_received reced
|
|
|
left join pay_pay_receivable rece on reced.receivable_id=rece.id
|
|
|
left join pay_amount_waterusedamount amount on amount.id=rece.usedamount_id
|
|
|
- where reced.payseriesno=#{payseriesno} and reced.site_id=#{siteId} and reced.customer_id=#{customerId}
|
|
|
+ where reced.payseriesno=#{payseriesno}
|
|
|
group by amount.account_id
|
|
|
|
|
|
</select>
|
|
@@ -344,4 +354,101 @@
|
|
|
where id=#{id}
|
|
|
|
|
|
</update>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="countTransactiondetails" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
|
|
|
+ select
|
|
|
+ account_id as "accountId"
|
|
|
+ ,max(minPeriod) minPeriod
|
|
|
+ ,max(remaining) remaining
|
|
|
+ ,max(lastRemaining) lastRemaining
|
|
|
+ ,max(createBy) createBy
|
|
|
+ ,max(createDate) createDate
|
|
|
+ ,sum(transamount) transamount
|
|
|
+ from (
|
|
|
+ select
|
|
|
+ account_id
|
|
|
+ ,max(year*12 + month ) minPeriod
|
|
|
+ ,max(lastrecreamaing) remaining
|
|
|
+ ,max(remaining) lastRemaining
|
|
|
+ ,(select u.name from sc_user u where id = max(t.create_by)) createBy
|
|
|
+ ,max(create_date) createDate
|
|
|
+ ,sum(case when payway != 5 then transamount else 0 end ) transamount
|
|
|
+ from pay_pay_transactiondetails t
|
|
|
+ where payseriesno=#{payseriesno}
|
|
|
+ group by account_id
|
|
|
+ union all
|
|
|
+ select
|
|
|
+ account_id
|
|
|
+ ,0 minPeriod
|
|
|
+ ,0 remaining
|
|
|
+ ,0 lastRemaining
|
|
|
+ ,(select u.name from sc_user u where id = max(r.create_by)) createBy
|
|
|
+ ,max(create_date) createDate
|
|
|
+ ,sum(case when payway != 5 then r.receivedamount else 0 end ) transamount
|
|
|
+ from pay_pay_received r
|
|
|
+ where payseriesno=#{payseriesno}
|
|
|
+ group by account_id
|
|
|
+ ) t
|
|
|
+ group by account_id
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getAmountPeriod" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
|
|
|
+ select
|
|
|
+ max(amount.year*12+amount.`month`) as "maxPeriod",
|
|
|
+ min(amount.year*12+amount.`month`) as "minPeriod"
|
|
|
+ from pay_pay_received reced
|
|
|
+ left join pay_pay_receivable rece on reced.receivable_id=rece.id
|
|
|
+ left join pay_amount_waterusedamount amount on amount.id=rece.usedamount_id
|
|
|
+ where reced.payseriesno=#{payseriesno}
|
|
|
+ </select>
|
|
|
+ <select id="getAmountInfoAndReceivablefee" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
|
|
|
+ select
|
|
|
+ amount.account_id
|
|
|
+ ,sum(rece.receivablefee) receivablefee
|
|
|
+ ,sum(amount.payamount) payamount
|
|
|
+ ,min(amount.lastreading) lastreading
|
|
|
+ ,min(amount.lastrecorddate) lastrecorddate
|
|
|
+ ,max(amount.reading) reading
|
|
|
+ ,max(amount.recorddate) recorddate
|
|
|
+ from pay_amount_waterusedamount amount
|
|
|
+ left join pay_pay_receivable rece on rece.usedamount_id =amount.id
|
|
|
+ where amount.account_id =#{accountId}
|
|
|
+ and amount.year*12 + amount.month <= #{maxPeriod}
|
|
|
+ and amount.year*12 + amount.month >= #{minPeriod}
|
|
|
+ group by amount.account_id
|
|
|
+ </select>
|
|
|
+ <select id="getAccountBaseInfo" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
|
|
|
+ select
|
|
|
+ a.accountnumber
|
|
|
+ ,a.name as accountname
|
|
|
+ ,a.address as address
|
|
|
+ ,p.totalprice_l1 as totalPrice
|
|
|
+ ,d.water_meter_no as eleno
|
|
|
+ ,l.`name` as livingareaName
|
|
|
+ ,re.remaining
|
|
|
+ from pay_base_account a
|
|
|
+ left join pay_base_customerandmeterrela c on c.account_id=a.id
|
|
|
+ left join pay_pay_rechargeaccount re on re.account_id =a.id
|
|
|
+ left join pay_base_waterproperty p on p.id=c.waterproperty_id
|
|
|
+ left join sc_device d on d.id=c.watermeter_id
|
|
|
+ left join sc_building bd on bd.id=d.building_id
|
|
|
+ left join sc_community l on l.id=bd.community
|
|
|
+ where a.id= #{accountId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getPayInvoiceType" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
|
|
|
+ select
|
|
|
+ max(printType) printType
|
|
|
+ ,max(c.pay_invoice_type) payInvoiceType
|
|
|
+ from (
|
|
|
+ select account_id , 1 printType ,customer_id from pay_pay_transactiondetails where payseriesno = #{payseriesno}
|
|
|
+ union all
|
|
|
+ select account_id , 2 printType ,customer_id from pay_pay_received where payseriesno = #{payseriesno}
|
|
|
+ ) t
|
|
|
+ left join sc_customer c on c.id =t.customer_id
|
|
|
+
|
|
|
+ </select>
|
|
|
</mapper>
|