- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.6 KiB
PHP
48 lines
1.6 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('hold_expires_at', '>', now())
|
||
->with(['property', 'guest', 'importChannel', 'originChannel'])
|
||
->get()
|
||
->filter(fn (Booking $booking): bool => $autoOffer->applies($booking) && $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;
|
||
}
|
||
}
|