ChannelUserMapper.xml
12.9 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?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.yoho.unions.dal.IChannelUserDAO" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.ChannelUser" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="channel_source" property="channelSource" jdbcType="INTEGER" />
<result column="channel_purchases_number" property="channelPurchasesNumber" jdbcType="SMALLINT" />
<result column="channel_order_code" property="channelOrderCode" jdbcType="VARCHAR" />
<result column="channel_order_time" property="channelOrderTime" jdbcType="INTEGER" />
<result column="channel_order_amount" property="channelOrderAmount" jdbcType="DECIMAL" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="yh_purchases_number" property="yhPurchasesNumber" jdbcType="SMALLINT" />
<result column="yh_order_code" property="yhOrderCode" jdbcType="VARCHAR" />
<result column="yh_order_time" property="yhOrderTime" jdbcType="INTEGER" />
<result column="yh_order_amount" property="yhOrderAmount" jdbcType="DECIMAL" />
<result column="union_code" property="unionCode" jdbcType="VARCHAR" />
<result column="user_channel" property="userChannel" jdbcType="VARCHAR" />
<result column="register_time" property="registerTime" jdbcType="INTEGER" />
<result column="sms_number" property="smsNumber" jdbcType="SMALLINT" />
<result column="sms_time" property="smsTime" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, mobile, channel_source, channel_purchases_number, channel_order_code, channel_order_time,
channel_order_amount, uid, yh_purchases_number, yh_order_code, yh_order_time, yh_order_amount,
union_code, user_channel, register_time, sms_number, sms_time, create_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from channel_user
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from channel_user
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelUser" >
insert into channel_user (id, mobile, channel_source,
channel_purchases_number, channel_order_code,
channel_order_time, channel_order_amount, uid,
yh_purchases_number, yh_order_code, yh_order_time,
yh_order_amount, union_code, user_channel,
register_time, sms_number, sms_time,
create_time)
values (#{id,jdbcType=INTEGER}, #{mobile,jdbcType=VARCHAR}, #{channelSource,jdbcType=INTEGER},
#{channelPurchasesNumber,jdbcType=SMALLINT}, #{channelOrderCode,jdbcType=VARCHAR},
#{channelOrderTime,jdbcType=INTEGER}, #{channelOrderAmount,jdbcType=DECIMAL}, #{uid,jdbcType=INTEGER},
#{yhPurchasesNumber,jdbcType=SMALLINT}, #{yhOrderCode,jdbcType=VARCHAR}, #{yhOrderTime,jdbcType=INTEGER},
#{yhOrderAmount,jdbcType=DECIMAL}, #{unionCode,jdbcType=VARCHAR}, #{userChannel,jdbcType=VARCHAR},
#{registerTime,jdbcType=INTEGER}, #{smsNumber,jdbcType=SMALLINT}, #{smsTime,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelUser" >
insert into channel_user
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="mobile != null" >
mobile,
</if>
<if test="channelSource != null" >
channel_source,
</if>
<if test="channelPurchasesNumber != null" >
channel_purchases_number,
</if>
<if test="channelOrderCode != null" >
channel_order_code,
</if>
<if test="channelOrderTime != null" >
channel_order_time,
</if>
<if test="channelOrderAmount != null" >
channel_order_amount,
</if>
<if test="uid != null" >
uid,
</if>
<if test="yhPurchasesNumber != null" >
yh_purchases_number,
</if>
<if test="yhOrderCode != null" >
yh_order_code,
</if>
<if test="yhOrderTime != null" >
yh_order_time,
</if>
<if test="yhOrderAmount != null" >
yh_order_amount,
</if>
<if test="unionCode != null" >
union_code,
</if>
<if test="userChannel != null" >
user_channel,
</if>
<if test="registerTime != null" >
register_time,
</if>
<if test="smsNumber != null" >
sms_number,
</if>
<if test="smsTime != null" >
sms_time,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="mobile != null" >
#{mobile,jdbcType=VARCHAR},
</if>
<if test="channelSource != null" >
#{channelSource,jdbcType=INTEGER},
</if>
<if test="channelPurchasesNumber != null" >
#{channelPurchasesNumber,jdbcType=SMALLINT},
</if>
<if test="channelOrderCode != null" >
#{channelOrderCode,jdbcType=VARCHAR},
</if>
<if test="channelOrderTime != null" >
#{channelOrderTime,jdbcType=INTEGER},
</if>
<if test="channelOrderAmount != null" >
#{channelOrderAmount,jdbcType=DECIMAL},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="yhPurchasesNumber != null" >
#{yhPurchasesNumber,jdbcType=SMALLINT},
</if>
<if test="yhOrderCode != null" >
#{yhOrderCode,jdbcType=VARCHAR},
</if>
<if test="yhOrderTime != null" >
#{yhOrderTime,jdbcType=INTEGER},
</if>
<if test="yhOrderAmount != null" >
#{yhOrderAmount,jdbcType=DECIMAL},
</if>
<if test="unionCode != null" >
#{unionCode,jdbcType=VARCHAR},
</if>
<if test="userChannel != null" >
#{userChannel,jdbcType=VARCHAR},
</if>
<if test="registerTime != null" >
#{registerTime,jdbcType=INTEGER},
</if>
<if test="smsNumber != null" >
#{smsNumber,jdbcType=SMALLINT},
</if>
<if test="smsTime != null" >
#{smsTime,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.ChannelUser" >
update channel_user
<set >
<if test="mobile != null" >
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="channelSource != null" >
channel_source = #{channelSource,jdbcType=INTEGER},
</if>
<if test="channelPurchasesNumber != null" >
channel_purchases_number = #{channelPurchasesNumber,jdbcType=SMALLINT},
</if>
<if test="channelOrderCode != null" >
channel_order_code = #{channelOrderCode,jdbcType=VARCHAR},
</if>
<if test="channelOrderTime != null" >
channel_order_time = #{channelOrderTime,jdbcType=INTEGER},
</if>
<if test="channelOrderAmount != null" >
channel_order_amount = #{channelOrderAmount,jdbcType=DECIMAL},
</if>
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="yhPurchasesNumber != null" >
yh_purchases_number = #{yhPurchasesNumber,jdbcType=SMALLINT},
</if>
<if test="yhOrderCode != null" >
yh_order_code = #{yhOrderCode,jdbcType=VARCHAR},
</if>
<if test="yhOrderTime != null" >
yh_order_time = #{yhOrderTime,jdbcType=INTEGER},
</if>
<if test="yhOrderAmount != null" >
yh_order_amount = #{yhOrderAmount,jdbcType=DECIMAL},
</if>
<if test="unionCode != null" >
union_code = #{unionCode,jdbcType=VARCHAR},
</if>
<if test="userChannel != null" >
user_channel = #{userChannel,jdbcType=VARCHAR},
</if>
<if test="registerTime != null" >
register_time = #{registerTime,jdbcType=INTEGER},
</if>
<if test="smsNumber != null" >
sms_number = #{smsNumber,jdbcType=SMALLINT},
</if>
<if test="smsTime != null" >
sms_time = #{smsTime,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.ChannelUser" >
update channel_user
set mobile = #{mobile,jdbcType=VARCHAR},
channel_source = #{channelSource,jdbcType=INTEGER},
channel_purchases_number = #{channelPurchasesNumber,jdbcType=SMALLINT},
channel_order_code = #{channelOrderCode,jdbcType=VARCHAR},
channel_order_time = #{channelOrderTime,jdbcType=INTEGER},
channel_order_amount = #{channelOrderAmount,jdbcType=DECIMAL},
uid = #{uid,jdbcType=INTEGER},
yh_purchases_number = #{yhPurchasesNumber,jdbcType=SMALLINT},
yh_order_code = #{yhOrderCode,jdbcType=VARCHAR},
yh_order_time = #{yhOrderTime,jdbcType=INTEGER},
yh_order_amount = #{yhOrderAmount,jdbcType=DECIMAL},
union_code = #{unionCode,jdbcType=VARCHAR},
user_channel = #{userChannel,jdbcType=VARCHAR},
register_time = #{registerTime,jdbcType=INTEGER},
sms_number = #{smsNumber,jdbcType=SMALLINT},
sms_time = #{smsTime,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer">
SELECT count(*) FROM channel_user c
<include refid="WHERE_CONDITION"/>
</select>
<select id="selectPage" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" /> FROM channel_user c
<include refid="WHERE_CONDITION"/>
ORDER BY create_time DESC
limit #{offset}, #{rows}
</select>
<sql id="WHERE_CONDITION">
<if test="condition != null">
<trim prefix="where" prefixOverrides="and | or">
1 = 1
<if test="condition.channelSource != null">
and channel_source in (${condition.channelSource})
</if>
<if test="condition.channelOrderCode != null">
AND channel_order_code like CONCAT('%', #{condition.channelOrderCode}, '%')
</if>
<if test="condition.beginChannelOrderTime != null">
AND channel_order_time >= #{condition.beginChannelOrderTime}
</if>
<if test="condition.endChannelOrderTime != null">
<![CDATA[ AND channel_order_time <= #{condition.endChannelOrderTime} ]]>
</if>
<if test="condition.uid != null">
AND uid = #{condition.uid}
</if>
<choose>
<when test="condition.hasUid != null and condition.hasUid == 0">
and (uid = 0 or uid is null)
</when>
<when test="condition.hasUid != null and condition.hasUid == 1">
and uid > 0
</when>
</choose>
<choose>
<when test="condition.hasYHOrder != null and condition.hasYHOrder == 0">
and (yh_order_code = '' or yh_order_code is null)
</when>
<when test="condition.hasYHOrder != null and condition.hasYHOrder == 1">
and (yh_order_code != '' or yh_order_code is not null)
</when>
</choose>
<if test="condition.yhOrderCode != null">
AND yh_order_code = like CONCAT('%', #{condition.yhOrderCode}, '%')
</if>
<if test="condition.beginYHOrderTime != null">
AND yh_order_time >= #{condition.beginYHOrderTime}
</if>
<if test="condition.endYHOrderTime != null">
<![CDATA[ AND yh_order_time <= #{condition.endYHOrderTime} ]]>
</if>
<if test="condition.unionCode != null">
AND union_code = #{condition.unionCode}
</if>
<if test="condition.userChannel != null">
AND user_channel = #{condition.userChannel}
</if>
<if test="condition.beginRegisterTime != null">
AND register_time >= #{condition.beginRegisterTime}
</if>
<if test="condition.endRegisterTime != null">
<![CDATA[ AND register_time <= #{condition.endRegisterTime} ]]>
</if>
<if test="condition.beginSmsTime != null">
AND sms_time >= #{condition.beginSmsTime}
</if>
<if test="condition.endSmsTime != null">
<![CDATA[ AND sms_time <= #{condition.endSmsTime} ]]>
</if>
<if test="condition.ids != null">
and id in
<foreach item="item" index="index" collection="condition.ids" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</trim>
</if>
</sql>
</mapper>