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

import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.dto.SimpleUserDto;
import com.ym.mec.biz.dal.dto.Student4operating;
import com.ym.mec.biz.dal.dto.StudentServeCourseDto;
import com.ym.mec.biz.dal.dto.StudentServeDto;
import com.ym.mec.biz.dal.entity.Student;
import com.ym.mec.biz.dal.entity.Subject;
import com.ym.mec.biz.dal.enums.GroupType;
import org.apache.ibatis.annotations.Param;

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

public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Student> {
	
	Student getLocked(Integer userId);
	
    int lockUser(@Param("userId") Integer userId);

    List<Student> findByStudentIds(@Param("studentIds") List<Integer> studentIds);

    List<Student> lockStudents(@Param("studentIds") List<Integer> studentIds);

    SysUser lockUserReturnInfo(@Param("userId") Integer userId);

    SysUser getUser(@Param("userId") Integer userId);

    List<SysUser> findStudents(Map<String, Object> params);

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

    List<Student> queryByOperatingTempTag(Integer operatingTag);

    int batchUpdate(@Param("studentList") List<Student> studentList);

    /**
     * 查询运营学生列表
     *
     * @param params
     * @return
     */
    List<Student4operating> getOperatingStudents(Map<String, Object> params);

    /**
     * 查询运营学生总数
     *
     * @param params
     * @return
     */
    Integer countOperatingStudents(Map<String, Object> params);

    /**
     * 批量获取老师体验学生数
     *
     * @param teacherIds
     * @return
     */
    List<Map<Integer, Integer>> getTeacherOperatingStudentsNum(@Param("teacherIds") String teacherIds);

    List<String> getStudentNames(@Param("studentIds") List<Integer> studentIds);

    List<SimpleUserDto> getStudentsWithOrgan(Map<String, Object> params);

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

    /**
     * 根据类型批量获取老师转化
     *
     * @param teacherIds
     * @param groupType
     * @return
     */
    List<Map<Integer, Integer>> getBuyNums(@Param("teacherId") String teacherId, @Param("groupType") GroupType groupType);

    /**
     * 根据同事存在vip和网管的转化
     *
     * @param teacherIds
     * @return
     */
    List<Map<Integer, Integer>> getPracticeAndVipNums(@Param("teacherIds") String teacherIds);

    /**
     * @return java.util.List<com.ym.mec.biz.dal.entity.Student>
     * @describe 获取服务学员列表
     * @author Joburgess
     * @date 2020.04.29
     */

    List<Student> getServiceStudents();

    /**
     * @return java.util.List<java.lang.Integer>
     * @describe 获取被服务学员id列表
     * @author Joburgess
     * @date 2020.06.04
     */
    List<Integer> getServeStudentIds();

    List<StudentServeCourseDto> getServeStudentCourseStartTimes(@Param("monday") String monday);

    List<StudentServeCourseDto> getStudentFutureCourseInfo(@Param("monday") String monday,
                                                           @Param("nextMonday") String nextMonday,
                                                           @Param("studentIds") List<Integer> studentIds);

    List<StudentServeCourseDto> getNoCourseBeServeStudentInfo(@Param("noCourseStudentIds") List<Integer> noCourseStudentIds);

    /**
     * @param monday:
     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentServeDto>
     * @describe 查询被服务学员信息
     * @author Joburgess
     * @date 2020.05.27
     */
    List<StudentServeDto> getBeServiceStudents(@Param("monday") String monday,
                                               @Param("courseExpireDate") Date courseExpireDate);


    List<StudentServeDto> getBeServiceStudentsInfoWithStudents(@Param("monday") String monday,
                                                               @Param("courseExpireDate") Date courseExpireDate,
                                                               @Param("studentIds") List<Integer> studentIds);

    List<StudentServeDto> getBeServiceStudentsInfoWithStudentsForHistory(@Param("monday") String monday,
                                                                         @Param("courseExpireDate") Date courseExpireDate,
                                                                         @Param("studentIds") List<Integer> studentIds);

    /**
     * @param studentId:    学生编号
     * @param serviceTag:   服务指标
     * @param operatingTag: 运营指标
     * @return int
     * @describe 更新指定学员的服务指标或运营指标
     * @author Joburgess
     * @date 2020.05.28
     */
    int updateStudentServiceOrOperatingTag(@Param("studentId") Integer studentId,
                                           @Param("studentIds") List<Integer> studentIds,
                                           @Param("serviceTag") Integer serviceTag,
                                           @Param("operatingTag") Integer operatingTag);

    /**
     * @param studentId:  学生编号
     * @param serviceTag: 服务指标
     * @return int
     * @describe 更新指定学员的服务指标
     * @author Joburgess
     * @date 2020.05.28
     */
    int updateStudentServiceTag(@Param("studentId") Integer studentId,
                                @Param("studentIds") List<Integer> studentIds,
                                @Param("serviceTag") Integer serviceTag);

    /**
     * 修改学员的指导老师
     *
     * @param teacherId
     */
    void batchUpdateAdviser(@Param("teacherId") Integer teacherId, @Param("studentIds") String studentIds);

    /**
     * 获取学生的老师
     * @param studentIds
     * @return
     */
    List<Student> getStudentTeacher(@Param("studentIds") List<Integer> studentIds);

    /**
     * 当前服务指标已开启，但在系统中没有剩余课时，且在乐团中不是在读状态，这种用户需要关闭服务指标
     * @return
     */
    List<Integer> queryCloseServiceTagIds();

    /**
     * 更新用户服务指标
     * @param studentIds
     * @param serviceTag
     */
    void updateServiceTag(@Param("studentIds") List<Integer> studentIds, @Param("serviceTag") Integer serviceTag);

    /**
     * @describe 获取学员声部列表
     * @author Joburgess
     * @date 2021/2/5 0005
     * @param studentIds:
     * @return java.util.List<com.ym.mec.biz.dal.entity.Subject>
     */
    List<Subject> getStudentSubjects(@Param("studentIds") Set<Integer> studentIds);

    List<Student> queryByIds(Map<String, Object> params);
    int countByIds(Map<String, Object> params);

    /**
     * 更新学生班级
     * @return
     */
    int updateGrade();

    /**
     * @describe
     * @author Joburgess
     * @date 2021/3/29 0029
     * @return java.util.List<com.ym.mec.biz.dal.entity.Student>
     */
    List<Student> getNoTeacherOrNoSubjectStudent();

    /**
     * @describe 从新学员中找出有VIP课的学员编号
     * @author Joburgess
     * @date 2021/6/3 0003
     * @return java.util.List<java.lang.Integer>
     */
    List<Integer> getHasVipCourseStudentIdsFromNewStudents();

    /**
     * @describe 将指定学员更新为老学员
     * @author Joburgess
     * @date 2021/6/3 0003
     * @param userIds:
     * @return int
     */
    int updateNewStudentsToOld(@Param("userIds") List<Integer> userIds);

    /**
     * 获取有会员的学员列表
     * @param studentIdsStr
     * @return
     */
    int getMemberNum(@Param("studentIdsStr") String studentIdsStr);

    /**
     * 会员结束前15天提醒学员续费
     * @param pushMemberRenew
     * @return
     */
    List<Integer> queryPushMemberRenew(String pushMemberRenew);

    /**
     * 清空学员会员
     */
    void cleanStudentMember();

    void cleanMember(Integer userId);
}
