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:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user