Neue Spalten user_abos.status_reason / paused_until und
user_abo_orders.error_message. Der Grund wird zentral am Model gepflegt
(saving-Event): Zahlungsfehler, Kuendigung/Deaktivierung mit Akteur aus dem
Formular-Kanal, Loeschen beim Zurueckkehren in den Lauf; die Pause setzt
paused_until und paused_by_*. Cron- und Retry-Zahlung schreiben den Fehlertext
des Anbieters an die Abo-Bestellung.
AboStatusExplainer uebersetzt das in einen Satz ("Pausiert bis ... vom Kunden
am ...", "Zahlung am ... fehlgeschlagen - Grund: ...", "Gekuendigt am ... vom
Berater"), Partial _status_explain in Abo-Detail (CRM, Portal, Admin),
Abo-Uebersicht, Kundenabo-Liste, Team-Kundenabos und Admin-Datatable; dort
neuer Filter "Zustand" (pausiert / Zahlung fehlgeschlagen). Backfill-Kommando
abo:backfill-status-reasons fuer Bestandsdaten, Fallback ueber das
Statusprotokoll und die Pausenfelder.
Sprachdateien de/en/es/fr, Tests in AboStatusExplainTest, Plan-Status.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Abo;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
/**
|
|
* Erklaerter Zustand eines Abos fuer die Anzeige (Ticket A3): kurzer Zustand
|
|
* als Badge, ein Satz zur Erklaerung, dazu Datum und Akteur, soweit bekannt.
|
|
*/
|
|
final class AboStatusInfo
|
|
{
|
|
public const STATE_ACTIVE = 'active';
|
|
|
|
public const STATE_PAUSED = 'paused';
|
|
|
|
public const STATE_PAYMENT_FAILED = 'payment_failed';
|
|
|
|
public const STATE_CANCELLED = 'cancelled';
|
|
|
|
public const STATE_DEACTIVATED = 'deactivated';
|
|
|
|
public const STATE_PENDING_PAYMENT = 'pending_payment';
|
|
|
|
public const STATE_FINISHED = 'finished';
|
|
|
|
public const STATE_GRACE = 'grace';
|
|
|
|
public const STATE_EXTERN_DONE = 'extern_done';
|
|
|
|
public const STATE_UNKNOWN = 'unknown';
|
|
|
|
public function __construct(
|
|
public readonly string $state,
|
|
public readonly string $label,
|
|
public readonly string $color,
|
|
public readonly string $text,
|
|
public readonly ?Carbon $date = null,
|
|
public readonly ?string $actor = null,
|
|
public readonly ?string $errorMessage = null,
|
|
) {}
|
|
|
|
public function badge(): string
|
|
{
|
|
return '<span class="badge badge-pill badge-'.e($this->color).'">'.e($this->label).'</span>';
|
|
}
|
|
}
|