withdrawMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. <!-- 命名,每一个映射对象不一样 namespace:必须与对应的接口全类名一致 -->
  4. <mapper namespace="com.iamberry.wechat.service.mapper.WithdrawMapper">
  5. <resultMap type="Withdraw" id="withdraws">
  6. <id column="withdrawals_logs_id" property="withdrawalsLogsId" />
  7. <result column="withdrawals_openid" property="withdrawalsOpenid" />
  8. <result column="withdrawals_logs_integral_num" property="withdrawalsLogsIntegralNum" />
  9. <result column="withdrawals_logs_amount" property="withdrawalsLogsAmount" />
  10. <result column="withdrawals_logs_date" property="withdrawalsLogsDate" />
  11. <result column="withdrawals_username" property="withdrawalsUsername" />
  12. <result column="withdrawals_tel" property="withdrawalsTel" />
  13. <result column="withdrawals_status" property="withdrawalsStatus" />
  14. <result column="withdrawals_remark" property="withdrawalsRemark" />
  15. </resultMap>
  16. <sql id="allField">
  17. withdrawals_logs_id withdrawalsLogsId,
  18. withdrawals_openid withdrawalsOpenid,
  19. withdrawals_logs_integral_num withdrawalsLogsIntegralNum,
  20. withdrawals_logs_amount withdrawalsLogsAmount,
  21. withdrawals_logs_date withdrawalsLogsDate,
  22. withdrawals_username withdrawalsUsername,
  23. withdrawals_tel withdrawalsTel,
  24. withdrawals_status withdrawalsStatus,
  25. withdrawals_remark withdrawalsRemark,
  26. WITHDRAWALS_CARD_NO WITHDRAWALSCARDNO,
  27. WITHDRAWALS_BANK_NAME WITHDRAWALSBANKNAME
  28. </sql>
  29. <select id="getCount" resultType="int">
  30. select count(withdrawals_logs_id)
  31. from
  32. tb_iamberry_user_integral_withdrawals_logs
  33. </select>
  34. <!-- 用户提现修改 -->
  35. <update id="updateWithdraw" parameterType="Withdraw">
  36. update tb_iamberry_user_integral_withdrawals_logs
  37. <set>
  38. <if test="withdrawals_openid!=null">
  39. withdrawals_openid = #{withdrawalsOpenid}
  40. </if>
  41. <if test="withdrawals_logs_integral_num!=null">
  42. withdrawals_logs_integral_num = #{withdrawalsLogsIntegralNum}
  43. </if>
  44. <if test="withdrawals_logs_amount!=null">
  45. withdrawals_logs_amount = #{withdrawalsLogsAmount}
  46. </if>
  47. <if test="withdrawals_logs_date!=null">
  48. withdrawals_logs_date = #{withdrawalsLogsDate}
  49. </if>
  50. <if test="withdrawals_username!=null">
  51. withdrawals_username = #{withdrawalsUsername}
  52. </if>
  53. <if test="withdrawals_tel!=null">
  54. withdrawals_tel = #{withdrawalsTel}
  55. </if>
  56. <if test="withdrawals_status!=null">
  57. withdrawals_status = #{withdrawalsStatus}
  58. </if>
  59. </set>
  60. where withdrawals_logs_id = #{withdrawalsLogsId}
  61. </update>
  62. <!-- 添加一条申请记录 -->
  63. <insert id="insertApplyLogs" parameterType="Withdraw"
  64. useGeneratedKeys="true" keyProperty="withdrawalsLogsId">
  65. INSERT INTO
  66. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  67. (
  68. WITHDRAWALS_OPENID, WITHDRAWALS_LOGS_INTEGRAL_NUM,
  69. WITHDRAWALS_LOGS_AMOUNT, WITHDRAWALS_LOGS_DATE, WITHDRAWALS_USERNAME,
  70. WITHDRAWALS_TEL, WITHDRAWALS_STATUS,WITHDRAWALS_CARD_NO,
  71. WITHDRAWALS_BANK_NAME
  72. )
  73. VALUES
  74. (
  75. #{withdrawalsOpenid},
  76. #{withdrawalsLogsIntegralNum},
  77. #{withdrawalsLogsAmount},
  78. #{withdrawalsLogsDate},
  79. #{withdrawalsUsername},
  80. #{withdrawalsTel},
  81. #{withdrawalsStatus},
  82. #{withdrawalsCardNo},
  83. #{withdrawalsBankName}
  84. )
  85. </insert>
  86. <!-- 分页查询用户提现记录 -->
  87. <select id="selectLogsByOpenid" parameterType="Page" resultType="Withdraw">
  88. SELECT
  89. <include refid="allField"/>
  90. FROM
  91. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  92. <if test="params.openid != null">
  93. WHERE
  94. WITHDRAWALS_OPENID = #{params.openid}
  95. </if>
  96. ORDER BY
  97. WITHDRAWALS_LOGS_DATE DESC
  98. LIMIT #{pageNo}, #{pageSize}
  99. </select>
  100. <!-- 根据ID,查询提现记录 -->
  101. <select id="selectWithdrawLogsById" parameterType="Integer" resultType="Withdraw">
  102. SELECT
  103. <include refid="allField"/>
  104. FROM
  105. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  106. WHERE
  107. WITHDRAWALS_LOGS_ID = #{logsid}
  108. </select>
  109. <!-- 条件总数 -->
  110. <select id="selectLogsCountByOpenid" parameterType="Page" resultType="Integer">
  111. SELECT
  112. COUNT(WITHDRAWALS_LOGS_ID)
  113. FROM
  114. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  115. <if test="params.openid != null">
  116. WHERE
  117. WITHDRAWALS_OPENID = #{params.openid}
  118. </if>
  119. </select>
  120. <!-- 当前用户,已提现次数 -->
  121. <select id="selectUseLogsCount" parameterType="Withdraw" resultType="Integer">
  122. SELECT
  123. COUNT(WITHDRAWALS_LOGS_ID)
  124. FROM
  125. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  126. WHERE
  127. WITHDRAWALS_LOGS_DATE >= #{withdrawalsLogsDate} AND WITHDRAWALS_OPENID = #{withdrawalsOpenid}
  128. </select>
  129. <select id="selectWithDrawAllSumMoney" parameterType="Page" resultType="Withdraw">
  130. SELECT
  131. withdrawals_status withdrawalsStatus,count(1) withdrawalsLogsIntegralNum,IFNULL(sum(withdrawals_logs_amount),0) sumMoney
  132. FROM
  133. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  134. where 1=1
  135. <if test="params.userInput!=null and params.userInput!=''">
  136. AND withdrawals_username LIKE CONCAT('%',#{params.userInput},'%')
  137. OR withdrawals_tel LIKE CONCAT('%',#{params.userInput},'%')
  138. </if>
  139. <if test="params.beginDate!=null and params.beginDate!='' and params.endDate!=null and params.endDate!=''">
  140. AND DATE(withdrawals_logs_date) BETWEEN #{params.beginDate} AND #{params.endDate}
  141. </if>
  142. group by withdrawals_status
  143. </select>
  144. <select id="selectWithDraw" parameterType="Page" resultType="Withdraw">
  145. SELECT
  146. <include refid="allField" />
  147. FROM
  148. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  149. where 1=1
  150. <if test="params.userInput!=null and params.userInput!=''">
  151. AND withdrawals_username LIKE CONCAT('%',#{params.userInput},'%')
  152. OR withdrawals_tel LIKE CONCAT('%',#{params.userInput},'%')
  153. </if>
  154. <if test="params.beginDate!=null and params.beginDate!='' and params.endDate!=null and params.endDate!=''">
  155. AND DATE(withdrawals_logs_date) BETWEEN #{params.beginDate} AND #{params.endDate}
  156. </if>
  157. <if test="params.status!=null and params.status!=''">
  158. AND withdrawals_status != #{params.status}
  159. </if>
  160. ORDER BY withdrawals_logs_date DESC
  161. <if test="pageNo>=0 and pageSize>0 ">
  162. LIMIT
  163. ${pageNo},${pageSize}
  164. </if>
  165. </select>
  166. <!-- 修改订单信息 -->
  167. <update id="updateWithdrawStatusById" parameterType="Withdraw">
  168. UPDATE
  169. TB_IAMBERRY_USER_INTEGRAL_WITHDRAWALS_LOGS
  170. SET
  171. WITHDRAWALS_STATUS = #{withdrawalsStatus},
  172. withdrawals_remark = #{withdrawalsRemark}
  173. WHERE
  174. WITHDRAWALS_LOGS_ID = #{withdrawalsLogsId}
  175. </update>
  176. </mapper>