package com.huiju.estateagents.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huiju.estateagents.entity.TaChannel;
import com.huiju.estateagents.entity.TaPersonBuilding;
import com.huiju.estateagents.entity.TsActivityDaily;
import com.huiju.estateagents.excel.ActivityStatistics.ChannelAddRegistNum;
import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitNum;
import com.huiju.estateagents.excel.ActivityStatistics.ChannelVisitPersonNum;
import com.huiju.estateagents.excel.ActivityStatistics.TsChannelDaily;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *   Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-09-17
 */
@Mapper
public interface TaChannelMapper extends BaseMapper<TaChannel> {

    /**
     * 渠道码
     * @return
     */
    int channelCode();

    /**
     * 渠道页面下拉列表的所有数据
     * @return
     */
    List<TaChannel> selectChannelList(@Param("orgId")Integer orgId);

    /**
     * 渠道列表
     * @param pg
     * @return
     */
    IPage<TaChannel> pageTaChannel(IPage<TaChannel> pg,@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);

    List<TaChannel> recommendCount(@Param("orgId")Integer orgId,@Param("channelId")Integer channelId);

    /**
     * 渠道引进客户统计
     * @param pg
     * @param orgId
     * @param startDate
     * @param endDate
     * @param channelType
     * @param buildingId
     * @return
     */
    IPage<TsActivityDaily> getChannelIntroductionList(IPage<TsActivityDaily> pg, @Param("orgId") Integer orgId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, @Param("channelType") String channelType, @Param("buildingId") String buildingId, @Param("channelId") Integer channelId, @Param("sortField") String sortField, @Param("orderType") String orderType, @Param("taPersonBuildings") List<TaPersonBuilding> taPersonBuildings);

    IPage<ChannelAddRegistNum> getChannelNewuserList(IPage<ChannelAddRegistNum> iPage, @Param("orgId") Integer orgId, @Param("channelId") Integer channelId, @Param("activityId") String activityId, @Param("activityType") String activityType, @Param("buildingId") String buildingId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);

    IPage<ChannelVisitNum> getChannelVisitNumList(IPage<ChannelVisitNum> iPage,@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);

    IPage<ChannelVisitPersonNum> getChannelPersonNumList(IPage<ChannelVisitPersonNum> iPage,@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);

    List<TsChannelDaily> getChannelIntroductionListExport(@Param("orgId") Integer orgId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate,@Param("channelType") String channelType,@Param("buildingId") String buildingId,@Param("channelId") Integer channelId,@Param("taPersonBuildings") List<TaPersonBuilding> taPersonBuildings);

    List<ChannelAddRegistNum> getChannelNewuserListExport( @Param("orgId") Integer orgId, @Param("channelId") Integer channelId, @Param("activityId") String activityId, @Param("activityType") String activityType, @Param("buildingId") String buildingId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);

    List<ChannelVisitNum> getChannelVisitNumListExport(@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);

    List<ChannelVisitPersonNum> getChannelPersonNumListExport(@Param("orgId") Integer orgId,@Param("channelId") Integer channelId,@Param("targetId") String targetId,@Param("targetType") String targetType,@Param("buildingId") String buildingId,@Param("startDate") LocalDate startDate,@Param("endDate") LocalDate endDate);
}
