| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | querySiteInfoVo.setStoreLat(store.getLat()); |
| | | querySiteInfoVo.setStorePhone(store.getPhone()); |
| | | querySiteInfoVo.setImgs(site.getImgs()); |
| | | |
| | | querySiteInfoVo.setDistance(0D); |
| | | |
| | | |
| | | querySiteInfoVo.setCashPriceOne(site.getCashPriceOne()); |
| | | if(site.getPlayPaiCoinOne()!=null){ |
| | | querySiteInfoVo.setPlayPaiCoinOne(site.getPlayPaiCoinOne().intValue()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private ISiteBookingService iSiteBookingService; |
| | | @Autowired |
| | | private ISiteService siteService; |
| | | /** |
| | | * 获取场地预约日期数据 |
| | | * @param id |
| | |
| | | */ |
| | | @Override |
| | | public List<QuerySiteTimes> querySiteTimes(Integer id, String day) throws Exception { |
| | | Site site = this.getById(id); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(sdf.parse(day + " " + site.getAppointmentStartTime())); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(sdf.parse(day + " " + site.getAppointmentEndTime())); |
| | | // Site site = this.getById(id); |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // Calendar s = Calendar.getInstance(); |
| | | // s.setTime(sdf.parse(day + " " + site.getAppointmentStartTime())); |
| | | // Calendar e = Calendar.getInstance(); |
| | | // e.setTime(sdf.parse(day + " " + site.getAppointmentEndTime())); |
| | | // |
| | | // int hour = e.get(Calendar.HOUR_OF_DAY); |
| | | // |
| | | // int minute = e.get(Calendar.MINUTE); |
| | | // |
| | | // List<QuerySiteTimes> list = new ArrayList<>(); |
| | | // |
| | | // SimpleDateFormat sdfs = new SimpleDateFormat("HH:mm"); |
| | | // |
| | | // while (true){ |
| | | // |
| | | // String start = sdfs.format(s.getTime()); |
| | | // |
| | | // s.set(Calendar.MINUTE, s.get(Calendar.MINUTE) + 30); |
| | | // |
| | | // int e_hour = s.get(Calendar.HOUR_OF_DAY); |
| | | // |
| | | // int e_minute = s.get(Calendar.MINUTE); |
| | | // |
| | | // String end = sdfs.format(s.getTime()); |
| | | // |
| | | // QuerySiteTimes querySiteTimes = new QuerySiteTimes(); |
| | | // |
| | | // querySiteTimes.setTime(start + "-" + end); |
| | | // |
| | | // querySiteTimes.setSelectable(1); |
| | | // |
| | | // SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("state", 1) |
| | | // .in("status", Arrays.asList(3, 4, 5)).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'")); |
| | | // if(null != siteBooking){ |
| | | // querySiteTimes.setSelectable(0); |
| | | // } |
| | | // int count = siteLockService.count(new QueryWrapper<SiteLock>().eq("siteId", id).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'")); |
| | | // if(count > 0){ |
| | | // querySiteTimes.setSelectable(0); |
| | | // } |
| | | // |
| | | // list.add(querySiteTimes); |
| | | // |
| | | // if(e_hour == hour && minute == e_minute){ |
| | | // break; |
| | | // } |
| | | // } |
| | | // return list; |
| | | |
| | | int hour = e.get(Calendar.HOUR_OF_DAY); |
| | | System.out.println("=======date======"+day); |
| | | |
| | | int minute = e.get(Calendar.MINUTE); |
| | | List<String> strings = new ArrayList<>(); |
| | | |
| | | List<QuerySiteTimes> list = new ArrayList<>(); |
| | | // List<SiteBooking> siteBookings = siteClient.listBooks(id); |
| | | List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).like("times",date)); |
| | | System.out.println("=======siteBookings======"+siteBookings); |
| | | for (SiteBooking siteBooking : siteBookings) { |
| | | String[] split = siteBooking.getTimes().split(";"); |
| | | for (String s : split) { |
| | | |
| | | SimpleDateFormat sdfs = new SimpleDateFormat("HH:mm"); |
| | | |
| | | while (true){ |
| | | |
| | | String start = sdfs.format(s.getTime()); |
| | | |
| | | s.set(Calendar.MINUTE, s.get(Calendar.MINUTE) + 30); |
| | | |
| | | int e_hour = s.get(Calendar.HOUR_OF_DAY); |
| | | |
| | | int e_minute = s.get(Calendar.MINUTE); |
| | | |
| | | String end = sdfs.format(s.getTime()); |
| | | |
| | | QuerySiteTimes querySiteTimes = new QuerySiteTimes(); |
| | | |
| | | querySiteTimes.setTime(start + "-" + end); |
| | | |
| | | querySiteTimes.setSelectable(1); |
| | | |
| | | SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("state", 1) |
| | | .in("status", Arrays.asList(3, 4, 5)).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'")); |
| | | if(null != siteBooking){ |
| | | querySiteTimes.setSelectable(0); |
| | | } |
| | | int count = siteLockService.count(new QueryWrapper<SiteLock>().eq("siteId", id).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'")); |
| | | if(count > 0){ |
| | | querySiteTimes.setSelectable(0); |
| | | String convertedValue = s.substring(11); |
| | | strings.add(convertedValue); |
| | | } |
| | | |
| | | list.add(querySiteTimes); |
| | | } |
| | | System.out.println("======strings======="+strings); |
| | | |
| | | if(e_hour == hour && minute == e_minute){ |
| | | break; |
| | | |
| | | List<QuerySiteTimes> timeRanges = new ArrayList<>(); |
| | | |
| | | |
| | | Site site = siteService.getById(id); |
| | | System.out.println("================"+site); |
| | | String appointmentStartTime = site.getAppointmentStartTime(); |
| | | String appointmentEndTime = site.getAppointmentEndTime(); |
| | | |
| | | String currentTime = appointmentStartTime; |
| | | while (currentTime.compareTo(appointmentEndTime) < 0) { |
| | | String nextTime = getNextTime(currentTime); |
| | | |
| | | |
| | | String timeRange = currentTime + "-" + nextTime; |
| | | QuerySiteTimes orderDto = new QuerySiteTimes(); |
| | | orderDto.setTime(timeRange); |
| | | |
| | | LocalTime currentTime1 = LocalTime.now(); |
| | | LocalTime targetTime = LocalTime.parse(currentTime); |
| | | |
| | | boolean hasExceeded = currentTime1.isAfter(targetTime); |
| | | if (hasExceeded){ |
| | | orderDto.setSelectable(0); |
| | | } |
| | | if (strings.contains(timeRange)){ |
| | | orderDto.setSelectable(0); |
| | | } |
| | | return list; |
| | | |
| | | |
| | | timeRanges.add(orderDto); |
| | | currentTime = nextTime; |
| | | } |
| | | System.out.println("-------------"+timeRanges); |
| | | |
| | | return timeRanges; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public static String getNextTime(String currentTime) { |
| | | String[] parts = currentTime.split(":"); |
| | | int hour = Integer.parseInt(parts[0]); |
| | | int minute = Integer.parseInt(parts[1]); |
| | | |
| | | if (minute == 30) { |
| | | hour++; |
| | | minute = 0; |
| | | } else { |
| | | minute = 30; |
| | | } |
| | | |
| | | return String.format("%02d:%02d", hour, minute); |
| | | |
| | | // String[] parts = currentTime.split(":"); |
| | | // int hour = Integer.parseInt(parts[0]); |
| | | // int minute = Integer.parseInt(parts[1]); |
| | | // |
| | | // if (minute == 45) { |
| | | // hour++; |
| | | // minute = 0; |
| | | // } else if (minute == 0){ |
| | | // minute = 15; |
| | | // }else if (minute == 15){ |
| | | // minute = 30; |
| | | // }else if (minute == 30){ |
| | | // minute = 45; |
| | | // } |
| | | // |
| | | // return String.format("%02d:%02d", hour, minute); |
| | | |
| | | |
| | | } |
| | | |
| | | |