package org.jeecg.modules.adweb.enquiry.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.adweb.dmp.vo.report.EnquiryCountryStatsVO;
import org.jeecg.modules.adweb.enquiry.dto.EnquiryDTO;
import org.jeecg.modules.adweb.enquiry.dto.param.EnquirySearchDto;
import org.jeecg.modules.adweb.enquiry.dto.result.EnquiryListDto;
import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiry;

import java.util.Date;
import java.util.List;

/**
 * @Description: 询盘信息存储表单
 * @Author: jeecg-boot
 * @Date: 2024-10-12
 * @Version: V1.0
 */
public interface AdwebEnquiryMapper extends BaseMapper<AdwebEnquiry> {

    /**
     * @param page
     * @param userEffective
     * @param searchText
     * @param ctimeBegin
     * @param ctimeEnd
     * @return
     */
    IPage<EnquiryListDto> selectEnquiryList(IPage<EnquirySearchDto> page,
                                            @Param("codeList") List<String> codeList,
                                            @Param("userEffective") String userEffective,
                                            @Param("wasteEnquiryType") String wasteEnquiryType,
                                            @Param("searchText") String searchText,
                                            @Param("searchContent") String searchContent,
                                            @Param("ctimeBegin") Date ctimeBegin,
                                            @Param("ctimeEnd") Date ctimeEnd,
                                            @Param("whatsApp") String whatsApp,
                                            @Param("readStatus") Integer readStatus,
                                            @Param("principalUid") String principalUid,
                                            @Param("selfPrincipalUid") String selfPrincipalUid);

    /**
     * 根据地区更新询盘跟进人
     */
    void updatePrincipalUidByRegion(Integer siteId, List<Integer> siteIds);

    /**
     * @param page
     * @param siteId
     * @param userEffective
     * @param searchText
     * @param ctimeBegin
     * @param ctimeEnd
     * @return
     */
    IPage<EnquiryListDto> queryWasteEnquiryList(IPage<EnquirySearchDto> page,
                                                @Param("codeList") List<String> codeList,
                                                @Param("siteId") String siteId,
                                                @Param("userEffective") String userEffective,
                                                @Param("searchText") String searchText,
                                                @Param("ctimeBegin") String ctimeBegin,
                                                @Param("ctimeEnd") String ctimeEnd,
                                                @Param("whatsApp") String whatsApp,
                                                @Param("principalUid") String principalUid);

    List<EnquiryListDto> getWastedEnquiry(String wasteEnquiryType, String ip, String email, String keyword, String searchText, String type, Integer siteId);

    /**
     * 获取每日询盘数量及未读询盘数量
     *
     * @param siteCode
     * @param start
     * @param end
     * @return List<ImmutableTriple < String, Long, Long>> -- MyBatis COUNT()方法默认类型为Long
     */
    List<ImmutableTriple<String, Long, Long>> getEnquiryDailyCounts(String siteCode, Date start, Date end);

    /**
     * 获取分时间段的询盘数量 - 今天，昨天，本周，上周，本月，上月，全部
     *
     * @param siteCode
     * @return List<Pair < String, Long>> -- MyBatis COUNT()方法默认类型为Long
     */
    List<ImmutablePair<String, Long>> getEnquiryPeriodicCounts(String siteCode);

    /**
     * 获取按国家分布的询盘数量
     */
    List<EnquiryCountryStatsVO> getEnquiryCountryStats(String siteCode, Date start, Date end);

    List<EnquiryDTO> getEnquiryList(String siteCode, String startTime, String endTime);
}
