瀏覽代碼

1、退课后删除对应学生的课表
2、小课加学员新增人数限制

Joburgess 5 年之前
父節點
當前提交
804dda5ed0

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

@@ -76,4 +76,25 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @return java.math.BigDecimal
      */
     BigDecimal countAllCourseFee(@Param("classGroupId") Integer classGroupId);
+
+    /**
+     * @describe 删除用户在指定班级上的课程
+     * @author Joburgess
+     * @date 2019/12/3
+     * @param ids: 学生课程缴费信息编号
+     * @return int
+     */
+    int batchDeleteWithID(@Param("ids") List<Integer> ids);
+
+    /**
+     * @describe 获取用户在指定班级上缴费记录编号
+     * @author Joburgess
+     * @date 2019/12/3
+     * @param classGroupId:
+     * @param userId:
+     * @return java.util.List<java.lang.Integer>
+     */
+    List<Integer> findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(@Param("classGroupId") Integer classGroupId,
+                                                                              @Param("userId") Integer userId);
+
 }

+ 39 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1171,6 +1171,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		courseScheduleService.batchDeleteMusicGroupCourseWithStudent(vipGroupId.toString(),studentId,GroupType.VIP);
 
+        List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(classGroup.getId(), studentId);
+        if(!CollectionUtils.isEmpty(studentPaymentIds)){
+            courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
+        }
+
 //		classGroup.setStudentNum(classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId()));
 //		classGroupDao.update(classGroup);
 
@@ -1261,6 +1266,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 //				classGroup.setStudentNum(classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId()));
 //				classGroupDao.update(classGroup);
 
+                List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(classStudentMapperByUserIdAndClassGroupId.getClassGroupId(), studentApplyRefunds.getUserId());
+                if(!CollectionUtils.isEmpty(studentPaymentIds)){
+                    courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
+                }
+
 				courseScheduleService.batchDeleteMusicGroupCourseWithStudent(studentPaymentOrder.getMusicGroupId(),studentApplyRefunds.getUserId(),GroupType.VIP);
 
 				//学员退出班级群
@@ -1563,7 +1573,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
 
-		Integer exitStudentNum = classGroupStudentMapperDao.countClassGroupExitStudentNum(classGroup.getId(), studentIds);
+        Integer studentNum = classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId());
+        if(studentNum.compareTo(classGroup.getExpectStudentNum())>=0){
+            throw new BizException("该班级人数已达上限");
+        }
+
+        Integer exitStudentNum = classGroupStudentMapperDao.countClassGroupExitStudentNum(classGroup.getId(), studentIds);
 		if(exitStudentNum>0){
 			throw new BizException("选择的学生中存在此课程中已存在的学生");
 		}
@@ -1583,11 +1598,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				surplusCoursesPrice=surplusCoursesPrice.add(vipGroup.getOnlineClassesUnitPrice());
 			}
 		}
-		List<CourseSchedule> vipGroupCourseSchedules=courseScheduleDao.findVipGroupCourseSchedules(vipGroupId);
-
-		if(CollectionUtils.isEmpty(vipGroupCourseSchedules)){
-			throw new BizException("此vip课不存在课程");
-		}
 
 		List<ImGroupMember> imGroupMemberList = new ArrayList<>();
 		List<ClassGroupStudentMapper> classGroupStudentMappers=new ArrayList<>();
@@ -1600,7 +1610,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 //			courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupId,studentId);
 
 			List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
