TrickTreatMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.juxiao.xchat.module.xbd.mapper.report.TrickTreatMapper">
  6. <select id="selectTrickTreatByList" resultType="com.juxiao.xchat.module.xbd.vo.TrickTreatVO">
  7. select u.erban_no as erbanNo, u.nick, b.input_num as inputNum,b.out_num as outputNum,DATE_FORMAT(b.create_date,'%Y-%m-%d') as createTime,b.uid
  8. from user_draw_gift_day b
  9. inner join users u on b.uid = u.uid
  10. where 1 = 1
  11. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  12. AND b.create_date between #{beginTime} AND #{endTime}
  13. </if>
  14. <if test="osType != null and osType != ''">
  15. AND u.os = #{osType}
  16. </if>
  17. <if test="erbanNo!=null">
  18. AND u.erban_no = #{erbanNo}
  19. </if>
  20. <if test="gender!=null">
  21. AND u.gender = #{gender}
  22. </if>
  23. GROUP BY createTime,b.uid
  24. ORDER BY b.create_date desc,inputNum desc, outputNum desc
  25. </select>
  26. <select id="selectTrickTreatStatistics" resultType="com.juxiao.xchat.module.xbd.vo.TrickTreatStatisticsVO">
  27. SELECT COUNT(DISTINCT b.uid) as userNum,sum(b.input_num) as totalInputNum ,sum(b.out_num) as totalOutputNum
  28. from user_draw_gift_day b
  29. inner join users u on b.uid = u.uid
  30. where 1 = 1
  31. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  32. AND b.create_date between #{beginTime} AND #{endTime}
  33. </if>
  34. <if test="osType != null and osType != ''">
  35. AND u.os = #{osType}
  36. </if>
  37. <if test="erbanNo != null">
  38. AND u.erban_no = #{erbanNo}
  39. </if>
  40. <if test="gender!=null">
  41. AND u.gender = #{gender}
  42. </if>
  43. </select>
  44. <select id="selectFullGiftNum" resultType="java.lang.Integer">
  45. select COALESCE(sum(num),0) as num
  46. from user_draw_gift_record
  47. where gift_id = #{giftId}
  48. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  49. AND create_time between #{beginTime} AND #{endTime}
  50. </if>
  51. <if test="erbanNo != null">
  52. AND uid = #{erbanNo}
  53. </if>
  54. </select>
  55. <select id="selectTrickTreatWhitelistByList" resultType="com.juxiao.xchat.module.xbd.vo.TrickTreatVO">
  56. select SUM(b.gold_cost) as inputNum,SUM(b.gift_num * g.gold_price) as outputNum,DATE_FORMAT(b.create_time,'%Y-%m-%d') as createTime,b.uid
  57. from bill_gift_draw b
  58. inner join gift g on g.gift_id = b.gift_id
  59. where
  60. b.uid in
  61. <foreach collection="uidList" index="index" item="item" open="(" separator="," close=")">
  62. #{item}
  63. </foreach>
  64. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  65. AND b.create_time between #{beginTime} AND #{endTime}
  66. </if>
  67. GROUP BY createTime,b.uid
  68. ORDER BY inputNum desc,b.create_time desc, outputNum desc
  69. </select>
  70. <select id="selectTrickTreatWhitelistStatistics" resultType="com.juxiao.xchat.module.xbd.vo.TrickTreatStatisticsVO">
  71. SELECT COUNT(DISTINCT b.uid) as userNum, ifnull(SUM(b.gold_cost),0) as totalInputNum, ifnull(SUM(b.gift_num * g.gold_price),0) as totalOutputNum
  72. from bill_gift_draw b
  73. inner join users u on b.uid = u.uid
  74. inner join gift g on g.gift_id = b.gift_id
  75. where
  76. b.uid in
  77. <foreach collection="uidList" index="index" item="item" open="(" separator="," close=")">
  78. #{item}
  79. </foreach>
  80. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  81. AND b.create_time between #{beginTime} AND #{endTime}
  82. </if>
  83. </select>
  84. <select id="selectFullWhitelistGiftNum" resultType="java.lang.Integer">
  85. select COALESCE(sum(num),0) as num
  86. from user_draw_gift_record
  87. where gift_id = #{giftId}
  88. and uid in
  89. <foreach collection="uidList" index="index" item="item" open="(" separator="," close=")">
  90. #{item}
  91. </foreach>
  92. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  93. AND create_time between #{beginTime} AND #{endTime}
  94. </if>
  95. </select>
  96. </mapper>