PayReportMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.bz.smart_city.dao.pay.PayReportMapper">
  4. <select id="getPayTransactiondetailsReportList" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsReportDto">
  5. SELECT
  6. ppt.accountnumber as accountNumber,
  7. ppt.accountname as accountName,
  8. ppt.transamount as transAmount,
  9. ppt.transtime as transTime,
  10. ppt.create_by as createBy,
  11. ppt.office_id as officeId,
  12. ppt.transtype as transTypee,
  13. ppt.transtypelabel as transTypeLabel,
  14. ppt.payway as payWay,
  15. ppt.paywayLabel as paywayLabel,
  16. scu.NAME as createByName,
  17. ppa.address as accountAddr
  18. FROM
  19. pay_pay_transactiondetails ppt
  20. LEFT JOIN pay_base_account ppa ON ppt.accountnumber = ppa.accountnumber
  21. LEFT JOIN sc_user scu ON ppt.create_by = scu.id
  22. WHERE
  23. ppt.transtype =1 and (ppt.iscanceled = 0 or ppt.iscanceled is null) and ppt.canceledrecord_id is null
  24. <if test="customerId != null"> and ppt.customer_id = #{customerId}</if>
  25. <if test="siteId != null"> and ppt.site_id = #{siteId}</if>
  26. <if test ="officeId != null"> and ppt.office_id = #{officeId}</if>
  27. <if test="createBy != null"> and ppt.create_by = #{createBy}</if>
  28. <if test="beginTime != null"> and ppt.transtime >= #{beginTime,jdbcType=TIMESTAMP}</if>
  29. <if test="endTime != null"> and ppt.transtime &lt;= #{endTime,jdbcType=TIMESTAMP}</if>
  30. <if test="payWay != null"> and ppt.payway = #{payWay}</if>
  31. order by ppt.transtime desc
  32. </select>
  33. <select id="getPayTransactiondetailsReportCount" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsReportDto">
  34. SELECT
  35. '合计' as accountNumber,
  36. SUM(ppt.transamount) as transAmount
  37. FROM
  38. pay_pay_transactiondetails ppt
  39. LEFT JOIN pay_base_account ppa ON ppt.accountnumber = ppa.accountnumber
  40. LEFT JOIN sc_user scu ON ppt.create_by = scu.id
  41. WHERE
  42. ppt.transtype =1 and (ppt.iscanceled = 0 or ppt.iscanceled is null) and ppt.canceledrecord_id is null
  43. <if test="customerId != null"> and ppt.customer_id = #{customerId}</if>
  44. <if test="siteId != null"> and ppt.site_id = #{siteId}</if>
  45. <if test ="officeId != null"> and ppt.office_id = #{officeId}</if>
  46. <if test="createBy != null"> and ppt.create_by = #{createBy}</if>
  47. <if test="beginTime != null"> and ppt.transtime >= #{beginTime,jdbcType=TIMESTAMP}</if>
  48. <if test="endTime != null"> and ppt.transtime &lt;= #{endTime,jdbcType=TIMESTAMP}</if>
  49. <if test="payWay != null"> and ppt.payway = #{payWay}</if>
  50. </select>
  51. <select id="getPayOperatordetailsReportList" resultType="com.bz.smart_city.dto.pay.PayOperatordetailsReportDto">
  52. SELECT * from
  53. (
  54. SELECT
  55. pba.`name` as accountName,
  56. pba.accountnumber as accountNumber,
  57. pba.address as accountAddr,
  58. scc.`name` communityName,
  59. SUM(ppr.receivedamount) receivedCount,
  60. max(ifnull(ppt.transamount,0)) transamount,
  61. sum(ppr.receivedamount) + max(ifnull(ppt.transamount,0)) subtotal,
  62. min(ppr.create_date) transTime,
  63. min(scu.`name`) createByName
  64. FROM pay_pay_received ppr
  65. LEFT JOIN pay_base_account pba on ppr.account_id = pba.id
  66. LEFT JOIN sc_community scc on scc.`code` = substring(pba.accountnumber,1,3)
  67. LEFT JOIN sc_user scu on scu.id = ppr.create_by
  68. LEFT JOIN pay_pay_transactiondetails ppt on ppt.payseriesno = ppr.payseriesno and ppt.transtype = 4
  69. <where>
  70. ppr.canceledrecord_id is null and ppr.iscanceled =0
  71. <if test="customerId != null"> and ppr.customer_id = #{customerId}</if>
  72. <if test="siteId != null"> and ppr.site_id = #{siteId}</if>
  73. <if test="community != null and community != ''"> and scc.code = #{community,jdbcType=VARCHAR} </if>
  74. <if test="createBy != null"> and ppr.create_by = #{createBy} </if>
  75. <if test="beginTime != null"> and ppr.create_date >= #{beginTime,jdbcType=TIMESTAMP}</if>
  76. <if test="endTime != null"> and ppr.create_date &lt;= #{endTime,jdbcType=TIMESTAMP}</if>
  77. </where>
  78. GROUP BY pba.`name`,pba.accountnumber,pba.address,scc.`name`
  79. ) tb
  80. <where>
  81. <if test="dataType != null and subtotal != null">
  82. <if test="dataType == 0"> subtotal = #{subtotal}</if>
  83. <if test="dataType == 1"> subtotal &lt; #{subtotal}</if>
  84. <if test="dataType == 2"> subtotal > #{subtotal}</if>
  85. </if>
  86. </where>
  87. </select>
  88. <select id="getPayOperatordetailsReportCount" resultType="com.bz.smart_city.dto.pay.PayOperatordetailsReportDto">
  89. SELECT
  90. '合计' as accountName,
  91. sum(receivedCount) receivedCount,
  92. sum(transamount) transamount,
  93. sum(subtotal) subtotal
  94. from
  95. (
  96. SELECT
  97. pba.`name` as accountName,
  98. pba.accountnumber as accountNumber,
  99. pba.address as accountAddr,
  100. scc.`name` communityName,
  101. SUM(ppr.receivedamount) receivedCount,
  102. max(ifnull(ppt.transamount,0)) transamount,
  103. sum(ppr.receivedamount) + max(ifnull(ppt.transamount,0)) subtotal,
  104. min(ppr.create_date) transTime,
  105. min(scu.`name`) createByName
  106. FROM pay_pay_received ppr
  107. LEFT JOIN pay_base_account pba on ppr.account_id = pba.id
  108. LEFT JOIN sc_community scc on scc.`code` = substring(pba.accountnumber,1,3) and scc.customer_id = 47
  109. LEFT JOIN sc_user scu on scu.id = ppr.create_by
  110. LEFT JOIN pay_pay_transactiondetails ppt on ppt.payseriesno = ppr.payseriesno and ppt.transtype = 4
  111. <where>
  112. ppr.canceledrecord_id is null and ppr.iscanceled =0
  113. <if test="customerId != null"> and ppr.customer_id = #{customerId}</if>
  114. <if test="siteId != null"> and ppr.site_id = #{siteId}</if>
  115. <if test="community != null and community != ''"> and scc.code = #{community,jdbcType=VARCHAR} </if>
  116. <if test="createBy != null"> and ppr.create_by = #{createBy} </if>
  117. <if test="beginTime != null"> and ppr.create_date >= #{beginTime,jdbcType=TIMESTAMP}</if>
  118. <if test="endTime != null"> and ppr.create_date &lt;= #{endTime,jdbcType=TIMESTAMP}</if>
  119. </where>
  120. GROUP BY pba.`name`,pba.accountnumber,pba.address,scc.`name`
  121. ) tb
  122. <where>
  123. <if test="dataType != null and subtotal != null">
  124. <if test="dataType == 0"> subtotal = #{subtotal}</if>
  125. <if test="dataType == 1"> subtotal &lt; #{subtotal}</if>
  126. <if test="dataType == 2"> subtotal > #{subtotal}</if>
  127. </if>
  128. </where>
  129. </select>
  130. <select id="getPayArrearagedetailsReportList" resultType="com.bz.smart_city.dto.pay.PayArrearagedetailsReportDto">
  131. SELECT
  132. pba.NAME as accountName,
  133. pba.accountnumber as accountNumber,
  134. pba.address as accountAddr,
  135. pba.mobilephone as mobilePhone,
  136. sum( CASE WHEN pprb.feetype = 1 THEN pprb.receivablefee ELSE 0 END ) as payamountFee,
  137. sum( CASE WHEN pprb.feetype = 3 THEN pprb.receivablefee ELSE 0 END ) as taxExemptFee,
  138. sum( CASE WHEN pprb.feetype = 4 THEN pprb.receivablefee ELSE 0 END ) as polluteFee,
  139. sum( CASE WHEN pprb.feetype = 6 THEN pprb.receivablefee ELSE 0 END ) as penltyFee,
  140. sum( CASE WHEN pprb.feetype = 1 THEN pprb.payamount ELSE 0 END ) payamount,
  141. sum( CASE WHEN pprb.ladderlevel != 1 THEN pprb.receivablefee ELSE 0 END ) as outLevelFee,
  142. sum( CASE WHEN pprb.receivablefee IS NULL THEN 0 ELSE pprb.receivablefee END ) as subtotal,
  143. sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END ) as debtFee
  144. FROM
  145. pay_pay_receivable pprb
  146. LEFT JOIN pay_base_account pba ON pba.id = pprb.account_id
  147. <where>
  148. <if test="customerId != null"> and pprb.customer_id = #{customerId}</if>
  149. <if test="siteId != null"> and pprb.site_id = #{siteId}</if>
  150. <if test="officeId != null"> and pprb.office_id = #{officeId}</if>
  151. <if test="community != null and community != ''"> and substring(pba.accountnumber,1,3) = #{community,jdbcType=VARCHAR}</if>
  152. <if test="accountNumber != null and accountNumber != ''"> and pba.accountnumber like concat('%',#{accountNumber},'%')</if>
  153. </where>
  154. GROUP BY
  155. pba.NAME,
  156. pba.NAME,
  157. pba.accountnumber,
  158. pba.address,
  159. pba.mobilephone
  160. HAVING
  161. sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END )> 0
  162. </select>
  163. <select id="getPayArrearagedetailsReportCount" resultType="com.bz.smart_city.dto.pay.PayArrearagedetailsReportDto">
  164. SELECT
  165. '合计' as accountName,
  166. sum(payamount) as payamount,
  167. sum(payamountFee) as payamountFee,
  168. sum(taxExemptFee) as taxExemptFee,
  169. sum(polluteFee) as polluteFee,
  170. sum(penltyFee) as penltyFee,
  171. sum(outLevelFee) as outLevelFee,
  172. sum(subtotal) as subtotal,
  173. sum(debtFee) as debtFee
  174. FROM
  175. (
  176. SELECT
  177. pba.NAME as accountName,
  178. pba.accountnumber as accountNumber,
  179. pba.address as accountAddr,
  180. pba.mobilephone as mobilePhone,
  181. sum( CASE WHEN pprb.feetype = 1 THEN pprb.receivablefee ELSE 0 END ) as payamountFee,
  182. sum( CASE WHEN pprb.feetype = 3 THEN pprb.receivablefee ELSE 0 END ) as taxExemptFee,
  183. sum( CASE WHEN pprb.feetype = 4 THEN pprb.receivablefee ELSE 0 END ) as polluteFee,
  184. sum( CASE WHEN pprb.feetype = 6 THEN pprb.receivablefee ELSE 0 END ) as penltyFee,
  185. sum( CASE WHEN pprb.feetype = 1 THEN pprb.payamount ELSE 0 END ) payamount,
  186. sum( CASE WHEN pprb.ladderlevel != 1 THEN pprb.receivablefee ELSE 0 END ) as outLevelFee,
  187. sum( CASE WHEN pprb.receivablefee IS NULL THEN 0 ELSE pprb.receivablefee END ) as subtotal,
  188. sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END ) as debtFee
  189. FROM
  190. pay_pay_receivable pprb
  191. LEFT JOIN pay_base_account pba ON pba.id = pprb.account_id
  192. <where>
  193. <if test="customerId != null"> and pprb.customer_id = #{customerId}</if>
  194. <if test="siteId != null"> and pprb.site_id = #{siteId}</if>
  195. <if test="officeId != null"> and pprb.office_id = #{officeId}</if>
  196. <if test="community != null and community != ''"> and substring(pba.accountnumber,1,3) = #{community,jdbcType=VARCHAR}</if>
  197. <if test="accountNumber != null and accountNumber != ''"> and pba.accountnumber like concat('%',#{accountNumber},'%')</if>
  198. </where>
  199. GROUP BY
  200. pba.NAME,
  201. pba.NAME,
  202. pba.accountnumber,
  203. pba.address,
  204. pba.mobilephone
  205. HAVING
  206. sum( CASE WHEN pprb.debt IS NULL THEN 0 ELSE pprb.debt END )> 0
  207. ) tb
  208. </select>
  209. </mapper>