-			for (CourseSchedule vipGroupCourseSchedule : vipGroupCourseSchedules) {
+			for (CourseSchedule vipGroupCourseSchedule : surplusCourses) {
 				CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
 				courseScheduleStudentPayment.setGroupType(GroupType.VIP);
 				courseScheduleStudentPayment.setMusicGroupId(vipGroupId.toString());
@@ -1702,22 +1712,31 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		List<VipGroup> normalVipGroupList = vipGroupDao.queryNormalStatusList();
 		if (!CollectionUtils.isEmpty(normalVipGroupList)){
             Date now = new Date();
+            List<VipGroup> needUpdateVipGroups = new ArrayList<>();
             for (VipGroup vipGroup : normalVipGroupList) {
-                if(now.before(vipGroup.getRegistrationStartTime())){
-                    vipGroup.setStatus(VipGroupStatusEnum.NOT_START);
-                }
-                if(vipGroup.getRegistrationStartTime().before(now)&&vipGroup.getCoursesExpireDate().after(now)){
-                    vipGroup.setStatus(VipGroupStatusEnum.APPLYING);
-                }
-                if(vipGroup.getCoursesExpireDate().before(now)&&vipGroup.getCourseStartDate().after(now)){
-                    vipGroup.setStatus(VipGroupStatusEnum.APPLYING_END);
-                }
-                if(vipGroup.getCourseStartDate().before(now)&&vipGroup.getCoursesExpireDate().after(now)){
-                    vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
+                try {
+                    if(now.before(vipGroup.getRegistrationStartTime())){
+                        vipGroup.setStatus(VipGroupStatusEnum.NOT_START);
+                    }
+                    if(vipGroup.getRegistrationStartTime().before(now)&&vipGroup.getCoursesExpireDate().after(now)){
+                        vipGroup.setStatus(VipGroupStatusEnum.APPLYING);
+                    }
+                    if(vipGroup.getCoursesExpireDate().before(now)&&vipGroup.getCourseStartDate().after(now)){
+                        vipGroup.setStatus(VipGroupStatusEnum.APPLYING_END);
+                    }
+                    if(vipGroup.getCourseStartDate().before(now)&&vipGroup.getCoursesExpireDate().after(now)){
+                        vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
+                    }
+                    VipGroup vipGroup1 = new VipGroup();
+                    vipGroup1.setId(vipGroup.getId());
+                    vipGroup1.setStatus(vipGroup.getStatus());
+                    vipGroup1.setUpdateTime(now);
+                    needUpdateVipGroups.add(vipGroup1);
+                } catch (Exception e) {
+                    e.printStackTrace();
                 }
-                vipGroup.setUpdateTime(now);
             }
-            vipGroupDao.batchUpdate(normalVipGroupList);
+            vipGroupDao.batchUpdate(needUpdateVipGroups);
         }
 	}
 

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -134,10 +134,11 @@
         FROM
             course_schedule_student_payment cssp
             LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
-            LEFT JOIN student_attendance sa ON cssp.course_schedule_id_ = sa.course_schedule_id_
-            AND cssp.user_id_ = sa.user_id_
+            LEFT JOIN student_attendance sa ON cssp.course_schedule_id_ = sa.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
+            LEFT JOIN class_group_student_mapper cgsm ON cssp.user_id_=cgsm.user_id_ AND cssp.class_group_id_=cgsm.class_group_id_
         WHERE
             cssp.course_schedule_id_ =#{courseScheduleId}
+            AND cgsm.status_!='QUIT'
     </select>
 
     <update id="deleteStudentByMusicGroupId" parameterType="map">

+ 2 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -974,7 +974,6 @@
             (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
             AND cs.class_group_id_ = #{classGroupId}
             AND csts.user_id_ = #{userId}
-            AND csts.expect_salary_ != 0
             <if test="onlyHistory!=null and onlyHistory==1">
                 AND CONCAT( cs.class_date_, ' ', cs.end_class_time_ )&lt;now()
             </if>
@@ -1333,6 +1332,8 @@
     <select id="findByClassGroupAndStatus" resultMap="CourseSchedule">
       select
         cs.id_,
+        cs.group_type_,
+        cs.music_group_id_,
         cs.class_group_id_,
         cs.status_,
         cs.subsidy_,

+ 10 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -162,8 +162,11 @@
 		(cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
 		AND cs.class_group_id_ = #{classGroupId}
     </select>
+	<select id="findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent" resultType="int">
+		SELECT id_ FROM course_schedule_student_payment WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
+	</select>
 
-    <delete id="deleteStudentCourseSchedule">
+	<delete id="deleteStudentCourseSchedule">
 		DELETE FROM course_schedule_student_payment WHERE user_id_ = #{userId} AND course_schedule_id_ IN
 		<foreach collection="courseScheduleList" item="courseSchedule" index="index" open="(" close=")" separator=",">
 			#{courseSchedule.id}
@@ -175,4 +178,10 @@
 			#{courseScheduleId}
 		</foreach>
 	</delete>
+    <delete id="batchDeleteWithID">
+		DELETE FROM course_schedule_student_payment WHERE id_ IN
+		<foreach collection="ids" item="id" open="(" close=")" separator=",">
+			#{id}
+		</foreach>
+    </delete>
 </mapper>