From f88cfa02e36752e4acad7adc4b045155e8e50f21 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期五, 08 十二月 2023 09:16:29 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java | 203 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 194 insertions(+), 9 deletions(-) diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java index 32c31f1..9fcfc58 100644 --- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java +++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java @@ -29,7 +29,7 @@ import com.dsh.guns.modular.system.util.DateComparisonExample; import com.dsh.guns.modular.system.util.HttpRequestUtil; import com.dsh.guns.modular.system.util.ResultUtil; - +import com.dsh.course.entity.SiteLock; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -40,6 +40,8 @@ import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; @@ -869,7 +871,6 @@ @RequestMapping("/getStudentTotal") @ResponseBody public List<Map<String, Object>>getStudentTotal(@RequestBody StudentQeryDto studentQeryDto) { -System.out.println("========ballQueryDto======"+studentQeryDto); if (studentQeryDto.getTimes()!=null&& studentQeryDto.getTimes()!=""){ String[] split = studentQeryDto.getTimes().split(","); studentQeryDto.setStart(split[0]); @@ -890,9 +891,6 @@ studentQeryDto.setCoursePackageIds(coursePackageByStoreIds); } List<Map<String, Object>> pays = coursePackageClient.getStudentTotal(studentQeryDto); - - System.out.println("=========getStudentTotal======="+pays); - return pays; } @@ -977,6 +975,23 @@ } } } + + if (Integer.parseInt(vo.get("status").toString())==1 ){ + String dateTimeStr = vo.get("times").toString(); + String formattedDateTimeStr = dateTimeStr.substring(0, 11) + dateTimeStr.substring(17); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + try { + Date date = sdf.parse(formattedDateTimeStr); + if (new Date().after(date)){ + vo.put("status",4); + } + + System.out.println(date); + } catch (ParseException e) { + e.printStackTrace(); + } + } } return orders; } @@ -1007,7 +1022,7 @@ System.out.println("=====stie====="+site); System.out.println("=====type====="+type); - if (type == 0 ){ + if (type == 1 ){ doubles.add(site.getCashPrice()); doubles.add(Double.valueOf(site.getPlayPaiCoin())); return doubles; @@ -1023,9 +1038,13 @@ + @Autowired + private ISiteLockService siteLockService; + + @RequestMapping("/yuyuetimes/{id}") @ResponseBody - public List<OrderDto> yuyuetimes(@PathVariable("id") Integer id,String day,String siteName,String halfName) { + public List<OrderDto> yuyuetimes(@PathVariable("id") Integer id,String date,String siteName,String halfName) throws ParseException { // System.out.println("=======date======"+date); // // List<String> strings = new ArrayList<>(); @@ -1053,7 +1072,7 @@ // String appointmentEndTime = site.getAppointmentEndTime(); // // String currentTime = appointmentStartTime; -// while (currentTime.compareTo(appointmentEndTime) < 0) { +// while (currentTime.compareTo(appointmentEndTime) < 0){ // String nextTime = null; // if("智慧场地".equals(site.getTypeName())){ // nextTime=getNextTimeOne(currentTime); @@ -1085,9 +1104,122 @@ // return timeRanges; + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date now = new Date(); + + System.out.println("=======date======" + date); + List<String> strings = new ArrayList<>(); + + List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).ne("status", 5).eq("nextName", siteName).like("times", date)); + + if (siteName == null || siteName.equals("")) { + siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).ne("status", 5).like("times", date)); + } -return null; + System.out.println("=======siteBookings======" + siteBookings); + for (SiteBooking siteBooking : siteBookings) { + + + String[] split = siteBooking.getTimes().split(";"); + + if (siteBooking.getIsHalf() == 2) { + for (String s : split) { + String convertedValue = s.substring(11); + strings.add(convertedValue); + } + } else { + if (halfName == null) { + for (String s : split) { + String convertedValue = s.substring(11); + strings.add(convertedValue); + } + } + + if (siteBooking.getHalfName().equals(halfName)) { + 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(id); + System.out.println("================" + site); + String appointmentStartTime = site.getAppointmentStartTime(); + String appointmentEndTime = site.getAppointmentEndTime(); + + String currentTime = appointmentStartTime; + while (currentTime.compareTo(appointmentEndTime) < 0) { + String nextTime = null; + if ("智慧场地".equals(site.getTypeName())) { + nextTime = getNextTimeOne(currentTime); + } else { + 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.setSelectable(0); +// } + if (strings.contains(timeRange)) { + + orderDto.setState(0); + } else { + + String stime = date + " " + currentTime; + String etime = date + " " + nextTime; + Date isPass = format.parse(etime); + + + + orderDto.setState(1); + // 查出lock + List<SiteLock> list = siteLockService.list(new LambdaQueryWrapper<SiteLock>().eq(SiteLock::getSiteId, id)); + for (SiteLock siteLock : list) { + boolean stringDateBetween = DateComparisonExample.isStringDateBetween(stime + " - " + etime, siteLock.getStartTime(), siteLock.getEndTime()); + if (stringDateBetween) { + orderDto.setState(0); + } + if (DateComparisonExample.isStringWithinTimeRange(stime, siteLock.getStartTime(), siteLock.getEndTime())) { + orderDto.setState(0); + } + if (DateComparisonExample.isStringWithinTimeRange(etime, siteLock.getStartTime(), siteLock.getEndTime())) { + orderDto.setState(0); + } + + } + if (isPass.before(now)){ + orderDto.setState(0); + } + + } + + + timeRanges.add(orderDto); + currentTime = nextTime; + } + System.out.println("-------------" + timeRanges); + + return timeRanges; + + + } @@ -1140,6 +1272,17 @@ return split; } + + @RequestMapping("/nextName/{id}") + @ResponseBody + public String[] nextName(@PathVariable("id") Integer id) { + TSite byId = siteService.getById(id); + String[] split = byId.getNextName().split(","); + System.out.println("=-============"+split); + + return split; + } + @RequestMapping("/yuyue_add") public String yuyueadd(Model model) { @@ -1195,6 +1338,48 @@ siteBooking.setState(1); siteBooking.setStatus(0); siteBooking.setAddType(1); + + //存开始和结束时间 + String times = siteBooking.getTimes(); + String[] dates = times.split(";"); + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + + Date minDate = null; + Date maxDate = null; + + for (String dateStr : dates) { + String[] dateRange = dateStr.split("-"); + String startDateStr = dateRange[0].trim(); + String endDateStr = dateRange[1].trim(); + + try { + Date startDate = format.parse(startDateStr); + Date endDate = format.parse(endDateStr); + + if (minDate == null || startDate.before(minDate)) { + minDate = startDate; + } + if (maxDate == null || endDate.after(maxDate)) { + maxDate = endDate; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + System.out.println("最小日期:" + minDate); + System.out.println("最大日期:" + maxDate); + siteBooking.setStartTime(minDate); + siteBooking.setEndTime(maxDate); + siteBooking.setPayType(2); + + //存多少钱 + String money = siteBooking.getMoney(); + String[] moneys = money.split(","); + siteBooking.setPayMoney(Double.valueOf(moneys[0])); + + // 查询当前预约人是否是会员 String phone = siteBooking.getPhone(); String booker = siteBooking.getBooker(); -- Gitblit v1.7.1