<?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.AcRecomUpgradeRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.activity.recommend.AcRecomUpgradeRecord">
        <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="PK_RULE_ID" property="pkRuleId"/>
        <result column="PK_MEMBER" property="pkMember"/>
        <result column="PK_SETTLE_GRADE" property="pkSettleGrade"/>
        <result column="PK_RECOMMEND_GRADE" property="pkRecommendGrade"/>
        <result column="PK_ORDER_ID" property="pkOrderId"/>
        <result column="UPGRADE_STATUS" property="upGradeStatus"/>
    </resultMap>

    <select id="selectUpgradeRecordByOrderId" resultMap="BaseResultMap">
        select *
        from ac_recom_upgrade_record r
        where r.del_flag = 0
          and r.pk_order_id = #{pkOrderId}
          and r.creation_time >= #{startDate}
          and r.creation_time &lt; #{endDate} + 1
    </select>

    <select id="selectRecommendNumber" resultType="long">
        select r.pk_id
        from ac_recom_upgrade_record r
        where r.del_flag = 0
          and r.pk_country = #{pkCountry}
          and r.pk_member = #{pkMember}
          and r.pk_settle_grade = #{pkSettleGrade}
          and r.pk_recommend_grade >= #{pkRecommendGrade}
          and r.upgrade_status = #{upgradeStatus}
    </select>

</mapper>
