- Haltefrist 0: unverbindliche Auskunft mit signiertem Link "Buchung anfragen", erneute Prüfung unter Sperre, automatische oder manuelle Bestätigung, Absage bei vergebenem Zeitraum, Ablauf unbeantworteter Auskünfte - Aufenthalt: Anreisedaten, Aufgaben je Wohnung, gebuchte Leistungen, Abweichungen und Folgeaufgaben als Aufgaben am Vorgang - Abschluss getrennt: Aufenthalt abgeschlossen / kaufmännisch abgeschlossen, Nachläufer (Forderung, Auszahlung) bleiben sichtbar - Zahlungsstatus nur aus Geld auf unserem Konto; Altbestand per Vorschau-Befehl - Verlauf weist Testzustellungen als solche aus - Abnahmetests T16-T25, T23 über isolierten SMTP-Empfänger Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.1 KiB
PHP
51 lines
2.1 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use App\Actions\AutoOffer;
|
||
use App\Enums\BookingStatus;
|
||
use App\Models\Booking;
|
||
use App\Models\Tenant;
|
||
use App\Tenancy\TenantRunner;
|
||
use Illuminate\Console\Attributes\Description;
|
||
use Illuminate\Console\Attributes\Signature;
|
||
use Illuminate\Console\Command;
|
||
use Throwable;
|
||
|
||
#[Signature('bookings:auto-offers')]
|
||
#[Description('Retry automatic offers of pending requests (e.g. once an instant-booking portal has fetched our calendar) – once per landlord')]
|
||
class SendPendingAutoOffers extends Command
|
||
{
|
||
/**
|
||
* Execute the console command.
|
||
*/
|
||
public function handle(AutoOffer $autoOffer, TenantRunner $runner): int
|
||
{
|
||
$runner->each(function (Tenant $tenant) use ($autoOffer): void {
|
||
$pending = Booking::query()
|
||
->where('status', BookingStatus::Reserved)
|
||
->where('offer_version', 0)
|
||
->where('information_version', 0)
|
||
// Held requests while their hold runs; requests without a hold (information, package 7) for two weeks.
|
||
->where(fn ($query) => $query->where('hold_expires_at', '>', now())->orWhere(fn ($open) => $open->whereNull('hold_expires_at')->where('created_at', '>', now()->subDays(14))))
|
||
->where(fn ($query) => $query->whereNull('intake')->orWhere('intake', 'inquiry'))
|
||
->with(['property', 'guest', 'importChannel', 'originChannel'])
|
||
->get()
|
||
->filter(fn (Booking $booking): bool => $autoOffer->applies($booking) && ($booking->isHoldActive() || ! $booking->process()->preReservation()));
|
||
|
||
$sent = 0;
|
||
foreach ($pending as $booking) {
|
||
try {
|
||
$sent += $autoOffer->handle($booking) === [] ? 1 : 0;
|
||
} catch (Throwable) {
|
||
// The request stays pending for the landlord; the next run tries again.
|
||
}
|
||
}
|
||
|
||
$this->info("{$tenant->name}: {$sent} von {$pending->count()} Angebot(e) automatisch versendet.");
|
||
});
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|