package com.fs.course.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fs.course.domain.FsUserCompanyBind;
import com.fs.course.vo.CourseProgressResultVO;
import com.fs.course.vo.RelatedSalesResultVO;
import com.fs.course.vo.RepeatProjectResultVO;
import com.fs.course.vo.UserWatchLogListVo;
import com.fs.qw.param.UserWatchLogParam;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户客服关联Mapper接口
 *
 * @author fs
 * @date 2025-07-22
 */
public interface FsUserCompanyBindMapper extends BaseMapper<FsUserCompanyBind>{
    /**
     * 查询用户客服关联
     *
     * @param id 用户客服关联主键
     * @return 用户客服关联
     */
    FsUserCompanyBind selectFsUserCompanyBindById(Long id);

    /**
     * 查询用户客服关联列表
     *
     * @param fsUserCompanyBind 用户客服关联
     * @return 用户客服关联集合
     */
    List<FsUserCompanyBind> selectFsUserCompanyBindList(FsUserCompanyBind fsUserCompanyBind);

    /**
     * 新增用户客服关联
     *
     * @param fsUserCompanyBind 用户客服关联
     * @return 结果
     */
    int insertFsUserCompanyBind(FsUserCompanyBind fsUserCompanyBind);

    /**
     * 修改用户客服关联
     *
     * @param fsUserCompanyBind 用户客服关联
     * @return 结果
     */
    int updateFsUserCompanyBind(FsUserCompanyBind fsUserCompanyBind);

    /**
     * 删除用户客服关联
     *
     * @param id 用户客服关联主键
     * @return 结果
     */
    int deleteFsUserCompanyBindById(Long id);

    /**
     * 批量删除用户客服关联
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteFsUserCompanyBindByIds(Long[] ids);

    List<UserWatchLogListVo> getWatchLogList(UserWatchLogParam param);
    
    int deleteFsUserCompanyBindByCompanyUserIdAndFsUserId(@Param("companyUserId") Long companyUserId,
                                                          @Param("fsUserId") Long fsUserId);

    /**
     * 查询重粉看课历史 - 关联销售信息
     * 通过fsUserId查找所有同名fsUserId的QwExternalContact记录，关联QwUser和QwCompany
     */
    List<RelatedSalesResultVO> getRelatedSalesByFsUserId(@Param("fsUserId") Long fsUserId);

    /**
     * 查询重粉看课历史 - 课程学习进度
     * 通过fsUserId查找FsCourseWatchLog记录，计算每门课程的进度
     */
    List<CourseProgressResultVO> getCourseProgressByFsUserId(@Param("fsUserId") Long fsUserId);

    /**
     * 查询重粉看课历史 - 客户企微发课看过的项目（send_type=2）
     */
    List<RepeatProjectResultVO> getUserWatchedProjectsByFsUserId(@Param("fsUserId") Long fsUserId);
}
