package com.ym.mec.biz.dal.dao;

import com.ym.mec.biz.dal.dto.*;
import com.ym.mec.biz.dal.entity.CourseSchedule;
import com.ym.mec.biz.dal.entity.School;
import com.ym.mec.biz.dal.entity.VipGroup;
import com.ym.mec.common.dal.BaseDAO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface VipGroupDao extends BaseDAO<Long, VipGroup> {

    /**
     * @param vipGroupId: vip课编号
     * @return com.ym.mec.biz.dal.entity.VipGroup
     * @describe 锁定指定vip课
     * @author Joburgess
     * @date 2019/10/21
     */
    VipGroup getLockVipGroup(Long vipGroupId);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.entity.VipGroup>
     * @Author: Joburgess
     * @Date: 2019/10/9
     * @params [organId]
     * @describe 根据部门获取
     */
    List<VipGroup> findAllByOrgan(Map<String, Object> params);

    int countVipGroupByOrgan(Map<String, Object> params);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.dto.VipGroupStudentDto>
     * @Author: Joburgess
     * @Date: 2019/10/9
     * @params [params]
     * @describe 获取小课学员
     */
    List<VipGroupStudentDto> findVipGroupStudents(Map<String, Object> params);

    /**
     * @param params:
     * @return java.util.List<com.ym.mec.biz.dal.dto.VipGroupStudentDto>
     * @describe 获取还有课程余额的学员
     * @author Joburgess
     * @date 2019/11/16
     */
    List<VipGroupStudentDto> findHaveCourseBalanceStudents(Map<String, Object> params);

    int countHaveCourseBalanceStudentNum(Map<String, Object> params);

    int countVipGroupStudents(Map<String, Object> params);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.dto.VipGroupCourseSchduleRecordDto>
     * @Author: Joburgess
     * @Date: 2019/10/9
     * @params [params]
     * @describe 获取vip课教学记录
     */
    List<VipGroupCourseSchduleRecordDto> findTeachingRecord(Map<String, Object> params);

    int countTeachingRecord(Map<String, Object> params);

    /**
     * @return int
     * @Author: Joburgess
     * @Date: 2019/10/9
     * @params [vipGroupId]
     * @describe 统计已结算课程数量
     */
    int countIsSalaryNum(Long vipGroupId);

    /**
     * @return int
     * @Author: Joburgess
     * @Date: 2019/10/9
     * @params [vipGroupId]
     * @describe 统计被投诉课程数量
     */
    int countComplaintsNum(Long vipGroupId);

    /**
     * @return com.ym.mec.biz.dal.dto.TeachingRecordBaseInfo
     * @Author: Joburgess
     * @Date: 2019/10/9
     * @params [vipGroupId]
     * @describe 获取vip课的总课次及已上课次
     */
    TeachingRecordBaseInfo getClassTimes(Long vipGroupId);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentManageVipGroupDto>
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [userID]
     * @describe 获取对应学生vip课
     */
    List<StudentManageVipGroupDto> findStudentVipGroups(Map<String, Object> params);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentVipGroupShowListDto>
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [params]
     * @describe 学生端获取vip课列表
     */
    List<StudentVipGroupShowListDto> findVipGroups(Map<String, Object> params);

    /**
     * @return int
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [params]
     * @describe 统计vip数
     */
    int countVipGorups(Map<String, Object> params);

    /**
     * @return com.ym.mec.biz.dal.dto.VipGroupManageDetailDto
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [vipGroupId]
     * @describe 获取小课详情
     */
    VipGroupManageDetailDto getVipGroupBaseInfo(Long vipGroupId);

    /**
     * @param vipGroupId: vip课编号
     * @return com.ym.mec.biz.dal.dto.VipGroupSalaryBaseInfo
     * @describe 获取vip课财务基本信息
     * @author Joburgess
     * @date 2019/11/5
     */
    VipGroupSalaryBaseInfo getVipGroupSalaryInfo(@Param("vipGroupId") Long vipGroupId);

    /**
     * @param classGroupId: 班级编号
     * @return int
     * @describe 统计学生缴费笔数
     * @author Joburgess
     * @date 2019/11/16
     */
    int countStudentPaymentNum(@Param("classGroupId") Integer classGroupId);

    BigDecimal countStudentPaymentFee(@Param("classGroupId") Integer classGroupId);

    /**
     * @return int
     * @Author: Joburgess
     * @Date: 2019/10/11
     * @params [vipGroupId]
     * @describe 统计扣费笔数
     */
    int countVipGroupDeductionNum(Long vipGroupId);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [params]
     * @describe 获取小课考勤记录
     */
    List<CourseSchedule> findVipGroupAttendances(Map<String, Object> params);

    /**
     * @return int
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [params]
     * @describe 统计小课考勤记录数
     */
    int countVipGroupAttendance(Map<String, Object> params);

    /**
     * @return com.ym.mec.biz.dal.dto.StudentVipGroupDetailDto
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [vipGroupId]
     * @describe 获取vip课详情
     */
    StudentVipGroupDetailDto getVipGroupDetail(Long vipGroupId);

    /**
     * @return java.util.List<java.util.Map < java.lang.String, java.lang.Integer>>
     * @Author: Joburgess
     * @Date: 2019/10/3
     * @params [vipGroupId]
     * @describe 统计剩余课时数
     */
    List<Map<String, Integer>> countSurplusClassTimes(Long vipGroupId);

    /**
     * @return java.math.BigDecimal
     * @Author: Joburgess
     * @Date: 2019/10/12
     * @params [vipGroupId]
     * @describe 统计学生vip课未上课时费用
     */
    List<Map<Integer, BigDecimal>> countSurplusCourseFee(Long vipGroupId);

    /**
     * @return int
     * @Author: Joburgess
     * @Date: 2019/10/14
     * @params [teacherId]
     * @describe 统计老师开启的vip课数
     */
    int countTeacherVipGroups(Long teacherId);

    /**
     * 根据教师编号获取老师vip课数量
     *
     * @param teacherId
     * @return
     */
    int countTeacherVipClass(Integer teacherId);

    /**
     * 根据教师编号获取老师vip课列表
     *
     * @param params
     * @return
     */
    List<TeacherVipClassInfoDto> getTeacherVipClass(Map<String, Object> params);

    /**
     * 根据老师查询vip课教学点
     *
     * @param userId
     * @return
     */
    List<School> querySchoolByUserId(Integer userId);

    /**
     * @param courseScheduleId: 课程编号
     * @return com.ym.mec.biz.dal.entity.VipGroup
     * @describe 根据课程编号获取vip课
     * @author Joburgess
     * @date 2019/10/23
     */
    VipGroup findByCourseSchedule(Long courseScheduleId);

    /**
     * 查询vip课数目
     *
     * @param organId
     * @return
     */
    Map<String, Integer> queryVipGroupNum(@Param("organId") String organId);

    /**
     * 查询当月vip课数量
     *
     * @param organId
     * @return
     */
    Integer queryCurrentMonthCoursesNum(@Param("organId") String organId);

    /**
     * @param :
     * @return java.util.List<com.ym.mec.biz.dal.entity.VipGroup>
     * @describe 获取报名已截至但是报名人数还未达到的vip课程
     * @author Joburgess
     * @date 2019/11/13
     */
    List<VipGroup> findNoCreateSuccessVipGroup();


    /**
     * count学员vip课程列表
     *
     * @param params
     * @return
     */
    int countStudentVipGroups(Map<String, Object> params);

    /**
     * 根编号列表查询对象
     *
     * @param idList
     * @return
     */
    List<VipGroup> queryByIds(String idList);

    /**
     * 批量更新
     *
     * @param vipGroupList
     * @return
     */
    int batchUpdate(@Param("vipGroupList") List<VipGroup> vipGroupList);

    /**
     * @param vipGroupId:
     * @return com.ym.mec.biz.dal.dto.VipBuyResultDto
     * @describe
     * @author Joburgess
     * @date 2019/11/29
     */
    VipBuyResultDto getVipBuyResultInfo(@Param("vipGroupId") Integer vipGroupId);

    /**
     * 查询需要结束的对象列表
     *
     * @return
     */
    List<VipGroup> queryRequiredOverList();

    /**
     * @return java.util.List<com.ym.mec.biz.dal.entity.VipGroup>
     * @describe 获取正常状态的vip课
     * @author Joburgess
     * @date 2019/12/3
     */
    List<VipGroup> queryNormalStatusList();

    int countUserRepeatVipGroupInCourseStartEndTime(@Param("userId") Integer userId,
                                                    @Param("courseStartDate") Date courseStartDate,
                                                    @Param("courseEndDate") Date courseEndDate);

    VipGroup findVipGroupInfo(@Param("id") Integer id, @Param("classGroupId") Integer classGroupId);

    /**
     * 获取用户所在vip名
     *
     * @param userIds
     * @return
     */
    List<Map<Integer, String>> queryUserVipNames(@Param("userIds") Set<Integer> userIds);

    /**
     * 获取用户所在vip状态
     *
     * @param userIds
     * @return
     */
    List<Map<Integer, String>> queryUserVipStatus(@Param("userIds") Set<Integer> userIds);

    /**
     * 临时用
     *
     * @return
     */
    List<VipCourseStudentInfoDto> queryVipCourseStudentInfo();

    List<VipBuyResultDto> getGroupTeachers(@Param("groupIds") List<Long> groupIds);
}
