TAppRechargeMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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.TAppRechargeMapper">
  6. <resultMap type="com.ruoyi.bussiness.domain.TAppRecharge" id="TAppRechargeResult">
  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="amount" column="amount"/>
  16. <result property="bonus" column="bonus"/>
  17. <result property="status" column="status"/>
  18. <result property="serialId" column="serial_id"/>
  19. <result property="txId" column="tx_id"/>
  20. <result property="type" column="type"/>
  21. <result property="searchValue" column="search_value"/>
  22. <result property="address" column="address"/>
  23. <result property="appParentIds" column="app_parent_ids"/>
  24. <result property="adminParentIds" column="admin_parent_ids"/>
  25. <result property="coin" column="coin"/>
  26. <result property="toAddress" column="to_address"/>
  27. <result property="blockTime" column="block_time"/>
  28. <result property="host" column="host"/>
  29. <result property="realAmount" column="real_amount"/>
  30. <result property="fileName" column="file_name"/>
  31. <result property="rechargeRemark" column="recharge_remark"/>
  32. <result property="noticeFlag" column="notice_flag"/>
  33. <result property="orderType" column="order_type"/>
  34. </resultMap>
  35. <sql id="selectTAppRechargeVo">
  36. select id, create_by, create_time, update_by, update_time, remark, user_id, username, amount, bonus,
  37. status, serial_id, tx_id, type, search_value, address, app_parent_ids, admin_parent_ids, coin, to_address,
  38. block_time, host,
  39. real_amount, file_name, recharge_remark, notice_flag,order_type from t_app_recharge
  40. </sql>
  41. <select id="selectTAppRechargeList" parameterType="TAppRecharge" resultMap="TAppRechargeResult">
  42. <include refid="selectTAppRechargeVo"/>
  43. <where>
  44. <if test="userId != null ">and user_id = #{userId}</if>
  45. <if test="username != null and username != ''">and username like concat('%', #{username}, '%')</if>
  46. <if test="amount != null ">and amount = #{amount}</if>
  47. <if test="bonus != null ">and bonus = #{bonus}</if>
  48. <if test="status != null ">and status = #{status}</if>
  49. <if test="serialId != null and serialId != ''">and serial_id = #{serialId}</if>
  50. <if test="txId != null and txId != ''">and tx_id = #{txId}</if>
  51. <if test="type != null and type != ''">and type = #{type}</if>
  52. <if test="searchValue != null and searchValue != ''">and search_value = #{searchValue}</if>
  53. <if test="address != null and address != ''">and address = #{address}</if>
  54. <if test="appParentIds != null and appParentIds != ''">and app_parent_ids = #{appParentIds}</if>
  55. <if test="adminParentIds != null and adminParentIds != '' ">and admin_parent_ids = #{adminParentIds}</if>
  56. <if test="coin != null and coin != ''">and coin = #{coin}</if>
  57. <if test="toAddress != null and toAddress != ''">and to_address = #{toAddress}</if>
  58. <if test="blockTime != null ">and block_time = #{blockTime}</if>
  59. <if test="host != null and host != ''">and host = #{host}</if>
  60. <if test="realAmount != null ">and real_amount = #{realAmount}</if>
  61. <if test="fileName != null and fileName != ''">and file_name like concat('%', #{fileName}, '%')</if>
  62. <if test="rechargeRemark != null and rechargeRemark != ''">and recharge_remark = #{rechargeRemark}</if>
  63. <if test="noticeFlag != null ">and notice_flag = #{noticeFlag}</if>
  64. <if test="orderType != null ">and order_type = #{orderType}</if>
  65. </where>
  66. order by create_time desc
  67. </select>
  68. <select id="selectTAppRechargeById" parameterType="Long" resultMap="TAppRechargeResult">
  69. <include refid="selectTAppRechargeVo"/>
  70. where id = #{id}
  71. </select>
  72. <select id="selectRechargeList" resultType="com.ruoyi.bussiness.domain.TAppRecharge"
  73. parameterType="com.ruoyi.bussiness.domain.TAppRecharge">
  74. SELECT
  75. a.id,
  76. a.serial_id as serialId,
  77. a.tx_id as txId,
  78. a.user_id as userId,
  79. a.username,
  80. a.amount,
  81. a.bonus,
  82. a.remark,
  83. a.type,
  84. a.status,
  85. a.update_time as updateTime,
  86. a.update_by as updateBy,
  87. a.create_time as createTime,
  88. a.tree,
  89. a.real_amount as realAmount,
  90. a.block_time as blockTime,
  91. a.address,
  92. a.file_name as fileName,
  93. a.`host`,
  94. a.to_address as toAddress,
  95. a.coin,
  96. u.is_test as isTest,
  97. a.recharge_remark as rechargeRemark,
  98. a.order_type as orderType,
  99. r.u_amount as uamount
  100. FROM
  101. t_app_recharge a
  102. LEFT JOIN t_app_user u ON a.user_id = u.user_id
  103. left join t_app_wallet_record r on r.serial_id = a.serial_id and (r.type = '1' or r.type = '3')
  104. <where>
  105. <if test="remark ==1">
  106. AND a.remark is not null and a.remark !=''
  107. </if>
  108. <if test="remark ==0">
  109. AND ( a.remark is null or a.remark ='' )
  110. </if>
  111. <if test="id!= null">
  112. AND a.id= #{id}
  113. </if>
  114. <if test="userId != null">
  115. AND a.user_id = #{userId}
  116. </if>
  117. <if test="address != null and address!=''">
  118. AND LOWER(a.address) = LOWER(#{address})
  119. </if>
  120. <if test="username != null and username !=''">
  121. AND a.username = #{username}
  122. </if>
  123. <if test="noticeFlag != null ">
  124. AND a.notice_flag = #{noticeFlag}
  125. </if>
  126. <if test="updateBy != null and updateBy !=''">
  127. AND a.update_by = #{updateBy}
  128. </if>
  129. <if test="serialId != null and serialId !=''">
  130. AND a.serial_id like concat('%', #{serialId}, '%')
  131. </if>
  132. <if test="txId != null and txId !=''">
  133. AND a.tx_id like concat('%', #{txId}, '%')
  134. </if>
  135. <if test="status != null and status!=''">
  136. AND a.status = #{status}
  137. </if>
  138. <if test="coin != null and coin!=''">
  139. AND a.coin like concat('%',#{coin},'%')
  140. </if>
  141. <if test="isTest != null">
  142. AND u.is_test = #{isTest}
  143. </if>
  144. <if test="type != null and type!=''">
  145. AND a.type = #{type}
  146. </if>
  147. <if test="orderType != null and orderType!='' and orderType!='-1'">
  148. <choose>
  149. <when test="orderType==2">
  150. AND a.order_type = #{orderType}
  151. </when>
  152. <otherwise>
  153. AND (a.order_type = #{orderType} or a.order_type is null)
  154. </otherwise>
  155. </choose>
  156. </if>
  157. <if test="adminParentIds != null and adminParentIds!=''">
  158. AND find_in_set(#{adminParentIds},a.admin_parent_ids)
  159. </if>
  160. <if test="params!=null">
  161. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  162. AND a.create_time &gt;= #{params.beginTime}
  163. </if>
  164. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  165. AND a.create_time &lt;= #{params.endTime}
  166. </if>
  167. <if test="params.startOperateTime != null and params.startOperateTime != ''"><!-- 开始时间检索 -->
  168. AND a.operate_time &gt;= #{params.startOperateTime}
  169. </if>
  170. <if test="params.endOperateTime != null and params.endOperateTime != ''"><!-- 结束时间检索 -->
  171. AND a.operate_time &lt;= #{params.endOperateTime}
  172. </if>
  173. <if test="params.isTest != null and params.isTest != ''">
  174. AND u.is_test = #{params.isTest}
  175. </if>
  176. <if test="params.isTest != null and params.isTest != ''">
  177. AND u.is_test = #{params.isTest}
  178. </if>
  179. <if test="params.minMoney != null and params.minMoney != ''">
  180. AND a.amount &gt;= #{params.minMoney}
  181. </if>
  182. <if test="params.maxMoney != null and params.maxMoney != ''">
  183. AND a.amount &lt;= #{params.maxMoney}
  184. </if>
  185. </if>
  186. </where>
  187. GROUP BY a.serial_id
  188. <!-- 数据范围过滤
  189. ${params.dataScope}-->
  190. </select>
  191. <select id="sumtotal" resultType="java.util.Map" parameterType="com.ruoyi.bussiness.domain.TAppRecharge">
  192. select IFNULL(SUM(amount),0) AS amount
  193. from t_app_recharge a
  194. LEFT JOIN t_app_user u ON a.user_id = u.user_id
  195. where 1=1
  196. <if test="id!= null">
  197. AND a.id= #{id}
  198. </if>
  199. <if test="userId != null">
  200. AND a.user_id = #{userId}
  201. </if>
  202. <if test="address != null and address!=''">
  203. AND a.address = #{address}
  204. </if>
  205. <if test="username != null and username !=''">
  206. AND a.username = #{username}
  207. </if>
  208. <if test="updateBy != null and updateBy !=''">
  209. AND a.update_by = #{updateBy}
  210. </if>
  211. <if test="serialId != null and serialId !=''">
  212. AND a.serial_id like concat('%', #{serialId}, '%')
  213. </if>
  214. <if test="txId != null and txId !=''">
  215. AND a.tx_id like concat('%', #{txId}, '%')
  216. </if>
  217. <if test="status != null and status!=''">
  218. AND a.status = #{status}
  219. </if>
  220. <if test="type != null and type!=''">
  221. AND a.type = #{type}
  222. </if>
  223. <if test="params!=null">
  224. <if test="params.isTest != null and params.isTest != ''">
  225. AND u.is_test = #{params.isTest}
  226. </if>
  227. <if test="params.minMoney != null and params.minMoney != ''">
  228. AND a.amount &gt;= #{params.minMoney}
  229. </if>
  230. <if test="params.maxMoney != null and params.maxMoney != ''">
  231. AND a.amount &lt;= #{params.maxMoney}
  232. </if>
  233. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  234. AND a.update_time &gt;= #{params.beginTime}
  235. </if>
  236. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  237. AND a.update_time &lt;= #{params.endTime}
  238. </if>
  239. <!-- <if test="params.list != null and params.list.size > 0">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
  240. <!-- AND a.admin_user_id in-->
  241. <!-- <foreach collection="params.list" separator="," item="item" open="(" close=")">-->
  242. <!-- #{item.userId}-->
  243. <!-- </foreach>-->
  244. <!-- </if>-->
  245. </if>
  246. <!-- 数据范围过滤
  247. ${params.dataScope}-->
  248. </select>
  249. <select id="selectRechargeVoice" resultType="com.ruoyi.bussiness.domain.TAppRecharge">
  250. select * from t_app_recharge r
  251. where r.status=0
  252. <if test="parentId != null and parentId!= '' ">
  253. and find_in_set(#{parentId},r.admin_parent_ids)
  254. </if>
  255. </select>
  256. <select id="getAllRecharge" resultType="java.math.BigDecimal">
  257. SELECT
  258. IFNULL(SUM(t.u_amount),0)
  259. FROM
  260. t_app_recharge w
  261. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  262. LEFT JOIN t_app_wallet_record t ON t.serial_id = w.serial_id
  263. WHERE
  264. u.is_test = 0
  265. AND w.`status` = 1
  266. <if test="type!=null">
  267. <choose>
  268. <when test="type == -1">
  269. AND (t.`type` = 1 or t.`type` = 3)
  270. </when>
  271. <otherwise>
  272. AND t.`type` = #{type}
  273. </otherwise>
  274. </choose>
  275. </if>
  276. <if test="parentId != null and parentId!=''">
  277. AND find_in_set(#{parentId},w.admin_parent_ids)
  278. </if>
  279. </select>
  280. <insert id="insertTAppRecharge" parameterType="TAppRecharge" useGeneratedKeys="true" keyProperty="id">
  281. insert into t_app_recharge
  282. <trim prefix="(" suffix=")" suffixOverrides=",">
  283. <if test="createBy != null">create_by,</if>
  284. <if test="createTime != null">create_time,</if>
  285. <if test="updateBy != null">update_by,</if>
  286. <if test="updateTime != null">update_time,</if>
  287. <if test="remark != null">remark,</if>
  288. <if test="userId != null">user_id,</if>
  289. <if test="username != null">username,</if>
  290. <if test="amount != null">amount,</if>
  291. <if test="bonus != null">bonus,</if>
  292. <if test="status != null">status,</if>
  293. <if test="serialId != null and serialId != ''">serial_id,</if>
  294. <if test="txId != null">tx_id,</if>
  295. <if test="type != null and type != ''">type,</if>
  296. <if test="searchValue != null">search_value,</if>
  297. <if test="address != null">address,</if>
  298. <if test="appParentIds != null">app_parent_ids,</if>
  299. <if test="adminParentIds != null">admin_parent_ids,</if>
  300. <if test="coin != null">coin,</if>
  301. <if test="toAddress != null">to_address,</if>
  302. <if test="blockTime != null">block_time,</if>
  303. <if test="host != null">host,</if>
  304. <if test="realAmount != null">real_amount,</if>
  305. <if test="fileName != null">file_name,</if>
  306. <if test="rechargeRemark != null">recharge_remark,</if>
  307. <if test="noticeFlag != null">notice_flag,</if>
  308. <if test="orderType != null">order_type,</if>
  309. </trim>
  310. <trim prefix="values (" suffix=")" suffixOverrides=",">
  311. <if test="createBy != null">#{createBy},</if>
  312. <if test="createTime != null">#{createTime},</if>
  313. <if test="updateBy != null">#{updateBy},</if>
  314. <if test="updateTime != null">#{updateTime},</if>
  315. <if test="remark != null">#{remark},</if>
  316. <if test="userId != null">#{userId},</if>
  317. <if test="username != null">#{username},</if>
  318. <if test="amount != null">#{amount},</if>
  319. <if test="bonus != null">#{bonus},</if>
  320. <if test="status != null">#{status},</if>
  321. <if test="serialId != null and serialId != ''">#{serialId},</if>
  322. <if test="txId != null">#{txId},</if>
  323. <if test="type != null and type != ''">#{type},</if>
  324. <if test="searchValue != null">#{searchValue},</if>
  325. <if test="address != null">#{address},</if>
  326. <if test="appParentIds != null">#{appParentIds},</if>
  327. <if test="adminParentIds != null">#{adminParentIds},</if>
  328. <if test="coin != null">#{coin},</if>
  329. <if test="toAddress != null">#{toAddress},</if>
  330. <if test="blockTime != null">#{blockTime},</if>
  331. <if test="host != null">#{host},</if>
  332. <if test="realAmount != null">#{realAmount},</if>
  333. <if test="fileName != null">#{fileName},</if>
  334. <if test="rechargeRemark != null">#{rechargeRemark},</if>
  335. <if test="noticeFlag != null">#{noticeFlag},</if>
  336. <if test="orderType != null">#{orderType},</if>
  337. </trim>
  338. </insert>
  339. <update id="updateTAppRecharge" parameterType="TAppRecharge">
  340. update t_app_recharge
  341. <trim prefix="SET" suffixOverrides=",">
  342. <if test="createBy != null">create_by = #{createBy},</if>
  343. <if test="createTime != null">create_time = #{createTime},</if>
  344. <if test="updateBy != null">update_by = #{updateBy},</if>
  345. <if test="updateTime != null">update_time = #{updateTime},</if>
  346. <if test="remark != null">remark = #{remark},</if>
  347. <if test="userId != null">user_id = #{userId},</if>
  348. <if test="username != null">username = #{username},</if>
  349. <if test="amount != null">amount = #{amount},</if>
  350. <if test="bonus != null">bonus = #{bonus},</if>
  351. <if test="status != null">status = #{status},</if>
  352. <if test="serialId != null and serialId != ''">serial_id = #{serialId},</if>
  353. <if test="txId != null">tx_id = #{txId},</if>
  354. <if test="type != null and type != ''">type = #{type},</if>
  355. <if test="searchValue != null">search_value = #{searchValue},</if>
  356. <if test="address != null">address = #{address},</if>
  357. <if test="appParentIds != null">app_parent_ids = #{appParentIds},</if>
  358. <if test="adminParentIds != null">admin_parent_ids = #{adminParentIds},</if>
  359. <if test="coin != null">coin = #{coin},</if>
  360. <if test="toAddress != null">to_address = #{toAddress},</if>
  361. <if test="blockTime != null">block_time = #{blockTime},</if>
  362. <if test="host != null">host = #{host},</if>
  363. <if test="realAmount != null">real_amount = #{realAmount},</if>
  364. <if test="fileName != null">file_name = #{fileName},</if>
  365. <if test="rechargeRemark != null">recharge_remark = #{rechargeRemark},</if>
  366. <if test="noticeFlag != null">notice_flag = #{noticeFlag},</if>
  367. <if test="orderType != null">order_type = #{orderType},</if>
  368. </trim>
  369. where id = #{id}
  370. </update>
  371. <update id="updateStatus" parameterType="TAppRecharge">
  372. update t_app_recharge
  373. <set>
  374. <if test="status!= null">status = #{status},</if>
  375. update_time = sysdate(),
  376. update_by =#{updateBy},
  377. remark=#{remark},
  378. real_amount=#{realAmount},
  379. recharge_remark=#{rechargeRemark}
  380. </set>
  381. where id = #{id}
  382. </update>
  383. <delete id="deleteTAppRechargeById" parameterType="Long">
  384. delete from t_app_recharge where id = #{id}
  385. </delete>
  386. <delete id="deleteTAppRechargeByIds" parameterType="String">
  387. delete from t_app_recharge where id in
  388. <foreach item="id" collection="array" open="(" separator="," close=")">
  389. #{id}
  390. </foreach>
  391. </delete>
  392. <select id="getWeekRecharge" resultType="java.util.Map">
  393. SELECT
  394. DATE_FORMAT(w.create_time,'%Y-%m-%d') as createTime,
  395. IFNULL(SUM(t.u_amount),0) as recharge
  396. FROM
  397. t_app_recharge w
  398. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  399. LEFT JOIN t_app_wallet_record t ON t.serial_id = w.serial_id
  400. WHERE
  401. u.is_test = 0
  402. AND w.`status` = 1
  403. AND (w.order_type = 1 OR w.order_type IS NULL)
  404. <if test="parentId != null and parentId!=''">
  405. AND find_in_set(#{parentId},w.admin_parent_ids)
  406. </if>
  407. AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<]]> DATE(w.create_time)
  408. AND w.user_id IN (SELECT u1.user_id FROM t_app_user u1)
  409. GROUP BY createTime;
  410. </select>
  411. <select id="getWeekFailedRecharge" resultType="java.util.Map">
  412. SELECT
  413. DATE_FORMAT(w.create_time,'%Y-%m-%d') as createTime,
  414. IFNULL(SUM(w.amount),0) as recharge
  415. FROM
  416. t_app_recharge w
  417. LEFT JOIN t_app_user u ON w.user_id = u.user_id
  418. WHERE
  419. u.is_test = 0
  420. AND w.`status` = 2
  421. AND (w.order_type = 1 OR w.order_type IS NULL)
  422. <if test="parentId != null and parentId!=''">
  423. AND find_in_set(#{parentId},w.admin_parent_ids)
  424. </if>
  425. AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<]]> DATE(w.create_time)
  426. AND w.user_id IN (SELECT u1.user_id FROM t_app_user u1)
  427. GROUP BY createTime;
  428. </select>
  429. </mapper>