金币系统后端
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.

176 lines
6.2 KiB

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.example.demo.mapper.RefundMapper">
  6. <select id="getRefundA" resultType="com.example.demo.domain.vo.RefundA">
  7. SELECT
  8. CASE
  9. WHEN au.status = 0 THEN '待审核'
  10. WHEN au.status = 1 THEN '已通过'
  11. WHEN au.status = 2 THEN '已驳回'
  12. ELSE '其他状态'
  13. END AS status,
  14. COUNT(*) AS Raudit,
  15. SUM(d.recharge_coin) AS SumRaudit1,
  16. SUM(d.free_coin) AS SumRaudit2,
  17. SUM(d.task_coin) AS SumRaudit3,
  18. (SUM(d.recharge_coin) + SUM(d.free_coin) + SUM(d.task_coin)) AS SumRaudit
  19. FROM
  20. detail d
  21. LEFT JOIN audit au ON d.detail_id = au.refund_id
  22. LEFT JOIN `user` ON d.jwcode = `user`.jwcode
  23. <where>
  24. d.detail_flag = 1
  25. AND d.update_type = 2
  26. <if test="flags != null and flags.size > 0">
  27. and au.status IN
  28. <foreach collection="flags" item="au.status" open="(" separator="," close=")">
  29. #{au.status}
  30. </foreach>
  31. </if>
  32. <if test='jwcode!=null and jwcode.length>0'>and d.jwcode=#{jwcode}</if>
  33. <if test='startDate != null and endDate != null'>AND d.create_time BETWEEN #{startDate} AND #{endDate}</if>
  34. <if test='area!=null and area.length>0'>and user.area=#{area}</if>
  35. <if test='refundType != null and refundType.length>0'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>
  36. <if test='refundGoods != null and refundGoods.length() > 0'>
  37. <choose>
  38. <!-- 是否走精确匹配 -->
  39. <when test="hasIndexMatch">
  40. AND d.refund_goods IN (
  41. SELECT name FROM `index`
  42. WHERE type = 1 AND remark = #{refundGoods}
  43. )
  44. </when>
  45. <!-- 否则模糊匹配 -->
  46. <otherwise>
  47. AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')
  48. </otherwise>
  49. </choose>
  50. </if>
  51. <if test="areas != null">
  52. AND area IN
  53. <foreach collection="areas" item="areas" open="(" separator="," close=")">
  54. #{areas}
  55. </foreach>
  56. </if>
  57. </where>
  58. GROUP BY
  59. au.status
  60. </select>
  61. <select id="select" resultType="com.example.demo.domain.entity.Detail">
  62. SELECT
  63. d.jwcode,
  64. d.refund_type,
  65. d.refund_goods,
  66. d.recharge_coin,
  67. d.free_coin,
  68. d.task_coin,
  69. d.remark,
  70. d.create_time,
  71. d.detail_id,
  72. u.area,
  73. a.name AS adminName,
  74. u.name AS userName,
  75. au.status,
  76. au.reson AS auditReson,
  77. au.refund_id,
  78. au.audit_id,
  79. au.audit_time
  80. FROM detail d
  81. LEFT JOIN `admin` a ON d.admin_id = a.admin_id
  82. LEFT JOIN `user` u ON d.jwcode = u.jwcode
  83. LEFT JOIN audit au ON d.detail_id = au.refund_id
  84. <where>
  85. d.detail_flag = 1
  86. AND update_type = 2
  87. <if test='status != null'>
  88. AND au.status = #{status}
  89. </if>
  90. <if test='area != null and area.length > 0'>
  91. AND u.area = #{area}
  92. </if>
  93. <if test='jwcode != null and jwcode.length > 0'>
  94. AND d.jwcode = #{jwcode}
  95. </if>
  96. <if test='refundType != null and refundType.length > 0'>
  97. AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')
  98. </if>
  99. <if test='refundGoods != null and refundGoods.length() > 0'>
  100. <choose>
  101. <!-- 是否走精确匹配 -->
  102. <when test="hasIndexMatch">
  103. AND d.refund_goods IN (
  104. SELECT name FROM `index`
  105. WHERE type = 1 AND remark = #{refundGoods}
  106. )
  107. </when>
  108. <!-- 否则模糊匹配 -->
  109. <otherwise>
  110. AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')
  111. </otherwise>
  112. </choose>
  113. </if>
  114. <if test='startDate != null and endDate != null'>
  115. AND d.create_time BETWEEN #{startDate} AND #{endDate}
  116. </if>
  117. <if test="areas != null">
  118. AND u.area IN
  119. <foreach collection="areas" item="areas" open="(" separator="," close=")">
  120. #{areas}
  121. </foreach>
  122. </if>
  123. </where>
  124. <choose>
  125. <when test="sortField != null and sortField.length >0 or sortOrder != null and sortOrder.length >0">
  126. ORDER BY ${sortField} ${sortOrder}
  127. </when>
  128. <otherwise>
  129. ORDER BY d.create_time DESC
  130. </otherwise>
  131. </choose>
  132. </select>
  133. <select id="queryDetailYWithUser" resultType="map">
  134. SELECT
  135. d.detaily_id,
  136. u.name,
  137. d.jwcode,
  138. u.area,
  139. d.consume_platform,
  140. d.update_type,
  141. d.recharge_coin,
  142. d.task_coin,
  143. d.free_coin,
  144. d.create_admin,
  145. d.create_time
  146. FROM
  147. detail_y d
  148. LEFT JOIN
  149. user u ON d.jwcode = u.jwcode
  150. <where>
  151. <if test='updateType != null'>
  152. AND d.update_type = #{updateType}
  153. </if>
  154. <if test='jwcode != null'>
  155. AND d.jwcode = #{jwcode}
  156. </if>
  157. <if test='area != null'>
  158. AND u.area = #{area}
  159. </if>
  160. <if test='startDate != null and endDate != null'>
  161. AND create_time BETWEEN #{startDate} AND #{endDate}
  162. </if>
  163. </where>
  164. ORDER BY
  165. detaily_id DESC
  166. </select>
  167. <!--检查是否有type值-->
  168. <select id="isIndexTypeExist" resultType="java.lang.Boolean">
  169. SELECT EXISTS (
  170. SELECT 1 FROM product
  171. WHERE type = 1 AND name = #{name}
  172. )
  173. </select>
  174. </mapper>