|
@@ -177,12 +177,14 @@
|
|
|
sum( CASE WHEN pprb.feetype = 6 THEN pprb.receivablefee ELSE 0 END ) as penltyFee,
|
|
|
sum( CASE WHEN pprb.feetype = 1 THEN pprb.payamount ELSE 0 END ) payamount,
|
|
|
sum( CASE WHEN pprb.ladderlevel != 1 THEN pprb.receivablefee ELSE 0 END ) as outLevelFee,
|
|
|
- sum( CASE WHEN pprb.receivablefee IS NULL THEN 0 ELSE pprb.receivablefee END ) as subtotal,
|
|
|
+ ppr.remaining - sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END ) as subtotal,
|
|
|
sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END ) as debtFee
|
|
|
FROM
|
|
|
pay_pay_receivable pprb
|
|
|
LEFT JOIN pay_base_account pba ON pba.id = pprb.account_id
|
|
|
+ LEFT JOIN pay_pay_rechargeaccount ppr on ppr.account_id = pprb.account_id
|
|
|
<where>
|
|
|
+ pprb.debt > 0
|
|
|
<if test="customerId != null"> and pprb.customer_id = #{customerId}</if>
|
|
|
<if test="siteId != null"> and pprb.site_id = #{siteId}</if>
|
|
|
<if test="officeId != null"> and pprb.office_id = #{officeId}</if>
|
|
@@ -192,13 +194,11 @@
|
|
|
</where>
|
|
|
|
|
|
GROUP BY
|
|
|
- pba.NAME,
|
|
|
pba.NAME,
|
|
|
pba.accountnumber,
|
|
|
pba.address,
|
|
|
- pba.mobilephone
|
|
|
- HAVING
|
|
|
- sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END )> 0
|
|
|
+ pba.mobilephone,
|
|
|
+ ppr.remaining
|
|
|
ORDER BY accountnumber asc
|
|
|
</select>
|
|
|
|