TWithdrawMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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.TWithdrawMapper">
  6. <resultMap type="TWithdraw" id="TWithdrawResult">
  7. <result property="id" column="id" />
  8. <result property="createBy" column="create_by" />
  9. <result property="createTime" column="create_time" />
  10. <result property="updateBy" column="update_by" />
  11. <result property="updateTime" column="update_time" />
  12. <result property="remark" column="remark" />
  13. <result property="userId" column="user_id" />
  14. <result property="username" column="username" />
  15. <result property="address" column="address" />
  16. <result property="amount" column="amount" />
  17. <result property="status" column="status" />
  18. <result property="serialId" column="serial_id" />
  19. <result property="searchValue" column="search_value" />
  20. <result property="fromAddr" column="from_addr" />
  21. <result property="type" column="type" />
  22. <result property="coin" column="coin" />
  23. <result property="ratio" column="ratio" />
  24. <result property="fee" column="fee" />
  25. <result property="withdrawId" column="withdraw_id" />
  26. <result property="host" column="host" />
  27. <result property="realAmount" column="real_amount" />
  28. <result property="toAdress" column="to_adress" />
  29. <result property="noticeFlag" column="notice_flag" />
  30. <result property="withDrawRemark" column="with_draw_remark" />
  31. <result property="bankName" column="bank_name" />
  32. <result property="bankUserName" column="bank_user_name" />
  33. <result property="bankBranch" column="bank_branch" />
  34. <result property="adminParentIds" column="admin_parent_ids" />
  35. <result property="fixedFee" column="fixed_fee"/>
  36. <result property="orderType" column="order_type"/>
  37. <result property="exchangeRate" column="exchange_rate"/>
  38. <result property="receiptAmount" column="receipt_amount"/>
  39. <result property="receiptRealAmount" column="receipt_real_amount"/>
  40. <result property="receiptCoin" column="receipt_coin"/>
  41. </resultMap>
  42. <sql id="selectTWithdrawVo">
  43. select id, create_by, create_time, update_by, update_time, remark, user_id, username,
  44. address, amount, status, serial_id, search_value, from_addr, type, coin, ratio,
  45. fee, withdraw_id, host, real_amount, to_adress, admin_parent_ids, notice_flag,
  46. with_draw_remark, bank_name, bank_user_name, bank_branch,order_type, exchange_rate,
  47. receipt_amount,receipt_real_amount,receipt_coin
  48. from t_withdraw
  49. </sql>
  50. <select id="selectTWithdrawList" parameterType="TWithdraw" resultType="TWithdraw">
  51. SELECT
  52. w.id,
  53. w.create_by createBy,
  54. w.create_time createTime,
  55. w.update_by updateBy,
  56. w.update_time updateTime,
  57. w.remark,
  58. w.user_id userId,
  59. w.username,
  60. w.address,
  61. w.amount,
  62. w.STATUS status,
  63. w.serial_id serialId,
  64. w.search_value searchValue,
  65. w.from_addr fromAddr,
  66. w.type,
  67. w.coin,
  68. w.ratio,
  69. w.fee,
  70. w.withdraw_id withdrawId,
  71. w.HOST host,
  72. w.real_amount realAmount,
  73. w.to_adress toAdress,
  74. w.admin_parent_ids adminParentIds,
  75. w.notice_flag noticeFlag,
  76. w.with_draw_remark withDrawRemark,
  77. w.bank_name bankName,
  78. w.bank_user_name bankUserName,
  79. w.bank_branch bankBranch,
  80. w.fixed_fee fixedFee,
  81. w.order_type orderType,
  82. w.exchange_rate exchangeRate,
  83. w.receipt_amount receiptAmount,
  84. w.receipt_real_amount receiptRealAmount,
  85. w.receipt_coin receiptCoin,
  86. u.is_test isTest,
  87. r.u_amount uamount
  88. FROM
  89. t_withdraw w
  90. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  91. left join t_app_wallet_record r on r.serial_id = w.serial_id and (r.type = '2' or r.type = '8' or r.type = '50')
  92. <where>
  93. <if test="orderType!=null and orderType!='' and orderType!='-1'">
  94. <choose>
  95. <when test="orderType==2">
  96. AND w.order_type = #{orderType}
  97. </when>
  98. <otherwise>
  99. AND (w.order_type = #{orderType} or w.order_type is null)
  100. </otherwise>
  101. </choose>
  102. </if>
  103. <if test="isTest != null "> and u.is_test = #{isTest}</if>
  104. <if test="userId != null "> and w.user_id = #{userId}</if>
  105. <if test="username != null and username != ''"> and w.username like concat('%', #{username}, '%')</if>
  106. <if test="address != null and address != ''"> and w.address = #{address}</if>
  107. <if test="maxAmount != null "> and w.amount &lt;= #{maxAmount}</if>
  108. <if test="minAmount != null "> and w.amount &gt;= #{minAmount}</if>
  109. <if test="status != null"> and w.status = #{status}</if>
  110. <if test="serialId != null and serialId != ''"> and w.serial_id = #{serialId}</if>
  111. <if test="searchValue != null and searchValue != ''"> and w.search_value = #{searchValue}</if>
  112. <if test="fromAddr != null and fromAddr != ''"> and w.from_addr = #{fromAddr}</if>
  113. <if test="type != null and type != ''"> and w.type = #{type}</if>
  114. <if test="coin != null and coin != ''"> and w.coin = #{coin}</if>
  115. <if test="ratio != null "> and w.ratio = #{ratio}</if>
  116. <if test="fee != null "> and w.fee = #{fee}</if>
  117. <if test="withdrawId != null and withdrawId != ''"> and w.withdraw_id = #{withdrawId}</if>
  118. <if test="host != null and host != ''"> and w.host = #{host}</if>
  119. <if test="realAmount != null "> and w.real_amount = #{realAmount}</if>
  120. <if test="toAdress != null and toAdress != ''"> and to_adress = #{toAdress}</if>
  121. <if test="noticeFlag != null "> and w.notice_flag = #{noticeFlag}</if>
  122. <if test="withDrawRemark != null and withDrawRemark != ''"> and w.with_draw_remark = #{withDrawRemark}</if>
  123. <if test="bankName != null and bankName != ''"> and w.bank_name like concat('%', #{bankName}, '%')</if>
  124. <if test="bankUserName != null and bankUserName != ''"> and w.bank_user_name like concat('%', #{bankUserName}, '%')</if>
  125. <if test="bankBranch != null and bankBranch != ''"> and w.bank_branch = #{bankBranch}</if>
  126. <if test="adminParentIds != null and adminParentIds!=''"> and find_in_set(#{adminParentIds},w.admin_parent_ids)</if>
  127. <if test="params!=null">
  128. <if test="params.startOperateTime != null and params.startOperateTime != ''"><!-- 开始时间检索 -->
  129. AND date_format(w.operate_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{params.startOperateTime},'%Y-%m-%d %H:%i:%s')
  130. </if>
  131. <if test="params.endOperateTime != null and params.endOperateTime != ''"><!-- 结束时间检索 -->
  132. AND date_format(w.operate_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{params.endOperateTime},'%Y-%m-%d %H:%i:%s')
  133. </if>
  134. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  135. AND date_format(w.create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{params.beginTime},'%Y-%m-%d %H:%i:%s')
  136. </if>
  137. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  138. AND date_format(w.create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{params.endTime},'%Y-%m-%d %H:%i:%s')
  139. </if>
  140. </if>
  141. </where>
  142. group by w.serial_id
  143. order by w.create_time desc
  144. </select>
  145. <select id="selectTWithdrawById" parameterType="Long" resultMap="TWithdrawResult">
  146. <include refid="selectTWithdrawVo"/>
  147. where id = #{id}
  148. </select>
  149. <select id="selectTWithdrawVoice" resultType="com.ruoyi.bussiness.domain.TWithdraw">
  150. select * from t_withdraw w
  151. where w.status=0
  152. <if test="parentId != null and parentId!= '' ">
  153. and find_in_set(#{parentId},w.admin_user_ids)
  154. </if>
  155. </select>
  156. <select id="getAllWithdraw" resultType="java.math.BigDecimal">
  157. SELECT
  158. IFNULL(SUM(t.u_amount),0)
  159. FROM
  160. t_withdraw w
  161. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  162. LEFT JOIN t_app_wallet_record t ON t.serial_id = w.serial_id
  163. WHERE
  164. u.is_test = 0
  165. and w.status != 2
  166. <if test="type !=null">
  167. <choose>
  168. <when test="type == -1">
  169. AND (t.`type` = 2 or t.`type` = 50)
  170. </when>
  171. <otherwise>
  172. AND t.`type` = #{type}
  173. </otherwise>
  174. </choose>
  175. </if>
  176. <if test="parentId != null and parentId!=''">
  177. AND find_in_set(#{parentId},w.admin_parent_ids)
  178. </if>
  179. AND w.user_id IN (
  180. SELECT
  181. u1.user_id
  182. FROM
  183. t_app_user u1)
  184. </select>
  185. <select id="selectFreezeList" resultType="WithdrawFreezeVO"
  186. parameterType="com.ruoyi.bussiness.domain.TWithdraw">
  187. SELECT coin AS coin,SUM(amount) AS price FROM t_withdraw WHERE `status` = #{status} and user_id = #{userId}
  188. GROUP BY coin
  189. </select>
  190. <insert id="insertTWithdraw" parameterType="TWithdraw" useGeneratedKeys="true" keyProperty="id">
  191. insert into t_withdraw
  192. <trim prefix="(" suffix=")" suffixOverrides=",">
  193. <if test="createBy != null">create_by,</if>
  194. <if test="createTime != null">create_time,</if>
  195. <if test="updateBy != null">update_by,</if>
  196. <if test="updateTime != null">update_time,</if>
  197. <if test="remark != null">remark,</if>
  198. <if test="userId != null">user_id,</if>
  199. <if test="username != null">username,</if>
  200. <if test="address != null">address,</if>
  201. <if test="amount != null">amount,</if>
  202. <if test="status != null">status,</if>
  203. <if test="serialId != null">serial_id,</if>
  204. <if test="searchValue != null">search_value,</if>
  205. <if test="fromAddr != null">from_addr,</if>
  206. <if test="type != null">type,</if>
  207. <if test="coin != null">coin,</if>
  208. <if test="ratio != null">ratio,</if>
  209. <if test="fee != null">fee,</if>
  210. <if test="withdrawId != null">withdraw_id,</if>
  211. <if test="host != null">host,</if>
  212. <if test="realAmount != null">real_amount,</if>
  213. <if test="toAdress != null">to_adress,</if>
  214. <if test="adminParentIds != null">admin_parent_ids,</if>
  215. <if test="noticeFlag != null">notice_flag,</if>
  216. <if test="withDrawRemark != null">with_draw_remark,</if>
  217. <if test="bankName != null">bank_name,</if>
  218. <if test="bankUserName != null">bank_user_name,</if>
  219. <if test="bankBranch != null">bank_branch,</if>
  220. <if test="fixedFee !=null">fixed_fee,</if>
  221. <if test="orderType !=null">order_type,</if>
  222. <if test="exchangeRate !=null">exchange_rate,</if>
  223. <if test="receiptAmount !=null">receipt_amount,</if>
  224. <if test="receiptRealAmount !=null">receipt_real_amount,</if>
  225. <if test="receiptCoin !=null">receipt_coin,</if>
  226. </trim>
  227. <trim prefix="values (" suffix=")" suffixOverrides=",">
  228. <if test="createBy != null">#{createBy},</if>
  229. <if test="createTime != null">#{createTime},</if>
  230. <if test="updateBy != null">#{updateBy},</if>
  231. <if test="updateTime != null">#{updateTime},</if>
  232. <if test="remark != null">#{remark},</if>
  233. <if test="userId != null">#{userId},</if>
  234. <if test="username != null">#{username},</if>
  235. <if test="address != null">#{address},</if>
  236. <if test="amount != null">#{amount},</if>
  237. <if test="status != null">#{status},</if>
  238. <if test="serialId != null">#{serialId},</if>
  239. <if test="searchValue != null">#{searchValue},</if>
  240. <if test="fromAddr != null">#{fromAddr},</if>
  241. <if test="type != null">#{type},</if>
  242. <if test="coin != null">#{coin},</if>
  243. <if test="ratio != null">#{ratio},</if>
  244. <if test="fee != null">#{fee},</if>
  245. <if test="withdrawId != null">#{withdrawId},</if>
  246. <if test="host != null">#{host},</if>
  247. <if test="realAmount != null">#{realAmount},</if>
  248. <if test="toAdress != null">#{toAdress},</if>
  249. <if test="adminParentIds != null">#{adminParentIds},</if>
  250. <if test="noticeFlag != null">#{noticeFlag},</if>
  251. <if test="withDrawRemark != null">#{withDrawRemark},</if>
  252. <if test="bankName != null">#{bankName},</if>
  253. <if test="bankUserName != null">#{bankUserName},</if>
  254. <if test="bankBranch != null">#{bankBranch},</if>
  255. <if test="fixedFee != null">#{fixedFee},</if>
  256. <if test="orderType != null">#{orderType},</if>
  257. <if test="exchangeRate != null">#{exchangeRate},</if>
  258. <if test="receiptAmount != null">#{receiptAmount},</if>
  259. <if test="receiptRealAmount != null">#{receiptRealAmount},</if>
  260. <if test="receiptCoin != null">#{receiptCoin},</if>
  261. </trim>
  262. </insert>
  263. <update id="updateTWithdraw" parameterType="TWithdraw">
  264. update t_withdraw
  265. <trim prefix="SET" suffixOverrides=",">
  266. <if test="createBy != null">create_by = #{createBy},</if>
  267. <if test="createTime != null">create_time = #{createTime},</if>
  268. <if test="updateBy != null">update_by = #{updateBy},</if>
  269. <if test="updateTime != null">update_time = #{updateTime},</if>
  270. <if test="remark != null">remark = #{remark},</if>
  271. <if test="userId != null">user_id = #{userId},</if>
  272. <if test="username != null">username = #{username},</if>
  273. <if test="address != null">address = #{address},</if>
  274. <if test="amount != null">amount = #{amount},</if>
  275. <if test="status != null ">status = #{status},</if>
  276. <if test="serialId != null">serial_id = #{serialId},</if>
  277. <if test="searchValue != null">search_value = #{searchValue},</if>
  278. <if test="fromAddr != null">from_addr = #{fromAddr},</if>
  279. <if test="type != null">type = #{type},</if>
  280. <if test="coin != null">coin = #{coin},</if>
  281. <if test="ratio != null">ratio = #{ratio},</if>
  282. <if test="fee != null">fee = #{fee},</if>
  283. <if test="withdrawId != null">withdraw_id = #{withdrawId},</if>
  284. <if test="host != null">host = #{host},</if>
  285. <if test="realAmount != null">real_amount = #{realAmount},</if>
  286. <if test="toAdress != null">to_adress = #{toAdress},</if>
  287. <if test="adminParentIds != null">admin_parent_ids = #{adminParentIds},</if>
  288. <if test="noticeFlag != null">notice_flag = #{noticeFlag},</if>
  289. <if test="withDrawRemark != null">with_draw_remark = #{withDrawRemark},</if>
  290. <if test="bankName != null">bank_name = #{bankName},</if>
  291. <if test="bankUserName != null">bank_user_name = #{bankUserName},</if>
  292. <if test="bankBranch != null">bank_branch = #{bankBranch},</if>
  293. <if test="fixedFee !=null">fixed_fee = #{fixedFee},</if>
  294. <if test="orderType !=null">order_type = #{orderType},</if>
  295. <if test="exchangeRate !=null">exchange_rate = #{exchangeRate},</if>
  296. <if test="receiptAmount !=null">receipt_amount = #{receiptAmount},</if>
  297. <if test="receiptRealAmount !=null">receipt_real_amount = #{receiptRealAmount},</if>
  298. <if test="receiptCoin !=null">receipt_coin = #{receiptCoin},</if>
  299. </trim>
  300. where id = #{id}
  301. </update>
  302. <delete id="deleteTWithdrawById" parameterType="Long">
  303. delete from t_withdraw where id = #{id}
  304. </delete>
  305. <delete id="deleteTWithdrawByIds" parameterType="String">
  306. delete from t_withdraw where id in
  307. <foreach item="id" collection="array" open="(" separator="," close=")">
  308. #{id}
  309. </foreach>
  310. </delete>
  311. <select id="getWeekWithdraw" resultType="java.util.Map">
  312. SELECT
  313. DATE_FORMAT(w.create_time,'%Y-%m-%d') as createTime,
  314. IFNULL(SUM(t.u_amount),0) as withdraw
  315. FROM
  316. t_withdraw w
  317. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  318. LEFT JOIN t_app_wallet_record t ON t.serial_id = w.serial_id
  319. WHERE
  320. u.is_test = 0
  321. AND w.`status` = 1
  322. AND (w.order_type = 1 OR w.order_type IS NULL)
  323. <if test="parentId != null and parentId!=''">
  324. AND find_in_set(#{parentId},w.admin_parent_ids)
  325. </if>
  326. AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<]]> DATE(w.create_time)
  327. AND w.user_id IN (SELECT u1.user_id FROM t_app_user u1)
  328. GROUP BY createTime;
  329. </select>
  330. <select id="getWeekFailedWithdraw" resultType="java.util.Map">
  331. SELECT
  332. DATE_FORMAT(w.create_time,'%Y-%m-%d') as createTime,
  333. IFNULL(SUM(w.amount),0) as withdraw
  334. FROM
  335. t_withdraw w
  336. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  337. WHERE
  338. u.is_test = 0
  339. AND w.`status` = 2
  340. AND (w.order_type = 1 OR w.order_type IS NULL)
  341. <if test="parentId != null and parentId!=''">
  342. AND find_in_set(#{parentId},w.admin_parent_ids)
  343. </if>
  344. AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<]]> DATE(w.create_time)
  345. AND w.user_id IN (SELECT u1.user_id FROM t_app_user u1)
  346. GROUP BY createTime;
  347. </select>
  348. <select id="getCountByUserId" parameterType="Long" resultType="java.lang.Integer">
  349. select count(id) from t_withdraw where user_id = #{userId} and (status = 0 or status =3)
  350. </select>
  351. </mapper>