123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="com.bz.smart_city.dao.pay.PayReportMapper">
- <select id="getPayTransactiondetailsReportList" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsReportDto">
- SELECT
- ppt.accountnumber as accountNumber,
- ppt.accountname as accountName,
- ppt.transamount as transAmount,
- ppt.transtime as transTime,
- ppt.create_by as createBy,
- ppt.office_id as officeId,
- ppt.transtype as transTypee,
- ppt.transtypelabel as transTypeLabel,
- ppt.payway as payWay,
- ppt.paywayLabel as paywayLabel,
- scu.NAME as createByName,
- ppa.address as accountAddr
- FROM
- pay_pay_transactiondetails ppt
- LEFT JOIN pay_base_account ppa ON ppt.accountnumber = ppa.accountnumber
- LEFT JOIN sc_user scu ON ppt.create_by = scu.id
- WHERE
- ppt.transtype =1 and (ppt.iscanceled = 0 or ppt.iscanceled is null) and ppt.canceledrecord_id is null
- <if test="customerId != null"> and ppt.customer_id = #{customerId}</if>
- <if test="siteId != null"> and ppt.site_id = #{siteId}</if>
- <if test ="officeId != null"> and ppt.office_id = #{officeId}</if>
- <if test="createBy != null"> and ppt.create_by = #{createBy}</if>
- <if test="beginTime != null"> and ppt.transtime >= #{beginTime,jdbcType=TIMESTAMP}</if>
- <if test="endTime != null"> and ppt.transtime <= #{endTime,jdbcType=TIMESTAMP}</if>
- <if test="payWay != null"> and ppt.payway = #{payWay}</if>
- order by ppt.transtime desc
- </select>
- <select id="getPayTransactiondetailsReportCount" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsReportDto">
- SELECT
- '合计' as accountNumber,
- SUM(ppt.transamount) as transAmount
- FROM
- pay_pay_transactiondetails ppt
- LEFT JOIN pay_base_account ppa ON ppt.accountnumber = ppa.accountnumber
- LEFT JOIN sc_user scu ON ppt.create_by = scu.id
- WHERE
- ppt.transtype =1 and (ppt.iscanceled = 0 or ppt.iscanceled is null) and ppt.canceledrecord_id is null
- <if test="customerId != null"> and ppt.customer_id = #{customerId}</if>
- <if test="siteId != null"> and ppt.site_id = #{siteId}</if>
- <if test ="officeId != null"> and ppt.office_id = #{officeId}</if>
- <if test="createBy != null"> and ppt.create_by = #{createBy}</if>
- <if test="beginTime != null"> and ppt.transtime >= #{beginTime,jdbcType=TIMESTAMP}</if>
- <if test="endTime != null"> and ppt.transtime <= #{endTime,jdbcType=TIMESTAMP}</if>
- <if test="payWay != null"> and ppt.payway = #{payWay}</if>
- </select>
- <select id="getPayOperatordetailsReportList" resultType="com.bz.smart_city.dto.pay.PayOperatordetailsReportDto">
- SELECT * from
- (
- SELECT
- pba.`name` as accountName,
- pba.accountnumber as accountNumber,
- pba.address as accountAddr,
- scc.`name` communityName,
- SUM(ppr.receivedamount) receivedCount,
- max(ifnull(ppt.transamount,0)) transamount,
- sum(ppr.receivedamount) + max(ifnull(ppt.transamount,0)) subtotal,
- min(ppr.create_date) transTime,
- min(scu.`name`) createByName
- FROM pay_pay_received ppr
- LEFT JOIN pay_base_account pba on ppr.account_id = pba.id
- LEFT JOIN sc_community scc on scc.`code` = substring(pba.accountnumber,1,3)
- LEFT JOIN sc_user scu on scu.id = ppr.create_by
- LEFT JOIN pay_pay_transactiondetails ppt on ppt.payseriesno = ppr.payseriesno and ppt.transtype = 4
- <where>
- ppr.canceledrecord_id is null and ppr.iscanceled =0
- <if test="customerId != null"> and ppr.customer_id = #{customerId}</if>
- <if test="siteId != null"> and ppr.site_id = #{siteId}</if>
- <if test="community != null and community != ''"> and scc.code = #{community,jdbcType=VARCHAR} </if>
- <if test="createBy != null"> and ppr.create_by = #{createBy} </if>
- <if test="beginTime != null"> and ppr.create_date >= #{beginTime,jdbcType=TIMESTAMP}</if>
- <if test="endTime != null"> and ppr.create_date <= #{endTime,jdbcType=TIMESTAMP}</if>
- </where>
- GROUP BY pba.`name`,pba.accountnumber,pba.address,scc.`name`
- ) tb
- <where>
- <if test="dataType != null and subtotal != null">
- <if test="dataType == 0"> subtotal = #{subtotal}</if>
- <if test="dataType == 1"> subtotal < #{subtotal}</if>
- <if test="dataType == 2"> subtotal > #{subtotal}</if>
- </if>
- </where>
- </select>
- <select id="getPayOperatordetailsReportCount" resultType="com.bz.smart_city.dto.pay.PayOperatordetailsReportDto">
- SELECT
- '合计' as accountName,
- sum(receivedCount) receivedCount,
- sum(transamount) transamount,
- sum(subtotal) subtotal
- from
- (
- SELECT
- pba.`name` as accountName,
- pba.accountnumber as accountNumber,
- pba.address as accountAddr,
- scc.`name` communityName,
- SUM(ppr.receivedamount) receivedCount,
- max(ifnull(ppt.transamount,0)) transamount,
- sum(ppr.receivedamount) + max(ifnull(ppt.transamount,0)) subtotal,
- min(ppr.create_date) transTime,
- min(scu.`name`) createByName
- FROM pay_pay_received ppr
- LEFT JOIN pay_base_account pba on ppr.account_id = pba.id
- LEFT JOIN sc_community scc on scc.`code` = substring(pba.accountnumber,1,3) and scc.customer_id = 47
- LEFT JOIN sc_user scu on scu.id = ppr.create_by
- LEFT JOIN pay_pay_transactiondetails ppt on ppt.payseriesno = ppr.payseriesno and ppt.transtype = 4
- <where>
- ppr.canceledrecord_id is null and ppr.iscanceled =0
- <if test="customerId != null"> and ppr.customer_id = #{customerId}</if>
- <if test="siteId != null"> and ppr.site_id = #{siteId}</if>
- <if test="community != null and community != ''"> and scc.code = #{community,jdbcType=VARCHAR} </if>
- <if test="createBy != null"> and ppr.create_by = #{createBy} </if>
- <if test="beginTime != null"> and ppr.create_date >= #{beginTime,jdbcType=TIMESTAMP}</if>
- <if test="endTime != null"> and ppr.create_date <= #{endTime,jdbcType=TIMESTAMP}</if>
- </where>
- GROUP BY pba.`name`,pba.accountnumber,pba.address,scc.`name`
- ) tb
- <where>
- <if test="dataType != null and subtotal != null">
- <if test="dataType == 0"> subtotal = #{subtotal}</if>
- <if test="dataType == 1"> subtotal < #{subtotal}</if>
- <if test="dataType == 2"> subtotal > #{subtotal}</if>
- </if>
- </where>
- </select>
- <select id="getPayArrearagedetailsReportList" resultType="com.bz.smart_city.dto.pay.PayArrearagedetailsReportDto">
- SELECT
- pba.NAME as accountName,
- pba.accountnumber as accountNumber,
- pba.address as accountAddr,
- pba.mobilephone as mobilePhone,
- sum( CASE WHEN pprb.feetype = 1 THEN pprb.receivablefee ELSE 0 END ) as payamountFee,
- sum( CASE WHEN pprb.feetype = 3 THEN pprb.receivablefee ELSE 0 END ) as taxExemptFee,
- sum( CASE WHEN pprb.feetype = 4 THEN pprb.receivablefee ELSE 0 END ) as polluteFee,
- 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,
- 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
- <where>
- <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>
- <if test="community != null and community != ''"> and substring(pba.accountnumber,1,3) = #{community,jdbcType=VARCHAR}</if>
- <if test="accountNumber != null and accountNumber != ''"> and pba.accountnumber like concat('%',#{accountNumber},'%')</if>
- </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
- </select>
- <select id="getPayArrearagedetailsReportCount" resultType="com.bz.smart_city.dto.pay.PayArrearagedetailsReportDto">
- SELECT
- '合计' as accountName,
- sum(payamount) as payamount,
- sum(payamountFee) as payamountFee,
- sum(taxExemptFee) as taxExemptFee,
- sum(polluteFee) as polluteFee,
- sum(penltyFee) as penltyFee,
- sum(outLevelFee) as outLevelFee,
- sum(subtotal) as subtotal,
- sum(debtFee) as debtFee
- FROM
- (
- SELECT
- pba.NAME as accountName,
- pba.accountnumber as accountNumber,
- pba.address as accountAddr,
- pba.mobilephone as mobilePhone,
- sum( CASE WHEN pprb.feetype = 1 THEN pprb.receivablefee ELSE 0 END ) as payamountFee,
- sum( CASE WHEN pprb.feetype = 3 THEN pprb.receivablefee ELSE 0 END ) as taxExemptFee,
- sum( CASE WHEN pprb.feetype = 4 THEN pprb.receivablefee ELSE 0 END ) as polluteFee,
- 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,
- 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
- <where>
- <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>
- <if test="community != null and community != ''"> and substring(pba.accountnumber,1,3) = #{community,jdbcType=VARCHAR}</if>
- <if test="accountNumber != null and accountNumber != ''"> and pba.accountnumber like concat('%',#{accountNumber},'%')</if>
- </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
- ) tb
- </select>
- </mapper>
|