123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <?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.mk.ApiMkStoreTicketDiscountGoodsMapper">
- <resultMap type="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo" id="mkStoreTicketDiscountGoodsMap">
- <result property="discGoodId" column="disc_good_id"/>
- <result property="tickDiscId" column="tick_disc_id"/>
- <result property="applyType" column="apply_type"/>
- <result property="storeRelaId" column="store_rela_id"/>
- <result property="isValid" column="is_valid"/>
- <result property="note" column="note"/>
- <result property="createrSn" column="creater_sn"/>
- <result property="createTime" column="create_time"/>
- <result property="moderSn" column="moder_sn"/>
- <result property="modTime" column="mod_time"/>
- <result property="tstm" column="tstm"/>
- </resultMap>
- <!-- 可根据自己的需求,是否要使用 -->
- <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"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo">
- select
- `disc_good_id`,
- `tick_disc_id`,
- `apply_type`,
- `store_rela_id`,
- `is_valid`,
- `note`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`,
- `tstm`
- from mk_store_ticket_discount_goods
- where disc_good_id = #{id}
- </select>
- <select id="queryObjectByStoreReal" resultType="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo">
- select
- `disc_good_id`,
- `tick_disc_id`,
- `apply_type`,
- `store_rela_id`,
- `is_valid`,
- `note`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`,
- `tstm`
- from mk_store_ticket_discount_goods
- where tick_disc_id = #{tickDiscId} and store_rela_id = #{storeRelaId} and apply_type = #{applyType}
- </select>
- <select id="queryList" resultType="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo">
- select
- `disc_good_id`,
- `tick_disc_id`,
- `apply_type`,
- `store_rela_id`,
- `is_valid`,
- `note`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`,
- `tstm`
- from mk_store_ticket_discount_goods
- WHERE 1=1
- <if test="name != null and name.trim() != ''">
- AND name LIKE concat('%',#{name},'%')
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by disc_good_id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
-
- <select id="queryTotal" resultType="int">
- select count(*) from mk_store_ticket_discount_goods
- WHERE 1=1
- <if test="name != null and name.trim() != ''">
- AND name LIKE concat('%',#{name},'%')
- </if>
- </select>
- <select id="queryDiscountGoodsList" 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 mk_store_ticket_discount_goods g ON psr1.id = g.store_rela_id
- <if test="tickDiscId != null and tickDiscId != ''">
- and g.tick_disc_id = #{tickDiscId}
- </if>
- LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = a.third_party_merch_code
- AND mb.merch_sn = a.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
- <if test="applyType != null and applyType == '01'">
- <if test="tickDiscId != null and tickDiscId != ''">
- and g.tick_disc_id = #{tickDiscId}
- </if>
- </if>
- <if test="applyType != null and applyType == '02'">
- and psr1.id not in(SELECT store_rela_id FROM mk_store_ticket_discount_goods WHERE tick_disc_id = #{tickDiscId})
- </if>
- <if test="isStockShare == 1">
- and (a.goods_number > 0 or psr1.stock_num > 0 )
- </if>
- <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="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="goodsId != null and goodsId != ''">
- and a.id = #{goodsId}
- </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="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>
- <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="queryDiscountGoodsTotal" 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 mk_store_ticket_discount_goods g ON psr1.id = g.store_rela_id
- <if test="tickDiscId != null and tickDiscId != ''">
- and g.tick_disc_id = #{tickDiscId}
- </if>
- LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = a.third_party_merch_code
- AND mb.merch_sn = a.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
- <if test="applyType != null and applyType == '01'">
- <if test="tickDiscId != null and tickDiscId != ''">
- and g.tick_disc_id = #{tickDiscId}
- </if>
- </if>
- <if test="applyType != null and applyType == '02'">
- and psr1.id not in(SELECT store_rela_id FROM mk_store_ticket_discount_goods WHERE tick_disc_id = #{tickDiscId})
- </if>
- <if test="isStockShare == 1">
- and (a.goods_number > 0 or psr1.stock_num > 0 )
- </if>
- <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="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="goodsId != null and goodsId != ''">
- and a.id = #{goodsId}
- </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="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>
- </mapper>
|