| | |
| | | //未上的排课数据 |
| | | List<CoursePackageScheduling> packageSchedulings = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().eq("studentId", coursePackageOrderStudent.getStudentId()) |
| | | .eq("type", 1).eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()).eq("status", 1).orderByDesc("classDate")); |
| | | //排课使用的总课时 |
| | | //已经排课的总课时 |
| | | int classHour = packageSchedulings.size() * codeTime; |
| | | //未排课的课时 |
| | | int notClass = laveClassHours - classHour; |
| | | |
| | | /** |
| | | * 1、查询剩余已经排课的数据 |
| | | * 2、判断 剩余课时- 未上排课 = 可扣减 -->是否满足扣减 |
| | | * --->满足扣减,直接减去剩余课时 |
| | | * --->不满足扣减,需要计算出删除的排课节数(注意每节消耗的课时数),然后减去剩余课时 |
| | | */ |
| | | |
| | | //判断是否需要删除排课数据 |
| | | if(notClass < deductionClassHour.getClassHour()){ |
| | | //计算需要删除的排课数量 |
| | | int clss = deductionClassHour.getClassHour() - notClass; |
| | | int n = clss % codeTime; |
| | | int l = 0; |
| | | int num = clss / codeTime; |
| | | //不整除的情况,需要多删除一节排课,回加差额课时。 |
| | | if(n != 0){ |
| | | n += 1; |
| | | l = (codeTime * n) - clss; |
| | | num += 1; |
| | | } |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() + l); |
| | | |
| | | //删除已排的课程 |
| | | List<CoursePackageScheduling> coursePackageSchedulings = packageSchedulings.subList(0, n); |
| | | List<CoursePackageScheduling> coursePackageSchedulings = packageSchedulings.subList(0, num); |
| | | List<Long> collect = coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | if(collect.size() > 0){ |
| | | coursePackageSchedulingService.removeByIds(collect); |
| | | coursePackageStudentMapper.delete(new QueryWrapper<CoursePackageStudent>().in("coursePackageSchedulingId", collect)); |
| | | |
| | | deductionClassHour.setScheduledCourses(n); |
| | | } |
| | | |
| | | deductionClassHour.setScheduledCourses(num); |
| | | }else{ |
| | | deductionClassHour.setScheduledCourses(0); |
| | | } |
| | | this.updateById(coursePackageOrderStudent); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackageOrderStudent.getId()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(deductionClassHour.getClassHour()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("社区世界杯报名"); |
| | | courseCounsum.setReason("取消社区世界杯报名"); |
| | | courseCounsum.setAppUserId(coursePackageOrderStudent.getAppUserId()); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | //需要排课的节数 |
| | | Integer scheduledCourses = deductionClassHour.getScheduledCourses(); |
| | | if(scheduledCourses > 0){ |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId()); |
| | | Integer codeTime = coursePackage.getCodeTime(); |
| | | CoursePackageScheduling one = coursePackageSchedulingService.getOne(new QueryWrapper<CoursePackageScheduling>().eq("studentId", coursePackageOrderStudent.getStudentId()) |
| | |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if(classDate.getTime() <= parse.getTime()){ |
| | | if(classDate.getTime() >= parse.getTime()){ |
| | | continue; |
| | | } |
| | | |
| | |
| | | coursePackageStudentMapper.insert(student1); |
| | | |
| | | num--; |
| | | if(num == 0){ |
| | | if(num <= 0){ |
| | | return; |
| | | } |
| | | } |
| | |
| | | start = calendar; |
| | | } |
| | | |
| | | if(num == 0){ |
| | | if(num <= 0){ |
| | | return; |
| | | } |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | num--; |
| | | if(num == 0){ |
| | | if(num <= 0){ |
| | | return; |
| | | } |
| | | } |
| | | start.set(Calendar.DAY_OF_YEAR, start.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |