package com.fs.hisStore.service;

import com.fs.common.core.domain.R;
import com.fs.common.core.domain.ResponseResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.course.param.newfs.FsUserCourseBeMemberParam;
import com.fs.course.vo.newfs.FsCourseAnalysisVO;
import com.fs.his.vo.OptionsVO;
import com.fs.qw.param.QwFsUserParam;
import com.fs.qw.vo.QwFsUserVO;
import com.fs.hisStore.domain.FsStoreOrderScrm;
import com.fs.hisStore.domain.FsStoreOrderItemScrm;
import com.fs.hisStore.domain.FsUserScrm;
import com.fs.hisStore.dto.FsUserTransferParamDTO;
import com.fs.hisStore.param.SelectCusListPageParam;
import com.fs.hisStore.param.h5.CourseAnalysisParam;
import com.fs.hisStore.param.h5.FsUserPageListParam;
import com.fs.hisStore.param.h5.UserStatisticsCommonParam;
import com.fs.hisStore.vo.FSUserVO;
import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
import com.fs.hisStore.vo.FsUserTuiVO;
import com.fs.hisStore.vo.h5.*;
import com.github.pagehelper.PageInfo;

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

/**
 * 用户Service接口
 *
 * @author fs
 * @date 2022-03-15
 */
public interface IFsUserScrmService
{
    /**
     * 查询用户
     *
     * @param userId 用户ID
     * @return 用户
     */
    public FsUserScrm selectFsUserById(Long userId);

    /**

     * 查询用户
     *
     * @param userId 用户ID
     * @return FSUserVO
     */
    public FSUserVO selectFsUserByUserId(Long userId);

    /**
     * 查询用户列表
     *
     * @param fsUser 用户
     * @return 用户集合
     */
    public List<FsUserScrm> selectFsUserList(FsUserScrm fsUser);

    /**
     * 查询用户列表
     *
     * @param fsUser 用户
     * @return 用户集合
     */
    public List<FSUserVO> selectFsUserVOList(FsUserScrm fsUser);

    /**
     * 新增用户
     *
     * @param fsUser 用户
     * @return 结果
     */
    public int insertFsUser(FsUserScrm fsUser);

    /**
     * 修改用户
     *
     * @param fsUser 用户
     * @return 结果
     */
    public int updateFsUser(FsUserScrm fsUser);

    /**
     * 批量删除用户
     *
     * @param userIds 需要删除的用户ID
     * @return 结果
     */
    public int deleteFsUserByIds(Long[] userIds);

    /**
     * 删除用户信息
     *
     * @param userId 用户ID
     * @return 结果
     */
    public int deleteFsUserById(Long userId);

    int decIntegral( Long uid,  double usedIntegral);

    int incPayCount(Long userId);

    FsUserScrm selectFsUserByPhone(String phone);

    TableDataInfo selectCusListPage(SelectCusListPageParam param);

    List<FsCompanyUserListQueryVO> selectFsCompanyUserListQuery(FsUserScrm fsUser);

    List<FsUserTuiVO> selectFsUserTuiList(String userId);

    Long selectFsUserCount(int type,Long companyI,Long companyUserId);

    void addTuiMoney(FsStoreOrderScrm order, List<FsStoreOrderItemScrm> items);

    void subTuiMoney(FsStoreOrderScrm order);

    void addMoney(FsStoreOrderScrm order);

    FsUserScrm selectFsUserByMaOpenId(String openid);

    FsUserScrm selectFsUserByMpOpenId(String openid);

    FsUserScrm selectFsUserByUnionId(String unionId);


    FsUserScrm selectFsUserByCourseMaOpenId(String openId);


    FsUserScrm selectFsUserByUserCode(String userCode);

    //CRM客户绑定 小程序客户之 查询小程序客户
    List<QwFsUserVO> selecQwFsUserListVO(QwFsUserParam qwFsUserParam);

    List<QwFsUserVO> selectQwFsUserListVO(QwFsUserParam qwFsUserParam);

    R clearUserVip(Long l);

