mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.panzhihua.service_community.dao.ComShopFlowerGoodsDAO">
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComShopFlowerGoodsDO">
        <!--@mbg.generated-->
        <!--@Table com_shop_flower_goods-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="type_id" jdbcType="BIGINT" property="typeId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="store_id" jdbcType="BIGINT" property="storeId"/>
        <result column="goods_pic" jdbcType="VARCHAR" property="goodsPic"/>
        <result column="images" jdbcType="VARCHAR" property="images"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="sale" jdbcType="INTEGER" property="sale"/>
        <result column="original_price" jdbcType="DECIMAL" property="originalPrice"/>
        <result column="price" jdbcType="DECIMAL" property="price"/>
        <result column="unit" jdbcType="VARCHAR" property="unit"/>
        <result column="order" jdbcType="INTEGER" property="order"/>
        <result column="stock" jdbcType="INTEGER" property="stock"/>
        <result column="details" jdbcType="LONGVARCHAR" property="details"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="goods_describe" jdbcType="VARCHAR" property="goodsDescribe"/>
        <result column="delivery_type" jdbcType="TINYINT" property="deliveryType"/>
        <result column="delete_status" jdbcType="TINYINT" property="deleteStatus"/>
        <result column="create_at" jdbcType="TIMESTAMP" property="createAt"/>
        <result column="update_at" jdbcType="TIMESTAMP" property="updateAt"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, type_id, `name`, store_id, goods_pic, images, `status`, sale, original_price,
        price, unit, `order`, stock, details, remark, goods_describe, delivery_type, delete_status,
        create_at, update_at
    </sql>
    <select id="pageShopGoods" resultType="com.panzhihua.common.model.vos.shop.PageShopFlowerGoodsVO">
        select c.id,c.type_id,ccm.name as
        storeName,c.name,c.store_id,c.goods_pic,c.images,c.status,c.sale,c.original_price,c.price,c.unit,c.order,c.stock,c.details,c.remark,c.goods_describe,c.delivery_type,c.delete_status,c.create_at,c.update_at
        from com_shop_flower_goods c
        left join com_convenient_merchants ccm on c.store_id=ccm.id
        left join  com_convenient_goods_scope as cgs on cgs.goods_id = c.id
        where  c.delete_status = 1 and ccm.is_del = 0
            <if test='pageComShopFlowerGoodsDTO.storeName != null and pageComShopFlowerGoodsDTO.storeName.trim() != &quot;&quot;'>
                and ccm.name like concat('%',#{pageComShopFlowerGoodsDTO.storeName},'%')
            </if>
            <if test='pageComShopFlowerGoodsDTO.name != null and pageComShopFlowerGoodsDTO.name.trim() != &quot;&quot;'>
                and c.name like concat('%',#{pageComShopFlowerGoodsDTO.name},'%')
            </if>
            <if test='pageComShopFlowerGoodsDTO.storeId != null'>
                and ccm.id=#{pageComShopFlowerGoodsDTO.storeId}
            </if>
            <if test='pageComShopFlowerGoodsDTO.status != null'>
                and c.status like concat('%',#{pageComShopFlowerGoodsDTO.status},'%')
            </if>
            <if test='pageComShopFlowerGoodsDTO.categoryIds != null '>
                AND cgs.goods_category_id = #{pageComShopFlowerGoodsDTO.categoryIds}
            </if>
        <if test='pageComShopFlowerGoodsDTO.userId != null'>
            and ccm.user_id = #{pageComShopFlowerGoodsDTO.userId}
        </if>
 
        order by c.create_at desc
    </select>
    <select id="pageShopGoodsByStoreId" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerGoodsVO">
        select id,`name`,store_id,goods_pic,images,`status`,sale,original_price,price
        ,unit,`order`,stock,details,delivery_type from com_shop_flower_goods where store_id =
        #{pageComShopFlowerStoreDTO.storeId}
        and delete_status = 1 and status = 1 order by sale desc,create_at desc
    </select>
    <select id="pageShopGoodByApps" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerGoodsVO">
        select csg.id,csg.`name`,csg.store_id,csg.goods_pic,csg.images,csg.`status`,csg.sale,csg.original_price
        ,csg.price,csg.unit,csg.`order`,csg.details,csg.delivery_type, csg.create_at,
        (SELECT count(fog.id) FROM com_shop_flower_order_goods as fog WHERE fog.goods_id = csg.id) as order_num,
        (SELECT ifnull(sum(ga.stock),0) from com_shop_flower_goods_attr ga where ga.goods_id = csg.id ) as stock
        from com_shop_flower_goods as csg
        left join com_convenient_merchants as css on css.id = csg.store_id
        left join  com_convenient_goods_scope as cgs on cgs.goods_id = csg.id
        where 1=1 and csg.delete_status = 1
 
        <if test='comShopFlowerGoodsDTO.name != null and comShopFlowerGoodsDTO.name !=&quot;&quot;'>
            AND csg.`name` like concat('%',#{comShopFlowerGoodsDTO.name},'%')
        </if>
        <if test='comShopFlowerGoodsDTO.status != null '>AND csg.`status` = #{comShopFlowerGoodsDTO.status}</if>
        <if test='comShopFlowerGoodsDTO.storeId != null '>AND csg.store_id = #{comShopFlowerGoodsDTO.storeId}</if>
        <if test='comShopFlowerGoodsDTO.storeId == null '>
            and css.`business_status` = 1
        </if>
        <if test='comShopFlowerGoodsDTO.deliveryType != null '>AND csg.delivery_type like concat('%',#{comShopFlowerGoodsDTO.deliveryType},'%') </if>
        <if test='comShopFlowerGoodsDTO.categoriesId != null '>AND cgs.goods_category_id = #{comShopFlowerGoodsDTO.categoriesId}</if>
        order by sale desc,create_at desc
    </select>
    <select id="selectCountSaleByStoreId" resultType="java.lang.Integer">
        select count(1) from com_shop_flower_goods where  store_id = #{storeId} and `status` = 1 and delete_status = 1
    </select>
 
 
    <select id="countSaleByUserId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
        SELECT count(1) AS count_num, 'sale' AS count_name  FROM com_shop_flower_goods  g LEFT JOIN com_convenient_merchants m on g.store_id = m.id WHERE g.delete_status = 1 and m.user_id = #{userId}  and g.`status` = 1
        union all
        SELECT count(1) AS count_num, 'noSale' AS count_name  FROM com_shop_flower_goods  g LEFT JOIN com_convenient_merchants m on g.store_id = m.id WHERE g.delete_status = 1 and m.user_id =  #{userId}  and g.`status` = 2
    </select>
</mapper>