Facility booking-mode redesign, multi-plan subscriptions, and Classes
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>
This commit is contained in:
@@ -23,14 +23,31 @@ namespace Fitness_core_BE.Interfaces
|
||||
Task<CustomerCards?> GetCardByIdAsync(Guid cardId, CancellationToken ct = default);
|
||||
Task<CustomerSubscription?> GetCustomerSubscriptionById(Guid subscriptionId);
|
||||
Task<List<CustomerSubscription>> GetCustomerSubscriptionsByCustomerId(Guid customerId);
|
||||
Task<CustomerSubscription?> GetActiveSubscriptionByCustomerId(Guid customerId);
|
||||
/// <summary>True for an ordinary plan (no CustomerPlanClass links) or a class-linked
|
||||
/// plan with GrantsGymAccess == true.</summary>
|
||||
Task<bool> PlanGrantsGymAccessAsync(Guid customerPlanId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The customer's active subscription whose plan grants gym access, if any --
|
||||
/// at most one can exist (enforced by HasActiveGymAccessPlanAsync at assignment time).
|
||||
/// Primary-only, same as the old GetActiveSubscriptionByCustomerId this replaces.</summary>
|
||||
Task<CustomerSubscription?> GetActiveGymAccessSubscriptionAsync(Guid customerId);
|
||||
|
||||
/// <summary>The customer's active subscription on this exact plan, if any -- the
|
||||
/// idempotency check for re-assigning a class-only plan (which, unlike a gym plan,
|
||||
/// doesn't block on ANY other active plan, only a duplicate of itself).</summary>
|
||||
Task<CustomerSubscription?> GetActiveSubscriptionForPlanAsync(Guid customerId, Guid customerPlanId);
|
||||
|
||||
/// <summary>The subscription that covers booking a specific class, preferring one with
|
||||
/// quota left this cycle. Null if none of the customer's active subscriptions link to
|
||||
/// this class at all.</summary>
|
||||
Task<CustomerSubscription?> GetActiveSubscriptionForClassAsync(Guid customerId, Guid facilityClassId);
|
||||
|
||||
// Whether this customer is currently an active member (primary OR secondary/group) of
|
||||
// ANY subscription at this gym. GetActiveSubscriptionByCustomerId only sees subscriptions
|
||||
// where they're the primary -- this also catches a group co-member, so "one customer, one
|
||||
// plan at a time" can be enforced everywhere a plan gets assigned, not just the primary
|
||||
// path.
|
||||
Task<bool> HasAnyActiveSubscriptionAsync(Guid customerId, CancellationToken ct = default);
|
||||
// ANY gym-access subscription at this gym -- a class-only subscription never counts, so
|
||||
// unlimited concurrent class-only subscriptions are allowed. "One customer, one
|
||||
// GYM-ACCESS plan at a time" is enforced everywhere a gym plan gets assigned, not just
|
||||
// the primary path.
|
||||
Task<bool> HasActiveGymAccessPlanAsync(Guid customerId, CancellationToken ct = default);
|
||||
|
||||
Task<SubscriptionMember> AddSubscriptionMemberAsync(SubscriptionMember member);
|
||||
Task<int> GetActiveMemberCountAsync(Guid subscriptionId);
|
||||
|
||||
Reference in New Issue
Block a user