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

    <select id="queryRangeDto" resultType="com.hzs.system.config.dto.RangeDTO">
        select br.range_name, br.range_value, bd.pk_range, bd.range_type, bd.pk_level, br.pk_country, (100 - br.achieve_ratio) achieve_ratio
        from bd_range br
        inner join bd_range_details bd
        on br.pk_id = bd.pk_range
        where br.del_flag = 0
        and bd.del_flag = 0
        <if test="pkCountry != null">
            and br.pk_country = #{pkCountry}
        </if>
        <if test="rangeType != null">
            and bd.range_type = #{rangeType}
        </if>
        <if test="pkLevel != null">
            and bd.pk_level = #{pkLevel}
        </if>
        order by br.pk_country, pk_range, range_type, pk_level
    </select>

</mapper>
