StatisticsUserMapper.xml
7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?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.bjivt.entity.showtime.StatisticsUser">
<resultMap id="BaseResultMap" type="com.bjivt.entity.vo.StatisticsUser">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="msisdn" jdbcType="VARCHAR" property="msisdn" />
<result column="email" jdbcType="VARCHAR" property="email" />
<result column="signature" jdbcType="VARCHAR" property="signature" />
<result column="hometown" jdbcType="VARCHAR" property="hometown" />
<result column="sex" jdbcType="VARCHAR" property="sex" />
<result column="fans_count" jdbcType="INTEGER" property="fansCount" />
<result column="follower_count" jdbcType="INTEGER" property="followerCount" />
<result column="chinese_coin" jdbcType="INTEGER" property="chineseCoin" />
<result column="me_coin_balance" jdbcType="INTEGER" property="meCoinBalance" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="money" jdbcType="INTEGER" property="money" />
<result column="recharge" jdbcType="INTEGER" property="recharge" />
<result column="age" jdbcType="INTEGER" property="age" />
</resultMap>
<!-- 统计注册人数 总数变化情况-->
<select id="getUserDataByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
select tu.id,tu.name, tu.msisdn,tu.email,tu.signature,tu.hometown,tu.sex,tu.age,
tu.fans_count,tu.follower_count,tu.chinese_coin,tu.me_coin_balance,
(<![CDATA[select te.level from tbl_level te where tu.exp>=te.exp_start AND tu.exp<=te.exp_end]]>) level,
(select sum(me_coin) from db_showtime_log.tbl_withdraw_record where user_id=tu.id
<![CDATA[and date_format(record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d')
and date_format(record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>) money,
(select sum(tr.money) as tmoney from db_showtime_log.tbl_recharge_record tr
where tr.user_id=tu.id
<![CDATA[ and date_format(tr.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d')
and date_format(tr.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>) as recharge
from tbl_user_list tu
<if test="id != null and id !=''">
where tu.id=#{id}
</if>
order by ${orderfield} ${orderrule}
<if test="page != null and page !=''">
<if test="page.from != null and page.size != null">
limit #{page.from},#{page.size}
</if>
</if>
</select>
<select id="getUserDataCountBy" resultType="java.lang.Integer" parameterType="java.util.Map">
SELECT
count(id)
FROM
tbl_user_list
</select>
<!-- 统计观众观看时长-->
<select id="getUserVisitTime" parameterType="java.util.Map" resultType="com.bjivt.entity.vo.StatisticsResult">
<if test="types==0 or types==1" >
select date_format(u.record_time,'%Y-%m-%d') time, sum(TIMESTAMPDIFF(SECOND, u.record_time, case when u.end_time is null then u.record_time else u.end_time end)) as counts
from db_showtime_log.tbl_live_record u where u.mark=1 and u.visit_user_id=${id} and u.record_time is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time
</if>
<if test="types==2">
select date_format(u.record_time,'%Y年第%u周') time, sum(TIMESTAMPDIFF(SECOND, u.record_time, case when u.end_time is null then u.record_time else u.end_time end)) as counts
from db_showtime_log.tbl_live_record u where u.mark=1 and u.visit_user_id=${id} and u.record_time is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time
</if>
<if test="types==3">
select date_format(u.record_time,'%Y年%m月') time, sum(TIMESTAMPDIFF(SECOND, u.record_time, case when u.end_time is null then u.record_time else u.end_time end)) as counts
from db_showtime_log.tbl_live_record u where u.mark=1 and u.visit_user_id=${id} and u.record_time is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time
</if>
<if test="types==4">
select date_format(u.record_time,'%Y年') time, sum(TIMESTAMPDIFF(SECOND, u.record_time, case when u.end_time is null then u.record_time else u.end_time end)) as counts
from db_showtime_log.tbl_live_record u where u.mark=1 and u.visit_user_id=${id} and u.record_time is not null
and date_format(u.record_time,'%Y') between date_format(#{startTime},'%Y') and date_format(#{endTime},'%Y')
group by time
</if>
</select>
<!-- 统计用户充值金额-->
<select id="getUserRecharge" parameterType="java.util.Map" resultType="com.bjivt.entity.vo.StatisticsResult">
<if test="types==0 or types==1" >
select date_format(u.record_time,'%Y-%m-%d') time,sum( case when u.money is null then 0 else u.money end ) as counts
from db_showtime_log.tbl_recharge_record u where u.user_id=${id} and u.record_time is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time
</if>
<if test="types==2">
select date_format(u.record_time,'%Y年第%u周') time,sum( case when u.money is null then 0 else u.money end ) as counts
from db_showtime_log.tbl_recharge_record u where u.user_id=${id} and u.record_time is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time
</if>
<if test="types==3">
select date_format(u.record_time,'%Y年%m月') time,sum( case when u.money is null then 0 else u.money end ) as counts
from db_showtime_log.tbl_recharge_record u where u.user_id=${id} and u.record_time is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.record_time,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time
</if>
<if test="types==4">
select date_format(u.record_time,'%Y年') time,sum( case when u.money is null then 0 else u.money end ) as counts
from db_showtime_log.tbl_recharge_record u where u.user_id=${id} and u.record_time is not null
and date_format(u.record_time,'%Y') between date_format(#{startTime},'%Y') and date_format(#{endTime},'%Y')
group by time
</if>
</select>
</mapper>