Pārlūkot izejas kodu

1、陪练课调整
2、付费陪练课可预约时间调整

Joburgess 5 gadi atpakaļ
vecāks
revīzija
0304176419

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -172,6 +172,17 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     List<ClassGroupStudentMapper> findByClassGroups(@Param("classGroupIds") List<Integer> classGroupIds);
 
     /**
+     * @describe 获取团体学员
+     * @author Joburgess
+     * @date 2020/3/8
+     * @param groupIds:
+     * @param groupType:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
+     */
+    List<ClassGroupStudentMapper> findByGroups(@Param("groupIds") List<String> groupIds,
+                                               @Param("groupType") GroupType groupType);
+
+    /**
      * @param classGroupId: 班级编号列表
      * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
      * @describe 根据班级获取学员

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1268,4 +1268,15 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
                                             @Param("groupType") GroupType groupType);
 
     List<CourseSchedule> findClassGroupLastTeacher(@Param("classGroupIds") List<Integer> classGroupIds);
+
+    /**
+     * @describe 获取团体课次信息
+     * @author Joburgess
+     * @date 2020/3/8
+     * @param groupIds:
+     * @param groupType:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.GroupCourseTimesDto>
+     */
+    List<GroupCourseTimesDto> findGroupsCourseTimesInfo(@Param("groupIds") List<String> groupIds,
+                                                        @Param("groupType") GroupType groupType);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CoursesGroupDao.java

