123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.juxiao.xchat.module.xbd.mapper.report.RoomStreamMapper">
- <select id="selectRoomStream" resultType="com.juxiao.xchat.module.xbd.vo.RoomStreamVO">
- SELECT
- COUNT(DISTINCT g.send_uid) AS countUsers,
- COUNT(DISTINCT g.send_uid,
- if(
- <if test="beginTime != null and beginTime != ''">
- u2.create_time >= #{beginTime}
- </if>
- <if test="endTime != null and endTime != ''">
- <if test="beginTime != null and beginTime != ''">AND</if>
- u2.create_time <= #{endTime}
- </if>
- , TRUE, NULL)
- ) AS countNewUsers,
- g.uid as uid ,
- SUM(g.sum_gold) as totalGoldNum,
- u.erban_no as erbanNo,
- u.nick as nick,
- u.phone as phone,
- u.alipay_account as alipayAccount,
- u.alipay_account_name as alipayAccountName,
- r.room_id AS roomId,
- r.room_tag as roomTag,
- r.is_permit_room as isPermitRoom,
- ifnull(r.reward_money,0) AS bounsPersent,
- if(uc.occupation_ratio is null,0,ROUND(uc.occupation_ratio*SUM(g.sum_gold)/100,2)) as occupation,
- uc.bank_card as bankCard,
- uc.cardholder as cardholder
- FROM one_day_room_send_sum g
- INNER JOIN users u ON g.uid = u.uid
- INNER JOIN room r ON r.uid = g.uid
- LEFT JOIN user_configure uc ON g.uid = uc.uid
- LEFT JOIN users u2 ON g.send_uid = u2.uid
- <where>
- <include refid="statQuery"></include>
- </where>
- GROUP BY g.uid
- order by totalGoldNum desc
- </select>
- <sql id="statQuery">
- 1=1
- <if test="erbanNo != null">
- AND u.erban_no=#{erbanNo}
- </if>
- <if test="beginTime != null and beginTime != ''">
- AND g.create_time >= #{beginTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND g.create_time <= #{endTime}
- </if>
- <if test="roomType != null">
- AND r.is_permit_room=#{roomType}
- </if>
- <if test="roomTag != null">
- AND r.tag_id=#{roomTag}
- </if>
- </sql>
- <select id="countStatRoomTotalFlow" resultType="java.lang.Long">
- select ifnull(sum(bgd.gift_num * g.gold_price),0)
- from bill_gift_draw bgd
- inner join gift g on bgd.gift_id = g.gift_id
- where bgd.uid = #{uid}
- </select>
- <select id="selectRoomStreamInfo" resultType="com.juxiao.xchat.module.xbd.vo.RoomStreamVO">
- SELECT SUM(g.sum_gold) as totalGoldNum,
- ifnull(r.reward_money,0) AS bounsPersent
- FROM one_day_room_send_sum g
- INNER JOIN users u ON g.uid = u.uid
- INNER JOIN room r ON r.uid = g.uid
- <where>
- <include refid="statQuery"></include>
- </where>
- </select>
- <select id="selectRoomStreamByEcharts" resultType="com.juxiao.xchat.module.xbd.dto.RoomFlowEchartsDTO">
- <!-- 根据时间统计房间流水 -->
- SELECT
- <if test="classType == 1">
- DATE_FORMAT(odr.create_time, '%Y%m%d') period,
- </if>
- <if test="classType == 2">
- DATE_FORMAT(odr.create_time, '%Y%u') period,
- </if>
- <if test="classType == 3">
- DATE_FORMAT(odr.create_time, '%Y%m') period,
- </if>
- <if test="classType == 4">
- DATE_FORMAT(odr.create_time, '%Y') period,
- </if>
- SUM(odr.sum_gold) totalGold,
- odr.uid as uid,
- u.nick,
- u.erban_no as erbanNo
- FROM
- one_day_room_recv_sum odr
- LEFT JOIN users u ON odr.uid = u.uid
- <where>
- <if test="beginDate != null and beginDate != ''">
- AND DATE(odr.create_time) >= #{beginDate}
- </if>
- <if test="endDate != null and endDate != ''">
- AND DATE(odr.create_time) <= #{endDate}
- </if>
- <if test="uid != null">
- AND odr.uid = #{uid}
- </if>
- <if test="uidList != null">
- AND odr.uid IN
- <foreach collection="uidList" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- period, odr.uid
- <if test="minNum != null">
- HAVING totalGold >= #{minNum}
- </if>
- ORDER BY period ASC, odr.uid ASC
- </select>
- </mapper>
|