| | |
| | | } |
| | | System.out.println("========strings1=====" + strings1); |
| | | |
| | | //时间段 |
| | | List<String> strings = new ArrayList<>(); |
| | | // List<SiteBooking> siteBookings = siteClient.listBooks(book.getSiteId()); |
| | | List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", book.getSiteId()).like("times", split1[0].substring(0, 10))); |
| | | System.out.println("=======siteBookings======" + siteBookings); |
| | | for (SiteBooking siteBooking : siteBookings) { |
| | | String[] split = siteBooking.getTimes().split(";"); |
| | | for (String s : split) { |
| | | |
| | | String convertedValue = s.substring(11); |
| | | strings.add(convertedValue); |
| | | } |
| | | |
| | | } |
| | | System.out.println("======strings=======" + strings); |
| | | ////时间段 |
| | | // List<String> strings = new ArrayList<>(); |
| | | //// List<SiteBooking> siteBookings = siteClient.listBooks(book.getSiteId()); |
| | | // List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", book.getSiteId()).like("times", split1[0].substring(0, 10))); |
| | | // System.out.println("=======siteBookings======" + siteBookings); |
| | | // for (SiteBooking siteBooking : siteBookings) { |
| | | // String[] split = siteBooking.getTimes().split(";"); |
| | | // for (String s : split) { |
| | | // |
| | | // String convertedValue = s.substring(11); |
| | | // strings.add(convertedValue); |
| | | // } |
| | | // |
| | | // } |
| | | // System.out.println("======strings=======" + strings); |
| | | |
| | | |
| | | List<OrderDto> timeRanges = new ArrayList<>(); |
| | | |
| | | TSite site = siteService.getById(book.getSiteId()); |
| | | System.out.println("================" + site); |
| | | String appointmentStartTime = site.getAppointmentStartTime(); |
| | | String appointmentEndTime = site.getAppointmentEndTime(); |
| | | //生成用于比较日期是否超过的当前日期 |
| | | LocalDate currentDate = LocalDate.now(); |
| | | LocalDate parsedDate = LocalDate.parse(split1[0].substring(0, 10), DateTimeFormatter.ISO_DATE); |
| | | boolean isAfterCurrentDate = parsedDate.isBefore(currentDate); |
| | | System.out.println("是否超过当前日期" + isAfterCurrentDate); |
| | | String currentTime = appointmentStartTime; |
| | | while (currentTime.compareTo(appointmentEndTime) < 0) { |
| | | String nextTime = getNextTime(currentTime); |
| | | |
| | | |
| | | String timeRange = currentTime + "-" + nextTime; |
| | | OrderDto orderDto = new OrderDto(); |
| | | orderDto.setTime(timeRange); |
| | | |
| | | LocalTime currentTime1 = LocalTime.now(); |
| | | LocalTime targetTime = LocalTime.parse(currentTime); |
| | | |
| | | boolean hasExceeded = currentTime1.isAfter(targetTime); |
| | | //是否超过当前时间 |
| | | if (hasExceeded) { |
| | | orderDto.setState(0); |
| | | } |
| | | //是否已经预定 |
| | | if (strings.contains(timeRange)) { |
| | | orderDto.setState(0); |
| | | } |
| | | //日期是否超过 |
| | | if (isAfterCurrentDate) { |
| | | orderDto.setState(0); |
| | | } |
| | | //是否是当前场地当前日期预定的 |
| | | if (strings1.contains(timeRange)) { |
| | | orderDto.setState(1); |
| | | } |
| | | |
| | | |
| | | timeRanges.add(orderDto); |
| | | currentTime = nextTime; |
| | | } |
| | | // String appointmentStartTime = site.getAppointmentStartTime(); |
| | | // String appointmentEndTime = site.getAppointmentEndTime(); |
| | | // //生成用于比较日期是否超过的当前日期 |
| | | // LocalDate currentDate = LocalDate.now(); |
| | | // LocalDate parsedDate = LocalDate.parse(split1[0].substring(0, 10), DateTimeFormatter.ISO_DATE); |
| | | // boolean isAfterCurrentDate = parsedDate.isBefore(currentDate); |
| | | // System.out.println("是否超过当前日期" + isAfterCurrentDate); |
| | | // String currentTime = appointmentStartTime; |
| | | // while (currentTime.compareTo(appointmentEndTime) < 0) { |
| | | // String nextTime = getNextTime(currentTime); |
| | | // |
| | | // |
| | | // String timeRange = currentTime + "-" + nextTime; |
| | | // OrderDto orderDto = new OrderDto(); |
| | | // orderDto.setTime(timeRange); |
| | | // |
| | | // LocalTime currentTime1 = LocalTime.now(); |
| | | // LocalTime targetTime = LocalTime.parse(currentTime); |
| | | // |
| | | // boolean hasExceeded = currentTime1.isAfter(targetTime); |
| | | // //是否超过当前时间 |
| | | // if (hasExceeded) { |
| | | // orderDto.setState(0); |
| | | // } |
| | | // //是否已经预定 |
| | | // if (strings.contains(timeRange)) { |
| | | // orderDto.setState(0); |
| | | // } |
| | | // //日期是否超过 |
| | | // if (isAfterCurrentDate) { |
| | | // orderDto.setState(0); |
| | | // } |
| | | // //是否是当前场地当前日期预定的 |
| | | // if (strings1.contains(timeRange)) { |
| | | // orderDto.setState(1); |
| | | // } |
| | | // timeRanges.add(orderDto); |
| | | // currentTime = nextTime; |
| | | // } |
| | | System.out.println("-------------" + timeRanges); |
| | | model.addAttribute("timeRanges", timeRanges); |
| | | System.out.println("======timeRanges========" + timeRanges); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | model.addAttribute("province", book.getProvince()); |
| | | String yuyueTime = ""; |
| | | if (strings1.size()>1){ |
| | | String start = strings1.get(0).split("-")[0]; |
| | | String end = strings1.get(strings1.size()-1).split("-")[1]; |
| | | yuyueTime = start +"-"+end; |
| | | }else{ |
| | | yuyueTime = strings1.get(0); |
| | | } |
| | | model.addAttribute("yuyueTime", yuyueTime); |
| | | model.addAttribute("targetAudience", book.getTargetAudience()); |
| | | model.addAttribute("city", book.getCity()); |
| | | model.addAttribute("store", storeService.getById(book.getStoreId()).getName()); |
| | | model.addAttribute("siteName", siteService.getById(book.getSiteId()).getName()); |
| | |
| | | siteBooking.setAddType(1); |
| | | |
| | | //存开始和结束时间 |
| | | // times格式示例: 2025-10-14 19:00-19:30;2025-10-14 19:30-20:00;2025-10-14 20:00-20:30;2025-10-14 20:30-21:00 |
| | | // targetAudience字段会由Spring MVC自动绑定(1=订场,2=散客) |
| | | String times = siteBooking.getTimes(); |
| | | String[] dates = times.split(";"); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | try { |
| | | // 提取最早的开始时间 |
| | | // dates[0] 格式: 2025-10-14 19:00-19:30 |
| | | String start = dates[0]; |
| | | String startDateStr = start.substring(0, start.lastIndexOf("-")); |
| | | Date startDate = format.parse(startDateStr); |
| | | |
| | | // 提取最晚的结束时间 |
| | | // dates[dates.length - 1] 格式: 2025-10-14 20:30-21:00 |
| | | String end = dates[dates.length - 1]; |
| | | String[] str = end.split(" "); |
| | | String endDateStr = str[0] + " " + str[1].substring(str[1].indexOf("-") + 1); |
| | | Date endDate = format.parse(endDateStr); |
| | | |
| | | siteBooking.setStartTime(startDate); |
| | | siteBooking.setEndTime(endDate); |
| | | } catch (Exception e) { |
| | |
| | | String money = siteBooking.getMoney(); |
| | | String[] moneys = money.split(","); |
| | | siteBooking.setPayMoney(Double.valueOf(moneys[0])); |
| | | siteBooking.setMoney(money); |
| | | // 查询当前预约人是否是会员 |
| | | String phone = siteBooking.getPhone(); |
| | | String booker = siteBooking.getBooker(); |
| | |
| | | siteBooking.setCityCode(byId.getCityCode()); |
| | | } |
| | | |
| | | if (siteBooking.getIsHalf()==2){ |
| | | siteBooking.setHalfName(null); |
| | | } |
| | | siteClient.addSiteBooking(siteBooking); |
| | | System.out.println("=================" + siteBooking); |
| | | return new ResultUtil<>(null, 200, null, null, null); |