|  | @@ -1,6 +1,7 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.CourseSchedule;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.StudentRegistration;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.CourseScheduleService;
 | 
	
	
		
			
				|  | @@ -16,6 +17,9 @@ import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
	
		
			
				|  | @@ -65,4 +69,39 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 | 
	
		
			
				|  |  |      public List<StudentRegistration> findClassStudentList(Integer classGroupId, ClassGroupStudentStatusEnum status) {
 | 
	
		
			
				|  |  |          return classGroupStudentMapperDao.findClassStudentList(classGroupId,status);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public boolean adjustClassGroup(Integer userId, Integer oldClassGroupId, Integer classGroupId) throws Exception {
 | 
	
		
			
				|  |  | +        ClassGroupStudentMapper classStudentMapper = findClassStudentMapperByUserIdAndClassGroupId(userId, oldClassGroupId);
 | 
	
		
			
				|  |  | +        if (classStudentMapper == null) {
 | 
	
		
			
				|  |  | +            throw new Exception("原班级学生不存在");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Date date = new Date();
 | 
	
		
			
				|  |  | +        //1、更新学生对应班级关系
 | 
	
		
			
				|  |  | +        classStudentMapper.setClassGroupId(classGroupId);
 | 
	
		
			
				|  |  | +        update(classStudentMapper);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //2、删除学生对应原班级未开始课程
 | 
	
		
			
				|  |  | +        List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(oldClassGroupId);
 | 
	
		
			
				|  |  | +        courseScheduleStudentPaymentService.deleteStudentCourseSchedule(userId, courseScheduleList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //3、学生加入新班级未开始课程
 | 
	
		
			
				|  |  | +        courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        BigDecimal coursePrice = new BigDecimal("0");
 | 
	
		
			
				|  |  | +        List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (CourseSchedule courseSchedule : courseScheduleList) {
 | 
	
		
			
				|  |  | +            CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayment.setUserId(userId);
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayment.setExpectPrice(coursePrice);
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayment.setClassGroupId(classGroupId);
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayment.setCreateTime(date);
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayment.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            courseScheduleStudentPayments.add(courseScheduleStudentPayment);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |