瀏覽代碼

Merge remote-tracking branch 'origin/master'

Joburgess 4 年之前
父節點
當前提交
4e080a0f8e

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

@@ -410,4 +410,22 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @return
      */
     List<CourseScheduleStudentPayment> queryCourseByIdsAndStudentId(@Param("courseIds") List<Long> courseIds, @Param("studentId") Integer studentId, @Param("courseType") String courseType);
+
+    /**
+     * 获取班级学员关联的编号
+     * @zouxuan
+     * @param classGroupIds
+     * @param studentIds
+     * @return
+     */
+    List<Long> queryStudentNotStartByClassIdsAndStudentIds(@Param("classGroupIds") List<Integer> classGroupIds, @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 获取指定列表中学员的费用列表
+     * @author zouxuan
+     * @param studentPaymentIds
+     * @param studentId
+     * @return
+     */
+    List<CourseScheduleStudentPayment> queryByIdsAndStudentId(@Param("studentPaymentIds") List<Long> studentPaymentIds, @Param("studentId") Integer studentId, @Param("courseType") String courseType);
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentClassAdjust.java

@@ -31,6 +31,9 @@ public class MusicGroupStudentClassAdjust {
 	@ApiModelProperty(value = "所有冻结的课程列表", required = false)
 	private String allLockCourseIds;
 
+	@ApiModelProperty(value = "学员课程编号", required = false)
+	private String studentPaymentIds;
+
 	@ApiModelProperty(value = "所选学员冻结的课程列表", required = false)
 	private String subLockCourseIds;
 
@@ -107,6 +110,15 @@ public class MusicGroupStudentClassAdjust {
 		this.subLockCourseIds = subLockCourseIds;
 	}
 
+
+	public String getStudentPaymentIds() {
+		return studentPaymentIds;
+	}
+
+	public void setStudentPaymentIds(String studentPaymentIds) {
+		this.studentPaymentIds = studentPaymentIds;
+	}
+
 	public boolean isCourseFlag() {
 		return courseFlag;
 	}

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3392,9 +3392,13 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         //获取需要冻结的课程
         List<Long> allLockCourseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,null);
         musicGroupStudentClassAdjust.setAllLockCourseIds(JSON.toJSONString(allLockCourseIds));
-        //获取需要删除的课程
+        //获取需要删除的学员关联的课程
         List<Long> courseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,studentIds);
-        musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
+
+        List<Long> studentPaymentIds = courseScheduleStudentPaymentDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,studentIds);
+
+//        musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
+        musicGroupStudentClassAdjust.setStudentPaymentIds(JSON.toJSONString(studentPaymentIds));
         //计算新增班级的可排课时长,总课次*默认时长  (用学员剩余的课程时长加上购买的时长,可能导致同一班级学员时长不一致)
         musicGroupStudentClassAdjust.setClassCourseMinute(JSON.toJSONString(findClassCourseMinuteMap(classGroupIds)));
         if(status == null || status != AUDITING){
@@ -3422,10 +3426,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 classGroupService.classGroupAdjust(classGroup4MixDtos);
             }
             //排课完成后删除所选课程
-            courseScheduleDao.batchDeleteCourseSchedules(courseIds);
-            courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseIds);
-            teacherAttendanceDao.batchDeleteByCourseSchedules(courseIds);
-            courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseIds);
+            courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds,studentIds);
         }else {
             //冻结班级
             classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds,1);

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

@@ -314,7 +314,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	public void createForMusicGroup(List<CourseSchedule> courseSchedules, List<Integer> studentIds,Integer musicGroupStudentClassAdjustId) {
 		//获取提交的合班申请
 		MusicGroupStudentClassAdjust classAdjust = musicGroupStudentClassAdjustDao.get(musicGroupStudentClassAdjustId);
-		List<Long> courseIds = JSON.parseArray(classAdjust.getSubLockCourseIds(), Long.class);
+		List<Long> studentPaymentIds = JSON.parseArray(classAdjust.getStudentPaymentIds(), Long.class);
 		String batchNo = classAdjust.getBatchNo();
 
 		List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
@@ -328,11 +328,11 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				CourseSchedule courseSchedule = courseSchedules.get(i);
 				//优先处理之前的剩余课程
 				//获取调班之前,学员剩余的课程列表
-				if(courseIds != null && courseIds.size() > 0){
-					List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.queryCourseByIdsAndStudentId(courseIds,studentId,courseSchedule.getType().getCode());
+				if(studentPaymentIds != null && studentPaymentIds.size() > 0){
+					List<CourseScheduleStudentPayment> studentPayments = courseScheduleStudentPaymentDao.queryByIdsAndStudentId(studentPaymentIds,studentId,courseSchedule.getType().getCode());
 					if(studentPayments != null && studentPayments.size() > 0){
 						CourseScheduleStudentPayment studentPayment = studentPayments.get(0);
-						courseIds.remove(studentPayment.getCourseScheduleId());
+						studentPaymentIds.remove(studentPayment.getCourseScheduleId());
 						studentPayment.setCourseScheduleId(courseSchedule.getId());
 						studentPayment.setClassGroupId(courseSchedule.getClassGroupId());
 						studentPayment.setOpenPlayMidi(null);

+ 15 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -360,19 +360,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
 					.getMusicGroupPaymentCalenderCourseSettingsList();
 
-			if (musicGroupPaymentCalender.getStatus() != AUDITING) {
-				// 如果是进行中加学生
-				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
-				}
-				if(StringUtils.isEmpty(musicGroupPaymentCalenderDto.getBatchNo())){
-					//缴费项目添加学员
-					int[] ints = Arrays.stream(musicGroupPaymentCalenderDto.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();
-					List<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toList());
-					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender.getId(),list2);
-				}
-			}
-
 			if (currentMusicGroupPaymentCalenderCourseSettings.size() > 0) {
 				MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender
 						.getMusicGroupOrganizationCourseSettingId());
@@ -384,6 +371,19 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 				musicGroupPaymentCalenderCourseSettingsDao.batchInsert(currentMusicGroupPaymentCalenderCourseSettings);
 			}
+
+			if (musicGroupPaymentCalender.getStatus() != AUDITING) {
+				// 如果是进行中加学生
+				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
+				}
+				if(StringUtils.isNotEmpty(musicGroupPaymentCalenderDto.getBatchNo())){
+					//缴费项目添加学员
+					int[] ints = Arrays.stream(musicGroupPaymentCalenderDto.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();
+					List<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toList());
+					musicGroupPaymentCalenderDetailService.batchAdd(musicGroupPaymentCalender.getId(),list2);
+				}
+			}
 		}
 
 		// 如果是报名,需要修改乐团状态
