PayControlRuleMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.PayControlRuleMapper">
  4. <insert id="add" useGeneratedKeys="true" keyColumn="id">
  5. insert into
  6. pay_control_rule(
  7. name,
  8. `condition`,
  9. condition_id,
  10. operator,
  11. value,
  12. action,
  13. unit,
  14. disable,
  15. create_by,
  16. create_date,
  17. update_by,
  18. update_date,
  19. remarks,
  20. del_flag,
  21. site_id,
  22. customer_id
  23. )
  24. values (
  25. #{payControlRule.name,jdbcType=VARCHAR},
  26. #{payControlRule.condition,jdbcType=VARCHAR},
  27. #{payControlRule.conditionId,jdbcType=INTEGER},
  28. #{payControlRule.operator,jdbcType=VARCHAR},
  29. #{payControlRule.value,jdbcType=VARCHAR},
  30. #{payControlRule.action,jdbcType=VARCHAR},
  31. #{payControlRule.unit,jdbcType=VARCHAR},
  32. #{payControlRule.disable,jdbcType=VARCHAR},
  33. #{payControlRule.createBy,jdbcType=BIGINT},
  34. #{payControlRule.createDate,jdbcType=TIMESTAMP},
  35. #{payControlRule.updateBy,jdbcType=BIGINT},
  36. #{payControlRule.updateDate,jdbcType=TIMESTAMP},
  37. #{payControlRule.remarks,jdbcType=VARCHAR},
  38. #{payControlRule.delFlag,jdbcType=VARCHAR},
  39. #{payControlRule.siteId,jdbcType=BIGINT},
  40. #{payControlRule.customerId,jdbcType=BIGINT}
  41. )
  42. </insert>
  43. <select id="findList" resultType="com.bz.smart_city.entity.pay.PayControlRule">
  44. select
  45. id,
  46. name,
  47. `condition`,
  48. condition_id,
  49. operator,
  50. value,
  51. action,
  52. unit,
  53. disable,
  54. create_by,
  55. create_date,
  56. update_by,
  57. update_date,
  58. remarks,
  59. del_flag,
  60. site_id,
  61. customer_id
  62. from pay_control_rule
  63. <where>
  64. del_flag = 0
  65. <if test="customerId != null"> and customer_id = #{customerId} </if>
  66. <if test="id != null"> and id = #{id}</if>
  67. <if test="name != null"> and name = #{name}</if>
  68. </where>
  69. </select>
  70. <select id="ExitsData" resultType="com.bz.smart_city.entity.pay.PayControlRule">
  71. select
  72. id,
  73. name,
  74. `condition`,
  75. operator,
  76. value,
  77. action,
  78. unit,
  79. disable,
  80. create_by,
  81. create_date,
  82. update_by,
  83. update_date,
  84. remarks,
  85. del_flag,
  86. site_id,
  87. customer_id
  88. from pay_control_rule
  89. <where>
  90. del_flag = 0 and customer_id = #{customerId}
  91. <if test="id != null"> and id = #{id}</if>
  92. <if test="name != null"> and name = #{name}</if>
  93. </where>
  94. </select>
  95. <delete id="delete">
  96. update pay_control_rule set del_flag = 1 where id = #{id,jdbcType=INTEGER}
  97. </delete>
  98. <update id="edit">
  99. update pay_control_rule pcr
  100. set
  101. <if test="payControlRule.name != null and payControlRule.name != ''"> name = #{payControlRule.name},</if>
  102. <if test="payControlRule.condition != null and payControlRule.condition != ''"> pcr.condition = #{payControlRule.condition},</if>
  103. <if test="payControlRule.value != null and payControlRule.value != ''"> value = #{payControlRule.value},</if>
  104. <if test="payControlRule.operator != null and payControlRule.operator != ''"> operator = #{payControlRule.operator},</if>
  105. <if test="payControlRule.action != null and payControlRule.action != ''"> action = #{payControlRule.action},</if>
  106. <if test="payControlRule.unit != null"> unit = #{payControlRule.unit},</if>
  107. <if test="payControlRule.disable != null"> disable = {payControlRule.disable},</if>
  108. <if test="payControlRule.updateBy != null"> update_by = #{payControlRule.updateBy},</if>
  109. <if test="payControlRule.updateDate != null"> update_date = #{payControlRule.updateDate},</if>
  110. <if test="payControlRule.remarks != null"> remarks = #{payControlRule.remarks},</if>
  111. <if test="payControlRule.delFlag != null"> del_flag = #{payControlRule.delFlag}</if>
  112. where id = #{payControlRule.id}
  113. </update>
  114. <select id="findDebtMoney" resultType="Decimal">
  115. select
  116. sum( CASE WHEN rece.debt IS NULL THEN 0 ELSE rece.debt END ) sumDebt
  117. from pay_pay_receivable rece
  118. where rece.debt > 0 and rece.account_id = #{accountId}
  119. </select>
  120. <select id="findDebtDay" resultType="integer">
  121. select
  122. to_days(now()) - to_days(create_date) days
  123. from pay_pay_receivable rece
  124. where rece.debt > 0 and rece.account_id = #{accountId}
  125. </select>
  126. <select id="findUseMoeny" resultType="decimal">
  127. select
  128. (
  129. SELECT remaining remaining from pay_pay_rechargeaccount
  130. where account_id=#{accountId})
  131. -
  132. (select IFNULL(SUM(debt),0) debt from pay_pay_receivable where
  133. account_id=#{accountId} and debt > 0 )
  134. as remaining
  135. </select>
  136. <select id="findOpenUse" resultType="integer">
  137. select
  138. scd.curr_status state
  139. from sc_device scd
  140. where scd.account_id = #{accountId}
  141. </select>
  142. </mapper>