Sfoglia il codice sorgente

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

yonge 5 anni fa
parent
commit
9426bbc4e1

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -704,6 +704,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
         if (courseScheduleList.size() > 0) {
             List<Long> courseScheduleIds = courseScheduleList.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
+            courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
             courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
             teacherAttendanceDao.batchDeleteByCourseSchedules(courseScheduleIds);
             courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseScheduleIds);

+ 28 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -126,7 +126,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Transactional(rollbackFor = Exception.class)
     public Integer batchUpdateSubject(Integer userId, Integer subId, String musicGroupId) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if(sysUser == null){
+        if (sysUser == null) {
             throw new BizException("获取用户信息失败");
         }
         //获取当前学员的当前声部
@@ -136,7 +136,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }
         //批量调剂(未缴费学员)
         int i = studentRegistrationDao.batchUpdateSubject(userId, subId, musicGroupId);
-        if(i > 0){
+        if (i > 0) {
             //当前专业报名人数减一
             musicGroupSubjectPlanService.addApplyStudentNum(musicGroupId, studentRegistration.getActualSubjectId(), -1);
             //修改专业已报名人数
@@ -146,8 +146,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             roleIds.add(SysUserRole.SECTION_MANAGER);
             roleIds.add(SysUserRole.OPERATION_EXECUTIVE);
 
-    		String[] organIds = { musicGroup.getOrganId() + "" };
-            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds,organIds), MessageTypeEnum.BACKSTAGE_STUDENT_SUBJECT_CHANGE, "", musicGroup.getName());
+            String[] organIds = {musicGroup.getOrganId() + ""};
+            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, organIds), MessageTypeEnum.BACKSTAGE_STUDENT_SUBJECT_CHANGE, "", musicGroup.getName());
         }
         return i;
     }
@@ -210,7 +210,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             sysUser.setDelFlag(com.ym.mec.auth.api.enums.YesOrNoEnum.NO);
             sysUser.setUserType(SysUserType.STUDENT);
             sysUser.setGender(studentRegistration.getGender());
-            if(studentRegistration.getOrganId() != null){
+            if (studentRegistration.getOrganId() != null) {
                 sysUser.setOrganId(studentRegistration.getOrganId());
             }
             sysUser.setRealName(studentRegistration.getParentsName());
@@ -258,8 +258,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         return studentRegistrationDao.queryStudentInfo(userId);
     }
 
-    @Transactional(rollbackFor = Exception.class)
     @Override
+    @Transactional
     public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList) throws Exception {
         Date date = new Date();
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
@@ -341,12 +341,15 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         if (studentRegistration.getTemporaryCourseFee() == null && musicOneSubjectClassPlan.getPaidStudentNum() > musicOneSubjectClassPlan.getExpectedStudentNum()) {
             throw new BizException("乐团人数已满");
         }
-        musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
+        int count = musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
+        if (count <= 0) {
+            throw new BizException("系统繁忙请重新");
+        }
         return studentPaymentOrder;
     }
 
-    @Transactional(rollbackFor = Exception.class)
     @Override
+    @Transactional
     public StudentPaymentOrder reAddOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId, StudentPaymentOrder oldOrder) {
         //关闭老订单
         oldOrder.setStatus(DealStatusEnum.CLOSE);
@@ -434,7 +437,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         StudentRegistration registration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
         SysUserCashAccount account = sysUserCashAccountDao.getLocked(userId);
         registration.setBalance(account.getBalance());
-        registration.setTransferStudent(registration.getTemporaryCourseFee() == null?0:1);
+        registration.setTransferStudent(registration.getTemporaryCourseFee() == null ? 0 : 1);
         return registration;
     }
 
@@ -494,8 +497,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             Set<Integer> roleIds = new HashSet<>(1);
             roleIds.add(SysUserRole.OPERATION_EXECUTIVE);
 
