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

import com.ym.mec.biz.dal.dto.ActivityStudentDto;
import com.ym.mec.biz.dal.dto.ActivityUserDto;
import com.ym.mec.biz.dal.dto.CourseFormDto;
import com.ym.mec.biz.dal.dto.ExportStudentSubCourse;
import com.ym.mec.biz.dal.entity.ActivityUserMapper;
import com.ym.mec.biz.dal.page.ActivityUserQueryInfo;
import com.ym.mec.common.dal.BaseDAO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

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

@Component
public interface ActivityUserMapperDao extends BaseDAO<Integer, ActivityUserMapper> {


    /**
    * @description: 获取学员排课资格
    * @param activityId
    * @param studentIds
    * @param type 排课资格类型
    * @return com.ym.mec.biz.dal.entity.ActivityUserMapper
    * @author zx
    * @date 2021/10/11 16:31
    */
    List<ActivityUserMapper> findByStudentIdList(@Param("activityId") Integer activityId, @Param("studentIds") String studentIds, @Param("type") String type);

    /**
    * @description: 获取学员购买的活动次数
     * @param activityId
     * @param userId
    * @return int
    * @author zx
    * @date 2021/10/12 18:22
    */
    int countActivityBuyNum(@Param("activityId") Integer activityId, @Param("userId") Integer userId);

    /**
     * @description: 消耗排课资格
     * @param activityUserMapperIds
     * @param studentIds
     * @param type
     * @param groupId
     * @return int
     * @author zx
     * @date 2021/10/15 15:53
     */
    Integer use(@Param("activityUserMapperIds") String activityUserMapperIds,
            @Param("studentIds") String studentIds,
            @Param("type") String type,
            @Param("groupId") Long groupId);

    /**
    * @description: 批量新增
     * @param activityUserMappers
    * @return void
    * @author zx
    * @date 2021/10/20 13:38
    */
    void batchInsert(@Param("activityUserMappers") List<ActivityUserMapper> activityUserMappers);

    /**
     * @description:
     * @param groupId
 * @param groupType
    * @return com.ym.mec.biz.dal.entity.ActivityUserMapper
     */
    ActivityUserMapper findVipUserMapper(@Param("groupId") Long groupId,
                                         @Param("groupType") String groupType,
                                         @Param("studentId") Integer studentId);

    /**
     * @description: 修改指导老师
     * @param userId
     * @param teacherId
     * @return void
     * @author zx
     * @date 2021/11/1 16:21
     */
    void updateTeacherId(@Param("userId") Integer userId, @Param("teacherId") Integer teacherId);

    /**
    * @description: 获取学员活动排课资格列表
     * @param params
    * @return int
    * @author zx
    * @date 2021/11/15 16:38
    */
    int countActivityUserMapper(Map<String, Object> params);

    /**
     * @description: 获取学员活动排课资格列表
     * @param params
     * @return int
     * @author zx
     * @date 2021/11/15 16:38
     */
    List<ActivityStudentDto> queryActivityUserMapper(Map<String, Object> params);

    //获取学员未排课资格
    Integer getStudentNoMapperInfo(@Param("userId") Integer userId,
                                  @Param("activityId") Integer activityId);

    List<ExportStudentSubCourse> exportStudentSubCourse(@Param("organId") String organId,@Param("tenantId") Integer tenantId);

    List<CourseFormDto> queryWaitCourseCategory(@Param("userId") Integer userId, @Param("organIds") String organIds);

    List<ActivityUserDto> queryActivityStudentList(@Param("queryInfo") ActivityUserQueryInfo activityUserQueryInfo);

    /**
    * @description: 获取活动排课可排课时长列表
     * @param activityUserQueryInfo
    * @return java.util.List<java.lang.Integer>
    * @author zx
    * @date 2022/7/25 10:01
    */
    List<Integer> queryActivityCourseTimeList(@Param("queryInfo") ActivityUserQueryInfo activityUserQueryInfo);

    List<ActivityUserMapper> findTotalByStudents(@Param("studentIdList") List<Integer> studentIdList,
                                            @Param("categoryId") Integer categoryId,
                                            @Param("classMinutes") Integer classMinutes);
    List<ActivityUserMapper> findByStudents(@Param("studentIdList") List<Integer> studentIdList,
                                            @Param("categoryId") Integer categoryId,
                                            @Param("classMinutes") Integer classMinutes);

    List<ActivityUserMapper> findByStudents1(@Param("studentIdList") List<Integer> studentIdList,
                                            @Param("categoryId") Integer categoryId,
                                            @Param("classMinutes") Integer classMinutes);

    void batchUpdate(@Param("useActivityUserMappers") List<ActivityUserMapper> useActivityUserMappers);
    void batchUpdateFree(@Param("useActivityUserMappers") List<ActivityUserMapper> useActivityUserMappers);
    void batchUpdate1(@Param("useActivityUserMappers") List<ActivityUserMapper> useActivityUserMappers);

    List<ActivityUserMapper> findByIds(@Param("activityUserMapperIds") String activityUserMapperIds);
}