IMPromotionMapper.xml 3.9 KB
<?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.sibu.orderHelper.integral.dao.IMPromotionDao">
    
    <!-- 促销规则 -->
    <select id="getValidPromotionRule" resultMap="listPromotionRule">
    	SELECT
			id,is_limit,limit_num,type 
		FROM
			promotion_rule 
		WHERE
			start_date &lt;= #{currentDate} and end_date >= #{currentDate} and is_delete = 0 and status = 1
    </select>
    <!-- 促销规则 -->
    <select id="getValidPromotionRuleByTypeAndCurrentDate" resultMap="listPromotionRule">
        SELECT
        id,is_limit,limit_num,type
        FROM
        promotion_rule
        WHERE
        start_date &lt;= #{currentDate} and end_date >= #{currentDate} and is_delete = 0 and status = 1 and type = #{type}
    </select>
    <!-- 促销规则 -->
    <select id="getValidPromotionRuleByTypeAndCurrentDateAndSupplierId" resultMap="listPromotionRule">
        SELECT
        id,is_limit,limit_num,type,supplier_id,platform_type
        FROM
        promotion_rule
        WHERE
        start_date &lt;= #{currentDate} and end_date >= #{currentDate} and is_delete = 0 and status = 1 and type = #{type} and supplier_id=#{supplierId}
    </select>

	<resultMap type="com.sibu.orderHelper.integral.reponse.PromotionRuleResponse" id="listPromotionRule">
        <result column="id" property="id" />
        <result column="is_limit" property="isLimit" />
        <result column="limit_num" property="limitNum" />
        <result column="type" property="type" />
        <result column="supplier_id" property="supplierId" />
        <result column="platform_type" property="platformType" />
    </resultMap>
    
    <!-- 订单满送 -->
    <select id="getMoneyPromotionById" resultMap="listMoneyPromotion">
    	select id,buy_money,gift_product_id,gift_num,gift_total,status from promotion_money_gift where promotion_id = ${promotionId} and buy_money &lt;= ${orderTotal} and is_delete = 0 order by buy_money desc limit 1 
    </select>
    <!-- 订单满送 -->
    <select id="getTheMostMoneyPromotionById" resultMap="listMoneyPromotion">
        select id,buy_money,gift_product_id,gift_num,gift_total,status from promotion_money_gift where promotion_id = ${promotionId} and buy_money &lt;= ${orderTotal} and is_delete = 0 order by buy_money desc limit 1
    </select>
    <resultMap type="com.sibu.orderHelper.integral.reponse.PromotionMoneyResponse" id="listMoneyPromotion">
    	<result column="id" property="id" />
        <result column="buy_money" property="buyMoney" />
        <result column="gift_product_id" property="giftProductId" />
        <result column="gift_num" property="giftNum" />
        <result column="gift_total" property="giftTotal" />
        <result column="status" property="status" />
    </resultMap>
    
    <!--商品买一送一 -->
    <select id="getProductPromotionById" resultMap="listProductPromotion">
    	select id,buy_product_id,buy_limit_num,gift_product_id,gift_num,gift_total,status from promotion_product_gift where promotion_id = ${promotionId} and is_delete = 0 
    </select>
    <!--商品买一送一 -->
    <select id="getProductPromotionById2" resultMap="listProductPromotion">
        select id,buy_product_id,buy_limit_num,gift_product_id,gift_num,gift_total,status from promotion_product_gift where promotion_id = ${promotionId} and is_delete = 0
    </select>
    <resultMap type="com.sibu.orderHelper.integral.reponse.PromotionProductResponse" id="listProductPromotion">
    	<result column="id" property="id" />
        <result column="buy_product_id" property="buyProductId" />
        <result column="buy_limit_num" property="buyLimitNum" />
        <result column="gift_product_id" property="giftProductId" />
        <result column="gift_num" property="giftNum" />
        <result column="gift_total" property="giftTotal" />
        <result column="status" property="status" />
    </resultMap>
</mapper>