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:
2026-10-09 14:26:59 +05:30
parent 1a502767ba
commit 5d711bd13e
38 changed files with 1437 additions and 226 deletions
+10 -6
View File
@@ -182,7 +182,7 @@ namespace Fitness_core_BE.Services.CustomerSubscription
}
var customerId = Guid.Parse(data["customerId"].GetString()!);
var subscription = await _customerSubscriptionRepository.GetActiveSubscriptionByCustomerId(customerId);
var subscription = await _customerSubscriptionRepository.GetActiveGymAccessSubscriptionAsync(customerId);
if (subscription == null)
{
@@ -257,11 +257,15 @@ namespace Fitness_core_BE.Services.CustomerSubscription
if (alreadyMember != null)
throw new ArgumentException("This customer is already a member of the subscription");
// One customer, one plan at a time -- catches both "already primary on their own
// plan" and "already a secondary on a different group", neither of which the
// check above sees (it only looks at this one subscription).
var hasOtherActivePlan = await _customerSubscriptionRepository.HasAnyActiveSubscriptionAsync(customerId);
if (hasOtherActivePlan)
// One customer, one GYM-ACCESS plan at a time -- catches both "already primary
// on their own plan" and "already a secondary on a different group", neither of
// which the check above sees (it only looks at this one subscription). Group
// plans are ordinary gym plans (no class links), so this is always the
// gym-access check in practice; left as such rather than a generic
// HasAnyActiveSubscriptionAsync so a class-only subscription elsewhere never
// blocks joining a group.
var hasOtherActiveGymPlan = await _customerSubscriptionRepository.HasActiveGymAccessPlanAsync(customerId);
if (hasOtherActiveGymPlan)
throw new ArgumentException("This customer already has an active plan. Remove them from it before adding them to another.");
var member = await _customerSubscriptionRepository.AddSubscriptionMemberAsync(new SubscriptionMember