<?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.hzs.activity.recommend.mapper.AcRepurCouponsRuleConfigMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="AcRepurCouponsRuleConfig" type="com.hzs.common.domain.activity.recommend.AcRepurCouponsRuleConfig">
        <id column="PK_ID" property="pkId"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="PK_BASE_ID" property="pkBaseId"/>
        <result column="ORDER_TYPE" property="orderType"/>
        <result column="ORDER_AMOUNT" property="orderAmount"/>
        <result column="ORDER_ACHIEVE" property="orderAchieve"/>
        <result column="RATIO_TYPE" property="ratioType"/>
        <result column="RATIO_VALUE" property="ratioValue"/>
    </resultMap>

    <select id="queryAcRepurchaseCouponsRule" resultMap="AcRepurCouponsRuleConfig">
        select dr.pk_base_id,dr.order_type,dr.order_amount,dr.order_achieve,dr.ratio_type,
        dr.ratio_value,ba.pk_country from ac_base_config ba
        inner join AC_REPUR_COUPONS_RULE_CONFIG dr
        on dr.pk_base_id = ba.pk_id
        where ba.del_flag = 0 and dr.del_flag=0
        and ba.act_start_date &lt;= #{settleDate, jdbcType=DATE} and ba.act_end_date >= #{settleDate, jdbcType=DATE}
        order by dr.pk_base_id,dr.ORDER_ACHIEVE desc
    </select>

</mapper>
