PayRechargeaccountMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.PayRechargeaccountMapper">
  4. <sql id="mainColumnInfo">
  5. a.id ,
  6. a.account_id as "accountId",
  7. a.businessstate as "businessstate",
  8. a.accountnumber as "accountnumber",
  9. a.remaining as "remaining",
  10. a.create_by as "createBy",
  11. a.create_date as "createDate",
  12. a.update_by as "updateBy",
  13. a.update_date as "updateDate",
  14. a.remarks as "remarks",
  15. a.del_flag as "delFlag",
  16. a.site_id as "siteId",
  17. a.customer_id as "customerId",
  18. a.office_id as "officeId",
  19. a.balance as "balance",
  20. a.estimatedDate as "estimatedDate"
  21. </sql>
  22. <select id="findList" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
  23. select
  24. <include refid="mainColumnInfo"/>
  25. ,cust.accountname as "accountname"
  26. from pay_pay_rechargeaccount a
  27. left join pay_base_customerandmeterrela cust on a.account_id=cust.account_id
  28. <where>
  29. cust.businessstate = 1
  30. <if test="accountnumber != null and accountnumber != ''">
  31. and (cust.accountnumber like concat('%',#{accountnumber},'%')
  32. or cust.accountname like concat('%',#{accountnumber},'%'))
  33. </if>
  34. <if test="siteId != null">
  35. and a.site_id=#{siteId}
  36. </if>
  37. <if test="customerId != null">
  38. and a.customer_id=#{customerId}
  39. </if>
  40. <if test="accountId != null">
  41. and a.account_id =#{accountId}
  42. </if>
  43. <if test="programItems != null and programItems.size() != 0">
  44. and <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  45. <if test="item.dimensionId == 10">
  46. cust.${item.dimensionCode} = #{item.dimensionValue}
  47. </if>
  48. </foreach>
  49. </if>
  50. </where>
  51. order by a.create_date desc
  52. </select>
  53. <select id="findById" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
  54. select
  55. <include refid="mainColumnInfo"/>
  56. from pay_pay_rechargeaccount a
  57. <where>
  58. <if test="id != null">
  59. and id=#{id}
  60. </if>
  61. <if test="accountId != null">
  62. and account_id=#{accountId}
  63. </if>
  64. </where>
  65. </select>
  66. <select id="findByAccountInfo" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
  67. select
  68. <include refid="mainColumnInfo"/>
  69. from pay_pay_rechargeaccount a
  70. <where>
  71. <if test="siteId != null">
  72. and a.site_id=#{siteId}
  73. </if>
  74. <if test="customerId != null">
  75. and a.customer_id=#{customerId}
  76. </if>
  77. <if test="accountId != null">
  78. and a.account_id=#{accountId}
  79. </if>
  80. <if test="accountnumber != null">
  81. and a.accountnumber=#{accountnumber}
  82. </if>
  83. </where>
  84. </select>
  85. <insert id="insert" parameterType="com.bz.smart_city.dto.pay.PayRechargeaccountDto" >
  86. insert INTO
  87. pay_pay_rechargeaccount
  88. (
  89. account_id,
  90. businessstate,
  91. accountnumber,
  92. accountname,
  93. remaining,
  94. create_by,
  95. create_date,
  96. update_by,
  97. update_date,
  98. remarks,
  99. del_flag,
  100. site_id,
  101. customer_id,
  102. office_id
  103. )
  104. values(
  105. #{accountId},
  106. #{businessstate},
  107. #{accountnumber},
  108. #{accountname},
  109. #{remaining},
  110. #{createBy},
  111. #{createDate},
  112. #{updateBy},
  113. #{updateDate},
  114. #{remarks},
  115. #{delFlag},
  116. #{siteId},
  117. #{customerId},
  118. #{officeId}
  119. )
  120. </insert>
  121. <select id="update" parameterType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
  122. update pay_pay_rechargeaccount
  123. <set>
  124. <if test="accountId != null ">
  125. account_id = #{accountId},
  126. </if>
  127. <if test="businessstate != null ">
  128. businessstate = #{businessstate},
  129. </if>
  130. <if test="accountnumber != null and accountnumber!='' ">
  131. accountnumber = #{accountnumber},
  132. </if>
  133. <if test="accountname != null and accountname!='' ">
  134. accountname = #{accountname},
  135. </if>
  136. <if test="remaining != null ">
  137. remaining = #{remaining},
  138. </if>
  139. <if test="updateDate != null ">
  140. update_date = #{updateDate},
  141. </if>
  142. <if test="updateBy != null ">
  143. update_by = #{updateBy},
  144. </if>
  145. <if test="customerId != null">
  146. customer_id = #{customerId},
  147. </if>
  148. <if test="siteId != null ">
  149. site_id = #{siteId},
  150. </if>
  151. <if test="officeId != null ">
  152. office_id = #{officeId}
  153. </if>
  154. </set>
  155. <where>
  156. <if test="id != null">
  157. and id = #{id}
  158. </if>
  159. <if test="accountId != null">
  160. and account_id =#{accountId}
  161. </if>
  162. </where>
  163. </select>
  164. <delete id="delete" >
  165. delete from pay_pay_rechargeaccount
  166. where account_id= #{accountId}
  167. </delete>
  168. <delete id="batchDelete" >
  169. delete from pay_pay_rechargeaccount
  170. where account_id in
  171. <foreach collection="accountIds" item="item" open="(" separator="," close=")">
  172. #{item}
  173. </foreach>
  174. </delete>
  175. <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
  176. <!--@mbg.generated-->
  177. insert INTO
  178. pay_pay_rechargeaccount
  179. (id,
  180. account_id,
  181. businessstate,
  182. accountnumber,
  183. accountname,
  184. remaining,
  185. create_by,
  186. create_date,
  187. update_by,
  188. update_date,
  189. remarks,
  190. del_flag,
  191. site_id,
  192. customer_id,
  193. office_id
  194. )
  195. values
  196. <foreach collection="list" item="item" separator=",">
  197. (
  198. #{item.id},
  199. #{item.accountId},
  200. #{item.businessstate},
  201. #{item.accountnumber},
  202. #{item.accountname},
  203. #{item.remaining},
  204. #{item.createBy},
  205. #{item.createDate},
  206. #{item.updateBy},
  207. #{item.updateDate},
  208. #{item.remarks},
  209. #{item.delFlag},
  210. #{item.siteId},
  211. #{item.customerId},
  212. #{item.officeId})
  213. </foreach>
  214. </insert>
  215. <update id="updateBalance">
  216. update pay_pay_rechargeaccount set balance=#{balance},estimatedDate =#{readdate} where id =#{id}
  217. </update>
  218. <select id="getEstimateBalance" resultType="com.bz.smart_city.dto.pay.PayRechargeaccountDto">
  219. select
  220. <include refid="mainColumnInfo"/>
  221. from pay_pay_rechargeaccount a
  222. <where>
  223. balance &lt; 0
  224. <if test="siteId != null">
  225. and a.site_id =#{siteId}
  226. </if>
  227. <if test="customerId != null">
  228. and a.customer_id =#{customerId}
  229. </if>
  230. </where>
  231. </select>
  232. </mapper>