package com.ruoyi.project.business.mapper;

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

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.project.business.domain.TcLead;
import com.ruoyi.project.business.domain.TcLeadForRelated;
import com.ruoyi.project.business.domain.vo.lead.LeadForAccountReq;
import com.ruoyi.project.business.domain.vo.lead.LeadListReq;
import com.ruoyi.project.business.domain.vo.lead.LeadRelatedQueryReq;
import com.ruoyi.project.business.domain.vo.lead.LeadRes;
import org.apache.ibatis.annotations.Param;

/**
 * 线索管理Mapper接口
 * 
 * @author ruoyi
 * @date 2024-04-10
 */
public interface TcLeadMapper extends BaseMapper<TcLead> 
{
    /**
     * 查询线索管理
     * 
     * @param leadId 线索管理主键
     * @return 线索管理
     */
    LeadRes selectTcLeadByLeadId(Long leadId);

    /**
     * 查询关联线索
     *
     * @param loginId  权限字符
     * @return 线索管理
     */
    List<TcLeadForRelated> selectLeadListByLoginId(Long loginId);
    List<TcLeadForRelated> selectLeadListByLeadId(LeadRelatedQueryReq tcLead);
    List<TcLeadForRelated> selectLeadListByQuery(LeadRelatedQueryReq tcLead);

    /**
     * 查询线索管理列表
     * 
     * @param tcLead 线索管理
     * @return 线索管理集合
     */
    List<LeadRes> selectTcLeadList(LeadListReq tcLead);


    /**
     * 删除线索管理
     * 
     * @param leadId 线索管理主键
     * @return 结果
     */
    int deleteTcLeadByLeadId(Long leadId);

    /**
     * 查询客户相关线索
     *
     * @param tcLead 线索
     * @return 结果
     */
    List<TcLeadForRelated> selectLeadListByAccount(LeadRelatedQueryReq tcLead);

    /**
     * 查询市场线索并且未分配线索
     */
    List<TcLead> selectLeadsFromMarketAndUnassigned();

    // void updateFollowStatusByLeadId(Long leadId);

    void resetAccountId(Long accountId);

    /**
     * 根据客户id查询关联线索
     *
     * @param accountId 客户id
     * @return 结果
     */
    List<LeadRes> selectLeadListByAccountId(Long accountId);

    List<LeadRes> selectLeadListByProjectId(Long projectId);
    List<LeadRes> curAgent(String permissionChar);

    void resetAccountIds(Long[] accountIds);

    List<TcLead> selectLeadCountStat(@Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate, @Param("permissionChar") String permissionCharSea);

    int selectCountByCountryIds(Long[] countryIds);

    List<TcLead> listByCurUser(LeadForAccountReq forAccountReq);

    
    // @Dynamic
    List<LeadRes> curCountry(@Param("permissionChar") String permissionCharSea, @Param("lan") String lan);

    List<Long> selectAreaIdsByCurUser(String permissionCharIns);

    List<Long> selectCountryIdsByCurUser(String permissionCharIns);

    List<TcLeadForRelated> suppleProjectExportVO(@Param("language") String language,@Param("accountIdList") List<Long> accountIdList);

}
