TAppWalletRecordMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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.ruoyi.bussiness.mapper.TAppWalletRecordMapper">
  6. <resultMap type="TAppWalletRecord" id="TAppWalletRecordResult">
  7. <result property="id" column="id"/>
  8. <result property="amount" column="amount"/>
  9. <result property="createBy" column="create_by"/>
  10. <result property="createTime" column="create_time"/>
  11. <result property="updateBy" column="update_by"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="remark" column="remark"/>
  14. <result property="userId" column="user_id"/>
  15. <result property="searchValue" column="search_value"/>
  16. <result property="beforeAmount" column="before_amount"/>
  17. <result property="afterAmount" column="after_amount"/>
  18. <result property="serialId" column="serial_id"/>
  19. <result property="type" column="type"/>
  20. <result property="symbol" column="symbol"/>
  21. <result property="adminParentIds" column="admin_parent_ids"/>
  22. <result property="uAmount" column="u_amount"/>
  23. </resultMap>
  24. <sql id="selectTAppWalletRecordVo">
  25. select id,
  26. amount,
  27. create_by,
  28. create_time,
  29. update_by,
  30. update_time,
  31. remark,
  32. user_id,
  33. search_value,
  34. before_amount,
  35. after_amount,
  36. serial_id,
  37. type,
  38. symbol,
  39. admin_parent_ids,
  40. u_amount
  41. from t_app_wallet_record
  42. </sql>
  43. <select id="selectTAppWalletRecordList" parameterType="TAppWalletRecord" resultType="TAppWalletRecord">
  44. select
  45. r.id,
  46. r.amount,
  47. r.create_by createBy,
  48. r.create_time createTime,
  49. r.update_by updateBy,
  50. r.update_time updateTime,
  51. r.remark,
  52. r.user_id userId,
  53. r.search_value searchValue,
  54. r.before_amount beforeAmount,
  55. r.after_amount afterAmount,
  56. r.serial_id serialId,
  57. r.type,
  58. r.symbol,
  59. r.admin_parent_ids adminParentIds,
  60. r.u_amount uAmount,
  61. u.is_test isTest
  62. from t_app_wallet_record r left join t_app_user u on r.user_id=u.user_id
  63. <where>
  64. <if test="amount != null ">and r.amount = #{amount}</if>
  65. <if test="userId != null ">and r.user_id = #{userId}</if>
  66. <if test="searchValue != null and searchValue != ''">and r.search_value = #{searchValue}</if>
  67. <if test="beforeAmount != null ">and r.before_amount = #{beforeAmount}</if>
  68. <if test="afterAmount != null ">and r.after_amount = #{afterAmount}</if>
  69. <if test="serialId != null and serialId != ''">and r.serial_id = #{serialId}</if>
  70. <if test="type != null and type != ''">and r.type = #{type}</if>
  71. <if test="symbol != null and symbol != ''">and r.symbol = #{symbol}</if>
  72. <if test="startTime != null and startTime != ''">
  73. AND r.create_time &gt;= #{startTime}
  74. </if>
  75. <if test="endTime != null and endTime != ''">
  76. AND r.create_time &lt;= #{endTime}
  77. </if>
  78. <if test="maxAmount != null ">and r.amount &lt;= #{maxAmount}</if>
  79. <if test="isTest != null ">and u.is_test= #{isTest}</if>
  80. <if test="minAmount != null ">and r.amount &gt;= #{minAmount}</if>
  81. <if test="adminParentIds != null and adminParentIds!=''">and find_in_set(#{adminParentIds},r.admin_parent_ids)</if>
  82. <if test="uAmount != null">and r.u_amount = #{uAmount}</if>
  83. <if test="params!=null">
  84. <if test="params.startOperateTime != null and params.startOperateTime != ''"><!-- 开始时间检索 -->
  85. AND date_format(r.operate_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{params.startOperateTime},'%Y-%m-%d %H:%i:%s')
  86. </if>
  87. <if test="params.endOperateTime != null and params.endOperateTime != ''"><!-- 结束时间检索 -->
  88. AND date_format(r.operate_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{params.endOperateTime},'%Y-%m-%d %H:%i:%s')
  89. </if>
  90. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  91. AND date_format(r.create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{params.beginTime},'%Y-%m-%d %H:%i:%s')
  92. </if>
  93. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  94. AND date_format(r.create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{params.endTime},'%Y-%m-%d %H:%i:%s')
  95. </if>
  96. </if>
  97. </where>
  98. ORDER BY r.create_time DESC
  99. </select>
  100. <select id="selectTAppWalletRecordById" parameterType="Long" resultMap="TAppWalletRecordResult">
  101. <include refid="selectTAppWalletRecordVo"/>
  102. where id = #{id}
  103. </select>
  104. <insert id="insertTAppWalletRecord" parameterType="TAppWalletRecord" useGeneratedKeys="true" keyProperty="id">
  105. insert into t_app_wallet_record
  106. <trim prefix="(" suffix=")" suffixOverrides=",">
  107. <if test="amount != null">amount,</if>
  108. <if test="createBy != null">create_by,</if>
  109. <if test="createTime != null">create_time,</if>
  110. <if test="updateBy != null">update_by,</if>
  111. <if test="updateTime != null">update_time,</if>
  112. <if test="remark != null">remark,</if>
  113. <if test="userId != null">user_id,</if>
  114. <if test="searchValue != null">search_value,</if>
  115. <if test="beforeAmount != null">before_amount,</if>
  116. <if test="afterAmount != null">after_amount,</if>
  117. <if test="serialId != null">serial_id,</if>
  118. <if test="type != null and type != ''">type,</if>
  119. <if test="symbol != null">symbol,</if>
  120. <if test="adminParentIds != null">admin_parent_ids,</if>
  121. <if test="uAmount != null">u_amount,</if>
  122. </trim>
  123. <trim prefix="values (" suffix=")" suffixOverrides=",">
  124. <if test="amount != null">#{amount},</if>
  125. <if test="createBy != null">#{createBy},</if>
  126. <if test="createTime != null">#{createTime},</if>
  127. <if test="updateBy != null">#{updateBy},</if>
  128. <if test="updateTime != null">#{updateTime},</if>
  129. <if test="remark != null">#{remark},</if>
  130. <if test="userId != null">#{userId},</if>
  131. <if test="searchValue != null">#{searchValue},</if>
  132. <if test="beforeAmount != null">#{beforeAmount},</if>
  133. <if test="afterAmount != null">#{afterAmount},</if>
  134. <if test="serialId != null">#{serialId},</if>
  135. <if test="type != null and type != ''">#{type},</if>
  136. <if test="symbol != null">#{symbol},</if>
  137. <if test="adminParentIds != null">#{adminParentIds},</if>
  138. <if test="uAmount != null">#{uAmount},</if>
  139. </trim>
  140. </insert>
  141. <update id="updateTAppWalletRecord" parameterType="TAppWalletRecord">
  142. update t_app_wallet_record
  143. <trim prefix="SET" suffixOverrides=",">
  144. <if test="amount != null">amount = #{amount},</if>
  145. <if test="createBy != null">create_by = #{createBy},</if>
  146. <if test="createTime != null">create_time = #{createTime},</if>
  147. <if test="updateBy != null">update_by = #{updateBy},</if>
  148. <if test="updateTime != null">update_time = #{updateTime},</if>
  149. <if test="remark != null">remark = #{remark},</if>
  150. <if test="userId != null">user_id = #{userId},</if>
  151. <if test="searchValue != null">search_value = #{searchValue},</if>
  152. <if test="beforeAmount != null">before_amount = #{beforeAmount},</if>
  153. <if test="afterAmount != null">after_amount = #{afterAmount},</if>
  154. <if test="serialId != null">serial_id = #{serialId},</if>
  155. <if test="type != null and type != ''">type = #{type},</if>
  156. <if test="symbol != null">symbol = #{symbol},</if>
  157. <if test="adminParentIds != null">admin_parent_ids = #{adminParentIds},</if>
  158. <if test="uAmount != null">u_amount = #{uAmount},</if>
  159. </trim>
  160. where id = #{id}
  161. </update>
  162. <delete id="deleteTAppWalletRecordById" parameterType="Long">
  163. delete
  164. from t_app_wallet_record
  165. where id = #{id}
  166. </delete>
  167. <delete id="deleteTAppWalletRecordByIds" parameterType="String">
  168. delete from t_app_wallet_record where id in
  169. <foreach item="id" collection="array" open="(" separator="," close=")">
  170. #{id}
  171. </foreach>
  172. </delete>
  173. <select id="selectUserDataList" parameterType="TAppWalletRecord" resultType="com.ruoyi.bussiness.domain.vo.UserDataVO">
  174. SELECT
  175. SUM(
  176. IF
  177. ( t.type = 1 ,t.u_amount, 0 )) AS totalRechargeAmount,
  178. SUM(
  179. IF
  180. ( t.type = 3 ,t.u_amount, 0 )) AS totalWingAmount,
  181. SUM(
  182. IF
  183. ( t.type = 50 ,t.u_amount, 0 )) AS totalSubBousAmount,
  184. SUM(
  185. IF
  186. ( t.type = 4 ,t.u_amount, 0 )) AS totalSubAmount,
  187. SUM(
  188. IF
  189. ( t.type = 51 ,t.u_amount, 0 )) AS totalAddAmount,
  190. SUM(
  191. IF
  192. ( t.type = 40 ,t.u_amount, 0 )) AS totalCollectAmount,
  193. SUM(
  194. IF
  195. ( t.type = 5 ,t.u_amount, 0 )) AS betAmount,
  196. SUM(
  197. IF
  198. ( t.type = 9 ,t.u_amount, 0 )) AS rewardAmount,
  199. SUM(
  200. IF
  201. ( t.type = 28 || t.type=29 ,t.u_amount, 0 )) AS totalContractAmount,
  202. SUM(
  203. IF
  204. ( t.type = 6 ,t.u_amount, 0 )) AS totalMattersAmount,
  205. t.user_id as userId
  206. FROM
  207. t_app_wallet_record t
  208. <where>
  209. <if test="userId != null ">and t.user_id = #{userId}</if>
  210. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  211. AND date_format(t.create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{params.beginTime},'%Y-%m-%d
  212. %H:%i:%s')
  213. </if>
  214. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  215. AND date_format(t.create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{params.endTime},'%Y-%m-%d
  216. %H:%i:%s')
  217. </if>
  218. </where>
  219. GROUP BY user_id
  220. </select>
  221. <select id="dailyData" parameterType="com.ruoyi.bussiness.domain.TAppWalletRecord"
  222. resultType="com.ruoyi.bussiness.domain.vo.DailyDataVO">
  223. SELECT
  224. SUM( IF( t.type = 1 &amp;&amp; (SELECT r.status FROM t_app_recharge r WHERE t.serial_id=r.serial_id )=1, t.u_amount, 0 )) AS totalRechargeAmount,
  225. SUM( IF( t.type = 2 &amp;&amp; (SELECT w.status FROM t_withdraw w WHERE t.serial_id=w.serial_id )=1, t.u_amount, 0 )) AS totalWithdrawAmount, SUM( IF( t.type = 3, t.u_amount, 0 )) AS totalWingAmount,
  226. SUM( IF( t.type = 50, t.u_amount, 0 )) AS totalSubBousAmount,
  227. SUM( IF( t.type = 4, t.u_amount, 0 )) AS totalSubAmount,
  228. SUM( IF( t.type = 51, t.u_amount, 0 )) AS totalAddAmount,
  229. SUM( IF( t.type = 40, t.u_amount, 0 )) AS totalCollectAmount,
  230. SUM( IF( t.type = 5, t.u_amount, 0 )) AS betAmount,
  231. SUM( IF( t.type = 9, t.u_amount, 0 )) AS rewardAmount,
  232. SUM( IF( t.type = 28 || t.type = 29, t.u_amount, 0 )) AS totalContractAmount,
  233. SUM( IF( t.type = 6, t.u_amount, 0 )) AS totalMattersAmount
  234. FROM
  235. t_app_wallet_record t ,t_app_user u
  236. <where>
  237. t.user_id = u.user_id and u.is_test = 0
  238. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  239. AND t.create_time &gt;= #{params.beginTime}
  240. </if>
  241. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  242. AND t.create_time &lt;= #{params.endTime}
  243. </if>
  244. </where>
  245. </select>
  246. <select id="selectAgencyList" resultType="com.ruoyi.bussiness.domain.vo.AgencyDataVo"
  247. parameterType="com.ruoyi.bussiness.domain.TAppWalletRecord">
  248. SELECT
  249. c.agencyId,
  250. c.agencyUserName,
  251. IF( c.user_id IS NOT NULL, group_concat( c.user_id SEPARATOR ',' ), '' ) AS appAllUserId,
  252. sum( c.recharge ) AS recharge,
  253. sum( c.withdraw ) AS withdraw,
  254. sum( c.sendBonus ) AS sendBonus,
  255. sum( c.subBonus ) AS subBonus,
  256. sum( c.btcManualScoring ) AS btcManualScoring,
  257. sum( c.ethManualScoring ) AS ethManualScoring,
  258. sum( c.subAmount ) AS subAmount,
  259. sum( c.sendAmount ) AS sendAmount,
  260. sum( c.btcManualSubdivision ) AS btcManualSubdivision,
  261. sum( c.ethManualSubdivision ) AS ethManualSubdivision
  262. FROM
  263. (
  264. SELECT
  265. a.user_id AS agencyId,
  266. a.user_name AS agencyUserName,
  267. u.user_id,
  268. sum( IF ( r.type = 1, r.amount, 0 ) ) AS recharge,
  269. sum( IF ( r.type = 2, r.amount, 0 ) ) AS withdraw,
  270. sum( IF ( r.type = 3, r.amount, 0 ) ) AS sendBonus,
  271. sum( IF ( r.type = 50, r.amount, 0 ) ) AS subBonus,
  272. sum( IF ( r.type = 16, r.amount, 0 ) ) AS btcManualScoring,
  273. sum( IF ( r.type = 18, r.amount, 0 ) ) AS ethManualScoring,
  274. sum( IF ( r.type = 4, r.amount, 0 ) ) AS subAmount,
  275. sum( IF ( r.type = 51, r.amount, 0 ) ) AS sendAmount,
  276. sum( IF ( r.type = 17, r.amount, 0 ) ) AS btcManualSubdivision,
  277. sum( IF ( r.type = 19, r.amount, 0 ) ) AS ethManualSubdivision
  278. FROM
  279. sys_user a
  280. LEFT JOIN t_app_user u ON FIND_IN_SET( a.user_id, u.admin_parent_ids )
  281. LEFT JOIN t_app_wallet_record r ON r.user_id = u.user_id
  282. WHERE
  283. a.user_type != 0 and a.del_flag=0
  284. <if test="adminParentIds != null and adminParentIds!=''">and (a.parent_id = #{adminParentIds} or a.user_id = #{adminParentIds})</if>
  285. GROUP BY
  286. a.user_id,u.user_id
  287. ) c
  288. <where>
  289. <if test="userId != null ">and c.user_id = #{userId}</if>
  290. </where>
  291. GROUP BY
  292. c.agencyId
  293. </select>
  294. <select id="selectAgencyAppUserList" resultType="com.ruoyi.bussiness.domain.vo.AgencyAppUserDataVo"
  295. parameterType="com.ruoyi.bussiness.domain.TAppWalletRecord">
  296. SELECT
  297. a.user_id AS appUserId,
  298. sum( IF ( r.type = 1, r.amount, 0 ) ) AS recharge,
  299. sum( IF ( r.type = 2, r.amount, 0 ) ) AS withdraw,
  300. sum( IF ( r.type = 3, r.amount, 0 ) ) AS sendBonus,
  301. sum( IF ( r.type = 50, r.amount, 0 ) ) AS subBonus,
  302. sum( IF ( r.type = 16, r.amount, 0 ) ) AS btcManualScoring,
  303. sum( IF ( r.type = 18, r.amount, 0 ) ) AS ethManualScoring,
  304. sum( IF ( r.type = 4, r.amount, 0 ) ) AS subAmount,
  305. sum( IF ( r.type = 51, r.amount, 0 ) ) AS sendAmount,
  306. sum( IF ( r.type = 17, r.amount, 0 ) ) AS btcManualSubdivision,
  307. sum( IF ( r.type = 19, r.amount, 0 ) ) AS ethManualSubdivision
  308. FROM t_app_user a
  309. left join t_app_wallet_record r on r.user_id = a.user_id
  310. <where>
  311. <if test="adminParentIds !=null and adminParentIds !=''">
  312. and FIND_IN_SET(#{adminParentIds},a.admin_parent_ids)
  313. </if>
  314. <if test="userId !=null">
  315. and a.user_id = #{userId}
  316. </if>
  317. </where>
  318. GROUP BY a.user_id
  319. </select>
  320. <select id="statisticsAmount" resultType="java.math.BigDecimal">
  321. SELECT
  322. sum( r.amount ) AS statisticsAmount
  323. FROM t_app_user a
  324. left join t_app_wallet_record r on r.user_id = a.user_id
  325. where a.is_test=0;
  326. </select>
  327. <select id="getAllWithdrawOfUser" resultType="java.math.BigDecimal">
  328. SELECT
  329. IFNULL(SUM(t.u_amount),0) as allWithdraw
  330. FROM
  331. t_withdraw w
  332. LEFT JOIN
  333. t_app_wallet_record t ON t.serial_id = w.serial_id
  334. WHERE
  335. w.`status` = 1 AND w.user_id = #{userId}
  336. </select>
  337. </mapper>