StoragePriceMapper.xml
18.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<?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.ufo.dal.StoragePriceMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.StoragePrice">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="skup" jdbcType="INTEGER" property="skup"/>
<result column="product_id" jdbcType="INTEGER" property="productId"/>
<result column="goods_id" jdbcType="INTEGER" property="goodsId"/>
<result column="storage_id" jdbcType="INTEGER" property="storageId"/>
<result column="depot_num" jdbcType="INTEGER" property="depotNum"/>
<result column="seller_uid" jdbcType="INTEGER" property="sellerUid"/>
<result column="price" jdbcType="DECIMAL" property="price"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="update_time" jdbcType="INTEGER" property="updateTime"/>
<result column="create_time" jdbcType="INTEGER" property="createTime"/>
<result column="pre_sale_flag" jdbcType="INTEGER" property="preSaleFlag"/>
<result column="region" jdbcType="INTEGER" property="region"/>
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from storage_price
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.ufo.dal.model.StoragePrice">
insert into storage_price (id, skup, product_id,
goods_id, storage_id, depot_num,
seller_uid, price, status,
update_time, create_time)
values (#{id,jdbcType=INTEGER}, #{skup,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER},
#{goodsId,jdbcType=INTEGER}, #{storageId,jdbcType=INTEGER}, #{depotNum,jdbcType=INTEGER},
#{sellerUid,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER})
</insert>
<update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.StoragePrice">
update storage_price
set skup = #{skup,jdbcType=INTEGER},
product_id = #{productId,jdbcType=INTEGER},
goods_id = #{goodsId,jdbcType=INTEGER},
storage_id = #{storageId,jdbcType=INTEGER},
depot_num = #{depotNum,jdbcType=INTEGER},
seller_uid = #{sellerUid,jdbcType=INTEGER},
price = #{price,jdbcType=DECIMAL},
status = #{status,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price,
status, update_time, create_time
from storage_price
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price,
status, update_time, create_time
from storage_price
</select>
<select id="selectMinPriceByProductIdList" resultMap="BaseResultMap">
select product_id, min(price) as price
from storage_price where product_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1 group by product_id
</select>
<select id="selectByGoodsIdList" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price,
status, update_time, create_time
from storage_price where goods_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectPage" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price,
status, update_time, create_time
from storage_price where storage_id = #{storageId}
<include refid="skupPageCondition"/>
order by id desc limit #{start},#{rows}
</select>
<select id="selectCount" resultType="java.lang.Integer">
select count(*)
from storage_price where storage_id = #{storageId}
<include refid="skupPageCondition"/>
</select>
<select id="selectFirstUidByProductIdAndUidList" resultType="java.lang.Integer">
select seller_uid
from storage_price where product_id = #{productId} and status=1
<if test="uidList != null">
and seller_uid in
<foreach item="item" index="index" collection="uidList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
limit 1
</select>
<sql id="skupPageCondition">
<if test="sellerUid != null and sellerUid > 0">
and seller_uid = #{sellerUid}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="skup != null and skup > 0">
and skup = #{skup}
</if>
</sql>
<update id="cancelSaleSkup" parameterType="java.lang.Integer">
update storage_price set status = 200,
update_time = unix_timestamp()
where skup = #{skup,jdbcType=INTEGER} and status = 1
</update>
<select id="selectBySkup" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
update_time, create_time
from storage_price
where skup = #{skup,jdbcType=INTEGER}
</select>
<select id="selectStoragePriceCount" resultType="java.lang.Integer">
select count(*) from storage_price sp, storage s where sp.storage_id = s.id
<include refid="skupPageCondition2"/>
</select>
<select id="selectStoragePriceList" resultMap="BaseResultMap">
select sp.id, sp.skup, sp.product_id, s.goods_id, sp.storage_id, sp.depot_num, sp.seller_uid, sp.price, sp.status,
sp.update_time, sp.create_time, sp.pre_sale_flag, region
from storage_price sp, storage s where sp.storage_id = s.id
<include refid="skupPageCondition2"/>
order by sp.id desc limit #{start},#{rows}
</select>
<sql id="skupPageCondition2">
<if test="storagePrice.status != null and storagePrice.status > -1">
and sp.status = #{storagePrice.status}
</if>
<if test="storagePrice.storageId != null and storagePrice.storageId > 0">
and sp.storage_id = #{storagePrice.storageId}
</if>
<if test="storagePrice.sellerUid != null and storagePrice.sellerUid > 0">
and sp.seller_uid = #{storagePrice.sellerUid}
</if>
<if test="storagePrice.productId != null and storagePrice.productId > 0">
and sp.product_id = #{storagePrice.productId}
</if>
<if test="storagePrice.skup != null and storagePrice.skup > 0">
and sp.skup = #{storagePrice.skup}
</if>
<if test="storagePrice.sizeId != null and storagePrice.sizeId > 0">
and s.size_id = #{storagePrice.sizeId}
</if>
<if test="storagePrice.preSaleFlag != null">
and sp.pre_sale_flag = #{storagePrice.preSaleFlag}
</if>
<if test="storagePrice.region != null">
and sp.region = #{storagePrice.region}
</if>
</sql>
<select id="selectByProductIds" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
update_time, create_time, pre_sale_flag, region
from storage_price
where product_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach> and status = 1
limit 10000 <!-- 防止太多的数据,导致内存扛不住 -->
</select>
<select id="selectProductIdsBySkupInfo" resultType="java.lang.Integer">
select DISTINCT product_id from storage_price where 1 = 1
<if test="storagePrice.sellerUid != null and storagePrice.sellerUid > 0">
and seller_uid = #{storagePrice.sellerUid}
</if>
<if test="storagePrice.storageId != null and storagePrice.storageId > 0">
and storage_id = #{storagePrice.storageId}
</if>
<if test="storagePrice.skup != null and storagePrice.skup > 0">
and skup = #{storagePrice.skup}
</if>
order by create_time desc limit 300
</select>
<select id="selectMinPriceByStorageIdList" resultMap="BaseResultMap">
select storage_id, min(price) as price
from storage_price where storage_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1 group by storage_id
</select>
<select id="selectByProductIdsAndSellerUid" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status,
update_time, create_time
from storage_price
where status = #{status,jdbcType=INTEGER}
and product_id in
<foreach item="productItem" index="index" collection="productList" open="(" separator="," close=")">
#{productItem}
</foreach>
and seller_uid in
<foreach item="sellerItem" index="index" collection="sellerList" open="(" separator="," close=")">
#{sellerItem}
</foreach>
</select>
<select id="selectProductIdsBySkupInfoPlus" resultType="java.lang.Integer">
select DISTINCT product_id from storage_price where 1 = 1
<if test="storagePrice.storageId != null and storagePrice.storageId > 0">
and storage_id = #{storagePrice.storageId}
</if>
<if test="storagePrice.skup != null and storagePrice.skup > 0">
and skup = #{storagePrice.skup}
</if>
and seller_uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
order by create_time desc limit 300
</select>
<select id="selectStoragePriceCountBySellerUid" resultType="java.lang.Integer">
select count(*) from storage_price sp, storage s where sp.storage_id = s.id
<if test="storagePrice.status != null and storagePrice.status > -1">
and sp.status = #{storagePrice.status}
</if>
<if test="storagePrice.storageId != null and storagePrice.storageId > 0">
and sp.storage_id = #{storagePrice.storageId}
</if>
<if test="storagePrice.productId != null and storagePrice.productId > 0">
and sp.product_id = #{storagePrice.productId}
</if>
<if test="storagePrice.skup != null and storagePrice.skup > 0">
and sp.skup = #{storagePrice.skup}
</if>
<if test="storagePrice.sizeId != null and storagePrice.sizeId > 0">
and s.size_id = #{storagePrice.sizeId}
</if>
and sp.seller_uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectStoragePriceListBySellerUid" resultMap="BaseResultMap">
select sp.id, sp.skup, sp.product_id, s.goods_id, sp.storage_id, sp.depot_num, sp.seller_uid, sp.price, sp.status,
sp.update_time, sp.create_time
from storage_price sp, storage s where sp.storage_id = s.id
<if test="storagePrice.status != null and storagePrice.status > -1">
and sp.status = #{storagePrice.status}
</if>
<if test="storagePrice.storageId != null and storagePrice.storageId > 0">
and sp.storage_id = #{storagePrice.storageId}
</if>
<if test="storagePrice.productId != null and storagePrice.productId > 0">
and sp.product_id = #{storagePrice.productId}
</if>
<if test="storagePrice.skup != null and storagePrice.skup > 0">
and sp.skup = #{storagePrice.skup}
</if>
<if test="storagePrice.sizeId != null and storagePrice.sizeId > 0">
and s.size_id = #{storagePrice.sizeId}
</if>
and sp.seller_uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
order by sp.id desc limit #{start},#{rows}
</select>
<resultMap id="HiddenSkupMap" type="com.yoho.ufo.dal.model.HiddenSkup">
<result column="seller_uid" jdbcType="INTEGER" property="sellerUid"/>
<result column="skup_num" jdbcType="INTEGER" property="skupNum"/>
</resultMap>
<select id="selectHiddenSkup" resultMap="HiddenSkupMap">
select t2.seller_uid as seller_uid, count(t2.skup) as skup_num from storage t1, storage_price t2
where t1.id=t2.storage_id and t2.status=1 and t2.pre_sale_flag=0
and t1.suggest_high_price is not null and t2.price > t1.suggest_high_price
group by t2.seller_uid
having skup_num >0;
</select>
<select id="selectExportInfoCount" resultType="java.lang.Integer">
select
count(1)
from
ufo_product.storage_price a,
ufo_product.storage b,
ufo_product.product c,
ufo_product.goods d,
ufo_product.size e
where
a.status = #{status}
and a.storage_id = b.id
and a.product_id = c.id
and b.goods_id = d.id
and b.size_id = e.id
and a.seller_uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectExportInfoList" resultType="com.yoho.ufo.dal.model.ExportStoragePrice">
select
a.product_id,
c.product_name,
c.product_code,
a.skup,
a.storage_id,
d.color_name,
e.size_name,
a.price
from
ufo_product.storage_price a,
ufo_product.storage b,
ufo_product.product c,
ufo_product.goods d,
ufo_product.size e
where
a.status = #{status}
and a.storage_id = b.id
and a.product_id = c.id
and b.goods_id = d.id
and b.size_id = e.id
and a.seller_uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
order by a.product_id, e.size_name, a.skup
limit #{limit}
</select>
<select id="selectAllSkuBySeller" resultType="java.lang.Integer">
select distinct(storage_id) from storage_price
where status = #{status}
and seller_uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectExportInfoPlusList" resultType="com.yoho.ufo.dal.model.ExportStoragePriceInner">
select
min(price) as skuMinimumPrice,
count(skup) as skuRepertoryCount,
storage_id as storageId
from ufo_product.storage_price
where
status = #{status}
and pre_sale_flag = 0
and storage_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
group by storage_id
</select>
<select id="selectBySkupList" resultMap="BaseResultMap">
select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status, pre_sale_flag
from storage_price
where skup in
<foreach item="skup" collection="skupList" open="(" separator="," close=")">
#{skup}
</foreach>
</select>
<select id="selectSecondCntByStatus" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SecondhandReq">
select count(1)
from storage_price a
<if test="secondhandReq.sizeId != null">
LEFT JOIN storage b
ON( b.id=a.storage_id)
</if>
where a.pre_sale_flag in (5,6) and a.status in (10,11,1)
<include refid="Query_Second_Sql" />
</select>
<sql id="Query_Second_Sql" >
<if test="secondhandReq.status != null">
and a.status = #{secondhandReq.status}
</if>
<if test="secondhandReq.skup != null">
and a.skup = #{secondhandReq.skup}
</if>
<if test="secondhandReq.skupType != null and secondhandReq.skupType != -1">
and a.pre_sale_flag = #{secondhandReq.skupType}
</if>
<if test="secondhandReq.sellerUid != null">
and a.seller_uid = #{secondhandReq.sellerUid}
</if>
<if test="secondhandReq.sku != null">
and a.storage_id = #{secondhandReq.sku}
</if>
<if test="secondhandReq.sizeId != null">
and b.size_id=#{secondhandReq.sizeId}
</if>
<if test="secondhandReq.productIdList != null and secondhandReq.productIdList.size()>0">
and a.product_id in
<foreach item="productId" collection="secondhandReq.productIdList" open="(" separator="," close=")">
#{productId}
</foreach>
</if>
</sql>
<select id="selectSecondTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SecondhandReq">
select count(1)
from storage_price a
<if test="secondhandReq.sizeId != null">
LEFT JOIN storage b
ON( b.id=a.storage_id)
</if>
where a.pre_sale_flag in (5,6) and a.status in (10,11,1)
<include refid="Query_Second_Sql" />
</select>
<select id="selectSecondByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SecondhandReq">
select a.skup, a.product_id, a.goods_id, a.storage_id, a.depot_num, a.seller_uid, a.price,
a.status, a.update_time, a.create_time, a.pre_sale_flag
from storage_price a
<if test="secondhandReq.sizeId != null">
LEFT JOIN storage b
ON( b.id=a.storage_id)
</if>
where a.pre_sale_flag in (5,6) and a.status in (10,11,1)
<include refid="Query_Second_Sql" />
order by a.skup desc
<if test="secondhandReq.start!=null and secondhandReq.size != null">
limit #{secondhandReq.start},#{secondhandReq.size}
</if>
</select>
<update id="updateSecondhandStatusBySkup">
update storage_price set status=#{status}, update_time=unix_timestamp() where skup=#{skup} and status=10
</update>
<select id="selectProductStorageCount" resultType="com.yoho.ufo.dal.model.Storage">
select product_id as productId, count(*) as storageNum from storage_price where
product_id in
<foreach item="productId" collection="productIdList" open="(" separator="," close=")">
#{productId}
</foreach>
and status=1 and pre_sale_flag=0 and region=0 group by product_id
</select>
</mapper>