package com.hai.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsDistributionUserRelMapperExt {


    @Select({
            "<script> " +
                    " select agent_id as agentId , agent_name as agentName from bs_distribution_user_rel where status = 100 group by agent_id " +
                    "</script>"
    })
    List<Map<String , Object>> getDistributionAgent();

    @Select({
            "<script> " +
                    " select user_id as userId , user_name  as userName from bs_distribution_user_rel where popularize_user_id is null and status = 100   " +
                    "<if test='agentId != null'> and agent_id  = #{agentId} </if>" +
                    " group by user_id; " +
                    "</script>"
    })
    List<Map<String , Object>> getDistributionFirst(@Param("agentId") Long agentId);

    @Select({
            "<script> " +
                    " select user_id as userId , user_name  as userName from bs_distribution_user_rel where   status = 100   " +
                    "<if test='agentId != null'> and agent_id  = #{agentId} </if>" +
                    "<if test='popularizeUserId != null'> and popularize_user_id  = #{popularizeUserId} </if>" +
                    "<if test='popularizeUserId == null'> and popularize_user_id  is not null </if>" +
                    " group by user_id; " +
                    "</script>"
    })
    List<Map<String , Object>> getDistributionSecond(@Param("agentId") Long agentId , @Param("popularizeUserId") Long popularizeUserId);

}
