package com.hfkj.dao;

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

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

    @Select("<script>" +
            " select " +
            " b.header_img," +
            " b.user_name," +
            " b.phone," +
            " b.`status`," +
            " a.create_time" +
            " from bs_user_spread_rel a " +
            " LEFT JOIN bs_user b on b.id = a.user_id" +
            " where a.parent_user_id = #{param.parentUserId}" +
            " <if test='param.phone != null'> and b.phone like concat('%',#{param.phone},'%') </if>" +
            " ORDER BY a.create_time desc" +
            "</script>")
    List<HashMap<String,Object>> getTeamList(@Param("param") Map<String,Object> param);
    @Select("<script>" +
            " select " +
            " c.id userId," +
            " c.user_name userName," +
            " c.phone," +
            " b.amount," +
            " b.cash_out_amount cashOutAmount," +
            " a.create_time createTime," +
            " a.status," +
            " count(d.id) spreadCount" +
            " from bs_user_spread_power a" +
            " LEFT JOIN bs_user_spread_account b on b.user_id = a.user_id" +
            " LEFT JOIN bs_user c on c.id = a.user_id" +
            " LEFT JOIN bs_user_spread_rel d on d.parent_user_id = a.user_id" +
            " where 1 = 1" +
            " <if test='param.phone != null'> and c.phone like concat('%',#{param.phone},'%') </if>" +
            " GROUP BY c.id" +
            " ORDER BY spreadCount desc" +
            "</script>")
    List<HashMap<String,Object>> getUserSpreadList(@Param("param") Map<String,Object> param);

}
