|
@@ -12,9 +12,7 @@ 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;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
|
|
@@ -106,4 +104,52 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
|
|
|
courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean addStudents(Integer classGroupId, String userIdsStr) throws Exception {
|
|
|
+ ClassGroup classGroup = classGroupService.get(classGroupId);
|
|
|
+ if (classGroup == null) {
|
|
|
+ throw new Exception("添加学员的班级不存在");
|
|
|
+ }
|
|
|
+ Date nowDate = new Date();
|
|
|
+ HashSet<String> userIdStrSet = new HashSet<>(Arrays.asList(userIdsStr.split(",")));
|
|
|
+
|
|
|
+ //1、班级关系添加
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
|
|
|
+ for (String userIdStr : userIdStrSet) {
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroupId);
|
|
|
+ classGroupStudentMapper.setUserId(Integer.parseInt(userIdStr));
|
|
|
+ classGroupStudentMapper.setCreateTime(nowDate);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMappers.add(classGroupStudentMapper);
|
|
|
+ }
|
|
|
+ classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);
|
|
|
+
|
|
|
+ //2、班级人数调整
|
|
|
+ classGroupService.updateClassStudentNum(classGroupId.longValue(), userIdStrSet.size());
|
|
|
+
|
|
|
+ //3、学生加入新班级未开始课程
|
|
|
+ List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
|
|
|
+
|
|
|
+ BigDecimal coursePrice = new BigDecimal("0");
|
|
|
+
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
+ for (CourseSchedule courseSchedule : courseScheduleList) {
|
|
|
+ for (String userIdStr : userIdStrSet) {
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setUserId(Integer.parseInt(userIdStr));
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(coursePrice);
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroupId);
|
|
|
+ courseScheduleStudentPayment.setCreateTime(nowDate);
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(nowDate);
|
|
|
+ courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|