| | |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(coursePackageList.getLon(), coursePackageList.getLat()); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | // QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2)) |
| | | // .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode); |
| | | |
| | | QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2)) |
| | | .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode); |
| | | .eq("auditStatus", 2).eq("state", 1); |
| | | if(null != coursePackageList.getCoursePackageTypeId()){ |
| | | wrapper.eq("coursePackageTypeId", coursePackageList.getCoursePackageTypeId()); |
| | | } |
| | |
| | | wrapper.or().in("storeId", collect); |
| | | } |
| | | } |
| | | List<TCoursePackage> list = this.list(wrapper.last(" order by sort, insertTime desc")); |
| | | List<TCoursePackage> list = this.list(wrapper.last(" order by sort desc, insertTime desc")); |
| | | List<CoursePackageListVo> listVos = new ArrayList<>(); |
| | | for (TCoursePackage coursePackage : list) { |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | |
| | | public ResultUtil paymentCourse(Integer uid, PaymentCourseVo paymentCourseVo) throws Exception { |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | CoursePackageInfo coursePackageInfo = queryCourseInfo(uid, paymentCourseVo.getId(), null, null); |
| | | //校验是否已经报满 |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(paymentCourseVo.getId()); |
| | | TCoursePackage course = coursePackageService.getById(paymentCourseVo.getId()); |
| | | if (integer>=course.getMaxSubscribeNumber()){ |
| | | return ResultUtil.error("报名失败,已达最大报名人数"); |
| | | } |
| | | |
| | | |
| | | |
| | | List<CoursePackagePaymentConfigVo> list = coursePackageInfo.getList(); |
| | | |
| | | String[] students = paymentCourseVo.getStudentIds().split(";"); |
| | |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | System.out.println("===========到达支付"); |
| | | // 2.0 |
| | | String[] coupons = coursePackagePaymentConfig.getCouponIds().split(","); |
| | | |
| | | |
| | | |
| | | userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds())); |
| | | |
| | | |
| | | moneyOut(tradeNo,tradeNo); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(appUser.getId()); |
| | |
| | | if(student!=null){ |
| | | sId=student.getId(); |
| | | } |
| | | addPackageStudent(paymentCourseVo.getId(),appUser.getId(),sId,coursePackagePayment.getId()); |
| | | addPackageStudent(paymentCourseVo.getId(),appUser.getId(), Integer.valueOf(s),coursePackagePayment.getId()); |
| | | } |
| | | |
| | | Integer playPaiCoins = appUser.getPlayPaiCoins(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId) throws ParseException { |
| | | // 课包 |
| | | TCoursePackage tCoursePackage = this.baseMapper.selectById(courseId); |
| | |
| | | String[] split1 = tCoursePackage.getClassEndTime().split(","); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // 本周周几 |
| | | int i = DateUtil.dayOfWeek(new Date())-1; |
| | | for (Integer integer : week) { |
| | | if(integer<i){ |
| | | // 找下一周的时间 |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7-(i-integer)); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | //查出当前用户当前学员当前课包最后一天的排课数据 |
| | | List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId)); |
| | | List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | //拿到最后一天的排课记录 |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(paymentId); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | CoursePackageScheduling cs = null; |
| | | if (collect.size()>0) { |
| | | cs = coursePackageSchedulingService.getOne(new QueryWrapper<CoursePackageScheduling>().in("id", collect).orderByDesc("classDate").last("limit 1")); |
| | | |
| | | } |
| | | int i = -1; |
| | | |
| | | }else if(integer>i) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,integer-i); |
| | | Date time1 = instance.getTime(); |
| | | List<Date> list = new ArrayList<>(); |
| | | list.add(time1); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time2 = instance.getTime(); |
| | | list.add(time2); |
| | | for (Date time : list) { |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | // Calendar calendar = Calendar.getInstance(); |
| | | // Date currentDate = calendar.getTime(); |
| | | // calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | // Date today = calendar.getTime(); |
| | | Date today = new Date(); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(paymentId); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | } |
| | | } |
| | | |
| | | //判断最后一天是否超过当前日期 |
| | | if (cs==null||cs.getClassDate().before(new Date())){ |
| | | i = DateUtil.dayOfWeek(new Date())-1; |
| | | }else { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time = instance.getTime(); |
| | | i = DateUtil.dayOfWeek(cs.getClassDate())-1; |
| | | today = cs.getClassDate(); |
| | | } |
| | | |
| | | |
| | | TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId); |
| | | Integer laveClassHours = pay.getLaveClassHours(); |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | Integer can = 0; |
| | | |
| | | |
| | | int count = 0; |
| | | |
| | | // 本周周几 |
| | | // int i = DateUtil.dayOfWeek(new Date())-1; |
| | | |
| | | Date[] dates = generateDateArray(14,today); |
| | | if (tCoursePackage.getType()==1){ |
| | | can = laveClassHours/codeTime; |
| | | } |
| | | if (tCoursePackage.getType()==2){ |
| | | Date startDate = tCoursePackage.getStartTime(); |
| | | Date endDate = tCoursePackage.getEndTime(); |
| | | dates = generateDateArray1(startDate, endDate); |
| | | can = 999; |
| | | } |
| | | |
| | | for (Date date : dates) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | int wei = 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(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | 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(userId); |
| | | student1.setStudentId(sId); |
| | |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // for (Integer integer : week) { |
| | | // if (count==can){ |
| | | // break; |
| | | // } |
| | | // if(integer<i){ |
| | | // // 找下一周的时间 |
| | | // Calendar instance = Calendar.getInstance(); |
| | | // if (cs==null||cs.getClassDate().before(new Date())){ |
| | | // instance = Calendar.getInstance(); |
| | | // }else { |
| | | //// i = DateUtil.dayOfWeek(cs.getClassDate())-1; |
| | | // instance.setTime(cs.getClassDate()); |
| | | // } |
| | | // instance.add(Calendar.DATE,7-(i-integer)); |
| | | // Date time = instance.getTime(); |
| | | // |
| | | // 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(time) + " " + split[i1]); |
| | | // Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | // coursePackageScheduling.setClassDate(parse); |
| | | // coursePackageScheduling.setEndDate(parse1); |
| | | // coursePackageScheduling.setStatus(1); |
| | | // coursePackageSchedulingService.save(coursePackageScheduling); |
| | | // |
| | | // CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | // student1.setAppUserId(userId); |
| | | // student1.setStudentId(sId); |
| | | // student1.setCoursePackageId(tCoursePackage.getId()); |
| | | // student1.setCoursePackagePaymentId(paymentId); |
| | | // student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | // student1.setSignInOrNot(1); |
| | | // student1.setReservationStatus(1); |
| | | // student1.setInsertTime(new Date()); |
| | | // cpsMapper.insert(student1); |
| | | // count++; |
| | | // } |
| | | // |
| | | // |
| | | // }else if(integer>i) { |
| | | // if (count==can){ |
| | | // break; |
| | | // } |
| | | // |
| | | //// Calendar instance = Calendar.getInstance(); |
| | | // |
| | | // Calendar instance = Calendar.getInstance(); |
| | | // if (cs==null||cs.getClassDate().before(new Date())){ |
| | | // instance = Calendar.getInstance(); |
| | | // }else { |
| | | //// i = DateUtil.dayOfWeek(cs.getClassDate())-1; |
| | | // instance.setTime(cs.getClassDate()); |
| | | // } |
| | | // instance.add(Calendar.DATE,integer-i); |
| | | // Date time1 = instance.getTime(); |
| | | // List<Date> list = new ArrayList<>(); |
| | | // list.add(time1); |
| | | // instance.add(Calendar.DATE,7); |
| | | // Date time2 = instance.getTime(); |
| | | // list.add(time2); |
| | | // for (Date time : list) { |
| | | // for (int i1 = 0; i1 < split.length; i1++) { |
| | | // CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | // coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | // Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | // Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | // coursePackageScheduling.setClassDate(parse); |
| | | // coursePackageScheduling.setEndDate(parse1); |
| | | // coursePackageScheduling.setStatus(1); |
| | | // coursePackageSchedulingService.save(coursePackageScheduling); |
| | | // |
| | | // CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | // student1.setAppUserId(userId); |
| | | // student1.setStudentId(sId); |
| | | // student1.setCoursePackageId(tCoursePackage.getId()); |
| | | // student1.setCoursePackagePaymentId(paymentId); |
| | | // student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | // student1.setSignInOrNot(1); |
| | | // student1.setReservationStatus(1); |
| | | // student1.setInsertTime(new Date()); |
| | | // cpsMapper.insert(student1); |
| | | // count++; |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // }else { |
| | | //// Calendar instance = Calendar.getInstance(); |
| | | // Calendar instance = Calendar.getInstance(); |
| | | // if (cs==null||cs.getClassDate().before(new Date())){ |
| | | // instance = Calendar.getInstance(); |
| | | // }else { |
| | | //// i = DateUtil.dayOfWeek(cs.getClassDate())-1; |
| | | // instance.setTime(cs.getClassDate()); |
| | | // } |
| | | // instance.add(Calendar.DATE,7); |
| | | // Date time = instance.getTime(); |
| | | // |
| | | // 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(time) + " " + split[i1]); |
| | | // Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | // coursePackageScheduling.setClassDate(parse); |
| | | // coursePackageScheduling.setEndDate(parse1); |
| | | // coursePackageScheduling.setStatus(1); |
| | | // coursePackageSchedulingService.save(coursePackageScheduling); |
| | | // |
| | | // CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | // student1.setAppUserId(userId); |
| | | // student1.setStudentId(sId); |
| | | // student1.setCoursePackageId(tCoursePackage.getId()); |
| | | // student1.setCoursePackagePaymentId(paymentId); |
| | | // student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | // student1.setSignInOrNot(1); |
| | | // student1.setReservationStatus(1); |
| | | // student1.setInsertTime(new Date()); |
| | | // cpsMapper.insert(student1); |
| | | // count++; |
| | | // |
| | | // } |
| | | // } |
| | | // } |
| | | // 2.0 |
| | | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | tCourseInfoRecord.setUserId(userId); |
| | | tCourseInfoRecord.setCourseId(courseId); |
| | | tCourseInfoRecord.setName("报名假期班"); |
| | | tCourseInfoRecord.setName("报名运动营"); |
| | | tCourseInfoRecord.setNum(tCoursePackage.getNeedNum()); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | tCourseInfoRecord.setType(2); |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public static Date[] generateDateArray1(Date startDate, Date endDate) { |
| | | List<Date> dateList = new ArrayList<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (!calendar.getTime().after(endDate)) { |
| | | Date currentDate = calendar.getTime(); |
| | | dateList.add(currentDate); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | return dateList.toArray(new Date[0]); |
| | | } |
| | | |
| | | public static Date createDate1(int year, int month, int day) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(year, month - 1, day); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | private List<Integer> week(String week){ |
| | | String[] split = week.split(";"); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public static Date[] generateDateArray(int numDays,Date date) { |
| | | // LocalDate tomorrow = LocalDate.now().plusDays(1); |
| | | LocalDate tomorrow = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1); |
| | | |
| | | Date[] dates = new Date[numDays]; |
| | | |
| | | for (int i = 0; i < numDays; i++) { |
| | | LocalDate currentDate = tomorrow.plusDays(i); |
| | | dates[i] = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | return dates; |
| | | } |
| | | /** |
| | | * 获取课包管理列表数据 |
| | | * @param queryCoursePackageLists |