Browse Source

班级添加学生,处理学生在合奏班情况

周箭河 5 years ago
parent
commit
55d2cd2453

+ 8 - 28
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
@@ -177,17 +178,6 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
                 studentRegistration.setClassGroupId(classGroupId);
                 studentRegistrationService.update(studentRegistration);
             }
-            //班级在合奏班中
-            if (classGroupRelation != null) {
-                classGroupStudentMapper = new ClassGroupStudentMapper();
-                classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
-                classGroupStudentMapper.setClassGroupId(classGroupRelation.getClassGroupId());
-                classGroupStudentMapper.setUserId(userId);
-                classGroupStudentMapper.setCreateTime(nowDate);
-                classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-                classGroupStudentMapper.setGroupType(GroupType.MUSIC);
-                classGroupStudentMappers.add(classGroupStudentMapper);
-            }
             imGroupMemberList.add(new ImGroupMember(userId.toString()));
         }
 		if (classGroupStudentMappers.size() > 0) {
@@ -204,19 +194,6 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
         //3、学生加入新班级未开始课程
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
 
-        //4、班级在合奏班、添加合奏课程
-        if (classGroupRelation != null) {
-            //合奏班增加人数
-            classGroupService.updateClassStudentNum(classGroupRelation.getClassGroupId().longValue(), userIdStrSet.size());
-            List<CourseSchedule> mixCourseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupRelation.getClassGroupId());
-            courseScheduleList.addAll(mixCourseScheduleList);
-
-            //添加进合奏班IM群组
-            imFeignService.groupJoin(new ImGroupModel(classGroupRelation.getClassGroupId().toString(), imGroupMembers, null));
-        }
-
-        BigDecimal coursePrice = new BigDecimal("0");
-
         List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
         for (CourseSchedule courseSchedule : courseScheduleList) {
             for (String userIdStr : userIdStrSet) {
@@ -225,7 +202,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
                 courseScheduleStudentPayment.setMusicGroupId(classGroup.getMusicGroupId());
                 courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
                 courseScheduleStudentPayment.setUserId(Integer.parseInt(userIdStr));
-                courseScheduleStudentPayment.setExpectPrice(coursePrice);
+                courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
                 courseScheduleStudentPayment.setClassGroupId(classGroupId);
                 courseScheduleStudentPayment.setCreateTime(nowDate);
                 courseScheduleStudentPayment.setUpdateTime(nowDate);
@@ -233,11 +210,14 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
             }
         }
 
-        if (courseScheduleStudentPayments.size() == 0) {
-            return true;
+        if (courseScheduleStudentPayments.size() > 0) {
+            courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
+        }
+        //乐团在合奏班
+        if(classGroupRelation != null){
+            addStudents(classGroupRelation.getClassGroupId(),userIdsStr,GroupType.MUSIC);
         }
 
-        courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
         return true;
     }