UnionShareOrdersMapper.xml
12.1 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
<?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.UnionShareOrdersMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareOrders" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="settlement_code" property="settlementCode" jdbcType="VARCHAR" />
<result column="promote_uid" property="promoteUid" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="VARCHAR" />
<result column="last_order_amount" property="lastOrderAmount" jdbcType="DECIMAL" />
<result column="order_time" property="orderTime" jdbcType="INTEGER" />
<result column="is_new" property="isNew" jdbcType="TINYINT" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, order_code,settlement_code, promote_uid, status, last_order_amount, order_time, is_new, amount, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_orders
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCode" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where order_code = #{orderCode,jdbcType=VARCHAR}
limit 1
</select>
<select id="selectCountByCondition" resultType="java.lang.Integer" >
select count(1) from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
</select>
<select id="selectAmountByStatus" resultType="java.math.BigDecimal" >
select IFNULL(sum(amount),0) from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status in
<foreach collection="statusList" item="item" separator="," index="index" open="(" close=")">
#{item}
</foreach>
</select>
<select id="selectAmountBySettleCode" resultType="java.math.BigDecimal" >
select IFNULL(sum(amount),0) from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and settlement_code = #{settlementCode,jdbcType=VARCHAR}
</select>
<select id="selectListByCondition" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
limit #{offset}, #{rows}
</select>
<select id="selectListByIds" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where id in
<foreach collection="list" open="(" close=")" item="id" separator=",">
#{id}
</foreach>
</select>
<select id="selectOrderCodesByCondition" resultType="java.lang.String" >
select order_code from union_share_orders
where settlement_code = #{settlementCode,jdbcType=VARCHAR}
limit #{offset}, #{rows}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
insert into union_share_orders (id, order_code,settlement_code, promote_uid,
status, last_order_amount, order_time,
is_new, amount, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{settlementCode,jdbcType=VARCHAR}, #{promoteUid,jdbcType=INTEGER},
#{status,jdbcType=VARCHAR}, #{lastOrderAmount,jdbcType=DECIMAL}, #{orderTime,jdbcType=INTEGER},
#{isNew,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
insert into union_share_orders
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="settlementCode != null" >
settlement_code,
</if>
<if test="promoteUid != null" >
promote_uid,
</if>
<if test="status != null" >
status,
</if>
<if test="lastOrderAmount != null" >
last_order_amount,
</if>
<if test="orderTime != null" >
order_time,
</if>
<if test="isNew != null" >
is_new,
</if>
<if test="amount != null" >
amount,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=VARCHAR},
</if>
<if test="settlementCode != null" >
#{settlementCode,jdbcType=VARCHAR},
</if>
<if test="promoteUid != null" >
#{promoteUid,jdbcType=INTEGER},
</if>
<if test="status != null" >
#{status,jdbcType=VARCHAR},
</if>
<if test="lastOrderAmount != null" >
#{lastOrderAmount,jdbcType=DECIMAL},
</if>
<if test="orderTime != null" >
#{orderTime,jdbcType=INTEGER},
</if>
<if test="isNew != null" >
#{isNew,jdbcType=TINYINT},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
update union_share_orders
<set >
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=VARCHAR},
</if>
<if test="settlementCode != null" >
settlement_code = #{settlementCode,jdbcType=VARCHAR},
</if>
<if test="promoteUid != null" >
promote_uid = #{promoteUid,jdbcType=INTEGER},
</if>
<if test="status != null" >
status = #{status,jdbcType=VARCHAR},
</if>
<if test="lastOrderAmount != null" >
last_order_amount = #{lastOrderAmount,jdbcType=DECIMAL},
</if>
<if test="orderTime != null" >
order_time = #{orderTime,jdbcType=INTEGER},
</if>
<if test="isNew != null" >
is_new = #{isNew,jdbcType=TINYINT},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCountByUids" resultType="int">
select count(*) from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
and promote_uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time > #{beginTime}
</if>
<if test="endTime != 0" >
and create_time <#{endTime}
</if>
</select>
<select id="selectAllListByUids" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
and promote_uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time > #{beginTime}
</if>
<if test="endTime != 0" >
and create_time <#{endTime}
</if>
order BY create_time desc
</select>
<select id="selectListByUids" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
and promote_uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time > #{beginTime}
</if>
<if test="endTime != 0" >
and create_time <#{endTime}
</if>
order BY create_time desc
limit #{startIndex},#{pageSize}
</select>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
update union_share_orders
set order_code = #{orderCode,jdbcType=VARCHAR},
settlement_code = #{settlementCode,jdbcType=VARCHAR},
promote_uid = #{promoteUid,jdbcType=INTEGER},
status = #{status,jdbcType=VARCHAR},
last_order_amount = #{lastOrderAmount,jdbcType=DECIMAL},
order_time = #{orderTime,jdbcType=INTEGER},
is_new = #{isNew,jdbcType=TINYINT},
amount = #{amount,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusById" >
update union_share_orders
set status = #{newStatus,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
</update>
<update id="updateStatusByUid" >
update union_share_orders
set status = #{newStatus,jdbcType=VARCHAR},
<if test="settlementCode != null">
settlement_code = #{settlementCode,jdbcType=VARCHAR},
</if>
update_time = #{updateTime,jdbcType=INTEGER}
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
</update>
<update id="updateStatusByCode" >
update union_share_orders
set status = #{newStatus,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=INTEGER}
where settlement_code = #{settlementCode,jdbcType=VARCHAR} and status = #{oldStatus,jdbcType=VARCHAR}
</update>
<select id="selectRecentlyOrderLimitTen" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{uid,jdbcType=INTEGER}
order by order_time desc
limit 0,10
</select>
<select id="selectOrderList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{params.uid,jdbcType=INTEGER}
<if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
AND status != 100
</if>
<if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 1">
AND status = 10
</if>
<if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 2">
AND status = 20
</if>
<if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 3">
AND status IN (30,40)
</if>
<if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 0">
AND status IN (10,20,30,40)
</if>
<if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 1">
AND status = 10
</if>
<if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 2">
AND status = 20
</if>
<if test="params.tab1 != null and params.tab1 == 2 and params.tab2 == 3">
AND status IN (30,40)
</if>
<if test="params.tab1 != null and params.tab1 == 3">
AND status IN (91,92,93)
</if>
order by order_time desc
limit #{params.start,jdbcType=INTEGER}, #{params.size,jdbcType=INTEGER}
</select>
</mapper>