RoomStreamMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.RoomStreamMapper">
  6. <select id="selectRoomStream" resultType="com.juxiao.xchat.module.xbd.vo.RoomStreamVO">
  7. SELECT
  8. COUNT(DISTINCT g.send_uid) AS countUsers,
  9. COUNT(DISTINCT g.send_uid,
  10. if(
  11. <if test="beginTime != null and beginTime != ''">
  12. u2.create_time &gt;= #{beginTime}
  13. </if>
  14. <if test="endTime != null and endTime != ''">
  15. <if test="beginTime != null and beginTime != ''">AND</if>
  16. u2.create_time &lt;= #{endTime}
  17. </if>
  18. , TRUE, NULL)
  19. ) AS countNewUsers,
  20. g.uid as uid ,
  21. SUM(g.sum_gold) as totalGoldNum,
  22. u.erban_no as erbanNo,
  23. u.nick as nick,
  24. u.phone as phone,
  25. u.alipay_account as alipayAccount,
  26. u.alipay_account_name as alipayAccountName,
  27. r.room_id AS roomId,
  28. r.room_tag as roomTag,
  29. r.is_permit_room as isPermitRoom,
  30. ifnull(r.reward_money,0) AS bounsPersent,
  31. if(uc.occupation_ratio is null,0,ROUND(uc.occupation_ratio*SUM(g.sum_gold)/100,2)) as occupation,
  32. uc.bank_card as bankCard,
  33. uc.cardholder as cardholder
  34. FROM one_day_room_send_sum g
  35. INNER JOIN users u ON g.uid = u.uid
  36. INNER JOIN room r ON r.uid = g.uid
  37. LEFT JOIN user_configure uc ON g.uid = uc.uid
  38. LEFT JOIN users u2 ON g.send_uid = u2.uid
  39. <where>
  40. <include refid="statQuery"></include>
  41. </where>
  42. GROUP BY g.uid
  43. order by totalGoldNum desc
  44. </select>
  45. <sql id="statQuery">
  46. 1=1
  47. <if test="erbanNo != null">
  48. AND u.erban_no=#{erbanNo}
  49. </if>
  50. <if test="beginTime != null and beginTime != ''">
  51. AND g.create_time &gt;= #{beginTime}
  52. </if>
  53. <if test="endTime != null and endTime != ''">
  54. AND g.create_time &lt;= #{endTime}
  55. </if>
  56. <if test="roomType != null">
  57. AND r.is_permit_room=#{roomType}
  58. </if>
  59. <if test="roomTag != null">
  60. AND r.tag_id=#{roomTag}
  61. </if>
  62. </sql>
  63. <select id="countStatRoomTotalFlow" resultType="java.lang.Long">
  64. select ifnull(sum(bgd.gift_num * g.gold_price),0)
  65. from bill_gift_draw bgd
  66. inner join gift g on bgd.gift_id = g.gift_id
  67. where bgd.uid = #{uid}
  68. </select>
  69. <select id="selectRoomStreamInfo" resultType="com.juxiao.xchat.module.xbd.vo.RoomStreamVO">
  70. SELECT SUM(g.sum_gold) as totalGoldNum,
  71. ifnull(r.reward_money,0) AS bounsPersent
  72. FROM one_day_room_send_sum g
  73. INNER JOIN users u ON g.uid = u.uid
  74. INNER JOIN room r ON r.uid = g.uid
  75. <where>
  76. <include refid="statQuery"></include>
  77. </where>
  78. </select>
  79. <select id="selectRoomStreamByEcharts" resultType="com.juxiao.xchat.module.xbd.dto.RoomFlowEchartsDTO">
  80. <!-- 根据时间统计房间流水 -->
  81. SELECT
  82. <if test="classType == 1">
  83. DATE_FORMAT(odr.create_time, '%Y%m%d') period,
  84. </if>
  85. <if test="classType == 2">
  86. DATE_FORMAT(odr.create_time, '%Y%u') period,
  87. </if>
  88. <if test="classType == 3">
  89. DATE_FORMAT(odr.create_time, '%Y%m') period,
  90. </if>
  91. <if test="classType == 4">
  92. DATE_FORMAT(odr.create_time, '%Y') period,
  93. </if>
  94. SUM(odr.sum_gold) totalGold,
  95. odr.uid as uid,
  96. u.nick,
  97. u.erban_no as erbanNo
  98. FROM
  99. one_day_room_recv_sum odr
  100. LEFT JOIN users u ON odr.uid = u.uid
  101. <where>
  102. <if test="beginDate != null and beginDate != ''">
  103. AND DATE(odr.create_time) &gt;= #{beginDate}
  104. </if>
  105. <if test="endDate != null and endDate != ''">
  106. AND DATE(odr.create_time) &lt;= #{endDate}
  107. </if>
  108. <if test="uid != null">
  109. AND odr.uid = #{uid}
  110. </if>
  111. <if test="uidList != null">
  112. AND odr.uid IN
  113. <foreach collection="uidList" index="index" item="item" open="(" separator="," close=")">
  114. #{item}
  115. </foreach>
  116. </if>
  117. </where>
  118. GROUP BY
  119. period, odr.uid
  120. <if test="minNum != null">
  121. HAVING totalGold &gt;= #{minNum}
  122. </if>
  123. ORDER BY period ASC, odr.uid ASC
  124. </select>
  125. </mapper>