    FsUserScrm selectFsUserByUnionid(String unionId);

    List<FsUserScrm> getUserListLimit(FsUserScrm fsUser);

    PageInfo<FsUserPageListVO> selectFsUserPageList(FsUserPageListParam param);
    TableDataInfo selectFsUserPageListNew(FsUserPageListParam param);
    Long selectFsUserCount(FsUserPageListParam param);

    UserListPageVO getUserNumber(Long userId);

    UserDetailsVO getUserDetails(Long userId, Long fsUserId, String dateTag, Long userCompanyId);

    /**
     * 查询重粉用户是否存在
     * @param userIds
     * @return
     */
    Integer selectFsUserByUserIds(String[] userIds, Long companyUserId);

    Boolean disabledUser(String[] ids, boolean status);

    void transfer(FsUserTransferParamDTO param);

    /**
     * 查询销售会员总数,今日新增会员数
     * @param companyUserId 销售ID
     * @return map
     */
    Map<String, Long> getUserVipCountByCompanyUserId(Long companyUserId);

    /**
     * 首页-获取用户总数
     * @param userId 登录用户id
     * @return vo
     */
    FsUserSummaryCountVO userSummaryCount(Long userId);

    /**
     * 首页数据统计-课程、答题、红包统计
     * @param param 查询参数
     * @return vo
     */
    FsUserStatisticsVO userStatistics(UserStatisticsCommonParam param);

    /**
     * 数据详情统计-根据课程id 视频id进行详情统计
     * @param param 查询参数
     * @return vo
     */
    FsUserStatisticsVO userStatisticsDetails(UserStatisticsCommonParam param);

    /**
     * 首页数据/详情-获取群管排行榜统计
     * @param userId 登录用户id
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param periodId 营期id
     * @param videoId 视频id
     * @param order 排序，asc-正序，desc-倒序
     * @param type 类型，1-按完播率，2-按正确率
     * @return vo
     */
    List<FsUserRankingVO> userRanking(Long userId, String startTime, String endTime, String periodId, String videoId, String order, Integer type);

    /**
     * 首页数据/详情-获取课程排行榜统计
     * @param userId 登录用户id
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param periodId 营期id
     * @param videoId 视频id
     * @param order 排序，asc-正序，desc-倒序
     * @param type 类型，1-按完播率，2-按正确率
     * @return vo
     */
    List<FsCourseRankingVO> courseRanking(Long userId, String startTime, String endTime, String periodId, String videoId, String order, Integer type);

    /**
     *
     * @param param 查询参数
     * @return vo
     */
    List<FsUserGraphicStatisticsVO> graphicStatistics(UserStatisticsCommonParam param);

    /**
     * 课程分析查询-某销售下课程视频的观看和答题情况统计
     * @param param 参数
     * @return vo
     */
    List<FsCourseAnalysisVO> courseAnalysis(CourseAnalysisParam param);

    /**
     * 查询某个群管（二级销售）的会员统计
     * @param userId 登录用户id
     * @param companyUserId 销售id
     * @return vo
     */
    CompanyUserSummaryCountVO companyUserSummaryCount(Long userId, String companyUserId);

    /**
     * 成为销售的会员
     * @param param
     * @return 是否成功
     */
    ResponseResult<Boolean> becomeMember(FsUserCourseBeMemberParam param);

    /**
     * 查询会员选项列表
     * @param params    参数
     * @return  list
     */
    List<OptionsVO> selectUserListByMap(Map<String, Object> params);

    /**
     * 打重粉标签
     * @param param
     */
    void setRepeatFansTag(FsUserCourseBeMemberParam param);

    /**
     * 根据组合key(用户昵称+id)查询用户信息
     * @param userNameKey (用户昵称+id)
     * @return
     */
    List<FsUserScrm> selectFsUserListByJointUserNameKey(String userNameKey);

    /**
     * 查询项目会员数据
     *
     * @param fsUser
     * @return
     */
    List<FSUserVO> selectFsUserVOListByProject(FsUserScrm fsUser);

    FsUserScrm selectFsUserByOpenId(String openid);
}
