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.

266 lines
11 KiB

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