feat(appointment): expire pending bookings past their payment window

Add findPaymentExpired (pending with expires_at < now) and have the
cancel-expired command flip both payment-expired and slot-time-passed
pendings to expired (deduped). Run it on a schedule (e.g. every minute:
* * * * * php bin/console app:cancel-expired-appointments) to free locks
held by unpaid bookings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 17:58:28 +03:30
co-authored by Claude Opus 4.8
parent aa2e46dfdb
commit 089badbb5a
2 changed files with 22 additions and 4 deletions
@@ -80,6 +80,19 @@ class AppointmentRepository extends ServiceEntityRepository
return $this->findBy($criteria, ['slotStart' => 'DESC']);
}
/** @return Appointment[] pending bookings whose 15-minute payment window has lapsed */
public function findPaymentExpired(int $now): array
{
return $this->createQueryBuilder('a')
->where('a.status = :status')
->andWhere('a.expiresAt IS NOT NULL')
->andWhere('a.expiresAt < :now')
->setParameter('status', Appointment::STATUS_PENDING)
->setParameter('now', $now)
->getQuery()
->getResult();
}
/** @return Appointment[] pending appointments older than given timestamp */
public function findExpiredPending(int $before): array
{