package com.huiju.estateagents.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huiju.estateagents.bo.request.QrCodeStatisticResponseBO;
import com.huiju.estateagents.entity.TaPersonBuilding;
import com.huiju.estateagents.entity.TaPersonVisitRecord;
import com.huiju.estateagents.entity.TaQrcode;
import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeNewPersonNum;
import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitNum;
import com.huiju.estateagents.excel.QrCodeStatistics.QrCodeVisitPersonNum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 二维码管理表 Mapper 接口
 * </p>
 *
 * @author fxf
 * @since 2020-05-20
 */
@Mapper
@Component
public interface TaQrcodeMapper extends BaseMapper<TaQrcode> {

    QrCodeStatisticResponseBO getStatisticData(@Param("orgId") Integer orgId);

    IPage<TaQrcode> listQrCodeByCondition(IPage<TaQrcode> page,
                                          @Param("targetType") String targetType,
                                          @Param("targetName") String targetName,
                                          @Param("channelId") Integer channelId,
                                          @Param("buildingId") String buildingId,
                                          @Param("userId") Integer userId,
                                          @Param("orgId") Integer orgId,
                                          @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 获取访问用户人数
     *
     * @param qrCodeId
     * @param orgId
     * @return
     */
    Integer getVisitPersons(@Param("qrCodeId") Integer qrCodeId,
                            @Param("orgId") Integer orgId);

    /**
     * 获取访问次数
     *
     * @param qrCodeId
     * @param orgId
     * @return
     */
    Integer getVisitNum(@Param("qrCodeId") Integer qrCodeId,
                        @Param("orgId") Integer orgId);

    /**
     * 获取新增用户数
     *
     * @param qrCodeId
     * @param orgId
     * @return
     */
    Integer getNewPersons(@Param("qrCodeId") Integer qrCodeId,
                          @Param("orgId") Integer orgId);

    IPage<TaPersonVisitRecord> getVisitPersonsRecord(IPage<TaPersonVisitRecord> page,
                                                     @Param("qrCodeId") Integer qrCodeId,
                                                     @Param("orgId") Integer orgId);

    IPage<TaPersonVisitRecord> getVisitNumRecord(IPage<TaPersonVisitRecord> page,
                                                 @Param("qrCodeId") Integer qrCodeId,
                                                 @Param("orgId") Integer orgId);

    IPage<TaPersonVisitRecord> getNewPersonsRecord(IPage<TaPersonVisitRecord> page,
                                                   @Param("qrCodeId") Integer qrCodeId,
                                                   @Param("orgId") Integer orgId);

    List<QrCodeVisitPersonNum> getVisitPersonsRecordExport(@Param("qrCodeId") Integer qrCodeId,
                                                           @Param("orgId") Integer orgId);


    List<QrCodeVisitNum> getVisitNumRecordExport(@Param("qrCodeId") Integer qrCodeId,
                                                 @Param("orgId") Integer orgId);

    List<QrCodeNewPersonNum> getNewPersonsRecordExport(@Param("qrCodeId") Integer qrCodeId,
                                                       @Param("orgId") Integer orgId);
}