-    		String[] organIds = { musicGroup.getOrganId() + "" };
-            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds,organIds), MessageTypeEnum.BACKSTAGE_MUSIC_GROUP_ADD_STUDENT, "", musicGroup.getName(), studentRegistration.getName());
+            String[] organIds = {musicGroup.getOrganId() + ""};
+            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, organIds), MessageTypeEnum.BACKSTAGE_MUSIC_GROUP_ADD_STUDENT, "", musicGroup.getName(), studentRegistration.getName());
             //增加报名学生数
             musicGroupSubjectPlanService.addApplyStudentNum(musicGroupId, studentRegistration.getSubjectId(), 1);
             Integer classGroupId = studentRegistration.getClassGroupId();
@@ -521,7 +524,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 //                ClassGroupRelation classGroupRelation = classGroupRelationDao.findClassGroupRelation(classGroupId);
 //                classGroupStudentMapper.setClassGroupId(classGroupRelation.getClassGroupId());
 //                classGroupStudentMapperDao.insert(classGroupStudentMapper);
-                addStudents(classGroup,userId);
+                addStudents(classGroup, userId);
                 Date date = new Date();
                 //获取当前月
                 Integer month = Integer.parseInt(DateUtil.getMonth(date));
@@ -564,7 +567,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetails.add(studentPaymentOrderDetail);
                 //汇总金额
                 BigDecimal reduce = studentPaymentOrderDetails.stream().map(e -> e.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
-                if(reduce == BigDecimal.ZERO){
+                if (reduce == BigDecimal.ZERO) {
                     studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
                     studentRegistration.setPaymentStatus(PaymentStatusEnum.YES);
                     studentPaymentOrder.setActualAmount(reduce);
@@ -579,15 +582,15 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetails);
             }
             studentRegistrationDao.updateCurrentClass(studentRegistration);
-            Map<Integer,String> receivers = new HashMap<>(1);
-            receivers.put(studentRegistration.getUserId(),studentRegistration.getParentsPhone());
-            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI,MessageTypeEnum.SMS_MUSIC_GROUP_ADD_STUDENT,
-                    receivers,null,0,null,studentRegistration.getParentsName(),studentRegistration.getName(),musicGroup.getName());
+            Map<Integer, String> receivers = new HashMap<>(1);
+            receivers.put(studentRegistration.getUserId(), studentRegistration.getParentsPhone());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.SMS_MUSIC_GROUP_ADD_STUDENT,
+                    receivers, null, 0, null, studentRegistration.getParentsName(), studentRegistration.getName(), musicGroup.getName());
             return userId;
         }
     }
 
-    public void addStudents(ClassGroup classGroup, Integer userId){
+    public void addStudents(ClassGroup classGroup, Integer userId) {
         Date nowDate = new Date();
         //1、班级关系添加
         List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
@@ -597,9 +600,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
         //校验是否存在历史记录
         ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
-        if(classGroupStudentMapper != null){
+        if (classGroupStudentMapper != null) {
             classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-        }else {
+        } else {
             classGroupStudentMapper = new ClassGroupStudentMapper();
             classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
             classGroupStudentMapper.setClassGroupId(classGroupId);
@@ -784,7 +787,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         //减去缴费人数
         if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
             musicOneSubjectClassPlan.setPaidStudentNum(musicOneSubjectClassPlan.getPaidStudentNum() - 1);
-            musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
+            int updateCount = musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
+            if(updateCount <= 0){
+                throw new BizException("减去缴费人数失败");
+            }
             //发送缴费成功通知(短信 + push)
             String studentApplyUrl = sysConfigDao.findConfigValue(SysConfigService.STUDENT_APPLY_URL + studentRegistration.getMusicGroupId());
 
@@ -893,7 +899,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findMusicGroupClassGroupByType(musicGroupId, type);
         for (StudentRegistration student : students) {
             for (ClassGroupStudentMapper classGroupStudentMapper : classGroupStudentMappers) {
-                if(classGroupStudentMapper.getUserId().equals(student.getUserId())){
+                if (classGroupStudentMapper.getUserId().equals(student.getUserId())) {
                     students.remove(student);
                 }
             }