<?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.kmall.admin.dao.ProductStoreRelaDao">

    <resultMap type="com.kmall.admin.entity.ProductStoreRelaEntity" id="productStoreRelaMap">
        <result property="id" column="id"/>
        <result property="storeId" column="store_id"/>
        <result property="merchSn" column="merch_sn"/>
        <result property="productId" column="product_id"/>
        <result property="stockNum" column="stock_num"/>
        <result property="goodsId" column="goods_id"/>
        <result property="retailPrice" column="retail_price"/>
        <result property="marketPrice" column="market_price"/>
        <result property="stockPrice" column="stock_price"/>
        <result property="sellVolume" column="sell_volume"/>

        <result property="storeName" column="storeName"/>
        <result property="goodsName" column="goodsName"/>
        <result property="goodsSn" column="goodsSn"/>
        <result property="productSn" column="productSn"/>
        <result property="categoryName" column="categoryName"/>

        <result column="sku" property="sku" jdbcType="VARCHAR" />
        <result column="goods_biz_type" property="goodsBizType" />
        <result column="creater_sn" property="createrSn" />
        <result column="create_time" property="createTime" />
        <result column="moder_sn" property="moderSn" />
        <result column="mod_time" property="modTime" />
        <result column="tstm" property="tstm" />
        <result column="list_pic_url" property="listPicUrl" />
        <result column="merch_name" property="merchName" />
        <result column="goods_merch_sn" property="goodsMerchSn" />
        <result column="supplier_third_id" property="supplierThirdId" />

        <result column="category_id" property="categoryId" />
        <result column="attribute_category" property="attributeCategory" />
        <result column="brand_id" property="brandId" />
        <result column="freight_id" property="freightId" />
        <result column="goodsNumber" property="goodsNumber" />
        <result column="thirdPartyMerchCode" property="thirdPartyMerchCode" />
        <result column="isStockShare" property="isStockShare" />
        <result column="goodsSellVolume" property="goodsSellVolume" />
    </resultMap>

    <select id="queryObject" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
		SELECT
            a.`id`,
            a.`store_id`,
            a.`merch_sn`,
            a.`product_id`,
            a.`stock_num`,
            a.`goods_id`,
            a.`retail_price`,
            a.`market_price`,
            a.`stock_price`,
            a.`sell_volume`,
            a.sku,
            a.goods_biz_type,
            a.creater_sn,
            a.create_time,
            a.moder_sn,
            a.mod_time,
            a.tstm,
            b.goods_sn goodsSn,
            c.goods_sn productSn,
            b.NAME goodsName,
            cg.NAME categoryName,
            s.store_name storeName,
            gs.value as specification,
            a.category_id,
            a.attribute_category,
            a.brand_id,
            a.freight_id,
            supplier_third_id
        FROM
            mall_product_store_rela a
            LEFT JOIN mall_store s ON a.store_id = s.id
            LEFT JOIN mall_goods b ON a.goods_id = b.id
            LEFT JOIN mall_product c ON a.product_id = c.id
            LEFT JOIN mall_category cg ON a.category_id = cg.id
            left join mall_goods_specification gs on gs.goods_id = a.goods_id
		where a.id = #{id}
	</select>

    <select id="queryByStoreIdProductId" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        select
            a.`id`,
            a.`store_id`,
            a.`merch_sn`,
            a.`product_id`,
            a.`stock_num`,
            a.`goods_id`,
            a.`retail_price`,
            a.`market_price`,
            a.`stock_price`,
            a.`sell_volume`,
            a.sku,a.goods_biz_type, a.creater_sn, a.create_time, a.moder_sn, a.mod_time, a.tstm,
            b.goods_sn goodsSn,
            c.goods_sn productSn,
            b.name goodsName,
            cg.name categoryName,
            s.store_name storeName,
            a.category_id,
            a.attribute_category,
            a.brand_id,
            a.freight_id,
            b.goods_number goodsNumber,
            mb.is_stock_share isStockShare,
            b.sell_volume goodsSellVolume,
            supplier_third_id
        from mall_product_store_rela a
        left join mall_goods b on a.goods_id = b.id
        left join mall_store s on a.store_id = s.id
        left join third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
        left join mall_product c on a.product_id = c.id
        LEFT JOIN mall_category cg ON a.category_id = cg.id
        where a.store_id = #{storeId} and a.product_id = #{productId}
    </select>

    <select id="queryObjectByStoreAndGoodsId" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        select
            a.`id`,
            a.`store_id`,
            a.`merch_sn`,
            a.`product_id`,
            a.`stock_num`,
            a.`goods_id`,
            a.`retail_price`,
            a.`market_price`,
            a.`stock_price`,
            a.`sell_volume`,
            a.sku,a.goods_biz_type, a.creater_sn, a.create_time, a.moder_sn, a.mod_time, a.tstm,
            a.category_id,
            a.attribute_category,
            a.brand_id,
            a.freight_id,
            supplier_third_id
        from mall_product_store_rela a
        where a.store_id = #{storeId} and a.goods_id = #{goodsId}
    </select>

    <select id="queryList" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        select
        a.`id`,
        a.`store_id`,
        a.`merch_sn`,
        a.`product_id`,
        a.`stock_num`,
        a.`goods_id`,
        a.`retail_price`,
        a.`market_price`,
        a.`stock_price`,
        a.`sell_volume`,
        b.is_on_sale 'isOnSale',
        b.sell_volume 'goodsSellVolume',
        b.sku,a.goods_biz_type, a.creater_sn, a.create_time, a.moder_sn, a.mod_time, a.tstm,
        b.goods_sn goodsSn,
        b.list_pic_url,
        c.goods_sn productSn,
        b.name goodsName,
        cg.name categoryName,
        s.store_name storeName,
        m.merch_name,
        b.merch_sn goods_merch_sn,
        a.category_id,
        a.attribute_category,
        a.brand_id,
        a.freight_id,
        b.goods_number goodsNumber,
        b.third_party_merch_code thirdPartyMerchCode,
        mb.is_stock_share isStockShare,
        b.list_pic_url,supplier_third_id
        from mall_product_store_rela a
        left join mall_goods b on a.goods_id = b.id
        left join third_merchant_biz mb on mb.third_party_merch_code = b.third_party_merch_code and mb.merch_sn=b.merch_sn
        left join mall_merch m on a.merch_sn = m.merch_sn
        left join mall_product c on a.product_id = c.id
        LEFT JOIN mall_category cg ON a.category_id = cg.id
        left join mall_store s on a.store_id = s.id
        WHERE 1=1 and b.is_delete = 0
        <if test="categoryId != null and categoryId != '' ">
            AND a.category_id = #{categoryId}
        </if>
        <if test="brandId != null and brandId != '' ">
            AND a.brand_id = #{brandId}
        </if>
        <if test="category != null and category != ''">
            AND a.category_id IN (select id from mall_category where parent_id = #{category})
        </if>
        <if test="categoryTwo != null and categoryTwo != ''">
            AND a.category_id = #{categoryTwo}
        </if>
        <if test="storeId != null and storeId != '' ">
            AND a.store_id = #{storeId}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND a.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND s.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="goodsId != null">
            AND a.goods_id = #{goodsId}
        </if>
        <if test="goodsName != null and goodsName != '' ">
            AND b.name LIKE concat('%',#{goodsName},'%')
        </if>
        <if test="goodsSn != null and goodsSn != '' ">
            AND b.goods_sn = #{goodsSn}
        </if>
        <if test="productSn != null and productSn != '' ">
            AND c.goods_sn = #{productSn}
        </if>
        <if test="productId != null">
            AND a.product_id = #{productId}
        </if>
        <if test="storeId != null and storeId != ''">
            AND s.id = #{storeId}
        </if>
        <if test="goodsBizType != null and goodsBizType != ''">
            AND b.goods_biz_type = #{goodsBizType}
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by a.id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="querySameList" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        select
        a.`id`,
        a.`store_id`,
        a.`merch_sn`,
        a.`product_id`,
        a.`stock_num`,
        a.`goods_id`,
        a.`retail_price`,
        a.`market_price`,
        a.`stock_price`,
        a.`sell_volume`,
        a.sku,a.goods_biz_type, a.creater_sn, a.create_time, a.moder_sn, a.mod_time, a.tstm,
        b.goods_sn goodsSn,
        c.goods_sn productSn,
        b.name goodsName,
        cg.name categoryName,
        s.store_name storeName,
        a.category_id,
        a.attribute_category,
        a.brand_id,
        a.freight_id,supplier_third_id
        from mall_product_store_rela a
        left join mall_goods b on a.goods_id = b.id
        left join mall_product c on a.product_id = c.id
        LEFT JOIN mall_category cg ON a.category_id = cg.id
        left join mall_store s on a.store_id = s.id
        WHERE 1=1 and b.is_delete = 0
        <if test="goodsId != null">
            AND b.id = #{goodsId}
        </if>
        <if test="categoryId != null and categoryId != '' ">
            AND a.category_id = #{categoryId}
        </if>
        <if test="brandId != null and brandId != '' ">
            AND a.brand_id = #{brandId}
        </if>
        <if test="category != null and category != ''">
            AND a.category_id IN (select id from mall_category where parent_id = #{category})
        </if>
        <if test="categoryTwo != null and categoryTwo != ''">
            AND a.category_id = #{categoryTwo}
        </if>
        <if test="storeId != null and storeId != '' ">
            AND a.store_id = #{storeId}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND a.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND s.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="id != null">
            AND a.id != #{id}
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by a.id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(a.id)
        from mall_product_store_rela a
        left join mall_goods b on a.goods_id = b.id
        left join third_merchant_biz mb on mb.third_party_merch_code = b.third_party_merch_code and mb.merch_sn=b.merch_sn
        left join mall_product c on a.product_id = c.id
        LEFT JOIN mall_category cg ON a.category_id = cg.id
        left join mall_store s on a.store_id = s.id
        WHERE 1=1 and b.is_delete = 0
        <if test="storeId != null and storeId != '' ">
            AND a.store_id = #{storeId}
        </if>
        <if test="categoryId != null and categoryId != '' ">
            AND a.category_id = #{categoryId}
        </if>
        <if test="brandId != null and brandId != '' ">
            AND a.brand_id = #{brandId}
        </if>
        <if test="category != null and category != ''">
            AND a.category_id IN (select id from mall_category where parent_id = #{category})
        </if>
        <if test="categoryTwo != null and categoryTwo != ''">
            AND a.category_id = #{categoryTwo}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND a.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND s.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="goodsId != null">
            AND a.goods_id = #{goodsId}
        </if>
        <if test="goodsName != null and goodsName != '' ">
            AND b.name LIKE concat('%',#{goodsName},'%')
        </if>
        <if test="goodsSn != null and goodsSn != '' ">
            AND b.goods_sn = #{goodsSn}
        </if>
        <if test="productSn != null and productSn != '' ">
            AND c.goods_sn = #{productSn}
        </if>
        <if test="productId != null">
            AND a.product_id = #{productId}
        </if>
        <if test="storeId != null and storeId != ''">
            AND s.id = #{storeId}
        </if>
        <if test="goodsBizType != null and goodsBizType != ''">
            AND b.goods_biz_type = #{goodsBizType}
        </if>
    </select>

    <insert id="save" parameterType="com.kmall.admin.entity.ProductStoreRelaEntity" useGeneratedKeys="true"
            keyProperty="id">
		insert into mall_product_store_rela(
			`store_id`,
			`merch_sn`,
			`product_id`,
			`stock_num`,
			`goods_id`,
			`retail_price`,
			`market_price`,
            `stock_price`,
            `sell_volume`,
            supplier_third_id,

        <if test="sku != null" >
            sku,
        </if>
        <if test="goodsBizType != null" >
            goods_biz_type,
        </if>
        <if test="categoryId != null" >
            category_id,
        </if>
        <if test="attributeCategory != null" >
            attribute_category,
        </if>
        <if test="brandId != null" >
            brand_id,
        </if>
        <if test="freightId != null" >
            freight_id,
        </if>
        <if test="createrSn != null" >
            creater_sn,
        </if>
        <if test="createTime != null" >
            create_time,
        </if>
        <if test="moderSn != null" >
            moder_sn,
        </if>
        <if test="modTime != null" >
            mod_time
        </if>
        )
		values(
            #{storeId},
			#{merchSn},
			#{productId},
			#{stockNum},
			#{goodsId},
			#{retailPrice},
			#{marketPrice},
			#{stockPrice},
			#{sellVolume},
            #{supplierThirdId},

        <if test="sku != null" >
            #{sku,jdbcType=VARCHAR},
        </if>
        <if test="goodsBizType != null" >
            #{goodsBizType,jdbcType=CHAR},
        </if>
        <if test="categoryId != null" >
            #{categoryId,jdbcType=CHAR},
        </if>
        <if test="attributeCategory != null" >
            #{attributeCategory,jdbcType=CHAR},
        </if>
        <if test="brandId != null" >
            #{brandId,jdbcType=CHAR},
        </if>
        <if test="freightId != null" >
            #{freightId,jdbcType=CHAR},
        </if>
        <if test="createrSn != null" >
            #{createrSn,jdbcType=VARCHAR},
        </if>
        <if test="createTime != null" >
            #{createTime,jdbcType=TIMESTAMP},
        </if>
        <if test="moderSn != null" >
            #{moderSn,jdbcType=VARCHAR},
        </if>
        <if test="modTime != null" >
            #{modTime,jdbcType=TIMESTAMP}
        </if>
        )
	</insert>

    <update id="update" parameterType="com.kmall.admin.entity.ProductStoreRelaEntity">
        update mall_product_store_rela
        <set>
            <if test="storeId != null">`store_id` = #{storeId},</if>
            <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
            <if test="productId != null">`product_id` = #{productId},</if>
            <if test="stockNum != null">`stock_num` = #{stockNum},</if>
            <if test="goodsId != null">`goods_id` = #{goodsId},</if>
            <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
            <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
            <if test="stockPrice != null">`stock_price` = #{stockPrice},</if>
            <if test="sellVolume != null">`sell_volume` = #{sellVolume},</if>
            <if test="supplierThirdId != null">`supplier_third_id` = #{supplierThirdId},</if>

            <if test="sku != null" >
                sku = #{sku,jdbcType=VARCHAR},
            </if>
            <if test="goodsBizType != null" >
                goods_biz_type = #{goodsBizType,jdbcType=CHAR},
            </if>
            <if test="categoryId != null" >
                category_id = #{categoryId,jdbcType=CHAR},
            </if>
            <if test="attributeCategory != null" >
                attribute_category = #{attributeCategory,jdbcType=CHAR},
            </if>
            <if test="brandId != null" >
                brand_id = #{brandId,jdbcType=CHAR},
            </if>
            <if test="freightId != null" >
                freight_id = #{freightId,jdbcType=CHAR},
            </if>
            <if test="createrSn != null" >
                creater_sn = #{createrSn,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null" >
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="moderSn != null" >
                moder_sn = #{moderSn,jdbcType=VARCHAR},
            </if>
            <if test="modTime != null" >
                mod_time = #{modTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id}
    </update>

    <delete id="delete">
		delete from mall_product_store_rela where id = #{value}
	</delete>

    <delete id="deleteByGoodsId">
		delete from mall_product_store_rela where goods_id = #{goodsId}
	</delete>

    <delete id="deleteBatch">
        delete from mall_product_store_rela where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="queryByGoodsId" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        select a.*
		from mall_product_store_rela a
		where a.goods_id = #{goodsId}
    </select>

    <select id="queryByGoodsIdAndStoreId" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        select a.*
        from mall_product_store_rela a
        where a.goods_id = #{goodsId} and a.store_id = #{storeId}
    </select>

    <update id="updateStockNum" parameterType="com.kmall.admin.entity.ProductStoreRelaEntity">
        update mall_product_store_rela a
        <set>
            <if test="stockNum != null">a.`stock_num` = #{stockNum},</if>
            <if test="sellVolume != null">a.`sell_volume` = #{sellVolume},</if>
        </set>
        where a.goods_id = #{goodsId} and a.store_id = #{storeId}
    </update>

    <update id="updateSellVolumeNum" parameterType="com.kmall.api.entity.ProductVo">
        update mall_product_store_rela a
        <set>
            <if test="sellVolume != null">a.`sell_volume` = #{sellVolume},</if>
        </set>
        where a.product_id = #{goodsId} and a.store_id = #{storeId}
    </update>

    <select id="queryGoodsRealListByDiscountTid" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        SELECT
        s.id,
        s.goods_id,
        s.retail_price,
        g.store_rela_id 'isCheck',
        g.apply_type applyType,
        gs.NAME 'goodsName',
        g.disc_good_temp_id 'discGoodTempId',
        g.guid,
        gs.goods_number goodsNumber,
        s.stock_num,
        gs.list_pic_url
        FROM
        mall_product_store_rela s
        LEFT JOIN mk_store_topic_goods_temp g ON s.id = g.store_rela_id AND g.guid = #{guid} and g.is_valid = '0' and g.is_button_cannel = '0'
        LEFT JOIN mall_goods gs ON s.goods_id = gs.id
        LEFT JOIN mall_store st ON st.id =  s.store_id
        WHERE  1=1 and gs.is_delete = 0
        <if test="storeId != null and storeId != '' ">
            AND s.store_id = #{storeId}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND s.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND st.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="goodsBizType != null and goodsBizType != '' ">
            AND gs.goods_biz_type = #{goodsBizType}
        </if>
        <if test="goodsName != null and goodsName != '' ">
            AND gs.name LIKE concat('%',#{goodsName},'%')
        </if>
        order by s.id desc
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryGoodsRealListByDiscountTidTotal" resultType="int">
        select count(*)
        FROM
        mall_product_store_rela s
        LEFT JOIN mk_store_topic_goods_temp g ON s.id = g.store_rela_id AND g.guid = #{guid} and g.is_valid = '0' and g.is_button_cannel = '0'
        LEFT JOIN mall_goods gs ON s.goods_id = gs.id
        LEFT JOIN mall_store st ON st.id =  s.store_id
        WHERE  1=1 and gs.is_delete = 0
        <if test="storeId != null and storeId != '' ">
            AND s.store_id = #{storeId}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND s.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND st.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="goodsBizType != null and goodsBizType != '' ">
            AND gs.goods_biz_type = #{goodsBizType}
        </if>
        <if test="goodsName != null and goodsName != '' ">
            AND gs.name LIKE concat('%',#{goodsName},'%')
        </if>
    </select>

    <select id="queryGoodsRealListByTopicId" resultType="com.kmall.admin.entity.ProductStoreRelaEntity">
        SELECT
        s.id,
        s.goods_id,
        s.retail_price,
        g.store_rela_id 'isCheck',
        g.apply_type applyType,
        gs.NAME 'goodsName',
        g.disc_good_temp_id 'discGoodTempId',
        g.store_topic_id 'storeTopicId',
        gs.goods_number goodsNumber,
        s.stock_num,
        gs.list_pic_url
        FROM
        mall_product_store_rela s
        LEFT JOIN mk_store_topic_goods_temp g ON s.id = g.store_rela_id and g.is_valid = '0' and g.is_button_cannel = '0'
        <if test="storeTopicId != null and storeTopicId != '' ">
            and g.store_topic_id = #{storeTopicId}
        </if>
        LEFT JOIN mall_goods gs ON s.goods_id = gs.id
        WHERE  1=1 and gs.is_delete = 0
        <if test="storeId != null and storeId != '' ">
            AND s.store_id = #{storeId}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND s.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND st.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="goodsBizType != null and goodsBizType != '' ">
            AND gs.goods_biz_type = #{goodsBizType}
        </if>
        <if test="goodsName != null and goodsName != '' ">
            AND gs.name LIKE concat('%',#{goodsName},'%')
        </if>
        order by s.id desc
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryGoodsRealListByTopicIdTotal" resultType="int">
        select count(*)
        FROM
        mall_product_store_rela s
        LEFT JOIN mk_store_topic_goods_temp g ON s.id = g.store_rela_id and g.is_valid = '0' and g.is_button_cannel = '0'
        <if test="storeTopicId != null and storeTopicId != '' ">
            and g.store_topic_id = #{storeTopicId}
        </if>
        LEFT JOIN mall_goods gs ON s.goods_id = gs.id
        WHERE  1=1 and gs.is_delete = 0
        <if test="storeId != null and storeId != '' ">
            AND s.store_id = #{storeId}
        </if>
        <if test="merchSn != null and merchSn.trim() != '' ">
            AND s.merch_sn = #{merchSn}
        </if>
        <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
            AND st.third_party_merch_code = #{thirdPartyMerchCode}
        </if>
        <if test="goodsBizType != null and goodsBizType != '' ">
            AND gs.goods_biz_type = #{goodsBizType}
        </if>
        <if test="goodsName != null and goodsName != '' ">
            AND gs.name LIKE concat('%',#{goodsName},'%')
        </if>
    </select>

</mapper>