<?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.yami.shop.distribution.comment.dao.DistributionLevelMapper">
    <resultMap id="BaseResultMap" type="com.yami.shop.distribution.comment.model.DistributionLevel">
        <id column="level_id" jdbcType="BIGINT" property="levelId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="condition_data" jdbcType="VARCHAR" property="conditionData"/>
        <result column="level" jdbcType="INTEGER" property="level"/>
        <result column="state" jdbcType="TINYINT" property="state"/>
        <result column="award_number" jdbcType="DECIMAL" property="awardNumber"/>
        <result column="parent_award_number" jdbcType="DECIMAL" property="parentAwardNumber"/>
    </resultMap>


    <select id="geyByShopId" resultMap="BaseResultMap">
      select
        dl.level_id,
        dl.name,
        dl.condition_data,
        dl.level,
        dl.award_number,
        dl.parent_award_number
      from tz_distribution_level dl
      where shop_id=#{shopId}
      order by
      level
  </select>

    <resultMap id="DistributionAwardDataVO" type="com.yami.shop.distribution.comment.vo.DistributionAwardDataVO">
        <result column="award_number" jdbcType="DECIMAL" property="awardNumber"/>
        <result column="parent_award_number" jdbcType="DECIMAL" property="parentAwardNumber"/>
    </resultMap>
    <select id="getDistributionAwardDataVOByLevelId" resultMap="DistributionAwardDataVO">
        select
        award_number,
        parent_award_number
        from
        tz_distribution_level
        where
        level_id = #{levelId}
    </select>

    <!--获取默认等级id-->
    <select id="getDistributionDefaultLevel" resultType="long">
        select * from
        tz_distribution_level
        where
        shop_id =#{shopId}
        and
        level = 1
    </select>

    <!--<select id="getDistributionLevelDtoByShopId" resultType="com.yami.shop.distribution.comment.dto.DistributionLevelDto">-->
    <!--select-->
    <!--level_id,-->
    <!--name,-->
    <!--condition_data,-->
    <!--level-->
    <!--from tz_distribution_level-->
    <!--where shop_id=#{shopId}-->
    <!--order by-->
    <!--level-->
    <!--</select>-->

    <!--<select id="getDistributionLevelDtoByDistributionUserId" resultType="com.yami.shop.distribution.comment.dto.DistributionLevelDto">-->
    <!--select-->
    <!--dl.level_id,-->
    <!--dl.name,-->
    <!--dl.condition_data,-->
    <!--dl.level-->
    <!--from tz_distribution_level dl right join-->
    <!--tz_distribution_user du on du.level_id = dl.level_id-->
    <!--where-->
    <!--du.distribution_user_id = #{distributionUserId}-->
    <!--</select>-->

    <!--<select id="getConditionDataByLevelId" resultType="string">-->
    <!--select-->
    <!--condition_data-->
    <!--from tz_distribution_level-->
    <!--where-->
    <!--level_id=#{levelId}-->
    <!--</select>-->


    <!--<select id="getSeniorLevelIdByDistributionUserId" resultType="com.yami.shop.distribution.comment.vo.DistributionLevelVO">-->
    <!--select-->
    <!--level_id,-->
    <!--name-->
    <!--from tz_distribution_level-->
    <!--where shop_id = #{shopId}-->
    <!--and level = (select dl.level from tz_distribution_user du-->
    <!--left join  tz_distribution_level dl on du.level_id=dl.level_id-->
    <!--where distribution_user_id = #{distributionUserId})+1-->
    <!--</select>-->


</mapper>