| | |
| | | |
| | | //开始排课 |
| | | if(b){ |
| | | addPackageStudent(coursePackage, coursePackageOrder.getAppUserId(), Integer.valueOf(id), coursePackageOrderStudent, student.getValidity()); |
| | | addPackageStudent(coursePackage, coursePackageOrder, Integer.valueOf(id), coursePackageOrderStudent, student.getValidity()); |
| | | } |
| | | |
| | | //课时记录 |
| | |
| | | studentClient.frozen(student); |
| | | |
| | | //中间断课,没有连续续费的情况需要重新排课 |
| | | if (useTime.compareTo(new Date()) < 0 && b) { |
| | | addPackageStudent(coursePackage, coursePackageOrder.getAppUserId(), Integer.valueOf(id), coursePackageOrderStudent, student.getValidity()); |
| | | // if (useTime.compareTo(new Date()) < 0 && b) { |
| | | // addPackageStudent(coursePackage, coursePackageOrder.getAppUserId(), Integer.valueOf(id), coursePackageOrderStudent, student.getValidity()); |
| | | // } |
| | | //开始排课 |
| | | if(b){ |
| | | addPackageStudent(coursePackage, coursePackageOrder, Integer.valueOf(id), coursePackageOrderStudent, student.getValidity()); |
| | | } |
| | | |
| | | //课时记录 |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackageOrderStudent.getId()); |
| | |
| | | } |
| | | } |
| | | if(coursePackage.getType() == 2){ |
| | | addPackageStudent(coursePackage, coursePackageOrder.getAppUserId(), Integer.valueOf(id), null, null); |
| | | addPackageStudent(coursePackage, coursePackageOrder, Integer.valueOf(id), null, null); |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 新购买课程后的排课 |
| | | * |
| | | * @param userId |
| | | * @param sId |
| | | * @throws ParseException |
| | | */ |
| | | private void addPackageStudent(TCoursePackage tCoursePackage, Integer userId, Integer sId, CoursePackageOrderStudent coursePackageOrderStudent, Date validity) { |
| | | private void addPackageStudent(TCoursePackage tCoursePackage, CoursePackageOrder coursePackageOrder, Integer sId, CoursePackageOrderStudent coursePackageOrderStudent, Date validity) { |
| | | try { |
| | | Integer userId = coursePackageOrder.getAppUserId(); |
| | | //扣除课时数 |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | Integer totalClassHours = coursePackageOrder.getClassHours(); |
| | | // 排课次数 |
| | | Integer schedulingNum= totalClassHours/codeTime; |
| | | //1常规 2假期 3体验 |
| | | if (tCoursePackage.getType() == 1) { |
| | | //上课星期 |
| | |
| | | .orderByDesc("classDate") |
| | | .last(" limit 0, 1") |
| | | ); |
| | | if(null != one){ |
| | | //先检测是否需要继续进行排课 |
| | | Calendar calendar1 = Calendar.getInstance(); |
| | | calendar1.setTime(one.getClassDate()); |
| | | int day_week1 = calendar1.get(Calendar.DAY_OF_WEEK); |
| | | day_week1 = day_week1 - 1 == 0 ? 7 : day_week1 - 1; |
| | | int week_of_month = calendar1.get(Calendar.WEEK_OF_MONTH); |
| | | |
| | | Calendar calendar2 = Calendar.getInstance(); |
| | | calendar2.setTime(new Date()); |
| | | int week_of_month1 = calendar2.get(Calendar.WEEK_OF_MONTH); |
| | | |
| | | //最后一次的排课时间不在本周,且是一周的最后一天。(如果是本周则表明已经课时用完了) |
| | | if(week.get(week.size() - 1).equals(day_week1) && week_of_month != week_of_month1){ |
| | | return; |
| | | } |
| | | } |
| | | // if(null != one){ |
| | | // //先检测是否需要继续进行排课 |
| | | // Calendar calendar1 = Calendar.getInstance(); |
| | | // calendar1.setTime(one.getClassDate()); |
| | | // int day_week1 = calendar1.get(Calendar.DAY_OF_WEEK); |
| | | // day_week1 = day_week1 - 1 == 0 ? 7 : day_week1 - 1; |
| | | // int week_of_month = calendar1.get(Calendar.WEEK_OF_MONTH); |
| | | // |
| | | // Calendar calendar2 = Calendar.getInstance(); |
| | | // calendar2.setTime(new Date()); |
| | | // int week_of_month1 = calendar2.get(Calendar.WEEK_OF_MONTH); |
| | | // |
| | | // //最后一次的排课时间不在本周,且是一周的最后一天。(如果是本周则表明已经课时用完了) |
| | | // if(week.get(week.size() - 1).equals(day_week1) && week_of_month != week_of_month1){ |
| | | // return; |
| | | // } |
| | | // } |
| | | |
| | | //上课时段 |
| | | String[] split = tCoursePackage.getClassStartTime().split(","); |
| | |
| | | |
| | | //剩余课时 |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | //扣除课时数 |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | //排课 本周+下周,课时不够扣则直接剩余不排课 |
| | | |
| | | //排课 课时不够扣则直接剩余不排课 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | if (one!=null){ |
| | | calendar.setTime(one.getClassDate()); |
| | | }else{ |
| | | calendar.setTime(new Date()); |
| | | } |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | |
| | | day_week = day_week - 1 == 0 ? 7 : day_week - 1; |
| | | int num = 8 - day_week + 7; |
| | | |
| | | for (int i = 0; i < num; i++) { |
| | | for (int i = 0; i < schedulingNum; i++) { |
| | | Date time = calendar.getTime(); |
| | | |
| | | //判断当天是否在排课星期内 |
| | |
| | | day = day - 1 == 0 ? 7 : day - 1; |
| | | if (!week.contains(day)) { |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1); |
| | | schedulingNum--; |
| | | continue; |
| | | } |
| | | |
| | |
| | | //有体验购课,不进行排课 |
| | | if(count != 0){ |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1); |
| | | schedulingNum--; |
| | | |
| | | continue; |
| | | } |
| | | |