Helius
2020-12-23 c554c7ad5405bafa149dbb6429e8245f78b33ffc
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
<?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.matrix.system.hive.dao.ShoppingGoodsAssembleDao">
 
    <resultMap type="ShoppingGoodsAssemble" id="ShoppingGoodsAssembleMap">
        <id property="id" column="id"/>
        <result property="shoppingGoodsId" column="shopping_goods_id"/>
        <result property="assembleSkuId" column="assemble_sku_id"/>
        <result property="assembleProjId" column="assemble_proj_id"/>
        <result property="price" column="price"/>
        <result property="total" column="total"/>
        <result property="status" column="status"/>
        <result property="deductionNum" column="deductionNum"/>
        <result property="assembleGoodId" column="assembleGoodId"/>
 
 
        <association property="shoppingGoods" resultMap="com.matrix.system.hive.dao.ShoppingGoodsDao.ShoppingGoodsSimpleMap" />
 
 
 
 
    </resultMap>
 
 
    <!-- 插入方法 -->
    <insert id="insert" parameterType="ShoppingGoodsAssemble"
            useGeneratedKeys="true" keyProperty="id">
        INSERT INTO
        shopping_goods_assemble (
        id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        price,
        status,
        deductionNum,
        assembleGoodId
        )
        VALUES (
        #{id},
        #{shoppingGoodsId},
        #{assembleSkuId},
        #{assembleProjId},
        #{total},
        #{price},
        #{status},
        #{deductionNum},
        #{assembleGoodId}
        )
    </insert>
 
    <!-- 批量插入 -->
    <insert id="batchInsert" parameterType="java.util.List">
        INSERT INTO shopping_goods_assemble (
        id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        price,
        status,
        deductionNum,
        assembleGoodId
        )
        VALUES
        <foreach collection="list" item="item" index="index"
                 separator=",">(
            #{item.id},
            #{item.shoppingGoodsId},
            #{item.assembleSkuId},
            #{item.assembleProjId},
            #{item.total},
            #{item.price},
            #{item.status},
            #{item.deductionNum},
            #{item.assembleGoodId}
            )
        </foreach>
    </insert>
 
 
    <!-- 根据id更新 部分更新 -->
    <update id="update">
        UPDATE shopping_goods_assemble
        <set>
            <if test="shoppingGoodsId != null and shoppingGoodsId !='' ">
                shopping_goods_id = #{shoppingGoodsId},
            </if>
            <if test="assembleSkuId != null and assembleSkuId !='' ">
                assemble_sku_id = #{assembleSkuId},
            </if>
            <if test="assembleProjId != null and assembleProjId !='' ">
                assemble_proj_id = #{assembleProjId},
            </if>
            <if test="total != null and total !='' ">
                total = #{total},
            </if>
            <if test="price != null and price !='' ">
                price = #{price},
            </if>
            <if test="status != null and status !='' ">
                status = #{status},
            </if>
            <if test="deductionNum != null and deductionNum !='' ">
                deductionNum = #{deductionNum},
            </if>
            <if test="assembleGoodId != null and assembleGoodId !='' ">
                assembleGoodId = #{assembleGoodId},
            </if>
        </set>
        WHERE id=#{id}
    </update>
 
 
    <!-- 批量删除 -->
    <delete id="deleteByIds" parameterType="java.util.List">
        delete from shopping_goods_assemble where id in
        <foreach collection="list" index="index" item="item" open="("
                 separator="," close=")">
            #{item}
        </foreach>
    </delete>
 
    <!-- 根据id删除 -->
    <delete id="deleteById">
        DELETE FROM
        shopping_goods_assemble
        where id=#{id}
    </delete>
 
 
    <delete id="deleteByGoodsId">
        DELETE FROM
        shopping_goods_assemble
        where shopping_goods_id=#{shoppingGoodsId}
    </delete>
 
    <!-- 分页查询 -->
    <select id="selectInPage" resultMap="ShoppingGoodsAssembleMap">
        select
        sga.id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        sga.price,
        status,
        deductionNum,
        assembleGoodId
        from shopping_goods_assemble sga
        LEFT JOIN sys_goods s ON sga.assemble_sku_id =s.id
        where 1=1
        <if test="record!=null">
            <if test="record.id != null and record.id !='' ">
                and id =#{record.id}
            </if>
            <if test="record.shoppingGoodsId != null and record.shoppingGoodsId !='' ">
                and shopping_goods_id =#{record.shoppingGoodsId}
            </if>
            <if test="record.assembleSkuId != null and record.assembleSkuId !='' ">
                and assemble_sku_id =#{record.assembleSkuId}
            </if>
            <if test="record.assembleProjId != null and record.assembleProjId !='' ">
                and assemble_proj_id =#{record.assembleProjId}
            </if>
            <if test="record.total != null and record.total !='' ">
                and total =#{record.total}
            </if>
            <if test="record.price != null and record.price !='' ">
                and price =#{record.price}
            </if>
            <if test="record.status != null and record.status !='' ">
                and status =#{record.status}
            </if>
        </if>
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
            <if test="pageVo.sort !=null  and pageVo.order !=null">
                order by
                ${pageVo.sort} ${pageVo.order}
            </if>
            <if test="pageVo.offset >=0  and pageVo.limit >0">
                limit
                #{pageVo.offset},#{pageVo.limit}
            </if>
        </if>
    </select>
 
    <!-- 查询总条数 -->
    <select id="selectTotalRecord" resultType="java.lang.Integer">
        select count(*)
        from shopping_goods_assemble
        where 1=1
        <if test="record!=null">
            <if test="record.id != null and record.id !='' ">
                and id =#{record.id}
            </if>
            <if test="record.shoppingGoodsId != null and record.shoppingGoodsId !='' ">
                and shopping_goods_id =#{record.shoppingGoodsId}
            </if>
            <if test="record.assembleSkuId != null and record.assembleSkuId !='' ">
                and assemble_sku_id =#{record.assembleSkuId}
            </if>
            <if test="record.assembleProjId != null and record.assembleProjId !='' ">
                and assemble_proj_id =#{record.assembleProjId}
            </if>
            <if test="record.total != null and record.total !='' ">
                and total =#{record.total}
            </if>
            <if test="record.price != null and record.price !='' ">
                and price =#{record.price}
            </if>
            <if test="record.status != null and record.status !='' ">
                and status =#{record.status}
            </if>
        </if>
    </select>
 
    <!-- 根据id查询 -->
    <select id="selectById" resultMap="ShoppingGoodsAssembleMap">
        select
        id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        price,
        status,
        deductionNum,
        assembleGoodId
        from shopping_goods_assemble
        where id=#{id}
    </select>
 
 
    <select id="selectForShoppingCar" resultMap="ShoppingGoodsAssembleMap">
        select
        sga.id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        sga.price,
        status,
        deductionNum,
        assembleGoodId
        from shopping_goods_assemble sga
        LEFT JOIN sys_goods s ON sga.assemble_sku_id
        =s.id
        LEFT JOIN shopping_goods sg ON sga.shopping_goods_id=sg.id
        where
        sga.id=#{id}
    </select>
 
 
    <!-- 根据对象查询 -->
    <select id="selectByModel" resultMap="ShoppingGoodsAssembleMap">
        select
        id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        price,
        status,
        deductionNum,
        assembleGoodId
        from shopping_goods_assemble
        where 1=1
        <if test="record!=null">
            <if test="record.id != null and record.id !='' ">
                and id =#{record.id}
            </if>
            <if test="record.shoppingGoodsId != null and record.shoppingGoodsId !='' ">
                and shopping_goods_id =#{record.shoppingGoodsId}
            </if>
            <if test="record.assembleSkuId != null and record.assembleSkuId !='' ">
                and assemble_sku_id =#{record.assembleSkuId}
            </if>
            <if test="record.assembleProjId != null and record.assembleProjId !='' ">
                and assemble_proj_id =#{record.assembleProjId}
            </if>
            <if test="record.total != null and record.total !='' ">
                and total =#{record.total}
            </if>
            <if test="record.price != null and record.price !='' ">
                and price =#{record.price}
            </if>
            <if test="record.status != null and record.status !='' ">
                and status =#{record.status}
            </if>
        </if>
    </select>
 
    <select id="selectGoodsByShoppingGoodsIdAndType"
            resultMap="ShoppingGoodsAssembleMap">
        SELECT
        a.id,
        shopping_goods_id,
        assemble_sku_id,
        assemble_proj_id,
        total,
        a.price,
        STATUS,
        deductionNum,
        assembleGoodId,
        g.*,
        (select TYPE_NAME from sys_goods_type t where t.id=g.GOODS_SORT_ID) GOODS_SORT_NAME,
        (select NAME from shopping_goods_category t where t.id = g.cate_id) as cate_name
        FROM
        shopping_goods_assemble a
        LEFT JOIN shopping_goods g ON a.assembleGoodId = g.id
        where
        shopping_goods_id=#{goodsId}
        <if test="goodsType!=null">
            and g.good_type=#{goodsType}
        </if>
 
    </select>
 
 
    <select id="selectGoodsByShoppingGoodsId"
            resultMap="ShoppingGoodsAssembleMap">
            SELECT
            a.id,
            shopping_goods_id,
            assemble_sku_id,
            assemble_proj_id,
            total,
            a.price,
            STATUS,
            deductionNum,
            assembleGoodId,
            g.*,
            (select TYPE_NAME from sys_goods_type t where t.id=g.GOODS_SORT_ID) GOODS_SORT_NAME,
            (select NAME from shopping_goods_category t where t.id = g.cate_id) as cate_name
        FROM
            shopping_goods_assemble a
        LEFT JOIN shopping_goods g ON a.assembleGoodId = g.id
        where
        shopping_goods_id=#{goodsId}
 
 
    </select>
 
    <select id="selectProjByShoppingGoodsId"
            resultMap="ShoppingGoodsAssembleMap">
            SELECT
            a.id,
            shopping_goods_id,
            assemble_sku_id,
            assemble_proj_id,
            total,
            a.price,
            STATUS,
            deductionNum,
            assembleGoodId
        FROM
            shopping_goods_assemble a
        where
        shopping_goods_id=#{goodsId}
        and assemble_proj_id is not null
    </select>
 
    <select id="selectAssembleShoppingGoodsByShoppingGoodsId"
            resultMap="ShoppingGoodsAssembleMap">
            SELECT
            a.id,
            shopping_goods_id,
            assemble_sku_id,
            assemble_proj_id,
            total,
            a.price,
            STATUS,
            deductionNum,
            assembleGoodId,
 
        g.ID as sp_id,
        g.name,
        g.introduction,
        g.staus,
        g.seal_pice,
        g.reference_pice,
        g.seal_count,
        g.is_assemble,
        g.deleted,
        g.cate_id,
        g.jf_pice,
        g.jf_number,
        g.good_type,
        g.sale_off_time,
        g.is_present,
        g.is_once,
        g.sale_platform,
        g.validity,
        g.is_course,
        g.car_max_sale_count,
        g.car_is_all,
        g.car_use_count,
        (select NAME from shopping_goods_category t where t.id=cate_id) as cate_name,
        g.is_vip_car,
        g.vip_grad_id,
        g.is_integral,
        g.real_seal_count,
        g.store,
        g.commission_rate,
        g.is_distribution,
        g.frist_commission,
        g.second_commission
        FROM
            shopping_goods_assemble a
        LEFT JOIN shopping_goods g ON a.assembleGoodId = g.id
        where
        shopping_goods_id=#{goodsId}
        and assembleGoodId is not null
    </select>
 
 
 
 
 
    <!-- 如果商品到了自动下架时间 则它绑定的商品全部下架,根据商品id修改它所绑定的商品 -->
    <update id="updateByGoodsId">
        UPDATE shopping_goods_assemble
        <set>
            <if test="status != null and status !='' ">
                status = #{status}
            </if>
        </set>
        WHERE shopping_goods_id = #{shoppingGoodsId}
    </update>
 
 
</mapper>