<?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.caimei.www.mapper.CommonDao">
	<select id="getActivityPriceByProductId" resultType="com.caimei.www.pojo.order.ActivityPrice">
        select	ca.id,
        		cpa.productId,
        		cpa.actPrice as price,
        		ca.startTime as beginTime,
        		ca.endTime as endTime
        from cm_product_activity cpa
        left join cm_activity ca on cpa.activityId = ca.id
        where cpa.productId = #{productId}
        and ca.startTime <![CDATA[ <= ]]> NOW()
        and NOW() <![CDATA[ <= ]]> ca.endTime
        and cpa.delFlag = 0
	</select>
	<select id="getladderPricesByProductId" resultType="com.caimei.www.pojo.order.LadderPrice">
        select
        	id, productId, ladderNum, buyNum, buyPrice
        from product_ladder_price
        where productId = #{productId} and userType = 3 and delFlag = 0
        order by ladderNum asc
	</select>
	<select id="getRepurchasePrice" resultType="java.lang.Double">
        select
          r.currentPrice
        from repeat_purchase_price r
        left join product p on p.productID = r.productId
        where r.productId = #{productId} and userId = #{userId}
        and ((p.costCheckFlag=1 and r.currentPrice <![CDATA[ >= ]]> p.costPrice) or p.costCheckFlag=0)
        and r.delFlag = 0
	</select>

</mapper>
