package com.hfkj.dao;

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

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

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

    @Select("<script>" +
            " SELECT" +
            " b.province_name provinceName," +
            " b.city_name cityName," +
            " b.area_name areaName," +
            " b.mer_no merNo," +
            " b.mer_name merName," +
            " b.address," +
            " a.amount," +
            " c.amount merAmount " +
            " FROM" +
            " bs_agent_mer_account a" +
            " LEFT JOIN bs_merchant b ON a.mer_no = b.mer_no" +
            " LEFT JOIN bs_merchant_account c on c.mer_id = b.id" +
            " where 1 = 1 and a.status = 1" +
            " <if test='param.agentStaffId != null'>  and a.mer_id in (select mer_id from bs_agent_mer where agent_staff_id = #{param.agentStaffId} and `status` = 1) </if>" +
            " <if test='param.provinceCode != null'> and b.province_code = #{param.provinceCode} </if>" +
            " <if test='param.cityCode != null'> and b.city_code = #{param.cityCode} </if>" +
            " <if test='param.areaCode != null'> and b.area_code = #{param.areaCode} </if>" +
            " <if test='param.agentId != null'> and a.agent_id = #{param.agentId} </if>" +
            " <if test='param.merNo != null'> and b.mer_no like concat('%',#{param.merNo},'%') </if>" +
            " <if test='param.merName != null'> and b.mer_name like concat('%',#{param.merName},'%') </if>" +
            " ORDER BY a.amount asc" +
            "</script>")
    List<Map<String,Object>> selectMerList(@Param("param") Map<String,Object> param);

}
