Joburgess před 5 roky
rodič
revize
ab47e5addf

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPauseInfoDao.java

@@ -5,6 +5,8 @@ import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * @Author Joburgess
  * @Date 2019/12/18
@@ -24,5 +26,15 @@ public interface StudentPauseInfoDao extends BaseDAO<Long, StudentPauseInfo> {
                                         @Param("groupId") String groupId,
                                         @Param("userId") Integer userId);
 
+    /**
+     * @describe 获取指定乐团下的学员休学信息
+     * @author Joburgess
+     * @date 2019/12/25
+     * @param groupType:
+     * @param groupId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.StudentPauseInfo>
+     */
+    List<StudentPauseInfo> findByGroup(@Param("groupType") GroupType groupType,
+                                       @Param("groupId") String groupId);
 
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPauseInfo.java

@@ -30,6 +30,16 @@ public class StudentPauseInfo {
 
     private int delFlag;
 
+    private int surplusCourseNum;
+
+    public int getSurplusCourseNum() {
+        return surplusCourseNum;
+    }
+
+    public void setSurplusCourseNum(int surplusCourseNum) {
+        this.surplusCourseNum = surplusCourseNum;
+    }
+
     public int getDelFlag() {
         return delFlag;
     }

+ 7 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1387,6 +1387,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentPauseInfo.setMusicGroupId(vipGroup.getId().intValue());
 		studentPauseInfo.setClassGroupId(classGroup.getId());
         studentPauseInfo.setCoursesJson(JSON.toJSONString(pauseInfos));
+        studentPauseInfo.setSurplusCourseNum(userSurplusCourseInfoByGroup.size());
 
         studentPauseInfoDao.insert(studentPauseInfo);
 
@@ -1462,7 +1463,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		Collections.reverse(coursePrices);
 
 		if(vipGroup.getStatus().equals(VipGroupStatusEnum.PAUSE)){
-			studentRecoverInfo.setCourseCount(teachModeSequence.length);
+			List<StudentPauseInfo> studentPauseInfos=studentPauseInfoDao.findByGroup(GroupType.VIP, vipGroup.getId().toString());
+			StudentPauseInfo studentPauseInfo1 = studentPauseInfos.stream().min(Comparator.comparing(StudentPauseInfo::getSurplusCourseNum)).get();
+			Map<String, Object> courseInfo1 = JSON.parseObject(studentPauseInfo1.getCoursesJson(), Map.class);
+			Integer[] teachModeSequence1=JSON.parseArray(courseInfo1.get("teaChModeSequence").toString(), Integer.class).stream().toArray(Integer[]::new);
+			studentRecoverInfo.setCourseCount(teachModeSequence1.length);
 			List<CourseSchedule> newCourseSchedules = courseScheduleService.createCourses(studentRecoverInfo);
 			for(int i=0;i<newCourseSchedules.size();i++){
 				newCourseSchedules.get(i).setGroupType(GroupType.VIP);
@@ -1473,7 +1478,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				newCourseSchedules.get(i).setActualTeacherId(vipGroup.getUserId());
 				newCourseSchedules.get(i).setTeacherId(vipGroup.getUserId());
 				newCourseSchedules.get(i).setType(CourseSchedule.CourseScheduleType.VIP);
-				newCourseSchedules.get(i).setTeachMode(teachModeSequence[i]==0?TeachModeEnum.OFFLINE:TeachModeEnum.ONLINE);
+				newCourseSchedules.get(i).setTeachMode(teachModeSequence1[i]==0?TeachModeEnum.OFFLINE:TeachModeEnum.ONLINE);
 			}
 			courseScheduleService.batchAddCourseSchedule(newCourseSchedules);
 

+ 13 - 2
mec-biz/src/main/resources/config/mybatis/StudentPauseInfoMapper.xml

@@ -16,6 +16,7 @@
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
         <result column="del_flag_" property="delFlag"/>
+        <result column="surplus_course_num" property="surplusCourseNum"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -32,8 +33,8 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPauseInfo" useGeneratedKeys="true"
             keyColumn="id"
             keyProperty="id">
-        INSERT INTO student_pause_info (group_type_,music_group_id_,class_group_id_,user_id_,courses_json_,create_time_,update_time_)
-        VALUES(#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{userId},#{coursesJson},now(),now())
+        INSERT INTO student_pause_info (group_type_,music_group_id_,class_group_id_,user_id_,courses_json_,create_time_,update_time_,surplus_course_num)
+        VALUES(#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{userId},#{coursesJson},now(),now(),#{surplusCourseNum})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -58,6 +59,9 @@
             <if test="delFlag != null">
                 del_flag_ = #{delFlag},
             </if>
+            <if test="surplusCourseNum != null">
+                surplus_course_num = #{surplusCourseNum},
+            </if>
             update_time_ = NOW()
         </set>
         WHERE id_ = #{id}
@@ -85,4 +89,11 @@
             AND user_id_ = #{userId}
             AND del_flag_ = 0
     </select>
+    <select id="findByGroup" resultMap="StudentPauseInfo">
+        SELECT * FROM student_pause_info
+        WHERE
+          group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            AND music_group_id_ = #{groupId}
+            AND del_flag_ = 0
+    </select>
 </mapper>