|
|
@@ -362,9 +362,9 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
|
|
|
continue;
|
|
|
}
|
|
|
// 校验已取消状态的记录不回显
|
|
|
-// if (reservation.getStatus() != null && reservation.getStatus() == STATUS_CANCELLED) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
+ if (reservation.getStatus() != null && reservation.getStatus() == STATUS_CANCELLED) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
// if (reservation.getStatus() != null && reservation.getStatus() == 2) {
|
|
|
// continue;
|
|
|
@@ -377,6 +377,10 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
+ // 当前时间已超过预约结束时间则不回显(endTime 为 String,需与 reservationDate 组合判断)
|
|
|
+ if (isReservationEndBeforeNow(reservation.getReservationDate(), reservation.getEndTime())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
UserReservationVo vo = getDetail(reservation.getId());
|
|
|
if (vo != null) {
|
|
|
list.add(vo);
|
|
|
@@ -396,6 +400,44 @@ public class UserReservationServiceImpl extends ServiceImpl<UserReservationMappe
|
|
|
return c;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断预约是否已结束(当前时刻晚于结束时刻)。endTime 支持 "HH:mm"(需 reservationDate)或 "yyyy-MM-dd HH:mm(:ss)"。
|
|
|
+ */
|
|
|
+ private static boolean isReservationEndBeforeNow(Date reservationDate, String endTimeStr) {
|
|
|
+ if (endTimeStr == null || endTimeStr.trim().isEmpty()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String trimmed = endTimeStr.trim();
|
|
|
+ Date now = new Date();
|
|
|
+ if (trimmed.contains(" ")) {
|
|
|
+ for (String pattern : new String[]{"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm"}) {
|
|
|
+ try {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
|
|
+ sdf.setLenient(false);
|
|
|
+ Date end = sdf.parse(trimmed);
|
|
|
+ return end.before(now);
|
|
|
+ } catch (ParseException ignored) {
|
|
|
+ // try next pattern
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (reservationDate == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ int minutes = timeToMinutes(trimmed);
|
|
|
+ if (minutes < 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Calendar endCal = Calendar.getInstance();
|
|
|
+ endCal.setTime(reservationDate);
|
|
|
+ endCal.set(Calendar.HOUR_OF_DAY, minutes / 60);
|
|
|
+ endCal.set(Calendar.MINUTE, minutes % 60);
|
|
|
+ endCal.set(Calendar.SECOND, 0);
|
|
|
+ endCal.set(Calendar.MILLISECOND, 0);
|
|
|
+ return endCal.getTime().before(now);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<UserReservationVo> pageList(Integer userId, Integer storeId, Integer status,
|
|
|
Date dateFrom, Date dateTo,
|