zouxuan hace 4 años
padre
commit
f111e300ab

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1613,4 +1613,30 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }
         return true;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean batchDelRegs(String musicGroupId, List<Integer> userIds) {
+        List<StudentRegistration> registrations = studentRegistrationDao.findStudentListByUserIdList(musicGroupId, userIds);
+        if (registrations.size() <= 0) {
+            throw new BizException("删除的学员不存在,请核查");
+        }
+        Map<Integer, List<StudentRegistration>> regMap = registrations.stream().collect(Collectors.groupingBy(StudentRegistration::getSubjectId));
+        //更新声部信息
+        for (Map.Entry<Integer, List<StudentRegistration>> regEntry : regMap.entrySet()) {
+            MusicGroupSubjectPlan subjectPlan = musicGroupSubjectPlanDao.findSubjectPlan(musicGroupId, regEntry.getKey());
+            subjectPlan.setApplyStudentNum(subjectPlan.getApplyStudentNum() - regEntry.getValue().size());
+            int updateNum = musicGroupSubjectPlanDao.update(subjectPlan);
+            if (updateNum <= 0) {
+                throw new BizException("声部信息更新失败");
+            }
+        }
+        //删除注册信息
+        List<Long> ids = registrations.stream().map(StudentRegistration::getId).collect(Collectors.toList());
+        int delNum = studentRegistrationDao.batchDelete(ids);
+        if (delNum <= 0) {
+            throw new BizException("学员删除失败");
+        }
+        return true;
+    }
 }