| | |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.mapper.*; |
| | | import com.dsh.course.model.DeductionClassHour; |
| | | import com.dsh.course.model.DeductionClassHourList; |
| | | import com.dsh.course.service.ICoursePackageOrderStudentService; |
| | | import com.dsh.course.service.ICoursePackageSchedulingService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.util.DateTimeHelper; |
| | | import com.dsh.course.util.DateUtil; |
| | | import com.dsh.course.util.ToolUtil; |
| | |
| | | @Resource |
| | | private StoreClient stoClient; |
| | | |
| | | @Autowired |
| | | private TCoursePackageService coursePackageService; |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | List<CoursePackageScheduling> list = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("appUserId", appUserId) |
| | | .eq("studentId", stuId) |
| | | .lt("classDate", sdf.format(calendar.getTime())) |
| | | // .lt("classDate", sdf.format(calendar.getTime())) |
| | | .orderByAsc("classDate") |
| | | ); |
| | | List<Long> ids = list.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | |
| | | String[] split = classWeeks.split(";"); |
| | | List<String> integerList = Arrays.asList(split); |
| | | String weekOfDate = DateTimeHelper.getWeekOfDate(new Date()); |
| | | if (integerList.contains(weekOfDate)) { |
| | | // if (integerList.contains(weekOfDate)) { |
| | | String dat = simpleDateFormat.format(byId.getClassDate()) + " " + dateString1.substring(11); |
| | | String ed = simpleDateFormat.format(byId.getEndDate()) + " " + dateString2.substring(11); |
| | | |
| | | Date start = null; |
| | | Date end = null; |
| | | try { |
| | | start = format.parse(dat); |
| | | end = format.parse(ed); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageSchedulingId", byId.getId()).last("limit 1")); |
| | | // else { |
| | | // Date now = new Date(); |
| | | // if (now.after(byId.getClassDate()) && now.before(byId.getEndDate())) { |
| | | // recordVo.setStatus(2); |
| | | // } else { |
| | | // recordVo.setStatus(3); |
| | | // |
| | | // } |
| | | // } |
| | | |
| | | //已取消 |
| | | if (byId.getStatus() == 4) { |
| | | recordVo.setStatus(4); |
| | | } else if (coursePackageStudent.getSignInOrNot() == 2) { |
| | | //已请假 |
| | | recordVo.setStatus(5); |
| | | } else if (start.after(new Date())) { |
| | | }else if (ToolUtil.isNotEmpty(cancelledClasses)) { |
| | | recordVo.setStatus(3); |
| | | // 消课 到课状态0 旷课 |
| | | if (coursePackageStudent.getSignInOrNot() == 0) { |
| | | recordVo.setStatus(6); |
| | | } |
| | | |
| | | }else if (new Date().after(start)&&new Date().before(end)){ |
| | | recordVo.setStatus(2); |
| | | }else if (start.after(new Date())) { |
| | | //待上课 |
| | | recordVo.setStatus(1); |
| | | } |
| | | else { |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageSchedulingId", byId.getId()).last("limit 1")); |
| | | if (ToolUtil.isNotEmpty(cancelledClasses)) { |
| | | recordVo.setStatus(3); |
| | | // 消课 到课状态0 旷课 |
| | | if (coursePackageStudent.getSignInOrNot() == 0) { |
| | | recordVo.setStatus(6); |
| | | } |
| | | |
| | | } else { |
| | | Date now = new Date(); |
| | | if (now.after(byId.getClassDate()) && now.before(byId.getEndDate())) { |
| | | recordVo.setStatus(2); |
| | | } else { |
| | | recordVo.setStatus(3); |
| | | |
| | | } |
| | | } |
| | | // CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | // .eq("coursePackageSchedulingId", byId.getId()).last("limit 1")); |
| | | // if (ToolUtil.isNotEmpty(cancelledClasses)) { |
| | | // recordVo.setStatus(3); |
| | | // // 消课 到课状态0 旷课 |
| | | // if (coursePackageStudent.getSignInOrNot() == 0) { |
| | | // recordVo.setStatus(6); |
| | | // } |
| | | // |
| | | // } else { |
| | | // Date now = new Date(); |
| | | // if (now.after(byId.getClassDate()) && now.before(byId.getEndDate())) { |
| | | // recordVo.setStatus(2); |
| | | // } else { |
| | | // recordVo.setStatus(3); |
| | | // |
| | | // } |
| | | // } |
| | | } |
| | | } else { |
| | | recordVo.setStatus(1); |
| | | } |
| | | // } else { |
| | | // recordVo.setStatus(1); |
| | | // } |
| | | recordVoList.add(recordVo); |
| | | } |
| | | |
| | |
| | | return ids; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 扣除学员课时 |
| | | * @param deductionClassHourList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean deductionClassHour(DeductionClassHourList deductionClassHourList) { |
| | | try { |
| | | List<DeductionClassHour> list = deductionClassHourList.getDeductionClassHourList(); |
| | | for (DeductionClassHour deductionClassHour : list) { |
| | | CoursePackageOrderStudent coursePackageOrderStudent = this.getById(deductionClassHour.getId()); |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() - deductionClassHour.getClassHour()); |
| | | |
| | | //计算需要删除几个排课记录 |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId()); |
| | | Integer codeTime = coursePackage.getCodeTime(); |
| | | //未上的排课数据 |
| | | List<CoursePackageScheduling> packageSchedulings = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().eq("studentId", coursePackageOrderStudent.getStudentId()) |
| | | .eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()).eq("status", 1).orderByDesc("classDate")); |
| | | //排课使用的总课时 |
| | | int classHour = packageSchedulings.size() * codeTime; |
| | | //未排课的课时 |
| | | int notClass = laveClassHours - classHour; |
| | | |
| | | //判断是否需要删除排课数据 |
| | | if(notClass < deductionClassHour.getClassHour()){ |
| | | int clss = deductionClassHour.getClassHour() - notClass; |
| | | int n = clss % codeTime; |
| | | int l = 0; |
| | | //不整除的情况,需要多删除一节排课,回加差额课时。 |
| | | if(n != 0){ |
| | | n += 1; |
| | | l = (codeTime * n) - clss; |
| | | coursePackageOrderStudent.setLaveClassHours(l); |
| | | } |
| | | |
| | | //删除已排的课程 |
| | | List<CoursePackageScheduling> coursePackageSchedulings = packageSchedulings.subList(0, n); |
| | | List<Long> collect = coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | coursePackageSchedulingService.removeByIds(collect); |
| | | } |
| | | |
| | | this.updateById(coursePackageOrderStudent); |
| | | } |
| | | return true; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | } |