You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
9.8 KiB

8 months ago
8 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
3 months ago
  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.example.demo.mapper.coin.AuditMapper">
  4. <update id="updateOrder">
  5. update user_gold_record
  6. set audit_id = #{auditId},
  7. audit_status = #{auditStatus},
  8. reject_reason = #{rejectReason},
  9. audit_time = #{auditTime}
  10. where order_code = #{orderCode} and audit_status = 0
  11. order by create_time DESC
  12. limit 1
  13. </update>
  14. <update id="updateUserGold">
  15. update user
  16. <set>
  17. <if test="currentPermanentGold != null">
  18. current_permanent_gold = current_permanent_gold + #{currentPermanentGold},
  19. </if>
  20. <if test="currentFreeJune != null">
  21. current_free_june = current_free_june + #{currentFreeJune},
  22. </if>
  23. <if test="currentFreeDecember != null">
  24. current_free_december = current_free_december + #{currentFreeDecember},
  25. </if>
  26. <if test="currentTaskGold != null">
  27. current_task_gold = current_task_gold + #{currentTaskGold},
  28. </if>
  29. </set>
  30. where jwcode = #{jwcode}
  31. </update>
  32. <update id="updateOrderRefund">
  33. update user_gold_record
  34. set is_refund = #{isRefund}
  35. where order_code = #{orderCode} and type in (0,1)
  36. </update>
  37. <select id="selectRechargeBy" resultType="com.example.demo.domain.vo.coin.RechargeAudit">
  38. SELECT ugr.id,ugr.order_code,ugr.jwcode,ugr.activity,
  39. ugr.rate_id,ugr.money,ugr.sum_gold,ugr.permanent_gold,ugr.free_june,ugr.free_december,
  40. ugr.task_gold,ugr.remark,ugr.pay_model,ugr.pay_platform,ugr.voucher,
  41. ugr.goods_name,ugr.type,ugr.is_refund,ugr.admin_id,ugr.audit_id,
  42. ugr.audit_status,ugr.reject_reason,ugr.pay_time,
  43. ugr.create_time,ugr.audit_time,ugr.update_time,
  44. (COALESCE(ugr.free_june, 0) + COALESCE(ugr.free_december, 0)) AS freeGold,
  45. u.name as name,
  46. m.name as market,
  47. r.rate_name AS rateName,
  48. a1.admin_name as adminName,
  49. a2.admin_name as auditName
  50. FROM user_gold_record as ugr
  51. LEFT JOIN user u ON ugr.jwcode = u.jwcode
  52. LEFT JOIN admin a1 ON ugr.admin_id = a1.id
  53. LEFT JOIN admin a2 ON ugr.audit_id = a2.id
  54. left join market m ON u.market = m.id
  55. left JOIN rate r ON ugr.rate_id = r.id
  56. <where>
  57. <!-- <if test="rechargeAudit.flag != 0">
  58. AND u.flag = 1
  59. </if>-->
  60. <if test="rechargeAudit.jwcode != null and rechargeAudit.jwcode != ''">
  61. AND ugr.jwcode = #{rechargeAudit.jwcode}
  62. </if>
  63. <if test="rechargeAudit.flag!=0">
  64. AND u.flag = 1
  65. </if>
  66. <if test="rechargeAudit.activity != null and rechargeAudit.activity != ''">
  67. AND ugr.activity = #{rechargeAudit.activity}
  68. </if>
  69. <!-- 判断 market 是否不为总部且 markets 不为空 -->
  70. <!-- <if test="rechargeAudit.markets != null and rechargeAudit.markets.size() > 0">
  71. AND (
  72. <foreach collection="rechargeAudit.markets" item="market" open="" close="" separator=" OR ">
  73. u.market = #{market}
  74. </foreach>
  75. )
  76. </if>-->
  77. <if test="rechargeAudit.markets != null and rechargeAudit.markets.size() > 0">
  78. AND u.market IN
  79. <foreach collection="rechargeAudit.markets" item="market" open="(" separator="," close=")">
  80. #{market}
  81. </foreach>
  82. </if>
  83. <if test="rechargeAudit.payModel != null and rechargeAudit.payModel != ''">
  84. AND ugr.pay_model = #{rechargeAudit.payModel}
  85. </if>
  86. <!-- <if test="rechargeAudit.rateId != null and rechargeAudit.rateId != ''">
  87. AND ugr.rate_id = #{rechargeAudit.rateId}
  88. </if>-->
  89. <if test="rechargeAudit.market != null and rechargeAudit.market != ''">
  90. AND m.id = #{rechargeAudit.market}
  91. </if>
  92. <if test="rechargeAudit.startTime != null and rechargeAudit.endTime != null ">
  93. AND ugr.audit_time between #{rechargeAudit.startTime} and #{rechargeAudit.endTime}
  94. </if>
  95. <if test="rechargeAudit.auditStatus != null and rechargeAudit.auditStatus != ''">
  96. AND ugr.audit_status = #{rechargeAudit.auditStatus}
  97. </if>
  98. AND ugr.type = 0
  99. and ugr.flag=1
  100. </where>
  101. <choose>
  102. <when test="rechargeAudit.sortField != null and rechargeAudit.sortField.length > 0 or rechargeAudit.sortOrder != null and rechargeAudit.sortOrder.length > 0">
  103. ORDER BY ${rechargeAudit.sortField} ${rechargeAudit.sortOrder}
  104. </when>
  105. <otherwise>
  106. ORDER BY audit_time DESC
  107. </otherwise>
  108. </choose>
  109. </select>
  110. <select id="selectRefundBy" resultType="com.example.demo.domain.vo.coin.RefundAudit">
  111. SELECT ugr.*,
  112. (COALESCE(ugr.free_june, 0) + COALESCE(ugr.free_december, 0)) AS freeGold,
  113. u.name as name,
  114. r.rate_name AS rateName,
  115. m.name as market,
  116. a1.admin_name as adminName,
  117. a2.admin_name as auditName
  118. FROM user_gold_record as ugr
  119. LEFT JOIN user u ON ugr.jwcode = u.jwcode
  120. LEFT JOIN admin a1 ON ugr.admin_id = a1.id
  121. LEFT JOIN admin a2 ON ugr.audit_id = a2.id
  122. left join market m ON u.market = m.id
  123. left JOIN rate r ON ugr.rate_id = r.id
  124. <where>
  125. <!-- <if test="refundAudit.flag != 0">
  126. AND u.flag = 1
  127. </if>-->
  128. <if test="refundAudit.jwcode != null">
  129. AND ugr.jwcode = #{refundAudit.jwcode}
  130. </if>
  131. <if test="refundAudit.flag!=0">
  132. AND u.flag = 1
  133. </if>
  134. <if test="refundAudit.refundModel != null ">
  135. AND ugr.refund_model = #{refundAudit.refundModel}
  136. </if>
  137. <if test="refundAudit.refundType != null and refundAudit.refundType!='' ">
  138. AND ugr.refund_type = #{refundAudit.refundType}
  139. </if>
  140. <if test="refundAudit.goodsName != null and refundAudit.goodsName != ''">
  141. AND ugr.goods_name = #{refundAudit.goodsName}
  142. </if>
  143. <!-- 判断 market 是否不为总部且 markets 不为空 -->
  144. <if test="refundAudit.markets != null and refundAudit.markets.size() > 0">
  145. AND (
  146. <foreach collection="refundAudit.markets" item="market" open="" close="" separator=" OR ">
  147. u.market = #{market}
  148. </foreach>
  149. )
  150. </if>
  151. <if test="refundAudit.startTime != null and refundAudit.endTime != null ">
  152. AND ugr.audit_time between #{refundAudit.startTime} and #{refundAudit.endTime}
  153. </if>
  154. <if test="refundAudit.market != null and refundAudit.market != ''">
  155. AND m.id = #{refundAudit.market}
  156. </if>
  157. <if test="refundAudit.auditStatus != null and refundAudit.auditStatus != ''">
  158. AND ugr.audit_status = #{refundAudit.auditStatus}
  159. </if>
  160. AND ugr.type = 2
  161. and ugr.flag=1
  162. </where>
  163. <choose>
  164. <when test="refundAudit.sortField != null and refundAudit.sortField.length > 0 or refundAudit.sortOrder != null and refundAudit.sortOrder.length > 0">
  165. ORDER BY ${refundAudit.sortField} ${refundAudit.sortOrder}
  166. </when>
  167. <otherwise>
  168. ORDER BY audit_time DESC
  169. </otherwise>
  170. </choose>
  171. </select>
  172. <select id="getName" resultType="java.lang.String">
  173. select admin_name from admin where id = #{auditId}
  174. </select>
  175. <select id="getNamesByIds" resultType="com.example.demo.domain.entity.Admin">
  176. select id, admin_name from admin
  177. <where>
  178. <if test="submitterIds != null and submitterIds.size() > 0">
  179. id in
  180. <foreach collection="submitterIds" item="id" open="(" separator="," close=")">
  181. #{id}
  182. </foreach>
  183. </if>
  184. <if test="submitterIds == null or submitterIds.size() == 0">
  185. 1=0
  186. </if>
  187. </where>
  188. </select>
  189. <update id="updateFirstRecharge">
  190. update user set first_recharge = now() where jwcode = #{jwcode} and first_recharge is null
  191. </update>
  192. <!--根据订单号查订单-->
  193. <select id="selectAllOrderByOrderCode" resultType="com.example.demo.domain.entity.UserGoldRecord">
  194. select * from user_gold_record where order_code = #{orderCode} and flag=1
  195. ORDER BY create_time DESC
  196. limit 1
  197. </select>
  198. <select id="getAdminMarket" resultType="java.lang.String">
  199. </select>
  200. <!--根据订单号查未审核订单-->
  201. <select id="selectOrderByOrderCode" resultType="com.example.demo.domain.entity.UserGoldRecord">
  202. select * from user_gold_record
  203. where order_code = #{orderCode} and audit_status = 0
  204. and flag=1
  205. ORDER BY create_time DESC
  206. limit 1
  207. </select>
  208. <select id="getNamesByJwcodes" resultType="com.example.demo.domain.entity.Admin">
  209. select account, admin_name from admin
  210. <where>
  211. <if test="executorIds != null and executorIds.size() > 0">
  212. account in
  213. <foreach collection="executorIds" item="account" open="(" separator="," close=")">
  214. #{account}
  215. </foreach>
  216. </if>
  217. <if test="executorIds == null or executorIds.size() == 0">
  218. 1=0
  219. </if>
  220. </where>
  221. </select>
  222. </mapper>