123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- <?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.api.dao.ApiGoodsMapper">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.kmall.api.entity.GoodsVo" id="goodsMap">
- <result property="id" column="id"/>
- <result property="category_id" column="category_id"/>
- <result property="goods_sn" column="goods_sn"/>
- <result property="name" column="name"/>
- <result property="brand_id" column="brand_id"/>
- <result property="goods_number" column="goods_number"/>
- <result property="keywords" column="keywords"/>
- <result property="goods_brief" column="goods_brief"/>
- <result property="goods_desc" column="goods_desc"/>
- <result property="is_on_sale" column="is_on_sale"/>
- <result property="add_time" column="add_time"/>
- <result property="sort_order" column="sort_order"/>
- <result property="is_delete" column="is_delete"/>
- <result property="attribute_category" column="attribute_category"/>
- <result property="counter_price" column="counter_price"/>
- <result property="extra_price" column="extra_price"/>
- <result property="is_new" column="is_new"/>
- <result property="goods_unit" column="goods_unit"/>
- <result property="primary_pic_url" column="primary_pic_url"/>
- <result property="list_pic_url" column="list_pic_url"/>
- <result property="retail_price" column="retail_price"/>
- <result property="market_price" column="market_price"/>
- <result property="sell_volume" column="sell_volume"/>
- <result property="primary_product_id" column="primary_product_id"/>
- <result property="unit_price" column="unit_price"/>
- <result property="promotion_desc" column="promotion_desc"/>
- <result property="promotion_tag" column="promotion_tag"/>
- <result property="app_exclusive_price" column="app_exclusive_price"/>
- <result property="is_app_exclusive" column="is_app_exclusive"/>
- <result property="is_limited" column="is_limited"/>
- <result property="is_hot" column="is_hot"/>
- <result property="product_id" column="product_id"/>
- <result property="sku" column="sku"/>
- <result property="goodsBizType" column="goods_biz_type"/>
- <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
- <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
- <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
- <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
- <result property="goodsRate" column="goods_rate"/>
- <result property="stockNum" column="stock_num"/>
- <result property="storeId" column="store_id"/>
- <result property="merchSn" column="merch_sn"/>
- <result property="merchName" column="merch_name"/>
- <result column="third_party_merch_code" property="thirdPartyMerchCode" />
- <result column="isStockShare" property="isStockShare" />
- <result property="goods_sell_volume" column="goods_sell_volume"/>
- <result property="isGoodsShareStock" column="is_goods_share_stock"/>
- </resultMap>
- <sql id="Base_Column_List" >
- id, goods_sn, sku, goods_biz_type, name, goods_number, keywords,
- goods_brief, is_on_sale, add_time, sort_order, is_delete, counter_price,
- extra_price, is_new, goods_unit, primary_pic_url, list_pic_url, retail_price, sell_volume,
- primary_product_id, unit_price, promotion_desc, promotion_tag, app_exclusive_price,
- is_app_exclusive, is_limited, is_hot, market_price, creater_sn, create_time, moder_sn,
- mod_time, tstm,goods_desc,goods_rate,third_party_merch_code
- </sql>
- <select id="queryObject" resultMap="goodsMap">
- select a.id,
- a.goods_sn,
- a.name,
- a.goods_number,
- a.keywords,
- a.goods_brief,
- a.is_on_sale,
- a.add_time,
- a.sort_order,
- a.is_delete,
- a.counter_price,
- a.extra_price,
- a.is_new,
- a.goods_unit,
- a.primary_pic_url,
- a.list_pic_url,
- a.sell_volume,
- a.primary_product_id,
- a.unit_price,
- a.promotion_desc,
- a.promotion_tag,
- a.app_exclusive_price,
- a.is_app_exclusive,
- a.is_limited,
- a.is_hot,
- a.merch_sn,
- a.goods_desc,a.goods_biz_type,a.goods_rate,a.third_party_merch_code
- from mall_goods a
- where a.id = #{value}
- </select>
- <select id="queryObjectByStoreId" resultMap="goodsMap">
- select
- a.sku,
- a.id,
- psr1.category_id,
- a.goods_sn,
- a.name,
- psr1.brand_id,
- a.goods_number,
- a.keywords,
- a.goods_brief,
- a.is_on_sale,
- a.add_time,
- a.sort_order,
- a.is_delete,
- psr1.attribute_category,
- a.counter_price,
- a.extra_price,
- a.is_new,
- a.goods_unit,
- a.primary_pic_url,
- a.list_pic_url,
- psr1.retail_price,
- psr1.sell_volume,
- a.primary_product_id,
- a.unit_price,
- a.promotion_desc,
- a.promotion_tag,
- a.app_exclusive_price,
- a.is_app_exclusive,
- a.is_limited,
- a.is_hot,
- a.merch_sn,
- m.merch_name,
- psr1.store_id,
- psr1.market_price,
- psr1.stock_num,
- a.goods_desc,a.goods_biz_type,a.goods_rate,
- a.sell_volume goods_sell_volume,
- mb.third_party_merch_code,
- mb.is_stock_share isStockShare,
- mb.is_supplier_goods 'isSupplierGoods',
- mb2.third_party_merch_code 'supplierThirdMerchCode',
- mb2.is_stock_share 'isStockShareBySuppler',psr1.product_id
- from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
- LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
- LEFT JOIN mall_store s ON s.id = psr1.store_id
- LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
- LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
- where a.id = #{id} and psr1.store_id = #{storeId}
- </select>
- <select id="queryList" resultMap="goodsMap">
- select
- <if test="fields != null and fields != ''">
- ${fields}
- </if>
- <if test="fields == null or fields == ''">
- a.*
- </if>
- ,psr1.stock_num,psr1.category_id,psr1.brand_id,psr1.attribute_category,a.third_party_merch_code
- ,a.goods_biz_type,a.goods_number,mb.is_stock_share isStockShare,psr1.store_id
- from mall_goods a
- LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
- LEFT JOIN mall_store s ON s.id = psr1.store_id
- left join third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code and mb.merch_sn=s.merch_sn
- LEFT JOIN mall_product b ON b.id = psr1.product_id
- left join mall_category c on psr1.category_id = c.id
- where 1 = 1
- and a.is_delete != 1 and a.is_on_sale = 1
- <if test="is_new != null and is_new != ''">
- and a.is_new = #{is_new}
- </if>
- <if test="is_hot != null and is_hot != ''">
- and a.is_hot = #{is_hot}
- </if>
- <if test="brand_id != null and brand_id != ''">
- and psr1.brand_id = #{brand_id}
- </if>
- <if test="category_id != null and category_id != ''">
- and psr1.category_id = #{category_id}
- </if>
- <if test="keyword != null">
- and a.name like concat('%',#{keyword},'%')
- </if>
- <if test="is_delete != null">
- and a.is_delete = #{is_delete}
- </if>
- <if test="goodsBizType != null">
- and a.goods_biz_type = #{goodsBizType}
- </if>
- <if test="notGoodsBizType == true">
- and a.goods_biz_type in ('00','11')
- </if>
- <if test="categoryIds != null">
- and psr1.category_id in
- <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
- and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="category_parent_id != null and category_parent_id != null and category_parent_id == 0">
- and FIND_IN_SET(c.parent_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="goods_ids != null">
- and a.id in
- <foreach item="item" collection="goods_ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="store_id != null and store_id != ''">
- and psr1.store_id = #{store_id}
- and c.store_id = #{store_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="queryHotGoodsList" resultMap="goodsMap">
- select
- <if test="fields != null and fields != ''">
- ${fields}
- </if>
- <if test="fields == null or fields == ''">
- a.*,b.id as product_id,psr1.category_id,psr1.brand_id,psr1.attribute_category
- </if>
- ,a.goods_biz_type,
- a.goods_number,
- a.third_party_merch_code third_party_merch_code,
- mb.is_stock_share isStockShare,psr1.store_id,
- ( SELECT sum( number ) FROM mall_cart WHERE goods_id = a.id AND store_id = psr1.store_id ) cart_num
- FROM
- mall_goods a
- LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id AND a.merch_sn = psr1.merch_sn
- LEFT JOIN mall_store s ON psr1.store_id = s.id
- LEFT JOIN third_merchant_biz mb ON s.third_party_merch_code = mb.third_party_merch_code AND mb.merch_sn = s.merch_sn
- LEFT JOIN mall_product b ON b.id = psr1.product_id
- LEFT JOIN mall_category c ON psr1.category_id = c.id
- where 1 = 1 and a.goods_number > 0
- <if test="isStockShare == 0">
- and psr1.stock_num > 0
- </if>
- and b.id is not null and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
- <if test="is_new != null and is_new != ''">
- and a.is_new = #{is_new}
- </if>
- <if test="is_hot != null and is_hot != ''">
- and a.is_hot = #{is_hot}
- </if>
- <if test="brand_id != null and brand_id != ''">
- and psr1.brand_id = #{brand_id}
- </if>
- <if test="category_id != null and category_id != ''">
- and psr1.category_id = #{category_id}
- </if>
- <if test="keyword != null">
- and a.keywords like concat('%',#{keyword},'%')
- </if>
- <if test="categoryIds != null">
- and psr1.category_id in
- <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
- and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="category_parent_id != null and category_parent_id != null and category_parent_id == 0">
- and c.parent_id = psr1.attribute_category
- </if>
- <if test="goods_ids != null">
- and a.id in
- <foreach item="item" collection="goods_ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="store_id != null and store_id != ''">
- and psr1.store_id = #{store_id}
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by psr1.hot_sort_num asc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryCatalogProductList" resultMap="goodsMap">
- select a.id, a.name, a.list_pic_url,psr1.category_id,psr1.brand_id,psr1.attribute_category , psr1.market_price, psr1.retail_price, a.goods_brief, b.id AS product_id,
- psr1.stock_num,a.third_party_merch_code,a.goods_biz_type,a.goods_number,
- mb.is_stock_share isStockShare,psr1.store_id ,
- ( SELECT sum( number ) FROM mall_cart WHERE goods_id = a.id AND store_id = psr1.store_id ) cart_num
- <if test="is_group != null and is_group == true">
- ,gg.id as group_id
- </if>
- FROM
- mall_goods a
- LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
- LEFT JOIN mall_store s ON s.id = psr1.store_id
- LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code and mb.merch_sn=s.merch_sn
- LEFT JOIN mall_product b ON b.id = psr1.product_id
- <if test="is_group != null and is_group == true">
- LEFT JOIN mall_goods_group gg on gg.goods_id = a.id
- </if>
- WHERE
- 1 = 1 and b.id > 0 and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
- <if test="is_new != null and is_new != ''">
- and a.is_new = #{is_new}
- </if>
- <if test="is_hot != null and is_hot != ''">
- and a.is_hot = #{is_hot}
- </if>
- <if test="brand_id != null and brand_id != ''">
- and psr1.brand_id = #{brand_id}
- </if>
- <if test="name != null and name != ''">
- and a.'name' like concat('%',#{keyword},'%')
- </if>
- <if test="category_id != null and category_id != ''">
- and psr1.category_id = #{category_id}
- </if>
- <if test="keyword != null">
- and a.keywords like concat('%',#{keyword},'%')
- </if>
- <if test="is_group != null and is_group == true">
- and gg.id is not null
- </if>
- <if test="categoryIds != null">
- and psr1.category_id in
- <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="category_parent_id != null and category_parent_id != null">
- and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="goods_ids != null">
- and a.id in
- <foreach item="item" collection="goods_ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="store_id != null and store_id != ''">
- and psr1.store_id = #{store_id}
- </if>
- <if test="goodsBizType != null and goodsBizType != ''">
- and a.goods_biz_type = #{goodsBizType}
- </if>
- group by a.id, a.name, a.list_pic_url, psr1.market_price, psr1.retail_price, a.goods_brief, b.id
- <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(*)
- from mall_goods a
- LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
- LEFT JOIN mall_store s ON s.id = psr1.store_id
- left join third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code and mb.merch_sn=s.merch_sn
- LEFT JOIN mall_product b ON b.id = psr1.product_id
- left join mall_category c on psr1.category_id = c.id
- where 1 = 1
- and a.is_delete != 1 and a.is_on_sale = 1
- <if test="is_new != null and is_new != ''">
- and a.is_new = #{is_new}
- </if>
- <if test="is_hot != null and is_hot != ''">
- and a.is_hot = #{is_hot}
- </if>
- <if test="brand_id != null and brand_id != ''">
- and psr1.brand_id = #{brand_id}
- </if>
- <if test="category_id != null and category_id != ''">
- and psr1.category_id = #{category_id}
- </if>
- <if test="keyword != null">
- and a.name like concat('%',#{keyword},'%')
- </if>
- <if test="is_delete != null">
- and a.is_delete = #{is_delete}
- </if>
- <if test="goodsBizType != null">
- and a.goods_biz_type = #{goodsBizType}
- </if>
- <if test="notGoodsBizType == true">
- and a.goods_biz_type in ('00','11')
- </if>
- <if test="categoryIds != null">
- and psr1.category_id in
- <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
- and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="category_parent_id != null and category_parent_id != null and category_parent_id == 0">
- and FIND_IN_SET(c.parent_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="goods_ids != null">
- and a.id in
- <foreach item="item" collection="goods_ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="store_id != null and store_id != ''">
- and psr1.store_id = #{store_id}
- and c.store_id = #{store_id}
- </if>
- </select>
- <select id="selectCountByCatalogProductList" resultType="int">
- SELECT count(*) FROM
- mall_goods a
- LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
- LEFT JOIN mall_store s ON s.id = psr1.store_id
- LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code and mb.merch_sn=s.merch_sn
- LEFT JOIN mall_product b ON b.id = psr1.product_id
- <if test="is_group != null and is_group == true">
- LEFT JOIN mall_goods_group gg on gg.goods_id = a.id
- </if>
- WHERE
- 1 = 1 and b.id > 0 and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
- <if test="is_new != null and is_new != ''">
- and a.is_new = #{is_new}
- </if>
- <if test="is_hot != null and is_hot != ''">
- and a.is_hot = #{is_hot}
- </if>
- <if test="brand_id != null and brand_id != ''">
- and psr1.brand_id = #{brand_id}
- </if>
- <if test="name != null and name != ''">
- and a.'name' like concat('%',#{keyword},'%')
- </if>
- <if test="category_id != null and category_id != ''">
- and psr1.category_id = #{category_id}
- </if>
- <if test="keyword != null">
- and a.keywords like concat('%',#{keyword},'%')
- </if>
- <if test="is_group != null and is_group == true">
- and gg.id is not null
- </if>
- <if test="categoryIds != null">
- and psr1.category_id in
- <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="category_parent_id != null and category_parent_id != null">
- and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
- </if>
- <if test="goods_ids != null">
- and a.id in
- <foreach item="item" collection="goods_ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="store_id != null and store_id != ''">
- and psr1.store_id = #{store_id}
- </if>
- <if test="goodsBizType != null and goodsBizType != ''">
- and a.goods_biz_type = #{goodsBizType}
- </if>
- </select>
- <update id="updateGoodsStock" parameterType="com.kmall.api.entity.GoodsVo">
- update mall_goods a
- <set>
- <if test="goods_number != null">a.`goods_number` = #{goods_number},</if>
- <if test="sell_volume != null">a.`sell_volume` = #{sell_volume},</if>
- </set>
- where a.id = #{id}
- </update>
- <update id="updateByGoodsShareStock" parameterType="com.kmall.api.entity.GoodsVo">
- update mall_goods
- <set>
- <if test="isGoodsShareStock != null">`is_goods_share_stock` = #{isGoodsShareStock} </if>
- </set>
- where id = #{id}
- </update>
- </mapper>
|