5d711bd13e
Implements the facility-classes-booking-dashboard plan (backend): - Facility.BookingMode (single Scheduled/AdHoc choice) replaced with independent SupportsClasses/SupportsBooking flags, so one facility can run a class and accept walk-in bookings; a running class now blocks walk-in booking for its window on both create and reschedule. - CustomerPlan.GrantsGymAccess + CustomerPlanClass join table let a customer hold one gym-access plan plus any number of class-only plans. Replaced the old single-subscription resolution (GetActiveSubscriptionByCustomerId/HasAnyActiveSubscriptionAsync) with gym-access-aware and class-aware resolvers across booking creation/cancellation, plan assignment, and customer self-service. Fixed ChangeMembershipPlan/renewal plan-changes, which resolved "the subscription to replace" by most-recent-created and would have deactivated a member's class subscription instead of their gym one. - New FacilityClass model: recurring class definitions (Daily/Weekly/ Monthly/Custom) with lazy occurrence generation (8-week horizon, race-safe via a unique index) and proper unlimited-capacity handling. "Mark not held" replaces the old bare-cancel: cascades to cancel and refund every confirmed booking on the occurrence through the same core CancelBooking uses, and frees the slot for walk-in booking. Scheduling conflicts (a walk-in booking now overlapping a class) are surfaced for staff to resolve via the existing Reschedule flow. - Renamed the pre-existing "AdHoc" booking-mode terminology to "WalkIn" throughout (routes, methods, DTOs, the stored BookingMode value) for a clearer, simpler name. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
50 lines
2.6 KiB
C#
50 lines
2.6 KiB
C#
using Fitness_core_BE.Models;
|
|
|
|
namespace Fitness_core_BE.Interfaces
|
|
{
|
|
public interface IBookingRepository
|
|
{
|
|
Task<Booking> CreateBooking(Booking booking);
|
|
Task<Booking?> GetBookingById(Guid bookingId);
|
|
|
|
// "Confirmed" only -- an OTP that's already been used/cancelled shouldn't check anyone in.
|
|
Task<Booking?> GetActiveBookingByOtp(string otpCode);
|
|
|
|
Task<List<Booking>> GetBookingsForSession(Guid facilitySessionId);
|
|
Task<List<Booking>> GetBookingsForCustomer(Guid customerId);
|
|
Task<bool> CustomerHasActiveBookingForSession(Guid facilitySessionId, Guid customerId);
|
|
|
|
/// <summary>Unified roster query covering both Scheduled and WalkIn bookings -- backs
|
|
/// GET api/client/bookings. All filters are optional/AND-combined.</summary>
|
|
Task<List<Booking>> GetBookings(Guid clientId, Guid? facilityId, Guid? facilitySessionId, DateTime? fromUtc, DateTime? toUtc, string? status);
|
|
|
|
// --- Lazy overdue reconciliation (BookingService.SweepOverdueBookingsAsync), run at the
|
|
// top of every check-in AND every checkout instead of a background job -- see
|
|
// Booking.Status doc comment. ---
|
|
|
|
/// <summary>Bulk-flips every Confirmed booking for this client whose EndTime has passed
|
|
/// to NoShow. Returns the number of rows affected (informational/logging only).</summary>
|
|
Task<int> MarkOverdueConfirmedAsNoShowAsync(Guid clientId, DateTime now);
|
|
|
|
/// <summary>Atomically flips a tag from Available to InUse -- the ONE place a real race
|
|
/// matters (two staff picking the same tag for two different bookings must not both
|
|
/// win), so this uses a conditional bulk update rather than read-then-write. Returns
|
|
/// false if the tag was no longer Available.</summary>
|
|
Task<bool> TryClaimRfidTagAsync(Guid tagId, DateTime now);
|
|
|
|
// --- Booking invoices (snapshot receipts created when a payment is recorded) ---
|
|
|
|
Task<BookingInvoice> CreateBookingInvoice(BookingInvoice invoice);
|
|
|
|
/// <summary>Listed on their own "Invoices" tab -- deliberately not mixed into the
|
|
/// membership-based Customer Payments view.</summary>
|
|
Task<List<BookingInvoice>> GetBookingInvoices(Guid clientId, DateTime? fromUtc, DateTime? toUtc);
|
|
|
|
Task<BookingInvoice?> GetBookingInvoiceById(Guid bookingInvoiceId);
|
|
|
|
/// <summary>Aggregate counts/sums backing the Bookings page's Dashboard tab.</summary>
|
|
Task<(int bookingsToday, decimal revenueToday, int checkedInNow, int upcomingConfirmed, decimal outstandingUnpaid)>
|
|
GetDashboardSummaryAsync(Guid clientId, DateTime now);
|
|
}
|
|
}
|