PayPayReceivedMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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.PayPayReceivedMapper">
  4. <select id="findListByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayPayReceivedListDto">
  5. select
  6. CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月',(select label from pay_sys_dict where type = '收费类型' and site_id = #{siteId} and customer_id =#{customerId} and value = rece.feetype)) as "name",
  7. rece.accountnumber as "accountnumber",
  8. rece.accountname as "accountname",
  9. rece.id as "id",
  10. rece.account_id as "accountId",
  11. rece.customerandmeterrela_id as "customerandmeterrelaId",
  12. rece.office_id as "officeId",
  13. rece.meter_id as "meterId",
  14. rece.metercode as "metercode",
  15. rece.receivable_id as "receivableId",
  16. rece.waterproperty_id as "waterpropertyId",
  17. rece.payamount as "payamount",
  18. rece.watertype as "watertype",
  19. groy.name as "watertypename",
  20. case when rece.ladderlevel = 1 then '一阶'
  21. when rece.ladderlevel = 2 then '二阶'
  22. when rece.ladderlevel = 3 then '三阶'
  23. when rece.ladderlevel = 4 then '四阶'
  24. else '' end as "ladderlevelname",
  25. rece.payseriesno as "payseriesno",
  26. rece.receivedamount as "receivedamount",
  27. (select label from pay_sys_dict where type = '支付方式' and value = rece.payway and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
  28. rece.create_date as "transtime",
  29. (select label from pay_sys_dict where type = '交易状态' and value = rece.state and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
  30. rece.state as "state",
  31. users.name as "createbyname",
  32. (select name from sc_user where id = rece.cancelperson) as "cancelperson",
  33. rece.canceltime as "canceltime",
  34. rece.year as "year",
  35. rece.month as "month"
  36. from pay_pay_received rece
  37. left join pay_base_waterproperty pro on rece.waterproperty_id = pro.id
  38. left join pay_base_watercategory groy on groy.id = pro.category_id
  39. left join sc_user users on users.id = rece.create_by
  40. <where>
  41. <if test="siteId != null">
  42. and rece.site_id=#{siteId}
  43. </if>
  44. <if test="customerId != null">
  45. and rece.customer_id=#{customerId}
  46. </if>
  47. <if test="payseriesno != null">
  48. and rece.payseriesno =#{payseriesno}
  49. </if>
  50. <if test="year != null">
  51. and rece.year =#{year}
  52. </if>
  53. <if test="month != null">
  54. and rece.month =#{month}
  55. </if>
  56. <if test="accountnumber != null">
  57. and rece.accountnumber =#{accountnumber}
  58. </if>
  59. <if test="beginDate != null">
  60. and rece.create_date &gt;=#{beginDate}
  61. </if>
  62. <if test="endDate != null">
  63. and rece.create_date &lt;=#{endDate}
  64. </if>
  65. <if test="state != null">
  66. and rece.state =#{state}
  67. </if>
  68. <if test="payway != null">
  69. and rece.payway =#{payway}
  70. </if>
  71. order by rece.create_date desc
  72. </where>
  73. </select>
  74. <select id="findTotalList" resultType="com.bz.smart_city.dto.pay.PayPayReceivedListDto">
  75. select
  76. CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月费用') as "name",
  77. rece.accountnumber as "accountnumber",
  78. rece.accountname as "accountname",
  79. max(groy.name) as "watertypename",
  80. '' as "ladderlevelname",
  81. rece.payseriesno as "payseriesno",
  82. sum(rece.receivedamount) as "receivedamount",
  83. max(rece.state) as "state",
  84. min(rece.payway) as "payway",
  85. (select label from pay_sys_dict where type = '支付方式' and value = min(rece.payway) and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
  86. (select label from pay_sys_dict where type = '交易状态' and value = max(rece.state) and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
  87. max(users.name) as "createbyname",
  88. max(rece.create_date) as "transtime",
  89. max(rece.invoice_id) as "invoiceId",
  90. rece.year as "year",
  91. rece.month as "month"
  92. from pay_pay_received rece
  93. left join pay_base_waterproperty pro on rece.waterproperty_id = pro.id
  94. left join pay_base_watercategory groy on groy.id = pro.category_id
  95. left join sc_user users on users.id = rece.create_by
  96. <where>
  97. <if test="siteId != null">
  98. and rece.site_id=#{siteId}
  99. </if>
  100. <if test="customerId != null">
  101. and rece.customer_id=#{customerId}
  102. </if>
  103. <if test="year != null">
  104. rece.`year`=#{year}
  105. </if>
  106. <if test="accountId != null">
  107. rece.account_id=#{accountId}
  108. </if>
  109. <if test="condition != null">
  110. and
  111. (
  112. CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月费用') like concat('%',#{condition},'%')
  113. or rece.accountnumber like concat('%',#{condition},'%')
  114. or rece.accountname like concat('%',#{condition},'%')
  115. )
  116. </if>
  117. <if test="beginDate != null">
  118. and rece.create_date &gt;=#{beginDate}
  119. </if>
  120. <if test="endDate != null">
  121. and rece.create_date &lt;=#{endDate}
  122. </if>
  123. <if test="state != null">
  124. and rece.state =#{state}
  125. </if>
  126. <if test="payway != null">
  127. and rece.payway =#{payway}
  128. </if>
  129. <if test="programItems != null and programItems.size() != 0">
  130. and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  131. <if test="item.dimensionId == 10">
  132. rece.office_id = #{item.dimensionValue}
  133. </if>
  134. </foreach>
  135. </if>
  136. group by rece.accountnumber,rece.accountname,rece.year,rece.month,rece.payseriesno
  137. order by max(rece.create_date) desc
  138. </where>
  139. </select>
  140. <insert id="insert" parameterType="com.bz.smart_city.entity.pay.PayPayReceived" useGeneratedKeys="true" keyProperty="id">
  141. insert into pay_pay_received
  142. (
  143. site_id,
  144. customer_id,
  145. create_date,
  146. create_by,
  147. update_date,
  148. update_by,
  149. remarks,
  150. del_flag,
  151. name,
  152. account_id,
  153. accountname,
  154. accountnumber,
  155. customerandmeterrela_id,
  156. office_id,
  157. invoice_id,
  158. iscanceled,
  159. meter_id,
  160. metercode,
  161. payway,
  162. receivable_id,
  163. receivedamount,
  164. state,
  165. payseriesno,
  166. waterproperty_id,
  167. price,
  168. payamount,
  169. feetype,
  170. ladderlevel,
  171. year,
  172. month,
  173. isrefund,
  174. watertype,
  175. canceledrecord_id,
  176. canceltime,
  177. cancelperson
  178. )
  179. values
  180. (
  181. #{siteId},
  182. #{customerId},
  183. #{createDate},
  184. #{createBy},
  185. #{updateDate},
  186. #{updateBy},
  187. #{remarks},
  188. #{delFlag},
  189. #{name},
  190. #{accountId},
  191. #{accountname},
  192. #{accountnumber},
  193. #{customerandmeterrelaId},
  194. #{officeId},
  195. #{invoiceId},
  196. #{iscanceled},
  197. #{meterId},
  198. #{metercode},
  199. #{payway},
  200. #{receivableId},
  201. #{receivedamount},
  202. #{state},
  203. #{payseriesno},
  204. #{waterpropertyId},
  205. #{price},
  206. #{payamount},
  207. #{feetype},
  208. #{ladderlevel},
  209. #{year},
  210. #{month},
  211. #{isrefund},
  212. #{watertype},
  213. #{canceledrecordId},
  214. #{canceltime},
  215. #{cancelperson}
  216. )
  217. </insert>
  218. <select id="getReceivdePaySeriesno" resultType="com.bz.smart_city.dto.pay.PayPayReceivedDto">
  219. select * from pay_pay_received where id =#{id}
  220. </select>
  221. <select id="findBySeriesno" resultType="com.bz.smart_city.dto.pay.PayPayReceivedDto">
  222. select
  223. rece.id as "id",
  224. rece.name as "name",
  225. rece.account_id as "accountId",
  226. rece.accountname as "accountname",
  227. rece.accountnumber as "accountnumber",
  228. rece.customerandmeterrela_id as "customerandmeterrelaId",
  229. rece.cheque_id as "chequeId",
  230. rece.office_id as "officeId",
  231. rece.invoice_id as "invoiceId",
  232. rece.iscanceled as "iscanceled",
  233. rece.meter_id as "meterId",
  234. rece.metercode as "metercode",
  235. rece.payway as "payway",
  236. rece.receivable_id as "receivableId",
  237. rece.receivedamount as "receivedamount",
  238. rece.state as "state",
  239. rece.payseriesno as "payseriesno",
  240. rece.waterproperty_id as "waterpropertyId",
  241. rece.price as "price",
  242. rece.payamount as "payamount",
  243. rece.feetype as "feetype",
  244. rece.ladderlevel as "ladderlevel",
  245. rece.year as "year",
  246. rece.month as "month",
  247. rece.isrefund as "isrefund",
  248. rece.watertype as "watertype",
  249. rece.canceledrecord_id as "canceledrecordId",
  250. rece.cancelperson as "cancelperson",
  251. rece.canceltime as "canceltime",
  252. rece.create_by as "createBy",
  253. rece.create_date as "createDate",
  254. rece.update_by as "updateBy",
  255. rece.update_date as "updateDate",
  256. rece.remarks as "remarks",
  257. rece.del_flag as "delFlag",
  258. rece.site_id as "siteId",
  259. rece.customer_id as "customerId"
  260. from pay_pay_received rece
  261. <where>
  262. rece.canceledrecord_id is null and rece.state=1
  263. <if test="siteId != null">
  264. and rece.site_id =#{siteId}
  265. </if>
  266. <if test="customerId != null">
  267. and rece.customer_id =#{customerId}
  268. </if>
  269. <if test="payseriesno != null" >
  270. and rece.payseriesno =#{payseriesno}
  271. </if>
  272. </where>
  273. </select>
  274. <!-- 取消实收时回退应收欠费 -->
  275. <update id="updateDebtById">
  276. update pay_pay_receivable set debt= debt+#{debt}, update_date=now()
  277. where id=#{id}
  278. </update>
  279. <update id="updateReceived">
  280. update pay_pay_received set iscanceled =#{iscanceled},cancelperson=#{cancelperson},canceltime=#{canceltime},state=#{state} where id=#{id}
  281. </update>
  282. <update id="updateReceivedCancel">
  283. update pay_pay_agenttransaction set state=4 where payseriesno = #{payseriesno}and site_id= #{siteId} and customer_id= #{customerId}
  284. </update>
  285. <update id="cancelCheckAgentPayseriesno">
  286. update pay_pay_checkbalance set state=4
  287. where out_trade_no =(select order_no from pay_pay_agenttransaction where payseriesno=#{payseriesno} and site_id= #{siteId} and customer_id= #{customerId})
  288. </update>
  289. <update id="update">
  290. update pay_pay_received
  291. <set>
  292. <if test="iscanceled != null">
  293. iscanceled =#{iscanceled},
  294. </if>
  295. <if test="cancelperson != null">
  296. cancelperson =#{cancelperson},
  297. </if>
  298. <if test="canceltime != null">
  299. canceltime =#{canceltime},
  300. </if>
  301. <if test="state != null">
  302. state =#{state},
  303. </if>
  304. <if test="updateBy != null">
  305. update_by =#{updateBy},
  306. </if>
  307. <if test="updateDate != null">
  308. update_date =#{updateDate}
  309. </if>
  310. </set>
  311. <where>
  312. <if test="id != null">
  313. id =#{id}
  314. </if>
  315. </where>
  316. </update>
  317. <select id="findInvoiceReceivedByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayReceivedInvoiceDto">
  318. select
  319. rece.payseriesno as "payseriesno",
  320. rece.create_date as "createDate",
  321. rece.ladderlevel as "ladderlevel",
  322. rece.payway as "payway",
  323. dict2.label as "paywayname",
  324. sum(rece.receivedamount) as "receivedamount",
  325. rece.price as "price",
  326. rece.feetype as "feetype" ,
  327. dict.label as "feetypename"
  328. from pay_pay_received rece
  329. inner join pay_sys_dict dict on dict.type="收费类型" and dict.`value`= rece.feetype
  330. inner join pay_sys_dict dict2 on dict2.type="支付方式" and dict2.`value`= rece.payway
  331. where rece.canceledrecord_id is null and rece.iscanceled =0 and rece.receivedamount>0
  332. #and rece.payseriesno= #{payseriesno}
  333. and rece.site_id = #{siteId}
  334. and rece.customer_id = #{customerId}
  335. group by rece.payseriesno,rece.create_date,rece.ladderlevel,rece.payway,dict2.label,rece.price,rece.feetype,dict.label
  336. </select>
  337. </mapper>