package com.fs.course.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.domain.R;
import com.fs.common.core.domain.ResponseResult;
import com.fs.course.domain.FsUserCourseVideo;
import com.fs.course.dto.CoursePeriodSyncResultDTO;
import com.fs.course.param.*;
import com.fs.course.param.newfs.FsUserCourseAddCompanyUserParam;
import com.fs.course.param.newfs.FsUserCourseVideoLinkParam;
import com.fs.course.param.newfs.FsUserCourseVideoUParam;
import com.fs.course.param.newfs.UserCourseVideoPageParam;
import com.fs.course.vo.*;
import com.fs.course.vo.newfs.FsUserCourseVideoDetailsVO;
import com.fs.course.vo.newfs.FsUserCourseVideoLinkDetailsVO;
import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
import com.fs.course.vo.newfs.FsUserVideoListVO;
import com.fs.his.domain.FsUser;
import com.fs.his.vo.OptionsVO;
import com.fs.qw.param.FsUserCourseRedPageParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * 课堂视频Service接口
 *
 * @author fs
 * @date 2024-05-17
 */
public interface IFsUserCourseVideoService extends IService<FsUserCourseVideo> {
    /**
     * 查询课堂视频
     *
     * @param videoId 课堂视频主键
     * @return 课堂视频
     */
    public FsUserCourseVideo selectFsUserCourseVideoByVideoId(Long videoId);

    /**
     * 查询课堂视频列表
     *
     * @param fsUserCourseVideo 课堂视频
     * @return 课堂视频集合
     */
    public List<FsUserCourseVideo> selectFsUserCourseVideoList(FsUserCourseVideo fsUserCourseVideo);

    /**
     * 新增课堂视频
     *
     * @param fsUserCourseVideo 课堂视频
     * @return 结果
     */
    public int insertFsUserCourseVideo(FsUserCourseVideo fsUserCourseVideo);

    /**
     * 修改课堂视频
     *
     * @param fsUserCourseVideo 课堂视频
     * @return 结果
     */
    public int updateFsUserCourseVideo(FsUserCourseVideo fsUserCourseVideo);

    public int updateFsUserCourseRedPage(FsUserCourseRedPageParam userCourseRedPageParam);

    public void sortCourseVideo(List<FsUserCourseVideo> list);

    /**
     * 批量删除课堂视频
     *
     * @param videoIds 需要删除的课堂视频主键集合
     * @return 结果
     */
    public int deleteFsUserCourseVideoByVideoIds(String[] videoIds);

    /**
     * 删除课堂视频信息
     *
     * @param videoId 课堂视频主键
     * @return 结果
     */
    public int deleteFsUserCourseVideoByVideoId(String videoId);


    List<FsUserCourseVideo> selectFsUserCourseVideoListByCourseId(FsUserCourseVideo fsUserCourseVideo);


    List<FsUserCourseVideoListUVO> selectFsUserCourseVideoListUVOByCourseId(FsUserCourseVideoListUParam param);

    Long selectCourseVideoSort(Long courseId);

    R updateWatchDuration(FsUserCourseVideoFinishUParam param);

    R isAddKf(FsUserCourseVideoAddKfUParam param);

    List<FsUserCourseVideoVO> selectFsUserCourseVideoListByCourseIdAndCompany(FsUserCourseVideoParam fsUserCourseVideo);

    R updateFsUserCourseVideoCompanyRedPacket(FsUserCourseVideoParam fsUserCourseVideo);

    R getInternetTraffic(FsUserCourseVideoFinishUParam param);

    R getIntegralByH5Video(FsUserCourseVideoFinishUParam param);

    R sendReward(FsCourseSendRewardUParam param);

    R sendRewardByFsUser(FsCourseSendRewardUParam param);

    /**
     * 获取课程视频分页列表
     *
     * @return FsUserCourseVideoPageListVO
     */
    List<FsUserCourseVideoPageListVO> pageListCourseVideo(UserCourseVideoPageParam param);

    /**
     * 获取课程视频详情
     *
     * @return FsUserCourseVideoDetailsVO
     */
    ResponseResult<FsUserCourseVideoDetailsVO> getVideoDetails(Long videoId);

    R registerCourse(FsUserCourseRegisterParam param);

    /**
     * 获取下拉视频列表（有分页，仅返回两个字段）
     *
     * @param param 入参
     * @return list
     */
    List<FsUserVideoListVO> getListCourseVideo(UserCourseVideoPageParam param);

    /**
     * 判断是否添加销售
     *
     * @param param 入参
     * @return 是/否 成功
     */
    ResponseResult<FsUser> isAddCompanyUser(FsUserCourseAddCompanyUserParam param);

    /**
     * 获取链接用户课程详情
     *
     * @param param 入参
     */
    ResponseResult<FsUserCourseVideoLinkDetailsVO> getLinkCourseVideoDetails(FsUserCourseVideoLinkParam param);