@@ -2,8 +2,19 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.CoursesGroup;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface CoursesGroupDao extends BaseDAO<Long, CoursesGroup> {
 
+    /**
+     * @describe 获取指定教师的课程组列表
+     * @author Joburgess
+     * @date 2020/3/8
+     * @param teacherId: 教师编号
+     * @return java.util.List<com.ym.mec.biz.dal.entity.CoursesGroup>
+     */
+    List<CoursesGroup> findTeacherCourseGroups(@Param("teacherId") Integer teacherId);
 	
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectDao.java

@@ -104,6 +104,8 @@ public interface SubjectDao extends BaseDAO<Integer, Subject> {
 
     List<Subject> findBySubjectByIdList(@Param("subjectIdList") String subjectIdList);
 
+    List<Subject> findBySubjectIds(@Param("subjectIds") List<Integer> subjectIds);
+
     /**
      * @describe 获取乐团下对应用户的科目名称
      * @author Joburgess

+ 110 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseGroupTeacherCardDto.java

@@ -0,0 +1,110 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/3/8
+ */
+public class CourseGroupTeacherCardDto {
+
+    private Long id;
+
+    private String name;
+
+    private Integer subjectId;
+
+    private String subjectName;
+
+    private Integer totalCourseTimes;
+
+    private Integer singleClassMinutes;
+
+    private java.util.Date coursesStartDate;
+
+    private java.util.Date coursesEndDate;
+
+    private Integer surplusClassTimes;
+
+    private String studentNames;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public Integer getTotalCourseTimes() {
+        return totalCourseTimes;
+    }
+
+    public void setTotalCourseTimes(Integer totalCourseTimes) {
+        this.totalCourseTimes = totalCourseTimes;
+    }
+
+    public Integer getSingleClassMinutes() {
+        return singleClassMinutes;
+    }
+
+    public void setSingleClassMinutes(Integer singleClassMinutes) {
+        this.singleClassMinutes = singleClassMinutes;
+    }
+
+    public Date getCoursesStartDate() {
+        return coursesStartDate;
+    }
+
+    public void setCoursesStartDate(Date coursesStartDate) {
+        this.coursesStartDate = coursesStartDate;
+    }
+
+    public Date getCoursesEndDate() {
+        return coursesEndDate;
+    }
+
+    public void setCoursesEndDate(Date coursesEndDate) {
+        this.coursesEndDate = coursesEndDate;
+    }
+
+    public Integer getSurplusClassTimes() {
+        return surplusClassTimes;
+    }
+
+    public void setSurplusClassTimes(Integer surplusClassTimes) {
+        this.surplusClassTimes = surplusClassTimes;
+    }
+
+    public String getStudentNames() {
+        return studentNames;
+    }
+
+    public void setStudentNames(String studentNames) {
+        this.studentNames = studentNames;
+    }
+}

+ 60 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GroupCourseTimesDto.java

@@ -0,0 +1,60 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.GroupType;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/3/8
+ */
+public class GroupCourseTimesDto {
+
+    private String groupId;
+
+    private GroupType groupType;
+
+    private Integer classGroupId;
+
+    private Integer totalCourseTimes;
+
+    private Integer surplusClassTimes;
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public GroupType getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(GroupType groupType) {
+        this.groupType = groupType;
+    }
+
+    public Integer getClassGroupId() {
+        return classGroupId;
+    }
+
+    public void setClassGroupId(Integer classGroupId) {
+        this.classGroupId = classGroupId;
+    }
+
+    public Integer getTotalCourseTimes() {
+        return totalCourseTimes;
+    }
+
+    public void setTotalCourseTimes(Integer totalCourseTimes) {
+        this.totalCourseTimes = totalCourseTimes;
+    }
+
+    public Integer getSurplusClassTimes() {
+        return surplusClassTimes;
+    }
+
+    public void setSurplusClassTimes(Integer surplusClassTimes) {
+        this.surplusClassTimes = surplusClassTimes;
+    }
+}

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CoursesGroupService.java

@@ -1,9 +1,12 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.CourseGroupCreateDto;
+import com.ym.mec.biz.dal.dto.CourseGroupTeacherCardDto;
 import com.ym.mec.biz.dal.entity.CoursesGroup;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface CoursesGroupService extends BaseService<Long, CoursesGroup> {
 
     /**
@@ -15,4 +18,13 @@ public interface CoursesGroupService extends BaseService<Long, CoursesGroup> {
      */
     void createCourseGroup(CourseGroupCreateDto courseGroupCreateInfo);
 
+    /**
+     * @describe 获取教师课程组列表
+     * @author Joburgess
+     * @date 2020/3/8
+     * @param teacherId: 教师编号
+     * @return java.util.List<com.ym.mec.biz.dal.dto.CourseGroupTeacherCardDto>
+     */
+    List<CourseGroupTeacherCardDto> findTeacherCourseGroups(Integer teacherId);
+
 }

+ 53 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CoursesGroupServiceImpl.java

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.CourseGroupCreateDto;
+import com.ym.mec.biz.dal.dto.CourseGroupTeacherCardDto;
 import com.ym.mec.biz.dal.dto.CourseTimeDto;
+import com.ym.mec.biz.dal.dto.GroupCourseTimesDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.CourseScheduleService;
@@ -17,9 +19,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup> implements CoursesGroupService {
@@ -44,6 +48,10 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
     @Autowired
     private TeacherAttendanceDao teacherAttendanceDao;
+    @Autowired
+    private SubjectDao subjectDao;
+    @Autowired
+    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 
     @Override
     public BaseDAO<Long, CoursesGroup> getDAO() {
@@ -171,4 +179,49 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
         courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
         teacherAttendanceDao.batchInsert(teacherAttendances);
     }
+
+    @Override
+    public List<CourseGroupTeacherCardDto> findTeacherCourseGroups(Integer teacherId) {
+        if(Objects.isNull(teacherId)){
+            throw new BizException("请指定老师");
+        }
+        List<CoursesGroup> teacherCourseGroups = coursesGroupDao.findTeacherCourseGroups(teacherId);
+        if (CollectionUtils.isEmpty(teacherCourseGroups)){
+            return new ArrayList<>();
+        }
+
+        List<String> groupIds = teacherCourseGroups.stream().map(group -> String.valueOf(group.getId())).collect(Collectors.toList());
+
+        List<Integer> subjectIds = teacherCourseGroups.stream().map(CoursesGroup::getSubjectId).collect(Collectors.toList());
+        List<Subject> subjects = subjectDao.findBySubjectIds(subjectIds);
+        Map<Integer, Subject> idSubjectMap = subjects.stream().collect(Collectors.toMap(Subject::getId, subject -> subject));
+
+        List<ClassGroupStudentMapper> students = classGroupStudentMapperDao.findByGroups(groupIds, GroupType.COMM);
+        Map<String, List<ClassGroupStudentMapper>> groupStudentsMap = students.stream().collect(Collectors.groupingBy(ClassGroupStudentMapper::getMusicGroupId));
+
+        List<GroupCourseTimesDto> groupsCourseTimesInfo = courseScheduleDao.findGroupsCourseTimesInfo(groupIds, GroupType.COMM);
+        Map<String, GroupCourseTimesDto> groupCourseTimesInfoMap = groupsCourseTimesInfo.stream().collect(Collectors.toMap(GroupCourseTimesDto::getGroupId, e -> e));
+
+        List<CourseGroupTeacherCardDto> groupCards=new ArrayList<>();
+        for (CoursesGroup teacherCourseGroup : teacherCourseGroups) {
+            CourseGroupTeacherCardDto groupCard=new CourseGroupTeacherCardDto();
+            groupCard.setId(teacherCourseGroup.getId());
+            groupCard.setName(teacherCourseGroup.getName());
+            groupCard.setSingleClassMinutes(teacherCourseGroup.getSingleClassMinutes());
+            groupCard.setCoursesStartDate(teacherCourseGroup.getCoursesStartDate());
+            groupCard.setCoursesEndDate(teacherCourseGroup.getCoursesEndDate());
+            groupCard.setSubjectId(teacherCourseGroup.getSubjectId());
+            groupCard.setSubjectName(idSubjectMap.get(teacherCourseGroup.getSubjectId()).getName());
+            GroupCourseTimesDto groupCourseTimesInfo = groupCourseTimesInfoMap.get(String.valueOf(teacherCourseGroup.getId()));
+            groupCard.setTotalCourseTimes(groupCourseTimesInfo.getTotalCourseTimes());
+            groupCard.setSurplusClassTimes(groupCourseTimesInfo.getSurplusClassTimes());
+            List<ClassGroupStudentMapper> groupStudents = groupStudentsMap.get(String.valueOf(teacherCourseGroup.getId()));
+            if(!CollectionUtils.isEmpty(groupStudentsMap)){
+                List<String> userNames = groupStudents.stream().map(ClassGroupStudentMapper::getUserName).collect(Collectors.toList());
+                groupCard.setStudentNames(StringUtils.join(userNames,","));
+            }
+            groupCards.add(groupCard);
+        }
+        return groupCards;
+    }
 }

+ 16 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GroupClassServiceImpl.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CoursesGroup;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
@@ -56,6 +57,8 @@ public class GroupClassServiceImpl implements GroupClassService {
     private SysUserCashAccountService sysUserCashAccountService;
     @Autowired
     private StudentPaymentOrderDao studentPaymentOrderDao;
+    @Autowired
+    private CoursesGroupDao coursesGroupDao;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -115,6 +118,7 @@ public class GroupClassServiceImpl implements GroupClassService {
         if(Objects.isNull(groupType)){
             throw new BizException("请指定课程组类型");
         }
+        Date now=new Date();
         if(groupType.equals(GroupType.PRACTICE)){
             PracticeGroup practiceGroup = practiceGroupDao.get(groupId);
             if(Objects.isNull(practiceGroup)){
@@ -127,7 +131,6 @@ public class GroupClassServiceImpl implements GroupClassService {
             if(refundAmount.compareTo(orders.get(0).getExpectAmount())>0){
                 throw new BizException("退款不可大于购买金额");
             }
-            Date now=new Date();
             if(!practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL)||practiceGroup.getCoursesExpireDate().before(now)){
                 throw new BizException("当前课程组不可关闭");
             }
@@ -139,6 +142,18 @@ public class GroupClassServiceImpl implements GroupClassService {
             practiceGroup.setGroupStatus(GroupStatusEnum.CANCEL);
             practiceGroup.setUpdateTime(now);
             practiceGroupDao.update(practiceGroup);
+        }else if(groupType.equals(GroupType.COMM)){
+            CoursesGroup coursesGroup = coursesGroupDao.get(groupId);
+            if(Objects.isNull(coursesGroup)){
+                throw new BizException("指定的课程组不存在");
+            }
+            if(coursesGroup.getCoursesEndDate().before(now)){
+                throw new BizException("当前课程组不可关闭");
+            }
+            cleanGroupInfo(groupId.toString(), GroupType.COMM);
+            coursesGroup.setMemo("主动关闭课程组");
+            coursesGroup.setStatus(GroupStatusEnum.CANCEL);
+            coursesGroupDao.update(coursesGroup);
         }
     }
 }

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -394,4 +394,17 @@
 		LEFT JOIN course_schedule_student_payment cssp on cssp.course_schedule_id_ = cs.id_ and cssp.user_id_ = cgsm.user_id_
 		WHERE cssp.id_ IS NULL AND cgsm.status_ != 'QUIT' and cs.id_ = #{courseScheduleId}
     </select>
+    <select id="findByGroups" resultMap="ClassGroupStudentMapper">
+      SELECT
+          cgsm.*,
+	      su.username_
+        FROM class_group_student_mapper cgsm
+            LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
+        WHERE
+          cgsm.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND cgsm.music_group_id_ IN
+          <foreach collection="groupIds" item="groupId" separator="," open="(" close=")">
+              #{groupId}
+          </foreach>
+    </select>
 </mapper>

+ 29 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -2593,6 +2593,35 @@
         SELECT * FROM course_schedule WHERE group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND music_group_id_ = #{groupId} AND CONCAT(class_date_, ' ', start_class_time_)>NOW()
     </select>
 
+    <resultMap id="GroupCourseTimesDto" type="com.ym.mec.biz.dal.dto.GroupCourseTimesDto">
+        <result property="groupId" column="group_id_"/>
+        <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result property="classGroupId" column="class_group_id_"/>
+        <result property="totalCourseTimes" column="total_course_times_"/>
+        <result property="surplusClassTimes" column="surplus_class_times_"/>
+    </resultMap>
+
+    <select id="findGroupsCourseTimesInfo" resultMap="GroupCourseTimesDto">
+       SELECT
+            cg.music_group_id_ group_id_,
+            cg.group_type_,
+            cg.id_ class_group_id_,
+            cg.total_class_times_ total_course_times_,
+            COUNT( cs.id_ ) surplus_class_times_
+        FROM
+            course_schedule cs
+            LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
+        WHERE
+            cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > NOW( )
+            AND cs.music_group_id_ IN
+            <foreach collection="groupIds" item="groupId" separator="," open="(" close=")">
+                #{groupId}
+            </foreach>
+        GROUP BY
+            cg.id_
+    </select>
+
     <update id="updateCourseNameByGroup">
         UPDATE course_schedule SET name_=#{name} WHERE group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND music_group_id_ = #{groupId};
     </update>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/CoursesGroupMapper.xml

@@ -125,4 +125,8 @@
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM courses_group
 	</select>
+
+    <select id="findTeacherCourseGroups" resultMap="CoursesGroup">
+		SELECT * FROM courses_group WHERE teacher_id_=#{teacherId} AND status_ IN ('APPLYING', 'NORMAL') ORDER BY id_ DESC
+    </select>
 </mapper>

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -216,4 +216,10 @@
             sr.user_id_=#{student.studentId} AND sr.music_group_id_=#{student.musicGroupId}
         </foreach>
     </select>
+    <select id="findBySubjectIds" resultMap="Subject">
+      SELECT * FROM subject WHERE id_ IN
+      <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
+          #{subjectId}
+      </foreach>
+    </select>
 </mapper>

+ 21 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/CourseGroupController.java

@@ -3,7 +3,9 @@ package com.ym.mec.teacher.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.CourseGroupCreateDto;
+import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.service.CoursesGroupService;
+import com.ym.mec.biz.service.GroupClassService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
@@ -27,6 +29,8 @@ public class CourseGroupController extends BaseController {
     private CoursesGroupService coursesGroupService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private GroupClassService groupClassService;
 
     @ApiOperation(value = "创建课程组")
     @PostMapping("/createCourseGroup")
@@ -40,4 +44,21 @@ public class CourseGroupController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation(value = "获取课程组列表")
+    @GetMapping("/findTeacherCourseGroups")
+    public HttpResponseResult findTeacherCourseGroups(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(Objects.isNull(sysUser)){
+            return failed(HttpStatus.FORBIDDEN,"请登录");
+        }
+        return succeed(coursesGroupService.findTeacherCourseGroups(sysUser.getId()));
+    }
+
+    @ApiOperation(value = "关闭课程组")
+    @PostMapping("/cancelCourseGroup")
+    public HttpResponseResult cancelCourseGroup(Long groupId){
+        groupClassService.cancelGroup(groupId, GroupType.COMM, null);
+        return succeed();
+    }
+
 }