Pu Zhibing
2025-04-22 fd7b8fb7c89832c28a838b0449bbb8a392433ee2
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
<?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.api.domain.Goods">
        SELECT
        tg.id,
        tg.`name`,
        tg.type,
        tg.introduction,
        tg.selling_price as sellingPrice,
        tg.original_price as originalPrice,
        tg.integral as integral,
        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.appoint_store = 2 or (tg.appoint_store = 1 and tg.id in (select goods_id from t_goods_shop where shop_id = #{shopId})))
        and tg.type = 1
        <if test="vip != null">
            and (tg.commodity_authority like '%-1%' or tg.commodity_authority like CONCAT('%', #{vip}, '%'))
        </if>
        ORDER BY ifnull(tg.sort, -1) DESC
    </select>
    <select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods">
        SELECT
            tg.*
        FROM
            t_goods tg
                LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.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.type != null">
                and tg.type = #{goods.type}
            </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.payMethod != null and goods.payMethod == 1 ">
                and tg.`cash_payment` = 1 and (tg.`point_payment` = 0 or tg.`point_payment` is null)
            </if>
            <if test="goods.payMethod != null and goods.payMethod == 2 ">
                and tg.`point_payment` = 1 and (tg.`cash_payment` = 0 or tg.`cash_payment` is null)
            </if>
            <if test="goods.payMethod != null and goods.payMethod == 3 ">
                and (tg.`point_payment` = 1 and  tg.`cash_payment` = 1 )
            </if>
 
        </where>
        order by tg.sort desc
    </select>
 
 
    <select id="goodsList" resultType="com.ruoyi.other.vo.GoodsVO">
        select *, id as goodsId, name as goodsName from t_goods where status = 2 and del_flag = 0 and `type` = 2
        <if test="null != goodsCategoryId">
            and goods_category_id = #{goodsCategoryId}
        </if>
        <if test="null != name and '' != name">
            and name like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != vip">
            and (FIND_IN_SET(#{vip}, commodity_authority) or commodity_authority like '%-1%')
        </if>
        order by sort desc
    </select>
</mapper>