ソースを参照

Merge remote-tracking branch 'origin/master'

Joburgess 5 年 前
コミット
3d0c163017

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -325,4 +325,12 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @return
      */
     List<ClassGroupTeachersDto> getClassGroupAndTeacherByType(String musicGroupId, ClassGroupTypeEnum type);
+
+    /**
+     * 添加IM群组
+     * @param classGroup
+     * @param userIds
+     * @return
+     */
+    Boolean addImGroup(ClassGroup classGroup,List<Integer> userIds);
 }

+ 35 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -909,14 +909,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         }
         Integer schoolId = musicGroup.getSchoolId();
 
-        List<Integer> subjectIdSet = new ArrayList<>();
-
         List<Integer> studentIdList = classGroup4MixDto.getStudents();
         List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(musicGroupId, studentIdList);
-        for (StudentRegistration student : studentList) {
-            subjectIdSet.add(student.getSubjectId());
-        }
-        List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdSet);
+
+        List<Integer> subjectIdList = studentList.stream().map(student->student.getActualSubjectId()).collect(Collectors.toList());
+
+        List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdList);
 
         String subjectIds = subjectList.stream().map(subject -> subject.getId().toString()).collect(Collectors.joining(","));
         String subjectNames = subjectList.stream().map(subject -> subject.getName()).collect(Collectors.joining("/"));
@@ -940,6 +938,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
         //2、将学生加入新班级(学生注册表,关联表
         List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
+        List<Integer> userIds = new ArrayList<>(); //用户ids
         for (StudentRegistration studentRegistration : studentList) {
             studentRegistration.setClassGroupId(classGroup.getId());
             studentRegistrationService.update(studentRegistration);
@@ -952,6 +951,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
             classGroupStudentMapper.setGroupType(GroupType.MUSIC);
             classGroupStudentMapperList.add(classGroupStudentMapper);
+
+            userIds.add(studentRegistration.getUserId());
         }
         classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
 
@@ -959,13 +960,16 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         //3、将老师加入关联关系
         List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroup4MixDto.getClassGroupTeacherMapperList();
 
-
         for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
             classGroupTeacherMapper.setClassGroupId(classGroup.getId());
             classGroupTeacherMapper.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
+            userIds.add(classGroupTeacherMapper.getUserId());
         }
         classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
 
+        //创建IM群组
+        addImGroup(classGroup,userIds);
+
         //5、插入班级排课信息
         LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
 
@@ -1120,14 +1124,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
         Integer schoolId = musicGroup.getSchoolId();
 
-        List<Integer> subjectIdSet = new ArrayList<>();
 
         List<Integer> studentIdList = classGroup4MixDto.getStudents();
         List<StudentRegistration> studentList = studentRegistrationService.findStudentListByUserIdList(musicGroupId, studentIdList);
-        for (StudentRegistration student : studentList) {
-            subjectIdSet.add(student.getSubjectId());
-        }
-        List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdSet);
+        List<Integer> subjectIdList = studentList.stream().map(student->student.getActualSubjectId()).collect(Collectors.toList());
+
+        List<Subject> subjectList = subjectService.findBySubjectByIdList(subjectIdList);
 
         String subjectIds = subjectList.stream().map(subject -> subject.getId().toString()).collect(Collectors.joining(","));
         String subjectNames = subjectList.stream().map(subject -> subject.getName()).collect(Collectors.joining("/"));
@@ -1355,6 +1357,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
 
         //2、将学生加入新班级,关联表
+        List<Integer> userIds = new ArrayList<>();
         List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
         for (StudentRegistration studentRegistration : studentList) {
             ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
@@ -1365,6 +1368,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
             classGroupStudentMapper.setGroupType(GroupType.MUSIC);
             classGroupStudentMapperList.add(classGroupStudentMapper);
+            userIds.add(studentRegistration.getUserId());
         }
         classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
 
@@ -1375,9 +1379,13 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
             classGroupTeacherMapper.setClassGroupId(classGroup.getId());
             classGroupTeacherMapper.setMusicGroupId(classGroup4MixDto.getMusicGroupId());
+            userIds.add(classGroupTeacherMapper.getUserId());
         }
         classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
 
+        //创建IM群组
+        addImGroup(classGroup,userIds);
+
         //5、插入班级排课信息
         LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
 
@@ -1656,9 +1664,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
     @Transactional(rollbackFor = Exception.class)
     public void addStudentIntoClassGroup(String musicGroupId, Integer classGroupId, List<Integer> studentIds) {
-        List<ClassGroupStudentMapper> classGroupStudentMappers=new ArrayList<>();
+        List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
         for (Integer studentId : studentIds) {
-            ClassGroupStudentMapper classGroupStudentMapper=new ClassGroupStudentMapper(musicGroupId,classGroupId,studentId,ClassGroupStudentStatusEnum.NORMAL);
+            ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper(musicGroupId, classGroupId, studentId, ClassGroupStudentStatusEnum.NORMAL);
             classGroupStudentMapper.setGroupType(GroupType.VIP);
             classGroupStudentMappers.add(classGroupStudentMapper);
         }
@@ -1684,4 +1692,17 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         }
         return classGroups;
     }
+
+    @Override
+    public Boolean addImGroup(ClassGroup classGroup, List<Integer> userIds) {
+        List<ImGroupMember> imGroupMemberList = new ArrayList<>();
+        for (Integer userId : userIds) {
+            imGroupMemberList.add(new ImGroupMember(userId.toString()));
+        }
+        //创建IM群组
+        ImGroupMember[] imGroupMembers = imGroupMemberList.toArray(new ImGroupMember[imGroupMemberList.size()]);
+        // 创建群组
+        imFeignService.groupCreate(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
+        return true;
+    }
 }

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

@@ -513,10 +513,12 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderService.insert(studentPaymentOrder);
                 //生成订单明细
                 List<StudentPaymentOrderDetail> studentPaymentOrderDetails = studentAddDto.getStudentPaymentOrderDetails();
-                studentPaymentOrderDetails.forEach(e -> {
-                    e.setPaymentOrderId(studentPaymentOrder.getId());
-                });
-                studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetails);
+                if(studentPaymentOrderDetails != null && studentPaymentOrderDetails.size() > 0){
+                    studentPaymentOrderDetails.forEach(e -> {
+                        e.setPaymentOrderId(studentPaymentOrder.getId());
+                    });
+                    studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetails);
+                }
             }
             return userId;
         }

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -319,7 +319,7 @@ public class StudentOrderController extends BaseController {
 
     }
 
-    @Scheduled(cron = "0/30 * * * * ?")
+    //@Scheduled(cron = "0/30 * * * * ?")
     public void setSuccessStatus() throws Exception {
         List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "YQPAY");