zouxuan 5 years ago
parent
commit
6894a4fd5e

+ 19 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -53,7 +53,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
     @Autowired
-    private SysMessageConfigDao sysMessageConfigDao;
+    private ClassGroupRelationDao classGroupRelationDao;
     @Autowired
     private SysMessageService sysMessageService;
     @Autowired
@@ -410,7 +410,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         if(studentRegistration == null){
             throw new Exception("参数校验失败");
         }
-        StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(studentRegistration.getMusicGroupId(), studentRegistration.getParentsPhone());
+        String musicGroupId = studentRegistration.getMusicGroupId();
+        StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(musicGroupId, studentRegistration.getParentsPhone());
         if (phoneAndMusicGroupId != null) {
             throw new Exception("该学员已存在");
         } else {
@@ -446,16 +447,17 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.NORMAL);
             //学生报名表
             studentRegistrationDao.insertBasic(studentRegistration);
-            MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+            MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
             Set<Integer> roleIds = new HashSet<>(1);
             roleIds.add(SysUserRole.OPERATION_EXECUTIVE);
             sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds), MessageTypeEnum.BACKSTAGE_MUSIC_GROUP_ADD_STUDENT, "", musicGroup.getName(), studentRegistration.getName());
             //增加报名学生数
-//            musicGroupSubjectPlanService.addApplyStudentNum(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId(),1);
-            if (studentRegistration.getClassGroupId() != null) {
-                ClassGroup classGroup = classGroupDao.get(studentRegistration.getClassGroupId());
+            musicGroupSubjectPlanService.addApplyStudentNum(musicGroupId, studentRegistration.getSubjectId(),1);
+            Integer classGroupId = studentRegistration.getClassGroupId();
+            if (classGroupId != null) {
+                ClassGroup classGroup = classGroupDao.get(classGroupId);
                 if (classGroup != null) {
-                    if (!classGroup.getMusicGroupId().equals(studentRegistration.getMusicGroupId())) {
+                    if (!classGroup.getMusicGroupId().equals(musicGroupId)) {
                         throw new Exception("班级录入错误");
                     } else {
                         //修改实际学生人数
@@ -466,13 +468,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 } else {
                     throw new Exception("班级不存在");
                 }
-                //新增班级学生关系
-                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(studentRegistration.getClassGroupId(), userId));
+                //新增班级学生关系(单技班)
+                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(classGroupId, userId));
+                //新增班级学生关系(合奏班)
+                ClassGroupRelation classGroupRelation = classGroupRelationDao.findClassGroupRelation(classGroupId);
+                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(classGroupRelation.getClassGroupId(), userId));
 
                 //获取当前月
                 Integer month = Integer.parseInt(DateUtil.getMonth(new Date()));
                 //获取下次缴费月份
-                List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(studentRegistration.getMusicGroupId());
+                List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
                 List<Integer> months = musicGroupPaymentCalenders.stream().map(e -> e.getPaymentMonth()).collect(Collectors.toList());
                 for (int i = 0; i < months.size(); i++) {
                     if (months.get(i).equals(month)) {
@@ -484,10 +489,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 DateUtil.getFirstDayOfMonth(calendar.getTime());
                 //保存乐团学生费用表
                 if(studentAddDto.getCourseFee() == null){
-                    MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
+                    MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
                     studentAddDto.setCourseFee(musicOneSubjectClassPlan.getFee());
                 }
-                musicGroupStudentFeeDao.insert(new MusicGroupStudentFee(studentRegistration.getMusicGroupId(),
+                musicGroupStudentFeeDao.insert(new MusicGroupStudentFee(musicGroupId,
                         userId, studentRegistration.getSubjectId(), studentAddDto.getCourseFee(),
                         DateUtil.getFirstDayOfMonth(calendar.getTime()), studentAddDto.getTemporaryCourseFee()));
                 //生成订单
@@ -495,8 +500,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrder.setUserId(userId);
                 studentPaymentOrder.setType(OrderTypeEnum.APPLY);
                 studentPaymentOrder.setStatus(DealStatusEnum.ING);
-                studentPaymentOrder.setMusicGroupId(studentRegistration.getMusicGroupId());
-                studentPaymentOrder.setClassGroupId(studentRegistration.getClassGroupId());
+                studentPaymentOrder.setMusicGroupId(musicGroupId);
+                studentPaymentOrder.setClassGroupId(classGroupId);
                 studentPaymentOrderService.insert(studentPaymentOrder);
                 //生成订单明细
                 List<StudentPaymentOrderDetail> studentPaymentOrderDetails = studentAddDto.getStudentPaymentOrderDetails();