<?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.system.config.mapper.BdStoreLevelMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BdStoreLevelExt" type="com.hzs.common.domain.system.config.ext.BdStoreLevelExt">
        <id column="PK_ID" property="pkId" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_COUNTRY" property="pkCountry" />
        <result column="CREATION_TIME" property="creationTime" />
        <result column="MODIFIED_TIME" property="modifiedTime" />
        <result column="PK_CREATOR" property="pkCreator" />
        <result column="PK_MODIFIED" property="pkModified" />
        <result column="STORE_LEVEL_NAME" property="storeLevelName" />
        <result column="LEVEL_VALUE" property="levelValue" />
        <result column="PK_TRANSACTION" property="pkTransaction" />
        <collection property="storeLevelDetailList" ofType="com.hzs.common.domain.system.config.BdStoreLevelDetail" >
            <result column="RATIO" property="ratio" />
            <result column="END_ACHIEVEMENT" property="endAchievement" />
        </collection>
    </resultMap>

    <select id="queryStoreLevel" resultMap="BdStoreLevelExt">
        select bl.pk_id,bl.pk_country,bl.level_value,bd.end_achievement,bd.ratio from bd_store_level bl
        inner join bd_store_level_detail bd
        on bl.pk_id = bd.pk_store_level
        where bl.del_flag = 0 and bd.del_flag = 0 and bl.enable_state = 0
        order by bd.pk_id,bd.end_achievement desc
    </select>

</mapper>
