| | |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | |
| | | // int pageNum = 1; // 页码 |
| | | int pageSize = 100; // 每页记录数 |
| | | int pageSize = 10; // 每页记录数 |
| | | Page<CoursePackageStudent> page = new Page<>(pageNum, pageSize); |
| | | |
| | | // for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | |
| | | // String classStartTime = coursePackage.getClassStartTime(); |
| | | // String classEndTime = coursePackage.getClassEndTime(); |
| | | //这里是过滤今天之后的数据 |
| | | if (byId == null||byId.getClassDate().after(new Date())){ |
| | | continue; |
| | | } |
| | | |
| | | // if (byId == null||byId.getClassDate().after(new Date())){ |
| | | // continue; |
| | | // } |
| | | |
| | | if (byId == null){ |
| | | continue; |
| | |
| | | // CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | // .eq("coursePackageId",coursePackageStudent.getCoursePackageId())); |
| | | CancelledClasses cancelledClasses = cacMapper.selectOne(new QueryWrapper<CancelledClasses>() |
| | | .eq("coursePackageSchedulingId",byId.getId())); |
| | | .eq("coursePackageSchedulingId",byId.getId()).last("limit 1")); |
| | | if (ToolUtil.isNotEmpty(cancelledClasses)){ |
| | | recordVo.setStatus(3); |
| | | // 消课 到课状态0 旷课 |
| | |
| | | ArrayList<PayCourseRes> payCourseRes = new ArrayList<>(); |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | if (tCoursePackage.getType()!=1){ |
| | | continue; |
| | | } |
| | | if(tCoursePackage.getStoreId().equals(storeId)){ |
| | | PayCourseRes payCourseRes1 = new PayCourseRes(); |
| | | payCourseRes1.setId(tCoursePackagePayment.getId()); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) |
| | | public ResultUtil payCourse(PayCourseReq req,Integer userId){ |
| | | public ResultUtil payCourse(PayCourseReq req,Integer userId) throws ParseException { |
| | | // 扣除 原来的课时数 |
| | | // 添加购买课时 paytyoe为7 |
| | | // 排课可期 判断课程时间段 添加排课表 添加上课记录表 |
| | |
| | | tCoursePackagePayment.setLaveClassHours(tCoursePackagePayment.getLaveClassHours()-req.getNum()); |
| | | this.baseMapper.updateHoursById(tCoursePackagePayment.getId(),-req.getNum()); |
| | | |
| | | // |
| | | // List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", coursePackagePayment.getStudentId()).eq("coursePackageId", coursePackagePayment.getCoursePackageId())); |
| | | // List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | |
| | | List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", tCoursePackagePayment.getStudentId()).eq("coursePackageId", tCoursePackagePayment.getCoursePackageId())); |
| | | List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | |
| | | List<CoursePackageScheduling> list = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id", collect).le("classDate", new Date())); |
| | | coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id",collect).le("classDate", new Date())); |
| | | List<Long> collect1 = list.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); |
| | | |
| | | |
| | | // coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id",collect)); |
| | | // coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", paymentDeductionClassHour.getId()).eq("coursePackageId", coursePackagePayment.getCoursePackageId())); |
| | | // |
| | | // TCoursePackage tCoursePackage = packageService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | // String classWeeks = tCoursePackage.getClassWeeks(); |
| | | // List<Integer> week = week(classWeeks); |
| | | // |
| | | // TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", tCoursePackagePayment.getCoursePackageId()).eq("studentId", tCoursePackagePayment.getStudentId())); |
| | | // |
| | | // |
| | | // Date today = new Date(); |
| | | // |
| | | // Integer laveClassHours = pay.getLaveClassHours(); |
| | | // Integer codeTime = tCoursePackage.getCodeTime(); |
| | | // Integer can = laveClassHours/codeTime; |
| | | // |
| | | // int count = 0; |
| | | // String[] split = tCoursePackage.getClassStartTime().split(","); |
| | | // String[] split1 = tCoursePackage.getClassEndTime().split(","); |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // |
| | | // Date[] dates = generateDateArray(14,today); |
| | | // for (Date date : dates) { |
| | | // if (count==can){ |
| | | // break; |
| | | // } |
| | | // int wei = cn.hutool.core.date.DateUtil.dayOfWeek(date); |
| | | // if (week.contains(wei)){ |
| | | // for (int i1 = 0; i1 < split.length; i1++) { |
| | | // if (count==can){ |
| | | // break; |
| | | // } |
| | | // CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | // coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | // Date parse = format1.parse(format.format(date) + " " + split[i1]); |
| | | // Date parse1 = format1.parse(format.format(date) + " " + split1[i1]); |
| | | // coursePackageScheduling.setClassDate(parse); |
| | | // coursePackageScheduling.setEndDate(parse1); |
| | | // coursePackageScheduling.setStatus(1); |
| | | // coursePackageSchedulingService.save(coursePackageScheduling); |
| | | // CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | // student1.setAppUserId(pay.getAppUserId()); |
| | | // student1.setStudentId(pay.getStudentId()); |
| | | // student1.setCoursePackageId(pay.getCoursePackageId()); |
| | | // student1.setCoursePackagePaymentId(pay.getId()); |
| | | // student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | // student1.setSignInOrNot(1); |
| | | // student1.setReservationStatus(1); |
| | | // student1.setInsertTime(new Date()); |
| | | // studentService.save(student1); |
| | | // count++; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | |
| | | coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", tCoursePackagePayment.getStudentId()).eq("coursePackageId", tCoursePackagePayment.getCoursePackageId())); |
| | | |
| | | TCoursePackage tCoursePackage = tcpmapper.selectById(req.getCourseId()); |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", tCoursePackagePayment.getCoursePackageId()).eq("studentId", tCoursePackagePayment.getStudentId())); |
| | | |
| | | |
| | | Date today = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -1); |
| | | today = calendar.getTime(); |
| | | |
| | | Integer laveClassHours = pay.getLaveClassHours(); |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | Integer can = laveClassHours/codeTime; |
| | | |
| | | int count = 0; |
| | | String[] split = tCoursePackage.getClassStartTime().split(","); |
| | | String[] split1 = tCoursePackage.getClassEndTime().split(","); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | |
| | | Date[] dates = generateDateArray(14,today); |
| | | for (Date date : dates) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | int wei = cn.hutool.core.date.DateUtil.dayOfWeek(date); |
| | | if (week.contains(wei)){ |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(date) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(date) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(pay.getAppUserId()); |
| | | student1.setStudentId(pay.getStudentId()); |
| | | student1.setCoursePackageId(pay.getCoursePackageId()); |
| | | student1.setCoursePackagePaymentId(pay.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | coursePackageStudentService.save(student1); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // TCoursePackage tCoursePackage = tcpmapper.selectById(req.getCourseId()); |
| | | // 添加课包 |
| | | TCoursePackagePayment tCoursePackagePayment1 = new TCoursePackagePayment(); |
| | | // tCoursePackagePayment1.setAppUserId(userId); |
| | |
| | | tCoursePackagePayment1.setInsertTime(new Date()); |
| | | this.baseMapper.insert(tCoursePackagePayment1); |
| | | // 找出课包时间段 |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String classStartTime = tCoursePackage.getClassStartTime(); |
| | | String classEndTime = tCoursePackage.getClassEndTime(); |
| | | String[] split = classStartTime.split(","); |
| | | String[] split1 = classEndTime.split(","); |
| | | String[] split5 = classStartTime.split(","); |
| | | String[] split6 = classEndTime.split(","); |
| | | List<String> time = req.getTime(); |
| | | for (String s : time) { |
| | | for (int i = 0; i < split.length; i++) { |
| | | for (int i = 0; i < split5.length; i++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | try { |
| | | Date parse = format.parse(s + " " + split[i]); |
| | | Date parse1 = format.parse(s + " " + split1[i]); |
| | | Date parse = format.parse(s + " " + split5[i]); |
| | | Date parse1 = format.parse(s + " " + split6[i]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |