package com.huiju.estateagents.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huiju.estateagents.entity.PersonIntention;
import com.huiju.estateagents.entity.TaPerson;
import com.huiju.estateagents.entity.TaPersonBuilding;
import com.huiju.estateagents.entity.TaRecommendCustomer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huiju.estateagents.excel.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 推荐客户表 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-05-10
 */
@Mapper
public interface TaRecommendCustomerMapper extends BaseMapper<TaRecommendCustomer> {

    Integer getMyCutsomerNum(@Param("personId") String personId);

    String getCustomerPersonId(@Param("customerId")String customerId);

    TaRecommendCustomer getCustomerDetail(@Param("customerId")String customerId,@Param("personId")String personId);

    TaRecommendCustomer getCustomerById(@Param("customerId")String customerId);

    IPage<TaRecommendCustomer> getCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId,@Param("status")Integer status, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList,@Param("sceneType") String sceneType, @Param("startCreateDate") String startCreateDate, @Param("endCreateDate") String endCreateDate);
    IPage<TaRecommendCustomer> getRecCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
    IPage<TaRecommendCustomer> getRepCustomerList(IPage<TaRecommendCustomer> page,@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
    IPage<TaPerson> getIndependentAgents(IPage<TaPerson>page, @Param("name") String name, @Param("tel") String tel, @Param("orgId") Integer orgId);

    /**
     * 公客
     * @param page
     * @param name
     * @param tel
     * @param entryType
     * @param verifyStatus
     * @param sex
     * @param personBuildingList
     * @return
     */
    IPage<TaPerson> getPublicCustomerList(IPage<TaPerson> page, @Param("name") String name, @Param("tel") String tel, @Param("entryType") String entryType, @Param("verifyStatus") String verifyStatus, @Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("consultTel") String consultTel, @Param("sceneType") String sceneType,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList,@Param("buildingId") String buildingId, @Param("startCreateDate") String startCreateDate, @Param("endCreateDate") String endCreateDate);

    /**
     * 导出数据 获取推荐用户数据
     * @param orgId
     * @return
     */
    List<ExcelRecommendCustomer> getRecCustomerExport(@Param("orgId") Integer orgId, @Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 导出数据 获取推荐用户数据 总数
     * @param orgId
     * @return
     */
    Integer getRecCustomerExportCount(@Param("orgId") Integer orgId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 导出数据 获取报备客户数据 总数
     * @param orgId
     * @return
     */
    Integer getRepCustomerReportCount(@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex,@Param("orgId")Integer orgId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 导出数据 获取报备客户数据
     * @param orgId
     * @return
     */
    List<ReporRecommendCustomer> getRepCustomerReportExport(@Param("building") String building, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 导出数据 获取经纪人数据 总数
     * @param orgId
     * @return
     */
    Integer getIndependentAgentsCount(@Param("orgId") Integer orgId);

    /**
     * 导出数据 获取经纪人数据
     * @param orgId
     * @param pageCode
     * @param pageSize
     * @return
     */
    List<AgentsRecommendCustomer> getIndependentAgentsExport(@Param("orgId") Integer orgId, @Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize);

    /**
     * 导出数据 公客总数
     * @param name
     * @param tel
     * @param entryType
     * @param verifyStatus
     * @param sex
     * @param orgId
     * @param consultTel
     * @return
     */
    Integer getPublicCustomerExportListCount(@Param("name") String name, @Param("tel") String tel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId,@Param("consultTel")String consultTel);

    /**
     * 导出数据 公客
     * @param name
     * @param tel
     * @param entryType
     * @param verifyStatus
     * @param sex
     * @param orgId
     * @param consultTel
     * @return
     */
    List<PublicCustomerExport> getPublicCustomerExportList(@Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize, @Param("buildingId")String buildingId, @Param("name") String name, @Param("tel") String tel, @Param("entryType") String entryType, @Param("verifyStatus") String verifyStatus, @Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("consultTel")String consultTel, @Param("sceneType")String sceneType,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 导出数据 私客总数
     * @param buildingId
     * @param name
     * @param tel
     * @param consultName
     * @param consultTel
     * @param entryType
     * @param verifyStatus
     * @param sex
     * @param orgId
     * @param status
     * @return
     */
    Integer getCustomerExportListCount(@Param("building") String buildingId, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel,@Param("entryType") String entryType,@Param("verifyStatus") String verifyStatus,@Param("sex") Integer sex, @Param("orgId") Integer orgId,@Param("status")Integer status,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 导出数据 私客
     * @param pageCode
     * @param pageSize
     * @param buildingId
     * @param name
     * @param tel
     * @param consultName
     * @param consultTel
     * @param entryType
     * @param verifyStatus
     * @param sex
     * @param orgId
     * @param status
     * @return
     */
    List<PrivateCustomerExport> getCustomerExportList(@Param("pageCode") Integer pageCode, @Param("pageSize") Integer pageSize, @Param("building") String buildingId, @Param("name") String name, @Param("tel") String tel, @Param("consultName") String consultName, @Param("consultTel") String consultTel, @Param("entryType") String entryType, @Param("verifyStatus") String verifyStatus, @Param("sex") Integer sex, @Param("orgId") Integer orgId, @Param("status")Integer status,@Param("sceneType") String sceneType,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);
    
    /**
     * 获取我的客户的人数统计
     * @param personId
     * @param userId
     * @return
     */
	Map<String, Object> getMyCustStatistics(@Param("personId") String personId,@Param("userId") Integer userId,@Param("orgId") Integer orgId);
    
    /**
     * 获取我的跟进客户数据
     * @param page
     * @param personId
     * @param userId
     * @param orgId
     * @param type
     * @param name
     * @param phone
     * @param status
     * @param startReportDate
     * @param endReportDate
     * @param startArrivalDate
     * @param endArrivalDate
     * @return
     */
    IPage<TaRecommendCustomer> getMyCustFollowOrClinch(IPage<TaRecommendCustomer> page, @Param("personId") String personId, @Param("userId") Integer userId, @Param("orgId") Integer orgId, @Param("type") String type, @Param("name") String name, @Param("phone") String phone, @Param("status") Integer status,@Param("startReportDate") String startReportDate,@Param("endReportDate") String endReportDate,@Param("startArrivalDate") String startArrivalDate,@Param("endArrivalDate") String endArrivalDate);
    
    /**
     * 获取我的客户详情数据
     * @param customerId
     * @return
     */
    TaRecommendCustomer getMyCustDetailById(String customerId);

    List<PersonIntention> getCustomerIntentions(@Param("personId")String personId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    IPage<TaRecommendCustomer>getCustomersIRecommended(IPage<TaRecommendCustomer> page,@Param("customerId")String customerId,@Param("status")Integer status,@Param("orgId") Integer orgId,@Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    IPage<TaRecommendCustomer> getCustomerListOfConsultant(IPage<TaRecommendCustomer> page,
                                                           @Param("orgId") Integer orgId,
                                                           @Param("userId") String userId,
                                                           @Param("buildingId") String buildingId,
                                                           @Param("startDate") LocalDateTime startDate,
                                                           @Param("endDate") LocalDateTime endDate);
}
