无关风月
2025-07-23 7fd053651ac11db87fe4f6c57e65eed3b9a59452
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
<?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.ruoyi.other.mapper.GoodsMapper">
 
    <select id="selectListByShopId" resultType="com.ruoyi.other.vo.GoodsVO">
        SELECT distinct
        tg.id as goodsId,
        tg.`name` as goodsName,
        tg.purchase_limit as purchaseLimit,
        tg.integral,
        tg.introduction,
        tg.selling_price as sellingPrice,
        tg.original_price as originalPrice,
        tg.sale_num as saleNum,
        tg.home_page_picture as homePagePicture,
        tg.sort
        FROM t_goods tg
        where tg.del_flag = 0 and tg.status = 2 and tg.id in (select goods_id from t_goods_shop where shop_id = #{shopId})
        ORDER BY ifnull(tg.sort, -1) DESC
    </select>
    <select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods">
        SELECT
        tg.*,
        ts.name AS shop_name,
        ts.id AS shop_id,
        tgc.name AS category_name
        FROM
        t_goods_shop tgs
        LEFT JOIN t_goods tg ON tgs.goods_id = tg.id
        LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id
        LEFT JOIN t_shop ts ON tgs.shop_id = ts.id
        <where>
            tg.del_flag = 0
            <if test="goods.id != null">
                AND tg.id = #{goods.id}
            </if>
            <if test="goods.name != null and goods.name != ''">
                AND tg.`name` LIKE CONCAT('%', #{goods.name}, '%')
            </if>
            <if test="goods.goodsCategoryId != null">
                AND tg.goods_category_id = #{goods.goodsCategoryId}
            </if>
            <if test="goods.status != null">
                AND tg.`status` = #{goods.status}
            </if>
            <if test="goods.shopName != null and goods.shopName != ''">
                AND ts.`name` LIKE CONCAT('%', #{goods.shopName}, '%')
            </if>
            <if test="goods.shopId != null">
                AND ts.id = #{goods.shopId}
            </if>
        </where>
        ORDER BY IFNULL(tg.sort,0) DESC
    </select>
 
 
 
    <select id="goodsList" resultType="com.ruoyi.other.vo.GoodsVO">
        select  g.id as goodsId,
                g.name as goodsName,
                g.purchase_limit as purchaseLimit,
                g.selling_price as sellingPrice,
                g.type,
                g.original_price as originalPrice,
                g.integral,
                g.introduction,
                g.home_page_picture as homePagePicture,
                g.sale_num as saleNum
        from t_goods g
        <if test="null != shopIds and shopIds.size() > 0">
            inner join t_goods_shop gs on g.id = gs.goods_id
        </if>
        where g.status = 2 and g.del_flag = 0
        <if test="null != goodsCategoryId">
            and g.goods_category_id = #{goodsCategoryId}
        </if>
        <if test="null != name and '' != name">
            and g.name like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != shopIds and shopIds.size() > 0">
            and gs.shop_id in
            <foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
                #{shopId}
            </foreach>
        </if>
        order by g.sale_num  desc
    </select>
</mapper>