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.

269 lines
11 KiB

5 months ago
3 months ago
5 months ago
5 months ago
4 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 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.GoldDetailMapper">
  4. <insert id="insertExportRecord" useGeneratedKeys="true" keyProperty="recordId.id">
  5. insert into export (account,type,state,url,file_name,data_num)
  6. values(#{account},#{type},#{state},#{url},#{fileName},#{dataNum})
  7. </insert>
  8. <update id="updateConsumeNum">
  9. UPDATE user AS u
  10. JOIN (
  11. SELECT
  12. jwcode,
  13. SUM(CASE WHEN type = 1 THEN 1 ELSE 0 END) AS consume_cnt
  14. FROM user_gold_record
  15. WHERE type IN (0,1)
  16. AND audit_status IN (1,3)
  17. AND flag = 1
  18. GROUP BY jwcode
  19. ) AS t ON u.jwcode = t.jwcode
  20. SET
  21. u.consume_num = t.consume_cnt;
  22. </update>
  23. <select id="getGoldDetail" resultType="com.example.demo.domain.vo.coin.GoldDetail">
  24. SELECT
  25. `user`.name,
  26. `user`.jwcode,
  27. m.name AS market,
  28. `ugr`.pay_platform,
  29. `ugr`.type,
  30. `ugr`.is_refund,
  31. `ugr`.order_code,
  32. `ugr`.goods_name,
  33. Round((`ugr`.free_june + `ugr`.free_december) / 100.0, 2) AS freeGold,
  34. ROUND(`ugr`.sum_gold / 100.0, 2) AS SumGold,
  35. ROUND(`ugr`.permanent_gold / 100.0, 2) AS PermanentGold,
  36. ROUND(`ugr`.free_june / 100.0, 2) AS freeJune,
  37. ROUND(`ugr`.free_december / 100.0, 2) AS freeDecember,
  38. ROUND(`ugr`.task_gold / 100.0, 2) AS taskGold,
  39. `admin`.admin_name,
  40. `ugr`.audit_time,
  41. ROUND((`ugr`.free_june + `ugr`.free_december) / 100.0, 2) AS freeGold
  42. from user_gold_record ugr
  43. left join `user` on `user`.jwcode = `ugr`.jwcode
  44. left join `admin` on `admin`.id = `ugr`.admin_id
  45. left join market m on m.id=`user`.market
  46. <where>
  47. ugr.flag = 1 and
  48. ugr.audit_status IN (1,3)
  49. <if test="flag != 0">
  50. AND `user`.flag = 1
  51. </if>
  52. <if test="jwcode != null">
  53. and ugr.jwcode = #{jwcode}
  54. </if>
  55. <if test="payPlatform != null and payPlatform.length > 0">
  56. and ugr.pay_platform = #{payPlatform}
  57. </if>
  58. <if test="type != null">
  59. and `ugr`.type = #{type}
  60. </if>
  61. <if test="markets!= null and markets.size > 0">
  62. AND user.market IN
  63. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  64. #{markets}
  65. </foreach>
  66. </if>
  67. <if test="startTime != null and endTime != null">
  68. and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime}
  69. </if>
  70. </where>
  71. <choose>
  72. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  73. ORDER BY ${sortField} ${sortOrder}
  74. </when>
  75. <otherwise>
  76. ORDER BY audit_time DESC
  77. </otherwise>
  78. </choose>
  79. </select>
  80. <select id="getTotal" resultType="com.example.demo.domain.vo.coin.Total">
  81. SELECT
  82. ROUND(SUM(sum_gold) / 100.0, 2) AS Goldtotal,
  83. ROUND(SUM(permanent_gold) / 100.0, 2) AS permanentGold,
  84. ROUND((SUM(free_june) + SUM(free_december)) / 100.0, 2) AS freeGold,
  85. ROUND(SUM(task_gold) / 100.0, 2) AS taskGold
  86. from user_gold_record ugr
  87. left join `user` u on u.jwcode = ugr.jwcode
  88. <where>
  89. ugr.flag = 1 and
  90. ugr.audit_status IN (1,3)
  91. <if test="flag != 0">
  92. AND u.flag = 1
  93. </if>
  94. <if test="jwcode != null">
  95. and `ugr`.jwcode = #{jwcode}
  96. </if>
  97. <if test="payPlatform != null and payPlatform.length > 0">
  98. and `ugr`.pay_platform = #{payPlatform}
  99. </if>
  100. <if test="type != null">
  101. and `ugr`.type = #{type}
  102. </if>
  103. <if test="markets!= null and markets.size > 0">
  104. AND user.market IN
  105. <foreach collection="markets" item="market" open="(" separator="," close=")">
  106. #{market}
  107. </foreach>
  108. </if>
  109. <if test="startTime != null and endTime != null">
  110. and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime}
  111. </if>
  112. </where>
  113. </select>
  114. <select id="getGold" resultType="com.example.demo.domain.entity.User">
  115. SELECT
  116. u.id,
  117. u.jwcode,
  118. u.name,
  119. m.name AS market,
  120. ROUND(IFNULL(u.current_permanent_gold+u.current_free_june+u.current_free_december+u.current_task_gold, 0) / 100.0, 2) AS sumGold,
  121. ROUND(IFNULL(u.sum_permanent_gold, 0) / 100.0, 2) AS sumPermanentGold,
  122. ROUND(IFNULL(u.sum_free_june, 0) / 100.0, 2) AS sumFreeJune,
  123. ROUND(IFNULL(u.sum_free_december, 0) / 100.0, 2) AS sumFreeDecember,
  124. ROUND(IFNULL(u.sum_task_gold, 0) / 100.0, 2) AS sumTaskGold,
  125. ROUND(IFNULL(u.current_permanent_gold, 0) / 100.0, 2) AS currentPermanentGold,
  126. ROUND(IFNULL(u.current_free_june, 0) / 100.0, 2) AS currentFreeJune,
  127. ROUND(IFNULL(u.current_free_december, 0) / 100.0, 2) AS currentFreeDecember,
  128. ROUND(IFNULL(u.current_task_gold, 0) / 100.0, 2) AS currentTaskGold,
  129. ROUND(IFNULL(u.sum_consume_permanent, 0) / 100.0, 2) AS sumConsumePermanent,
  130. ROUND(IFNULL(u.sum_consume_task, 0) / 100.0, 2) AS sumConsumeTask,
  131. ROUND(IFNULL(u.sum_consume_free, 0) / 100.0, 2) AS sumConsumeFree,
  132. u.recharge_num,
  133. u.consume_num,
  134. u.first_recharge,
  135. u.create_time,
  136. u.update_time
  137. from user u
  138. left join market m on u.market = m.id
  139. <where>
  140. <if test="flag != 0">
  141. AND u.flag = 1
  142. </if>
  143. <if test="jwcode != null">
  144. and jwcode = #{jwcode}
  145. </if>
  146. <if test="markets != null and markets.size > 0">
  147. AND m.id IN
  148. <foreach collection="markets" item="market" open="(" separator="," close=")">
  149. #{market}
  150. </foreach>
  151. </if>
  152. </where>
  153. <choose>
  154. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  155. ORDER BY ${sortField} ${sortOrder}
  156. </when>
  157. <otherwise>
  158. ORDER BY create_time DESC
  159. </otherwise>
  160. </choose>
  161. </select>
  162. <select id="GoldTotal" resultType="com.example.demo.domain.vo.coin.Total">
  163. SELECT
  164. CAST(SUM(COALESCE(current_permanent_gold, 0)) / 100.0 AS DECIMAL(18,2)) AS permanentGold,
  165. CAST(SUM(COALESCE(current_free_june, 0) + COALESCE(current_free_december, 0)) / 100.0 AS DECIMAL(18,2)) AS freeGold,
  166. CAST(SUM(COALESCE(current_task_gold, 0)) / 100.0 AS DECIMAL(18,2)) AS taskGold,
  167. CAST(
  168. SUM(
  169. COALESCE(current_permanent_gold, 0) +
  170. COALESCE(current_free_june, 0) +
  171. COALESCE(current_free_december, 0) +
  172. COALESCE(current_task_gold, 0)
  173. ) / 100.0 AS DECIMAL(18,2)
  174. ) AS Goldtotal
  175. from `user`
  176. <where>
  177. <if test="flag != 0">
  178. AND `user`.flag = 1
  179. </if>
  180. <if test="jwcode != null ">
  181. and jwcode = #{jwcode}
  182. </if>
  183. <if test="markets!= null and markets.size > 0">
  184. AND user.market IN
  185. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  186. #{markets}
  187. </foreach>
  188. </if>
  189. </where>
  190. </select>
  191. <select id="getGoldDetail1" resultType="com.example.demo.domain.vo.coin.GoldDetail">
  192. select `user`.name, `user`.jwcode, `user`.market, `ugr`.pay_platform, `ugr`.type, `ugr`.sum_gold, `ugr`.permanent_gold, `ugr`.free_june, `ugr`.free_december, `ugr`.task_gold, `admin`.admin_name, `ugr`.audit_time
  193. from user_gold_record ugr
  194. left join `user` on `user`.jwcode = `ugr`.jwcode
  195. left join `admin` on `admin`.id = `ugr`.admin_id
  196. <where>
  197. ugr.flag = 1
  198. <if test="jwcode != null">
  199. and `ugr`.jwcode = #{jwcode}
  200. </if>
  201. <if test="payPlatform != null and payPlatform.length > 0">
  202. and `ugr`.pay_platform = #{payPlatform}
  203. </if>
  204. <if test="type != null">
  205. and `ugr`.type = #{type}
  206. </if>
  207. <if test="markets != null">
  208. AND user.market IN
  209. <foreach collection="markets" item="markets" open="(" separator="," close=")">
  210. #{markets}
  211. </foreach>
  212. </if>
  213. <if test="startTime != null and endTime != null">
  214. and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime}
  215. </if>
  216. </where>
  217. <choose>
  218. <when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0">
  219. ORDER BY ${sortField} ${sortOrder}
  220. </when>
  221. <otherwise>
  222. ORDER BY audit_time DESC
  223. </otherwise>
  224. </choose>
  225. </select>
  226. <select id="sumGold" resultType="com.example.demo.domain.vo.coin.Gold">
  227. SELECT
  228. ROUND(SUM(ugr.sum_gold) / 100.0, 2) AS sumGolds,
  229. ROUND(SUM(ugr.permanent_gold) / 100.0, 2) AS permanentGolds,
  230. ROUND(SUM(ugr.task_gold) / 100.0, 2) AS taskGolds,
  231. ROUND(SUM(ugr.free_june + ugr.free_december) / 100.0, 2) AS freeGolds,
  232. COUNT(*) AS totalNum
  233. from user_gold_record ugr
  234. left join `user` on `user`.jwcode = `ugr`.jwcode
  235. left join `admin` on `admin`.id = `ugr`.admin_id
  236. left join market m on m.id=`user`.market
  237. <where>
  238. ugr.flag = 1 and
  239. ugr.audit_status IN (1,3)
  240. <if test="goldDetail.flag != 0">
  241. AND `user`.flag = 1
  242. </if>
  243. <if test="goldDetail.jwcode != null">
  244. and ugr.jwcode = #{goldDetail.jwcode}
  245. </if>
  246. <if test="goldDetail.payPlatform != null and goldDetail.payPlatform.length > 0">
  247. and ugr.pay_platform = #{goldDetail.payPlatform}
  248. </if>
  249. <if test="goldDetail.type != null">
  250. and ugr.type = #{goldDetail.type}
  251. </if>
  252. <if test="goldDetail.markets!= null and goldDetail.markets.size > 0">
  253. AND user.market IN
  254. <foreach collection="goldDetail.markets" item="goldDetail.markets" open="(" separator="," close=")">
  255. #{goldDetail.markets}
  256. </foreach>
  257. </if>
  258. <if test="goldDetail.startTime != null and goldDetail.endTime != null">
  259. and ugr.`audit_time` BETWEEN #{goldDetail.startTime} AND #{goldDetail.endTime}
  260. </if>
  261. </where>
  262. </select>
  263. </mapper>