123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <?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.OverallMapper">
- <resultMap id="QueryResultMap" type="com.juxiao.xchat.module.xbd.vo.OverallRecordVO">
- <id column="uid" property="uid" jdbcType="BIGINT"/>
- <result column="phone" property="phone" jdbcType="VARCHAR"/>
- <result column="erban_no" property="erbanNo" jdbcType="BIGINT"/>
- <result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
- <result column="weixin_openid" property="weixinOpenid" jdbcType="VARCHAR"/>
- <result column="qq_openid" property="qqOpenid" jdbcType="VARCHAR"/>
- <result column="os" property="os" jdbcType="VARCHAR"/>
- <result column="sign_time" property="signTime" jdbcType="TIMESTAMP"/>
- <result column="channel" property="channel" jdbcType="VARCHAR"/>
- <result column="nick" property="nick" jdbcType="VARCHAR"/>
- <result column="gender" property="gender" jdbcType="TINYINT"/>
- <result column="charge_amount" property="chargeAmount" jdbcType="BIGINT"/>
- <result column="exechange_diamond" property="exechangeDiamond" jdbcType="DOUBLE"/>
- <result column="charm_change" property="charmChange" jdbcType="BIGINT"/>
- <result column="exper_change" property="experChange" jdbcType="BIGINT"/>
- </resultMap>
- <sql id="Query_Column_List">
- a.uid as uid, a.phone as phone, a.erban_no as erban_no, a.last_login_time as last_login_time,
- a.weixin_openid as weixin_openid, a.qq_openid as qq_openid, a.os as os,
- a.channel as channel, u.create_time as sign_time,
- u.gender as gender, u.nick as nick
- </sql>
- <select id="listOverallRecord" resultMap="QueryResultMap">
- select
- <include refid="Query_Column_List"/>
- <choose>
- <when test="orderBy==1">
- ,sum(c1.amount) as charge_amount
- </when>
- <when test="orderBy==2">
- ,sum(c2.ex_diamond_num) as exechange_diamond
- </when>
- <when test="orderBy==3">
- ,sum(c3.sum_gold) as charm_change
- </when>
- <when test="orderBy==4">
- ,sum(c4.sum_gold) as exper_change
- </when>
- </choose>
- from account a JOIN users u ON a.uid=u.uid
- <choose>
- <when test="orderBy==1">
- left join charge_record c1 on c1.uid=a.uid and c1.charge_status='2' AND c1.pingxx_charge_id IS NOT NULL
- and c1.create_time BETWEEN #{beginDate} and #{endDate}
- </when>
- <when test="orderBy==2">
- LEFT JOIN exchange_diamond_gold_record c2 on c2.uid=a.uid and c2.create_time BETWEEN #{beginDate} and
- #{endDate}
- </when>
- <when test="orderBy==3">
- LEFT JOIN one_day_room_recv_sum c3 FORCE index(key3) on c3.recv_uid=a.uid and c3.create_time BETWEEN
- #{beginDate} and #{endDate}
- </when>
- <when test="orderBy==4">
- LEFT JOIN one_day_room_send_sum c4 FORCE index(key3) on c4.send_uid=a.uid and c4.create_time BETWEEN
- #{beginDate} and #{endDate}
- </when>
- </choose>
- <where>
- <if test="signBegin!=null">
- AND u.create_time >= #{signBegin}
- </if>
- <if test="signEnd!=null">
- AND u.create_time <= #{signEnd}
- </if>
- <if test="erbanNo!=null and erbanNo!=''">
- AND u.erban_no=#{erbanNo}
- </if>
- <if test="os!=null and os!=''">
- AND a.os = #{os}
- </if>
- <if test="phone!=null and phone!=''">
- AND a.phone like concat('%', #{phone},'%')
- </if>
- <if test="channel!=null and channel!=''">
- AND u.channel=#{channel}
- </if>
- <if test="gender!=null">
- AND u.gender=#{gender}
- </if>
- <if test="nick!=null and nick!=''">
- AND u.nick like concat('%',#{nick},'%')
- </if>
- <choose>
- <when test="registerType==1">
- AND a.weixin_openid is null AND a.qq_openid is null
- </when>
- <when test="registerType==2">
- AND a.weixin_openid is not null
- </when>
- <when test="registerType==3">
- AND a.qq_openid is not null
- </when>
- </choose>
- </where>
- group by a.uid
- <choose>
- <when test="orderBy==1">
- order by charge_amount desc
- </when>
- <when test="orderBy==2">
- order by exechange_diamond desc
- </when>
- <when test="orderBy==3">
- order by charm_change desc
- </when>
- <when test="orderBy==4">
- order by exper_change desc
- </when>
- </choose>
- </select>
- <select id="selectByChargeAmount" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
- SELECT c.uid, sum(c.amount)/100 as num FROM charge_record c force index(uid)
- WHERE c.uid in (${uidStr}) and c.charge_status='2' AND c.pingxx_charge_id IS NOT NULL and c.create_time BETWEEN #{beginDate} and #{endDate}
- GROUP BY c.uid
- </select>
- <select id="selectByExechangeDiamond" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
- select c.uid, sum(c.ex_diamond_num) as doubleNum FROM exchange_diamond_gold_record c force index(uid)
- WHERE c.uid in (${uidStr}) and c.create_time BETWEEN #{beginDate} and #{endDate}
- GROUP BY c.uid
- </select>
- <select id="selectByCharmChange" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
- SELECT c.recv_uid as uid, sum(c.sum_gold) as num FROM one_day_room_recv_sum c force index(key3)
- WHERE c.recv_uid in (${uidStr}) and c.create_time BETWEEN #{beginDate} and #{endDate}
- GROUP BY c.recv_uid
- </select>
- <select id="selectByExperChange" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat">
- SELECT c.send_uid as uid, sum(c.sum_gold) as num
- FROM one_day_room_send_sum c force index(key3)
- WHERE c.send_uid in (${uidStr}) and c.create_time BETWEEN #{beginDate} and #{endDate}
- GROUP BY c.send_uid
- </select>
- <select id="listLatestLoginDate" resultType="com.juxiao.xchat.module.xbd.domain.report.OverallStat" >
- SELECT uid, max(create_time) as date FROM account_login_record
- WHERE uid IN (${uidStr})
- GROUP BY uid
- </select>
- <resultMap id="SelectByQueryMap" type="com.juxiao.xchat.module.xbd.domain.report.ExchangeDiamondRecord">
- <result column="record_id" property="recordId" jdbcType="VARCHAR" />
- <result column="uid" property="uid" jdbcType="BIGINT" />
- <result column="ex_diamond_num" property="exDiamondNum" jdbcType="DOUBLE" />
- <result column="ex_gold_num" property="exGoldNum" jdbcType="BIGINT" />
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
- <result column="erban_no" property="erbanNo" jdbcType="BIGINT" />
- <result column="phone" property="phone" jdbcType="VARCHAR" />
- <result column="nick" property="nick" jdbcType="VARCHAR" />
- <result column="alipay_account" property="alipayAccount" jdbcType="VARCHAR" />
- <result column="alipay_account_name" property="alipayAccountName" jdbcType="VARCHAR" />
- </resultMap>
- <select id="listExchangeGoldRecord" resultMap="SelectByQueryMap">
- SELECT e.record_id as record_id, e.uid as uid, e.ex_diamond_num as ex_diamond_num, e.ex_gold_num as ex_gold_num, e.create_time as create_time,
- u.nick as nick ,u.erban_no as erban_no,u.phone as phone ,u.alipay_account as alipay_account,u.alipay_account_name as alipay_account_name
- FROM exchange_diamond_gold_record e LEFT JOIN users u ON e.uid=u.uid
- WHERE u.def_user!='3'
- <if test="erbanNo!=null">
- AND u.erban_no=#{erbanNo}
- </if>
- <if test="beginDate!=null">
- AND e.create_time >= #{beginDate}
- </if>
- <if test="endDate!=null">
- AND e.create_time <= #{endDate}
- </if>
- order by e.create_time desc
- </select>
- <resultMap id="giftMap" type="com.juxiao.xchat.module.xbd.domain.report.CharmRecord" >
- <result column="sendNo" property="sendNo" jdbcType="BIGINT" />
- <result column="sendNick" property="sendNick" jdbcType="VARCHAR" />
- <result column="reciveNo" property="reciveNo" jdbcType="BIGINT" />
- <result column="reciveNick" property="reciveNick" jdbcType="VARCHAR" />
- <result column="roomNo" property="roomNo" jdbcType="BIGINT" />
- <result column="roomNick" property="roomNick" jdbcType="VARCHAR" />
- <result column="gift_name" property="giftName" jdbcType="VARCHAR" />
- <result column="gift_num" property="giftNum" jdbcType="BIGINT" />
- <result column="total_gold_num" property="totalGoldNum" jdbcType="BIGINT" />
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
- </resultMap>
- <select id="listGiftSend" resultMap="giftMap" >
- select se.erban_no as sendNo, se.nick as sendNick, re.erban_no as reciveNo, re.nick as reciveNick, ro.erban_no as roomNo, ro.nick as roomNick, gi.gift_name, g.gift_num, g.total_gold_num, g.create_time
- from gift_send_record g
- INNER JOIN users se on g.uid = se.uid
- INNER JOIN users re on g.recive_uid = re.uid
- LEFT JOIN users ro on g.room_uid = ro.uid
- INNER JOIN gift gi on g.gift_id = gi.gift_id
- where 1=1
- <if test="uid!=null">
- and g.uid = #{uid}
- </if>
- <if test="reciveUid!=null">
- and g.recive_uid = #{reciveUid}
- </if>
- <if test="beginDate!=null">
- and g.create_time >= #{beginDate}
- </if>
- <if test="endDate!=null">
- and g.create_time <= #{endDate}
- </if>
- order by g.create_time desc
- </select>
- </mapper>
|