    R addWatchLogByLink(FsUserCourseAddCompanyUserParam param);

    /**
     * 更新看课时长
     *
     * @param param 入参
     * @return
     */
    R updateWatchDurationWx(FsUserCourseVideoUParam param);

    void updates(CourseVideoUpdates vo);

    void batchSaveVideo(BatchVideoSvae vo);

    void batchUpdateRed(List<BatchRedUpdate> list);
    void batchUpdateTitle(List<BatchTitleUpdate> list);

    /**
     * 获取选项列表
     *
     * @param params 参数
     * @return list
     */
    List<OptionsVO> selectVideoListByMap(Map<String, Object> params);

    List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebar(FsCourseListBySidebarParam param);

    /**
     * 只查询用户当天课程章节数据
     *
     * @param param
     * @return
     */
    List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebarToday(FsCourseListBySidebarParam param);

    R createMiniLink(FsCourseLinkMiniParam param);

    R createCartLinkByFeiShu(FsCourseLinkMiniParam param);

    R createCartLink(FsCourseLinkMiniParam param);

    /**
     * 校验时长
     *
     * @param param
     * @return
     */
    R isAllowAnswer(FsUserCourseVideoFinishUParam param);

    List<FsUserCourseVideoPageListVO> selectCourseVideoListByMap(Map<String, Object> params);

    ResponseResult<Boolean> setWatchCourseTime(List<FsWatchCourseTimeParam> collect);

    R createRoomMiniLink(FsCourseLinkMiniParam param);

    FsUserCourseVideo selectByFileKey(String fileKey);

    String selectFsUserCourseVideoByVideoForTitle(Long videoId);

    R checkUserInfo(long l);

    R updateVideo();
    AjaxResult updateVideoByVideoUrl(String videoUrl, String oldVideoUrl, String thumbnail, String fileName, Integer duration, String lineOne, String lineTwo);

    /**
     * 同步视频时长到 Redis（看课完课判定依赖 h5user / h5wxuser 缓存）
     */
    void syncVideoDurationCache(Long videoId, Long duration);

    R checkUserInfo(Long userId);

    public FsUserCourseVideoQVO selectFsUserCourseVideoByVideoIdVO(Long videoId, Long userId);

    R updateWatchDurationIsOpen(FsUserCourseVideoFinishUParam param);

    R isAddKfIsOpen(FsUserCourseVideoAddKfUParam param);

    R getInternetTrafficIsOpen(FsUserCourseVideoFinishUParam param);

    /**
     * 查询选择使用的视频列表
     */
    List<FsUserCourseVideoChooseVO> getChooseCourseVideoListByMap(Map<String, Object> params);

    R sendAppReward(FsCourseSendRewardUParam param);

    R isSaveKf(FsUserCourseVideoAddKfUParam param);

    /**
     * 上传视频到火山云通过URL(把华为云的视频传到火山去并且存储JOBID)
     * @return
     */
    R uploadVideoToHuoShanByUrl();

    /**
     * 通过jobId拿vid
     * @return
     */
    R getVidByJob();

    /**
     * 通过vid获取视频路径并且组装地址存到替换线路二
     * @return
     */
    R getVideoInfoByVid();

    R createRoomMiniLinkByCourse(FsCourseLinkRoomNewParam param);

    /**
     * 课程目录提取飞书免授权看课链接
     */
    R createFeishuLinkByCourse(FsCourseLinkRoomNewParam param);

    void updateMediaPublishStatus(String vid);

    /**
     * 同步会员营期
     * 将课程的视频排序同步到绑定的营期中（更新lesson和dayDate）
     *
     * @param courseId 课程ID
     * @return 同步结果
     */
    CoursePeriodSyncResultDTO syncCoursePeriod(Long courseId);

    /**
     * 视频下架
     */
    int batchDown(String[] videoIds);

    /**
     * 视频上架
     */
    int batchUp(String[] videoIds);

    /**
     * 批量修改视频封面
     */
    int batchEditCover(BatchEditCoverParam param);

    /**
     * 获取课程视频选项列表
     *
     * @param courseId 课程ID
     * @return list
     */
    List<OptionsVO> selectVideoOptionsByCourseId(Long courseId);

    R withdrawal(FsCourseSendRewardUParam param);

    /**
     * 获取飞书课程详情
     */
    R getFeiShuLinkCourseVideoDetails(Long companyUserId, Long videoId, Long identifier);

    /**
     * 更新飞书看课时长
     */
    void feiShuUpdateWatchDurationWx(Long companyUserId, Long videoId, Long identifier, Long duration);

    /**
     * 飞书看课流量统计
     */
    void getFeiShuInternetTraffic(Long identifier, Long companyUserId, Long videoId, String uuid, java.math.BigDecimal bufferRate);
}
