UserGiftStaMapper.xml
7.98 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?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.vo.StatisticsUserGift">
<resultMap id="BaseResultMap" type="com.bjivt.entity.vo.StatisticsUserGift">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="date" jdbcType="DATE" property="date" />
<result column="from_user_id" jdbcType="INTEGER" property="fromUserId" />
<result column="to_user_id" jdbcType="INTEGER" property="toUserId" />
<result column="numTotal" jdbcType="INTEGER" property="numTotal" />
<result column="moneyTotal" jdbcType="INTEGER" property="moneyTotal" />
<result column="chinese_coin" jdbcType="INTEGER" property="chineseCoin" />
<result column="fromUserName" jdbcType="VARCHAR" property="fromUserName" />
</resultMap>
<resultMap id="UserDetailMap" type="com.bjivt.entity.vo.StatisticsUserGift">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="from_user_id" jdbcType="INTEGER" property="fromUserId" />
<result column="to_user_id" jdbcType="INTEGER" property="toUserId" />
<result column="live_id" jdbcType="INTEGER" property="liveId" />
<result column="gift_id" jdbcType="INTEGER" property="giftId" />
<result column="count" jdbcType="INTEGER" property="count" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="fromUserName" jdbcType="VARCHAR" property="fromUserName" />
<result column="toUserName" jdbcType="VARCHAR" property="toUserName" />
<result column="liveName" jdbcType="VARCHAR" property="liveName" />
<result column="giftName" jdbcType="VARCHAR" property="giftName" />
</resultMap>
<resultMap id="UserIdListMap" type="java.lang.String" >
<result column="from_user_id" property="id" />
</resultMap>
<sql id="Base_Column_List">
id, date,from_user_id, to_user_id, numTotal, moneyTotal
</sql>
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from db_showtime_stat.tbl_user_gift_statistics
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
delete from db_showtime_stat.tbl_user_gift_statistics
where id = #{id,jdbcType=INTEGER}
</delete>
<select id="getCountBy" resultType="java.lang.Integer" parameterType="com.bjivt.entity.vo.StatisticsUserGift">
SELECT
count(*)
FROM
db_showtime_stat.tbl_user_gift_statistics
<trim prefix="where" prefixOverrides="and|or">
<if test="fromUserId != null and fromUserId != ''" >
and db_showtime_stat.tbl_user_gift_statistics.to_user_id = #{StatisticsUserGift.id}
</if>
</trim>
</select>
<!-- 获取用户得到礼物的列表信息 -->
<select id="findListByMap" resultMap="UserDetailMap" parameterType="java.util.Map">
select a.*,
b.name fromUserName,
e.name toUserName
from db_showtime_stat.tbl_user_gift_statistics a
inner join tbl_user_list b on b.id=a.from_user_id
inner join tbl_user_list e on e.id=a.to_user_id
<trim prefix="where" prefixOverrides="and|or">
<if test="StatisticsUserGift.id!= null and StatisticsUserGift.id != ''" >
and a.to_user_id = #{StatisticsUserGift.id}
</if>
</trim>
<if test ="page.orderBy !=null and page.orderBy ==''">
order by a.numTotal desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'numTotal asc'">
order by a.numTotal asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'numTotal desc'">
order by a.numTotal desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'moneyTotal asc'">
order by a.moneyTotal asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'moneyTotal desc'">
order by a.moneyTotal desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'chineseCoin asc'">
order by a.chinese_coin asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'chineseCoin desc'">
order by a.chinese_coin desc
</if>
<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="findUserGfitList" resultMap="UserIdListMap" parameterType="java.util.Map">
select distinct a.from_user_id
from tbl_user_gift_detail a
where a.to_user_id=#{toUserId,jdbcType=INTEGER}
limit 0,10
</select>
<select id="findListByPager" resultMap="BaseResultMap" parameterType="java.util.Map">
select a.from_user_id,b.name fromUserName, sum(a.numTotal) numTotal, sum(a.moneyTotal) moneyTotal,b.chinese_coin
from db_showtime_stat.tbl_user_gift_statistics a
INNER join tbl_user_list b on b.id=a.from_user_id
<trim prefix="where" prefixOverrides="and|or">
<if test="toUserId != null and toUserId !=''">
and a.to_user_id = #{toUserId}
</if>
<if test="startTime != null and startTime !='' and endTime != null and endTime !=''">
and date_format(a.date,'%Y-%m-%d') between str_to_date(#{startTime},'%Y-%m-%d') and str_to_date(#{endTime},'%Y-%m-%d')
</if>
</trim>
group by a.from_user_id
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'createDate desc'">
order by numTotal desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'numTotal asc'">
order by numTotal asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'numTotal desc'">
order by numTotal desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'moneyTotal asc'">
order by moneyTotal asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'moneyTotal desc'">
order by moneyTotal desc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'chineseCoin asc'">
order by b.chinese_coin asc
</if>
<if test ="page.orderBy !=null and page.orderBy !='' and page.orderBy == 'chineseCoin desc'">
order by b.chinese_coin desc
</if>
<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="getCountByParam" resultType="java.lang.Integer" parameterType="java.util.Map">
select count(*)
from db_showtime_stat.tbl_user_gift_statistics a
inner join tbl_user_list b on b.id=a.from_user_id
<trim prefix="where" prefixOverrides="and|or">
<if test="toUserId != null and toUserId !=''">
and a.to_user_id = #{toUserId}
</if>
<if test="startTime != null and startTime !='' and endTime != null and endTime !=''">
and date_format(a.date,'%Y-%m-%d') between str_to_date(#{startTime},'%Y-%m-%d') and str_to_date(#{endTime},'%Y-%m-%d')
</if>
</trim>
</select>
<select id="findAllList" resultMap="BaseResultMap" parameterType="java.util.Map">
select a.from_user_id,b.name fromUserName, sum(a.numTotal) numTotal, sum(a.moneyTotal) moneyTotal,b.chinese_coin
from db_showtime_stat.tbl_user_gift_statistics a
inner join tbl_user_list b on b.id=a.from_user_id
<trim prefix="where" prefixOverrides="and|or">
<if test="toUserId != null and toUserId !=''">
and a.to_user_id = #{toUserId}
</if>
<if test="startTime != null and startTime !='' and endTime != null and endTime !=''">
and date_format(a.date,'%Y-%m-%d') between str_to_date(#{startTime},'%Y-%m-%d') and str_to_date(#{endTime},'%Y-%m-%d')
</if>
</trim>
group by a.from_user_id
</select>
</mapper>