浏览代码

feat: 解决由于学员不一致导致的vip课休学时未上课时不删除问题

Joburgess 4 年之前
父节点
当前提交
fd18f85bf5

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

@@ -115,6 +115,17 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
                                                                               @Param("userId") Integer userId);
 
     /**
+     * @describe 统计团体下为开始课程学生数量
+     * @author Joburgess
+     * @date 2020.09.27
+     * @param groupId:
+     * @param groupType:
+     * @return int
+     */
+    int countNotStartCourseStudentNumWithGroup(@Param("groupId") String groupId,
+                                      @Param("groupType") GroupType groupType);
+
+    /**
      * @param vipGroupId: 小课编号
      * @param teachMode:  教学形式
      * @return java.math.BigDecimal

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

@@ -3369,7 +3369,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         practiceBuyResult.setCreateTime(order.getCreateTime());
         practiceBuyResult.setPrice(order.getExpectAmount());
         practiceBuyResult.setType(order.getType().getCode());
-        if (order.getStatus().equals(DealStatusEnum.FAILED) || order.getGroupType().equals(GroupType.REPAIR)) {
+        if (order.getStatus().equals(DealStatusEnum.FAILED) || order.getGroupType().equals(GroupType.REPAIR)||Objects.isNull(order.getMusicGroupId())) {
             return practiceBuyResult;
         }
         SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);

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

@@ -1805,10 +1805,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		int studentCourseNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(classGroup.getId());
 		if(studentCourseNum<=0&&classGroup.getStudentNum().equals(classGroup.getExpectStudentNum())){
 			vipGroup.setStatus(VipGroupStatusEnum.PAUSE);
-			if(!CollectionUtils.isEmpty(courseScheduleIds)){
-				courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
-				courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
-				teacherAttendanceDao.batchDeleteByCourseSchedules(courseScheduleIds);
+			int notStartCourseStudentNum = courseScheduleStudentPaymentDao.countNotStartCourseStudentNumWithGroup(vipGroupId.toString(), GroupType.VIP);
+			if(notStartCourseStudentNum<=0){
+				List<CourseSchedule> groupNotFinishCourses = courseScheduleDao.findGroupNotFinishCourses(vipGroupId.toString(), GroupType.VIP);
+				List<Long> csIds = groupNotFinishCourses.stream().map(CourseSchedule::getId).collect(Collectors.toList());
+				courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(csIds);
+				courseScheduleDao.batchDeleteCourseSchedules(csIds);
+				teacherAttendanceDao.batchDeleteByCourseSchedules(csIds);
 			}
 			vipGroupDao.update(vipGroup);
 		}

+ 12 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -495,4 +495,16 @@
 		WHERE cssp.course_schedule_id_ = #{courseScheduleId}
 		AND NOT EXISTS (SELECT * FROM rongyun_room_member rrm WHERE rrm.rid = #{roomId} AND rrm.uid = cssp.user_id_)
 	</select>
+
+	<select id="countNotStartCourseStudentNumWithGroup" resultType="int">
+		SELECT
+			COUNT( cssp.user_id_ )
+		FROM
+			course_schedule_student_payment cssp
+			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+		WHERE
+			cssp.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+			AND cssp.music_group_id_ = #{groupId}
+			AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > NOW( )
+	</select>
 </mapper>