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

161 lines
5.7 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'>AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')</if>
  37. <if test="areas != null">
  38. AND area IN
  39. <foreach collection="areas" item="areas" open="(" separator="," close=")">
  40. #{areas}
  41. </foreach>
  42. </if>
  43. </where>
  44. GROUP BY
  45. au.status
  46. </select>
  47. <select id="select" resultType="com.example.demo.domain.entity.Detail">
  48. SELECT
  49. d.jwcode,
  50. d.refund_type,
  51. d.refund_goods,
  52. d.recharge_coin,
  53. d.free_coin,
  54. d.task_coin,
  55. d.remark,
  56. d.create_time,
  57. d.detail_id,
  58. u.area,
  59. a.name AS adminName,
  60. u.name AS userName,
  61. au.status,
  62. au.reson AS auditReson,
  63. au.refund_id,
  64. au.audit_id
  65. FROM detail d
  66. LEFT JOIN `admin` a ON d.admin_id = a.admin_id
  67. LEFT JOIN `user` u ON d.jwcode = u.jwcode
  68. LEFT JOIN audit au ON d.detail_id = au.refund_id
  69. <where>
  70. d.detail_flag = 1
  71. AND update_type = 2
  72. <if test='status != null'>
  73. AND au.status = #{status}
  74. </if>
  75. <if test='area != null and area.length > 0'>
  76. AND u.area = #{area}
  77. </if>
  78. <if test='jwcode != null and jwcode.length > 0'>
  79. AND d.jwcode = #{jwcode}
  80. </if>
  81. <if test='refundType != null and refundType.length > 0'>
  82. AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')
  83. </if>
  84. <if test='refundGoods != null and refundGoods.length() > 0'>
  85. <choose>
  86. <!-- 是否走精确匹配 -->
  87. <when test="hasIndexMatch">
  88. AND d.refund_goods IN (
  89. SELECT name FROM `index`
  90. WHERE type = 1 AND remark = #{refundGoods}
  91. )
  92. </when>
  93. <!-- 否则模糊匹配 -->
  94. <otherwise>
  95. AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')
  96. </otherwise>
  97. </choose>
  98. </if>
  99. <if test='startDate != null and endDate != null'>
  100. AND d.create_time BETWEEN #{startDate} AND #{endDate}
  101. </if>
  102. <if test="areas != null">
  103. AND u.area IN
  104. <foreach collection="areas" item="areas" open="(" separator="," close=")">
  105. #{areas}
  106. </foreach>
  107. </if>
  108. </where>
  109. <choose>
  110. <when test="sortField != null and sortField.length >0 or sortOrder != null and sortOrder.length >0">
  111. ORDER BY ${sortField} ${sortOrder}
  112. </when>
  113. <otherwise>
  114. ORDER BY d.create_time DESC
  115. </otherwise>
  116. </choose>
  117. </select>
  118. <select id="queryDetailYWithUser" resultType="map">
  119. SELECT
  120. d.detaily_id,
  121. u.name,
  122. d.jwcode,
  123. u.area,
  124. d.consume_platform,
  125. d.update_type,
  126. d.recharge_coin,
  127. d.task_coin,
  128. d.free_coin,
  129. d.create_admin,
  130. d.create_time
  131. FROM
  132. detail_y d
  133. LEFT JOIN
  134. user u ON d.jwcode = u.jwcode
  135. <where>
  136. <if test='updateType != null'>
  137. AND d.update_type = #{updateType}
  138. </if>
  139. <if test='jwcode != null'>
  140. AND d.jwcode = #{jwcode}
  141. </if>
  142. <if test='area != null'>
  143. AND u.area = #{area}
  144. </if>
  145. <if test='startDate != null and endDate != null'>
  146. AND create_time BETWEEN #{startDate} AND #{endDate}
  147. </if>
  148. </where>
  149. ORDER BY
  150. detaily_id DESC
  151. </select>
  152. <!--检查是否有type值-->
  153. <select id="isIndexTypeExist" resultType="java.lang.Boolean">
  154. SELECT EXISTS (
  155. SELECT 1 FROM product
  156. WHERE type = 1 AND name = #{name}
  157. )
  158. </select>
  159. </mapper>