IMCampaignCategoryMapper.xml
16.3 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
<?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.sibu.orderHelper.integral.web.dao.IMWebCampaignCategoryDao">
<select id="get" resultMap="IMCampaignCategoryMap" parameterType="java.util.Map">
SELECT
*
FROM
im_campaign_category
WHERE
im_campaign_category_id=#{campaignCategoryId}
</select>
<select id="list" parameterType="map" resultMap="IMCampaignCategoryMap">
SELECT cam.* FROM im_campaign_category cam
LEFT JOIN campaign_product cap ON cam.`im_campaign_category_id` = cap.campaign_id
LEFT JOIN im_product imp ON cap.product_id = imp.im_product_id
where cam.delete_flag = 1
<if test="campaignKeyword != null and campaignKeyword !=''">
and cam.name like concat('%',#{campaignKeyword},'%')
</if>
<if test="isShow != null and isShow !=''">
and cam.is_show = ${isShow}
</if>
<if test="campaginType != null and campaginType !=''">
and cam.campagin_type = ${campaginType}
</if>
<if test="productKeyword != null and productKeyword !=''">
and imp.name like concat('%',#{productKeyword},'%')
</if>
GROUP BY cam.`name`
order by cam.sort_index
LIMIT ${pageNow}, ${pageSize}
</select>
<select id="totalCountCampagin" resultType="int" parameterType="map">
SELECT COUNT(*) FROM (
SELECT cam.* FROM im_campaign_category cam
LEFT JOIN campaign_product cap ON cam.`im_campaign_category_id` = cap.campaign_id
LEFT JOIN im_product imp ON cap.product_id = imp.im_product_id
where cam.delete_flag = 1
<if test="campaignKeyword != null and campaignKeyword !=''">
and cam.name like concat('%',#{campaignKeyword},'%')
</if>
<if test="isShow != null and isShow !=''">
and cam.is_show = ${isShow}
</if>
<if test="campaginType != null and campaginType !=''">
and cam.campagin_type = ${campaginType}
</if>
<if test="productKeyword != null and productKeyword !=''">
and imp.name like concat('%',#{productKeyword},'%')
</if>
GROUP BY cam.`name`) a
</select>
<select id="listToIndex" resultMap="IMCampaignCategoryMap">
SELECT
*
FROM
im_campaign_category where delete_flag = 1 and is_show = 1 and campagin_type = 0
order by sort_index
</select>
<select id="listCampaignCategoryToAdvert" resultMap="IMCampaignCategoryMap">
SELECT * FROM
im_campaign_category where delete_flag = 1 and is_show = 1
order by sort_index
</select>
<insert id="add" parameterType="IMCampaignCategoryBean" useGeneratedKeys="true" keyProperty="im_campaign_category_id">
insert into im_campaign_category(name,image_url,is_show,sort_index,create_dt,delete_flag, campagin_type)
values(
#{name},
#{imageUrl},
#{isShow},
#{sortIndex},
now(),
1,
#{campaginType}
)
</insert>
<!--添加专场商品-->
<insert id="addCampaginProduct" parameterType="com.sibu.orderHelper.integral.request.CampaginProductAddRequest">
insert into campaign_product (campaign_id, product_id, product_type, is_show)
VALUES (#{campaginId}, #{productId}, #{productType}, #{isShow})
</insert>
<insert id="addCampaginProducts" parameterType="java.util.List">
INSERT INTO campaign_product (
campaign_id, product_id, product_type, is_show
) VALUES
<foreach collection="list" item="campaginProduct" separator=",">
(#{campaginProduct.campaginId}, #{campaginProduct.productId}, #{campaginProduct.productType}, #{campaginProduct.isShow})
</foreach>
</insert>
<!--更新专场-->
<update id="updateCampaginProduct" parameterType="java.util.Map">
update campaign_product set campaign_id = #{campaginId} where product_id = #{productId}
</update>
<!--更新专场商品的上下架状态-->
<update id="updateCampaginProductStatus" parameterType="java.util.Map">
update campaign_product set is_show = #{isShow} where product_id = #{productId}
</update>
<!--删除专场中的商品-->
<delete id="deleteCampaginProduct" parameterType="java.lang.String">
delete from campaign_product where product_id = #{productId}
</delete>
<!--删除专场中的一个商品-->
<delete id="deleteOneProductById" parameterType="com.sibu.orderHelper.integral.request.CampaginDeleteProductRequest">
delete from campaign_product where campaign_id = #{campaginId} AND product_id = #{productId}
</delete>
<!--删除专场级联删除商品-->
<delete id="deleteCampaginProductByCampaginId" parameterType="java.lang.Integer">
DELETE from campaign_product where campaign_id = #{campaginId}
</delete>
<select id="totalCampaginProduct" parameterType="java.util.Map" resultType="int">
select count(*) from campaign_product where campaign_id = #{campaginId} AND product_id = #{productId}
</select>
<select id="checkCampaginProductExist" parameterType="com.sibu.orderHelper.integral.request.CampaginProductAddRequest" resultType="int">
select count(*) from campaign_product where campaign_id = #{campaginId} and product_id = #{productId}
</select>
<select id="pagerProduct" parameterType="map" resultMap="listIMProduct">
SELECT
imp.im_product_id,
imp.name,
imp.short_name,
imp.stock_num,
imp.exchange_integral,
imp.xws_exchange_integral,
imp.sibukg_exchange_integral,
imp.onther1_exchange_integral,
imp.onther2_exchange_integral,
imp.onther3_exchange_integral,
imp.thumb_img,
imp.is_new,
imp.is_hot,
imp.is_reco,
imp.create_date,
imp.limit_exchange_number,
imp.product_type,
imp.member_price,
imp.retail_price,
imp.market_price,
imp.is_show,
imp.is_open_spec,
imp.spec,
imp.mini_purchase_number,
imp.erp_code,
imp.product_campagin,
imp.is_group,
s.id AS supplierId,
s.name AS supplierName
FROM
im_product imp
LEFT JOIN im_product_supplier ps ON imp.im_product_id = ps.product_id
LEFT JOIN im_supplier s ON ps.supplier_id = s.id
WHERE
imp.delete_flag = 1 and imp.is_show = 1
<if test="categoryId !=null and categoryId != ''">
and (imp.im_category_id =#{categoryId} or
imp.im_category_id in (select ic.im_category_id from im_category ic where ic.child_category_id = #{categoryId})
or imp.im_category_id in (select ic3.im_category_id from im_category ic3 where ic3.child_category_id in (select ic.im_category_id from im_category ic where ic.child_category_id = #{categoryId})))
</if>
<if test="keyword != null and keyword !=''">
and imp.name like concat('%',#{keyword},'%')
</if>
and imp.product_type = 1 and imp.im_product_id not IN
(select cp.product_id from campaign_product cp
LEFT join im_campaign_category cc on cp.campaign_id=cc.im_campaign_category_id
where cp.campaign_id = #{campaignId} and cp.product_type = 1 and cc.delete_flag=1)
ORDER BY
imp.create_date desc
LIMIT
${pageNow}, ${pageSize}
</select>
<select id="totalPagerProduct" parameterType="java.util.Map" resultType="int">
select count(*) from im_product imp where imp.delete_flag = 1 and imp.is_show = 1
<if test="categoryId !=null and categoryId != ''">
and (imp.im_category_id =#{categoryId} or
imp.im_category_id in (select ic.im_category_id from im_category ic where ic.child_category_id = #{categoryId})
or imp.im_category_id in (select ic3.im_category_id from im_category ic3 where ic3.child_category_id in (select ic.im_category_id from im_category ic where ic.child_category_id = #{categoryId})))
</if>
<if test="keyword != null and keyword !=''">
and imp.name like concat('%',#{keyword},'%')
</if>
and imp.product_type = 1
and imp.im_product_id not IN
(select cp.product_id from campaign_product cp
LEFT join im_campaign_category cc on cp.campaign_id=cc.im_campaign_category_id
where cp.campaign_id = #{campaignId} and cp.product_type = 1 and cc.delete_flag=1)
</select>
<select id="pagerCampaginProduct" parameterType="map" resultMap="listIMProduct">
SELECT
imp.im_product_id,
imp.name,
imp.short_name,
imp.stock_num,
imp.exchange_integral,
imp.xws_exchange_integral,
imp.sibukg_exchange_integral,
imp.onther1_exchange_integral,
imp.onther2_exchange_integral,
imp.onther3_exchange_integral,
imp.thumb_img,
imp.is_new,
imp.is_hot,
imp.is_reco,
imp.create_date,
imp.limit_exchange_number,
imp.product_type,
imp.member_price,
imp.retail_price,
imp.market_price,
imp.cost,
imp.is_show,
imp.is_open_spec,
imp.spec,
imp.mini_purchase_number,
imp.erp_code,
imp.product_campagin,
imp.is_group,
cp.campaign_sort_index,
cp.id AS campaignProductId,
s.id AS supplierId,
s.name AS supplierName
FROM campaign_product cp
LEFT JOIN im_campaign_category cc on cc.im_campaign_category_id=cp.campaign_id
LEFT JOIN im_product imp ON cp.product_id=imp.im_product_id
LEFT JOIN im_product_inventory imi on imp.im_product_id=imi.im_product_id
LEFT JOIN im_product_supplier ps ON imp.im_product_id = ps.product_id
LEFT JOIN im_supplier s ON ps.supplier_id = s.id
WHERE imp.delete_flag=1 AND cp.campaign_id = #{campaignId} and cc.campagin_type=#{campaginType}
and imp.audit_flag = 100 and imp.is_show=1
<if test="keyword != null and keyword !=''">
and imp.name like concat('%',#{keyword},'%')
</if>
ORDER BY cp.campaign_sort_index,imp.member_price,imi.cost DESC
LIMIT ${pageNow}, ${pageSize}
</select>
<select id="totalPagerCampaginProduct" parameterType="java.util.Map" resultType="int">
select count(*) FROM campaign_product cp
LEFT JOIN im_campaign_category cc on cc.im_campaign_category_id=cp.campaign_id
LEFT JOIN im_product imp ON cp.product_id=imp.im_product_id
LEFT JOIN im_product_inventory imi on imp.im_product_id=imi.im_product_id
LEFT JOIN im_product_supplier ps ON imp.im_product_id = ps.product_id
LEFT JOIN im_supplier s ON ps.supplier_id = s.id
WHERE imp.delete_flag=1 AND cp.campaign_id = #{campaignId} and cc.campagin_type=#{campaginType}
and imp.audit_flag = 100 and imp.is_show=1
<if test="keyword != null and keyword !=''">
and imp.name like concat('%',#{keyword},'%')
</if>
</select>
<resultMap type="IMProductBean" id="listIMProduct">
<result column="im_product_id" property="imProductId" />
<result column="im_category_id" property="imCategoryId" />
<result column="name" property="name" />
<result column="short_name" property="shortName" />
<result column="stock_num" property="stockNum" />
<result column="details" property="details" />
<result column="exchange_integral" property="exchangeIntegral" />
<result column="xws_exchange_integral" property="xwsExchangeIntegral" />
<result column="sibukg_exchange_integral" property="sibukgExchangeIntegral" />
<result column="onther1_exchange_integral" property="onther1ExchangeIntegral" />
<result column="onther2_exchange_integral" property="onther2ExchangeIntegral" />
<result column="onther3_exchange_integral" property="onther3ExchangeIntegral" />
<result column="thumb_img" property="thumbImg" />
<result column="bannel_img1" property="bannelImg1" />
<result column="bannel_img2" property="bannelImg2" />
<result column="bannel_img3" property="bannelImg3" />
<result column="bannel_img4" property="bannelImg4" />
<result column="bannel_img5" property="bannelImg5" />
<result column="limit_exchange_number" property="limitExchangeNumber"/>
<result column="is_new" property="isNew" />
<result column="is_hot" property="isHot" />
<result column="is_reco" property="isReco" />
<result column="cost" property="cost" />
<result column="attention" property="attention" />
<result column="total_comment_score" property="totalCommentScore" />
<result column="total_comment_number" property="totalCommentNumber" />
<result column="create_date" property="createDate"/>
<result column="product_type" property="productType"/>
<result column="member_price" property="memberPrice"/>
<result column="retail_price" property="retailPrice"/>
<result column="market_price" property="marketPrice"/>
<result column="delete_flag" property="deleteFlag"/>
<result column="is_show" property="isShow"/>
<result column="sort_index" property="sortIndex"/>
<result column="is_open_spec" property="isOpenSpec"/>
<result column="spec" property="spec"/>
<result column="mini_purchase_number" property="miniPurchaseNumber"/>
<result column="erp_code" property="erpCode"/>
<result column="format_str" property="formatStr"/>
<result column="bar_code" property="barCode"/>
<result column="is_copy" property="isCopy"/>
<result column="product_campagin" property="productCampagin"/>
<result column="is_group" property="isGroup"/>
<result column="campaign_sort_index" property="campaignSortIndex"/>
<result column="id" property="campaignProductId"/>
<result column="supplierId" property="supplierId"/>
<result column="supplierName" property="supplierName"/>
</resultMap>
<update id="update" parameterType="IMCampaignCategoryBean">
UPDATE im_campaign_category SET
name=#{name},
image_url=#{imageUrl},
sort_index=#{sortIndex},
is_show=#{isShow},
campagin_type=#{campaginType}
WHERE im_campaign_category_id=#{imCampaignCategoryId}
</update>
<update id="delete" parameterType="String" >
UPDATE im_campaign_category SET delete_flag=0
WHERE im_campaign_category_id=#{campaignCategoryId}
</update>
<resultMap type="IMCampaignCategoryBean" id="IMCampaignCategoryMap">
<id column="im_campaign_category_id" property="imCampaignCategoryId"/>
<result column="name" property="name" />
<result column="image_url" property="imageUrl" />
<result column="sort_index" property="sortIndex" />
<result column="create_dt" property="createDt" />
<result column="delete_flag" property="deleteFlag" />
<result column="is_show" property="isShow" />
<result column="campagin_type" property="campaginType" />
<result column="create_dt" property="createDt" />
</resultMap>
<select id="totalCampaingnProductByProductId" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT count(cp.id) FROM campaign_product cp
left join im_campaign_category cc on cp.campaign_id=cc.im_campaign_category_id
WHERE cp.product_id=#{productId} and cc.delete_flag=1
</select>
<update id="updateCampaignProduct" parameterType="map">
update campaign_product set campaign_sort_index=#{campaignSortIndex}
where id=#{campaignProductId} limit 1
</update>
<select id="listByValid" parameterType="map" resultMap="IMCampaignCategoryMap">
SELECT cam.* FROM im_campaign_category cam
where cam.delete_flag = 1 and is_show = 1
order by cam.sort_index
LIMIT ${pageNow}, ${pageSize}
</select>
<select id="totalCountCampaginByValid" resultType="int" parameterType="map">
SELECT count(*) FROM im_campaign_category cam
where cam.delete_flag = 1 and is_show = 1
</select>
</mapper>