ProductPop.xml
28.7 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
<?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.dili.titan.dao.ProductPopDao">
<resultMap type="productPop" id="productPop">
<result property="pid" javaType="Long" column="pid"/>
<result property="name" javaType="String" column="name"/>
<result property="quotationType" javaType="Integer" column="quotation_type"/>
<result property="cateId" javaType="Integer" column="cate_id"/>
<result property="userDefined" javaType="Integer" column="user_defined"/>
<result property="cate" javaType="String" column="cate"/>
<result property="status" javaType="Integer" column="status"/>
<result property="hasSpecial" javaType="Integer" column="has_special"/>
<result property="publishSettime" javaType="Date" column="publish_settime"/>
<result property="publishTime" javaType="Date" column="publish_time"/>
<result property="publishMode" javaType="Integer" column="publish_mode"/>
<result property="prepareTime" javaType="Long" column="prepare_time"/>
<result property="dropsTime" javaType="Date" column="drops_time"/>
<result property="ctime" javaType="Date" column="ctime"/>
<result property="utime" javaType="Date" column="utime"/>
<result property="desc" javaType="String" column="desc"/>
<result property="minPrice" javaType="Integer" column="minPrice"/>
<result property="maxPrice" javaType="Integer" column="maxPrice"/>
<result property="producingArea" javaType="Long" column="producing_area"/>
<result property="localityArea" javaType="Long" column="locality_area"/>
<result property="sellerName" javaType="String" column="seller_name"/>
<result property="manualAuditType" javaType="Integer" column="manual_audit_type"/>
<result property="seller" javaType="Long" column="seller"/>
<result property="shop" javaType="Long" column="shop"/>
<result property="shopName" javaType="String" column="shop_name"/>
<result property="marketId" javaType="Long" column="market_id"/>
<result property="marketName" javaType="String" column="market_name"/>
<result property="indate" javaType="Integer" column="indate"/>
<result property="defaultPic" javaType="String" column="img_url"/>
<result property="foreignPid" javaType="String" column="foreign_pid"/>
<result property="storeUnit" javaType="Integer" column="store_unit"/>
<collection property="subCateList" javaType="ArrayList" ofType="category">
<result property="id" column="id" javaType="Integer"/>
</collection>
</resultMap>
<!-- 全部条件(更多功能可以通过queryData扩展实现) 为防止column名重复,查询时将product_pop表取别名为a-->
<sql id="QUERY_WHERE_CLAUSE">
<where>
<if test="pid != null and pid != ''"><![CDATA[AND pid = #{pid}]]></if>
<if test="manualAuditType != null and manualAuditType != ''"><![CDATA[AND manual_audit_type = #{manualAuditType}]]></if>
<if test="name != null and name != ''"><![CDATA[AND a.name = #{name}]]></if>
<if test="cateId != null and cateId != ''"><![CDATA[AND cate_id = #{cateId}]]></if>
<if test="userDefined != null and userDefined != ''"><![CDATA[AND user_defined = #{userDefined}]]></if>
<if test="producingArea != null and producingArea != ''"><![CDATA[AND producing_area = #{producingArea}]]></if>
<if test="seller != null and seller != ''"><![CDATA[AND seller = #{seller}]]></if>
<if test="sellerName != null and sellerName != ''"><![CDATA[AND seller_name = #{sellerName}]]></if>
<if test="shop != null and shop != ''"><![CDATA[AND shop = #{shop}]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND market_id = #{marketId}]]></if>
<if test="publishMode != null and publishMode != ''"><![CDATA[AND publish_mode = #{publishMode}]]></if>
<if test="publishTime != null and publishTime != ''"><![CDATA[AND publish_time = #{publishTime}]]></if>
<if test="status != null and status != '' and status < 4"><![CDATA[AND a.status = #{status}]]></if>
<if test="userDefined !=null and userDefined !='' "><![CDATA[AND user_defined = #{userDefined}]]></if>
<if test="status != null and status != '' and status>=4"><![CDATA[AND a.status >3]]></if>
<if test="startTime != null and endTime == null "><![CDATA[AND ctime > #{startTime}]]></if>
<if test="startTime == null and endTime != null "><![CDATA[AND ctime < DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
<if test="startTime != null and endTime != null and startTime != '' and endTime!= '' "><![CDATA[AND ctime between #{startTime} and DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
<if test="utime != null and utime != ''"><![CDATA[AND utime = #{utime}]]></if>
<![CDATA[AND a.status > 0]]>
</where>
</sql>
<!-- 智能排序与分页 -->
<sql id="QUERY_ORDER_LIMIT_CONDTION">
<if test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY ${orderField} ${orderFieldType}]]></if>
<if test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
</sql>
<sql id="UPDATE_COLUMN_SET">
<set>
<if test="manualAuditType != null and manualAuditType != ''"><![CDATA[ manual_audit_type = #{manualAuditType},]]></if>
<if test="name != null and name != ''"><![CDATA[ name = #{name},]]></if>
<if test="cateId != null and cateId != ''"><![CDATA[cate_id = #{cateId},]]></if>
<if test="producingArea != null and producingArea != ''"><![CDATA[ producing_area = #{producingArea},]]></if>
<if test="seller != null and seller != ''"><![CDATA[ seller = #{seller},]]></if>
<if test="shop != null and shop != ''"><![CDATA[ shop = #{shop},]]></if>
<if test="localityArea != null and localityArea != ''"><![CDATA[ locality_area = #{localityArea},]]></if>
<if test="publishMode != null and publishMode != '' and publishMode > 0 "><![CDATA[ publish_mode = #{publishMode},]]></if>
<if test="publishTime != null and publishTime != ''"><![CDATA[ publish_time = #{publishTime},]]></if>
<if test="publishSettime != null and publishSettime != ''"><![CDATA[ publish_settime = #{publishSettime},]]></if>
<if test="prepareTime != null and prepareTime != ''"><![CDATA[ prepare_time = #{prepareTime},]]></if>
<if test="dropsTime != null and dropsTime != ''"><![CDATA[ drops_time = #{dropsTime},]]></if>
<if test="status != null and status != ''"><![CDATA[`status` = #{status},]]></if>
<if test="foreignPid != null and foreignPid != ''"><![CDATA[ foreign_pid = #{foreignPid},]]></if>
<if test="ctime != null and ctime != ''"><![CDATA[ ctime = #{ctime},]]></if>
<![CDATA[ utime = now()]]>
</set>
</sql>
<!-- 插入product_pop记录 -->
<insert id="insertEntry" parameterType="productPop">
<![CDATA[
INSERT INTO product_pop (pid,name,has_special,quotation_type,cate_id,producing_area,seller,seller_name,shop,shop_name,market_id,market_name,indate,publish_mode,publish_settime,status,ctime,prepare_time,foreign_pid,store_unit,manual_audit_type)
VALUES (#{pid},#{name},#{hasSpecial},#{quotationType},#{cateId},#{producingArea},#{seller},#{sellerName},#{shop},#{shopName},#{marketId},#{marketName},#{indate},#{publishMode},#{publishSettime},#{status},now(),#{prepareTime},#{foreignPid},#{storeUnit},#{manualAuditType})
]]>
</insert>
<!-- 删除,通过条件 -->
<update id="deleteByCondtion" parameterType="productPop">
<![CDATA[DELETE FROM product_pop a]]>
<include refid="QUERY_WHERE_CLAUSE" />
</update>
<!-- 修改记录通过主键 -->
<update id="updateByKey" parameterType="productPop">
<![CDATA[UPDATE product_pop]]>
<include refid="UPDATE_COLUMN_SET"/>
<![CDATA[WHERE pid = #{pid}]]>
</update>
<select id="searchEntryList" parameterType="com.dili.titan.domain.ProductPopQuery" resultMap="productPop">
<if test="minPrice != null or maxPrice != null">
<![CDATA[
SELECT t.pid,t.name,t.quotation_type,t.cate_id,t.user_defined,t.seller,t.seller_name,t.shop,t.shop_name,t.market_id,t.market_name,
t.producing_area,t.country_area,t.foreign_city_name,t.locality_area,t.shop_city_id,t.shop_type,
t.indate,t.publish_mode,t.publish_settime,t.publish_time,t.drops_time,t.status,t.prepare_time,
t.desc,t.ctime,t.utime,t.store_unit,t.manual_audit_type,t.has_special
FROM product_pop t RIGHT JOIN (select pid from product_pop_sku
]]>
<where>
<if test="minPrice != null and maxPrice == null"><![CDATA[AND price>=#{minPrice} ]]> </if>
<if test="minPrice == null and maxPrice != null"><![CDATA[AND price<=#{maxPrice} ]]> </if>
<if test="minPrice != null and maxPrice != null "><![CDATA[AND (price>=#{minPrice} and price<=#{maxPrice})]]></if>
<![CDATA[AND status=3 ]]>
</where>
<![CDATA[ GROUP BY pid union select pid from product_pop_price_range]]>
<where>
<if test="minPrice != null and maxPrice == null"><![CDATA[AND price>=#{minPrice} ]]> </if>
<if test="minPrice == null and maxPrice != null"><![CDATA[AND price<=#{maxPrice} ]]> </if>
<if test="minPrice != null and maxPrice != null "><![CDATA[AND (price>=#{minPrice} and price<=#{maxPrice})]]></if>
<![CDATA[AND status=1 ]]>
</where>
<![CDATA[ GROUP BY pid) s ON t.pid = s.pid]]>
</if>
<if test="minPrice == null and maxPrice == null">
<![CDATA[
SELECT t.pid,t.name,t.quotation_type,t.cate_id,t.user_defined,t.seller,t.seller_name,t.shop,t.shop_name,t.market_id,t.market_name,
t.producing_area,t.country_area,t.foreign_city_name,t.locality_area,t.shop_city_id,t.shop_type,
t.indate,t.publish_mode,t.publish_settime,t.publish_time,t.drops_time,t.status,t.prepare_time,
t.desc,t.ctime,t.utime,t.store_unit,t.manual_audit_type,t.has_special
FROM product_pop t
]]>
</if>
<where>
<if test="pid != null and pid != ''"><![CDATA[AND t.pid = #{pid}]]></if>
<if test="name != null and name != ''"><![CDATA[AND t.name like CONCAT('%',#{name},'%')]]></if>
<if test="sellerName != null and sellerName != ''"><![CDATA[AND t.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
<if test="shopName != null and shopName != ''"><![CDATA[AND t.shop_name like CONCAT('%',#{shopName},'%')]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND t.market_id = #{marketId} ]]></if>
<if test="status != null and status != '' and status == -1"><![CDATA[AND t.status >0 ]]></if>
<if test="status != null and status != '' and status>0 and status<3"><![CDATA[AND t.status =#{status} ]]></if>
<if test="status != null and status != '' and status>=3"><![CDATA[AND t.status >= 3 AND t.status <= 7]]></if>
<if test="manualAuditType != null and manualAuditType != ''"><![CDATA[AND t.manual_audit_type = #{manualAuditType}]]></if>
<if test="startTime != null and endTime == null "><![CDATA[AND t.ctime > #{startTime}]]></if>
<if test="startTime == null and endTime != null "><![CDATA[AND t.ctime < #{endTime}]]></if>
<if test="startTime != null and endTime != null and startTime != '' and endTime!= '' "><![CDATA[AND t.ctime between #{startTime} and #{endTime}]]></if>
<if test="cateList != null and cateList != ''"><![CDATA[AND t.cate_id IN]]>
<foreach collection="cateList" item="cate" open="(" separator="," close=")">
<![CDATA[#{cate}]]>
</foreach>
</if>
<if test="shopCityIds != null and shopCityIds != ''"><![CDATA[AND t.shop_city_id IN]]>
<foreach collection="shopCityIds" item="cityid" open="(" separator="," close=")">
<![CDATA[#{cityid}]]>
</foreach>
</if>
<if test="shopTypes != null and shopTypes != ''"><![CDATA[AND t.shop_type IN]]>
<foreach collection="shopTypes" item="shopType" open="(" separator="," close=")">
<![CDATA[#{shopType}]]>
</foreach>
</if>
</where>
ORDER BY t.pid desc
<if test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
</select>
<select id="searchEntryListCount" parameterType="com.dili.titan.domain.ProductPopQuery" resultType="int">
<if test="minPrice != null or maxPrice != null">
<![CDATA[
SELECT count(t.pid)
FROM product_pop t RIGHT JOIN (select pid from product_pop_sku
]]>
<where>
<if test="minPrice != null and maxPrice == null"><![CDATA[AND price>=#{minPrice} ]]> </if>
<if test="minPrice == null and maxPrice != null"><![CDATA[AND price<=#{maxPrice} ]]> </if>
<if test="minPrice != null and maxPrice != null "><![CDATA[AND (price>=#{minPrice} and price<=#{maxPrice})]]></if>
<![CDATA[AND status=3 ]]>
</where>
<![CDATA[ GROUP BY pid union select pid from product_pop_price_range]]>
<where>
<if test="minPrice != null and maxPrice == null"><![CDATA[AND price>=#{minPrice} ]]> </if>
<if test="minPrice == null and maxPrice != null"><![CDATA[AND price<=#{maxPrice} ]]> </if>
<if test="minPrice != null and maxPrice != null "><![CDATA[AND (price>=#{minPrice} and price<=#{maxPrice})]]></if>
<![CDATA[AND status=1 ]]>
</where>
<![CDATA[ GROUP BY pid) s ON t.pid = s.pid]]>
</if>
<if test="minPrice == null and maxPrice == null">
<![CDATA[SELECT count(t.pid) FROM product_pop t]]>
</if>
<where>
<if test="pid != null and pid != ''"><![CDATA[AND t.pid = #{pid}]]></if>
<if test="name != null and name != ''"><![CDATA[AND t.name like CONCAT('%',#{name},'%')]]></if>
<if test="sellerName != null and sellerName != ''"><![CDATA[AND t.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
<if test="shopName != null and shopName != ''"><![CDATA[AND t.shop_name like CONCAT('%',#{shopName},'%')]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND t.market_id = #{marketId} ]]></if>
<if test="status != null and status != '' and status == -1"><![CDATA[AND t.status >0 ]]></if>
<if test="status != null and status != '' and status>0 and status<4"><![CDATA[AND t.status =#{status} ]]></if>
<if test="status != null and status != '' and status>=4"><![CDATA[AND t.status >= 4 AND t.status <= 7]]></if>
<if test="manualAuditType != null and manualAuditType != ''"><![CDATA[AND t.manual_audit_type = #{manualAuditType}]]></if>
<if test="startTime != null and endTime == null "><![CDATA[AND t.ctime > #{startTime}]]></if>
<if test="startTime == null and endTime != null "><![CDATA[AND t.ctime < #{endTime}]]></if>
<if test="startTime != null and endTime != null and startTime != '' and endTime!= '' "><![CDATA[AND t.ctime between #{startTime} and #{endTime}]]></if>
<if test="cateList != null and cateList != ''"><![CDATA[AND t.cate_id IN]]>
<foreach collection="cateList" item="cate" open="(" separator="," close=")">
<![CDATA[#{cate}]]>
</foreach>
</if>
<if test="shopCityIds != null and shopCityIds != ''"><![CDATA[AND t.shop_city_id IN]]>
<foreach collection="shopCityIds" item="cityid" open="(" separator="," close=")">
<![CDATA[#{cityid}]]>
</foreach>
</if>
<if test="shopTypes != null and shopTypes != ''"><![CDATA[AND t.shop_type IN]]>
<foreach collection="shopTypes" item="shopType" open="(" separator="," close=")">
<![CDATA[#{shopType}]]>
</foreach>
</if>
</where>
</select>
<!-- 查询,通过主键IN(array) -->
<select id="selectEntryArray" parameterType="java.lang.reflect.Array" resultType="productPop">
<![CDATA[SELECT a.hasSpecial,a.pid,a.name,a.cateId,a.producingArea,a.seller,a.sellerName,a.shop,a.shopCityId,a.shopType,a.shopName,a.indate,a.dropsTime,a.publishMode,a.publishTime,a.publishSettime,a.status,a.desc,a.ctime,a.utime,b.name as cate,a.storeUnit from ]]>
<![CDATA[(SELECT `has_special` AS hasSpecial,`pid`,`name`,`cate_id` AS cateId,`producing_area` AS producingArea,`seller`,`seller_name` AS sellerName,`shop`,`shop_city_id` AS shopCityId,`shop_type` AS shopType,`shop_name` AS shopName,`indate`,`drops_time` AS dropsTime,`publish_mode` AS publishMode,`publish_time` AS publishTime, publish_settime as publishSettime,`status`,`desc`,`ctime`,`utime`,store_unit as storeUnit FROM product_pop]]>
<![CDATA[WHERE pid IN]]>
<foreach collection="array" item="pid" open="(" separator="," close=")">
<![CDATA[#{pid}]]>
</foreach>
<![CDATA[) a left join category b on b.id = a.cateId]]>
</select>
<select id="selectEntryList" parameterType="productPop" resultMap="productPop">
<![CDATA[SELECT g.deli_name,g.deli_type,g.deli_id,maxPrice,minPrice,f.pid,market_id,market_name,has_special,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,`status`,f.ctime,f.utime,f.storeUnit FROM ]]>
<![CDATA[(SELECT maxPrice,minPrice,market_id,market_name,has_special,e.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,`status`,e.ctime,e.utime,e.storeUnit FROM]]>
<![CDATA[(SELECT MAX(d.price) as maxPrice,MIN(d.price) as minPrice,market_id,market_name,has_special,c.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,c.status,c.ctime,c.utime,c.storeUnit FROM ]]>
<![CDATA[(SELECT a.market_id,a.market_name,a.has_special,a.pid,a.`name`,a.cate_id ,b.`name` AS cate,publish_settime,indate,shop_name,shop,seller,seller_name,a.producing_area,a.`desc`,a.drops_time ,a.publish_mode,a.publish_time,a.`status`,a.ctime,a.utime,a.store_unit as storeUnit ]]>
<![CDATA[FROM product_pop a LEFT JOIN category b on a.cate_id=b.id ]]>
<where>
<if test="pid != null and pid != ''"><![CDATA[AND a.pid = #{pid}]]></if>
<if test="name != null and name != ''"><![CDATA[AND a.name like CONCAT('%',#{name},'%')]]></if>
<if test="cateId != null and cateId != '' and cateId>0"><![CDATA[AND a.cate_id = #{cateId}]]></if>
<if test="subCateList != null and subCateList != ''"><![CDATA[AND a.cate_id IN]]>
<foreach collection="subCateList" item="cate" open="(" separator="," close=")">
<![CDATA[#{cate.id}]]>
</foreach></if>
<if test="sellerName != null and sellerName != ''"><![CDATA[AND a.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
<if test="status != null and status != '' and status < 4"><![CDATA[AND a.status = #{status}]]></if>
<if test="status != null and status != '' and status>=4"><![CDATA[AND a.status >3]]></if>
<if test="startTime != null and endTime == null "><![CDATA[AND a.ctime > #{startTime}]]></if>
<if test="startTime == null and endTime != null "><![CDATA[AND a.ctime < DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
<if test="startTime != null and endTime != null and startTime != '' and endTime!= '' "><![CDATA[AND a.ctime between #{startTime} and DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
<if test="isExcludeFailure != null and isExcludeFailure == true "><![CDATA[AND a.status > 0]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
</where>
<![CDATA[ )c LEFT JOIN product_pop_sku d ON d.pid=c.pid GROUP BY pid)e ]]>
<if test="minPrice != null and maxPrice == null"><![CDATA[WHERE minPrice>=#{minPrice} ]]> </if>
<if test="minPrice == null and maxPrice != null"><![CDATA[WHERE maxPrice<=#{maxPrice} ]]> </if>
<if test="minPrice != null and maxPrice != null "><![CDATA[WHERE (minPrice>=#{minPrice} and minPrice<=#{maxPrice}) or (maxPrice>=#{minPrice} and maxPrice<=#{maxPrice})]]> </if>
<include refid="QUERY_ORDER_LIMIT_CONDTION" />
<![CDATA[)f order by f.ctime desc,f.pid desc]]>
</select>
<!-- 总数查询,通过条件 -->
<select id="selectEntryListCount" parameterType="productPop" resultType="int">
<![CDATA[SELECT COUNT(pid) AS dataCount FROM]]>
<![CDATA[(SELECT maxPrice,minPrice,e.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,`status`,e.ctime,e.utime,e.storeUnit FROM]]>
<![CDATA[(SELECT MAX(d.price) as maxPrice,MIN(d.price) as minPrice,c.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,c.status,c.ctime,c.utime,c.storeUnit FROM ]]>
<![CDATA[(SELECT a.pid,a.`name`,a.cate_id ,b.`name` AS cate,publish_settime,indate,shop_name,shop,seller,seller_name,a.producing_area,a.`desc`,a.drops_time ,a.publish_mode,a.publish_time,a.`status`,a.ctime,a.utime,a.store_unit as storeUnit ]]>
<![CDATA[FROM product_pop a LEFT JOIN category b on a.cate_id=b.id ]]>
<where>
<if test="pid != null and pid != ''"><![CDATA[AND a.pid = #{pid}]]></if>
<if test="cateId != null and cateId != '' and cateId>0"><![CDATA[AND a.cate_id = #{cateId}]]></if>
<if test="name != null and name != ''"><![CDATA[AND a.name like CONCAT('%',#{name},'%')]]></if>
<if test="subCateList != null and subCateList != ''"><![CDATA[AND a.cate_id IN]]>
<foreach collection="subCateList" item="cate" open="(" separator="," close=")">
<![CDATA[#{cate.id}]]>
</foreach></if>
<if test="sellerName != null and sellerName != ''"><![CDATA[AND a.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
<if test="status != null and status != '' and status < 4"><![CDATA[AND a.status = #{status}]]></if>
<if test="userDefined !=null and userDefined !='' "><![CDATA[AND a.user_defined = #{userDefined}]]></if>
<if test="status != null and status != '' and status>=4"><![CDATA[AND a.status >3]]></if>
<if test="startTime != null and endTime == null "><![CDATA[AND a.ctime > #{startTime}]]></if>
<if test="startTime == null and endTime != null "><![CDATA[AND a.ctime < DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
<if test="startTime != null and endTime != null and startTime != '' and endTime!= '' "><![CDATA[AND a.ctime between #{startTime} and DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
<if test="isExcludeFailure != null and isExcludeFailure == true "><![CDATA[AND a.status > 0]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
</where>
<![CDATA[ )c LEFT JOIN product_pop_sku d ON d.pid=c.pid GROUP BY pid)e ]]>
<if test="minPrice != null and maxPrice == null"><![CDATA[WHERE minPrice>=#{minPrice} ]]> </if>
<if test="minPrice == null and maxPrice != null"><![CDATA[WHERE maxPrice<=#{maxPrice} ]]> </if>
<if test="minPrice != null and maxPrice != null "><![CDATA[WHERE (minPrice>=#{minPrice} and minPrice<=#{maxPrice}) or (maxPrice>=#{minPrice} and maxPrice<=#{maxPrice})]]> </if>
<![CDATA[)f]]>
</select>
<update id="updateByKeyAndStatus" parameterType="java.util.HashMap" >
<![CDATA[UPDATE product_pop]]>
<![CDATA[SET status = #{status},]]>
<if test="dropsTime != null"><![CDATA[drops_time = #{dropsTime},]]></if>
utime=now()
<![CDATA[WHERE status = #{whereStatus} AND pid in ]]>
<foreach collection="list" item="s" open="(" separator="," close=")">
<![CDATA[#{s}]]>
</foreach>
<if test="manualAuditType != null"><![CDATA[AND manual_audit_type = #{manualAuditType}]]></if>
</update>
<select id="selectPopList" parameterType="com.dili.titan.domain.ProductPopQuery" resultMap="productPop">
<![CDATA[select d.market_id,d.pid,d.name,d.quotation_type,d.cate_id,d.user_defined,d.seller,d.seller_name,d.shop,d.shop_name,
d.producing_area,d.country_area,d.foreign_city_name,d.locality_area,d.shop_city_id,d.shop_type,
d.indate,d.publish_mode,d.publish_settime,d.publish_time,d.drops_time,d.status,d.prepare_time,
d.desc,d.ctime,d.utime,d.store_unit,d.manual_audit_type,d.has_special,min(b.price) AS minPrice,MAX(b.price) AS maxPrice from(]]>
<![CDATA[select a.market_id,a.pid,a.name,a.quotation_type,a.cate_id,a.user_defined,a.seller,a.seller_name,a.shop,a.shop_name,
a.producing_area,a.country_area,a.foreign_city_name,a.locality_area,a.shop_city_id,a.shop_type,
a.indate,a.publish_mode,a.publish_settime,a.publish_time,a.drops_time,a.status,a.prepare_time,
a.desc,a.ctime,a.utime,a.store_unit,a.manual_audit_type,a.has_special FROM product_pop a
where a.`status` =3 ]]>
<if test="pids != null and pids != ''"><![CDATA[ AND a.pid not in]]>
<foreach collection="pids" item="item" open="(" separator="," close=")">
<![CDATA[#{item}]]>
</foreach>
</if>
<if test="cateList != null and cateList != ''"><![CDATA[AND a.cate_id IN]]>
<foreach collection="cateList" item="cate" open="(" separator="," close=")">
<![CDATA[#{cate}]]>
</foreach>
</if>
<if test="pid != null and pid != ''"><![CDATA[ AND a.pid = #{pid}]]></if>
<if test="name != null and name != ''"><![CDATA[ AND a.name like CONCAT('%',#{name},'%')]]></if>
<if test="shopName != null and shopName != ''"><![CDATA[ AND a.shop_name like CONCAT('%',#{shopName},'%')]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
<if test="shopCityIds != null and shopCityIds != ''"><![CDATA[AND a.shop_city_id IN]]>
<foreach collection="shopCityIds" item="cityid" open="(" separator="," close=")">
<![CDATA[#{cityid}]]>
</foreach>
</if>
<if test="shopTypes != null and shopTypes != ''"><![CDATA[AND a.shop_type IN]]>
<foreach collection="shopTypes" item="shopType" open="(" separator="," close=")">
<![CDATA[#{shopType}]]>
</foreach>
</if>
<include refid="QUERY_ORDER_LIMIT_CONDTION" />
<![CDATA[ )d LEFT JOIN product_pop_sku b on d.pid = b.pid GROUP BY b.pid ]]>
</select>
<select id="selectPopListCount" parameterType="com.dili.titan.domain.ProductPopQuery" resultType="int">
<![CDATA[ select count(1) FROM product_pop a where a.`status` =3 ]]>
<if test="pids != null and pids != ''"><![CDATA[ AND a.pid not in]]>
<foreach collection="pids" item="item" open="(" separator="," close=")">
<![CDATA[#{item}]]>
</foreach>
</if>
<if test="cateList != null and cateList != ''"><![CDATA[AND a.cate_id IN]]>
<foreach collection="cateList" item="cate" open="(" separator="," close=")">
<![CDATA[#{cate}]]>
</foreach>
</if>
<if test="pid != null and pid != ''"><![CDATA[ AND a.pid = #{pid}]]></if>
<if test="name != null and name != ''"><![CDATA[ AND a.name like CONCAT('%',#{name},'%')]]></if>
<if test="shopName != null and shopName != ''"><![CDATA[ AND a.shop_name like CONCAT('%',#{shopName},'%')]]></if>
<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
<if test="shopCityIds != null and shopCityIds != ''"><![CDATA[AND a.shop_city_id IN]]>
<foreach collection="shopCityIds" item="cityid" open="(" separator="," close=")">
<![CDATA[#{cityid}]]>
</foreach>
</if>
<if test="shopTypes != null and shopTypes != ''"><![CDATA[AND a.shop_type IN]]>
<foreach collection="shopTypes" item="shopType" open="(" separator="," close=")">
<![CDATA[#{shopType}]]>
</foreach>
</if>
</select>
<!--todo 初始化 -->
<select id="findShopId" parameterType="productPop" resultType="long">
<![CDATA[ select shop FROM product_pop group by shop]]>
</select>
<!--todo 初始化 -->
<update id="setShopCityId" parameterType="java.util.Map">
<![CDATA[UPDATE product_pop SET shop_city_id = #{cityId}, shop_type = #{shopType},shop_name= #{shopName}]]>
<![CDATA[ WHERE shop = #{shopId} ]]>
</update>
<!--todo 初始化 -->
<update id="updateMarket" parameterType="java.util.Map">
<![CDATA[UPDATE product_pop SET market_id = #{marketId}, market_name = #{marketName} ]]>
<![CDATA[ WHERE shop = #{shopId} ]]>
</update>
<!--todo 初始化 -->
<select id="findByLocalityId" parameterType="productPop" resultType="productPop">
<![CDATA[SELECT pid,shop from product_pop]]>
<![CDATA[WHERE locality_area=0 OR locality_area IS NULL ]]>
</select>
<!--todo 初始化 -->
<update id="updateLocalityId" parameterType="java.util.Map">
<![CDATA[UPDATE product_pop SET locality_area = #{localityId}]]>
<![CDATA[ WHERE shop = #{shopId} ]]>
</update>
</mapper>