<?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="cn.pluss.platform.mapper.UserLevelMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.UserLevel">
        <id column="id" property="id" />
        <result column="roleCode" property="roleCode" />
        <result column="levelName" property="levelName" />
        <result column="levelCode" property="levelCode" />
        <result column="rate" property="rate" />
        <result column="quota" property="quota" />
        <result column="directRate" property="directRate" />
        <result column="indirectRate" property="indirectRate" />
        <result column="t2Scale" property="t2Scale" />
        <result column="t3Scale" property="t3Scale" />
        <result column="dividScale" property="dividScale" />
        <result column="areaScale" property="areaScale" />
        <result column="createTime" property="createTime" />
    </resultMap>

    <select id="getLevelInfoByRole" resultType="cn.pluss.platform.vo.UserLevelVO">
        SELECT levelName,roleCode,quota,rate,levelCode from tb_pluss_user_level
        where roleCode = #{roleCode}
        <if test="type == 1">
            and roleCode != 'LV10'
        </if>
    </select>

    <select id="getNowQuotaLevel" resultType="cn.pluss.platform.entity.UserLevel">
        SELECT * from tb_pluss_user_level WHERE quota <![CDATA[<=]]> #{flow} ORDER BY quota desc limit 1;
    </select>
</mapper>