@@ -919,11 +919,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		musicGroupStudentClassAdjust.setCourseFlag(true);
 		//排课完成后删除所选课程
 		List<Long> courseIds = JSON.parseArray(musicGroupStudentClassAdjust.getSubLockCourseIds(), Long.class);
-//		courseScheduleDao.batchDeleteByCourseSchedules(courseIds);
-		courseScheduleDao.batchDeleteCourseSchedules(courseIds);
-		courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseIds);
-		teacherAttendanceDao.batchDeleteByCourseSchedules(courseIds);
-		courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseIds);
+		List<Integer> studentIds = JSON.parseArray(musicGroupStudentClassAdjust.getStudentIds(), Integer.class);
+		courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds,studentIds);
 		//解冻课程
 		List<Long> allCourseIds = JSON.parseArray(musicGroupStudentClassAdjust.getAllLockCourseIds(), Long.class);
 		courseScheduleDao.batchUpdateLockByCourseIds(allCourseIds,0);

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

@@ -643,4 +643,29 @@
 		</foreach>
 		AND cssp.user_id_ = #{studentId} AND cs.type_ = #{courseType}
 	</select>
+	<select id="queryStudentNotStartByClassIdsAndStudentIds" resultType="java.lang.Long">
+		SELECT cssp.id_ FROM course_schedule_student_payment cssp
+		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+		WHERE cssp.class_group_id_ IN
+		<foreach collection="classGroupIds" open="(" close=")" separator="," item="item">
+			#{item}
+		</foreach>
+		<if test="studentIds != null">
+			AND cssp.user_id_ IN
+			<foreach collection="studentIds" open="(" close=")" separator="," item="item">
+				#{item}
+			</foreach>
+		</if>
+		AND CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW()
+		GROUP BY cssp.id_
+	</select>
+	<select id="queryByIdsAndStudentId" resultMap="CourseScheduleStudentPayment">
+		SELECT cssp.* FROM course_schedule_student_payment cssp
+		LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+		WHERE cssp.id_ IN
+		<foreach collection="studentPaymentIds" open="(" item="item" close=")" separator=",">
+			#{item}
+		</foreach>
+		AND cssp.user_id_ = #{studentId} AND cs.type_ = #{courseType}
+	</select>
 </mapper>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml

@@ -16,6 +16,7 @@
 		<result column="class_course_minute_" property="classCourseMinute" />
 		<result column="all_lock_course_ids_" property="allLockCourseIds" />
 		<result column="sub_lock_course_ids_" property="subLockCourseIds" />
+		<result column="student_payment_ids_" property="studentPaymentIds" />
 		<result column="course_flag_" property="courseFlag" />
 		<result column="operator_id_" property="operatorId" />
 		<result column="create_time_" property="createTime" />
@@ -36,14 +37,17 @@
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO music_group_student_class_adjust (music_group_id_,batch_no_,new_class_group_json_,
 		class_group_ids_,student_ids_,class_course_minute_,all_lock_course_ids_,sub_lock_course_ids_,
-		course_flag_,operator_id_,create_time_,update_time_)
+		course_flag_,operator_id_,student_payment_ids_,create_time_,update_time_)
 		VALUES(#{musicGroupId},#{batchNo},#{newClassGroupJson},#{classGroupIds},#{studentIds},
-		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{courseFlag},#{operatorId},NOW(),NOW())
+		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{courseFlag},#{operatorId},#{studentPaymentIds},NOW(),NOW())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust">
 		UPDATE music_group_student_class_adjust <set>
+		<if test="studentPaymentIds != null">
+			student_payment_ids_ = #{studentPaymentIds},
+		</if>
 		<if test="courseFlag != null">
 		course_flag_ = #{courseFlag},
 		</if>