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>
104 lines
2.8 KiB
PHP
104 lines
2.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class UserAboOrder
|
|
*
|
|
* @property int $id
|
|
* @property int $user_abo_id
|
|
* @property int $shopping_order_id
|
|
* @property int $status
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property ShoppingOrder $shopping_order
|
|
* @property UserAbo $user_abo
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereShoppingOrderId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereUserAboId($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class UserAboOrder extends Model
|
|
{
|
|
protected $table = 'user_abo_orders';
|
|
|
|
protected $casts = [
|
|
'user_abo_id' => 'int',
|
|
'shopping_order_id' => 'int',
|
|
'status' => 'int',
|
|
'paid' => 'bool',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'user_abo_id',
|
|
'user_id',
|
|
'shopping_order_id',
|
|
'status',
|
|
'error_message',
|
|
'paid',
|
|
];
|
|
|
|
public static $statusTypes = [
|
|
0 => 'abo_new',
|
|
1 => 'abo_new',
|
|
2 => 'abo_okay',
|
|
3 => 'abo_hold',
|
|
4 => 'abo_cancel',
|
|
5 => 'abo_finish',
|
|
6 => 'abo_inactive',
|
|
7 => 'abo_grace',
|
|
8 => 'abo_extern_done',
|
|
];
|
|
|
|
public static $statusColors = [
|
|
0 => 'success',
|
|
1 => 'success',
|
|
2 => 'secondary',
|
|
3 => 'warning',
|
|
4 => 'danger',
|
|
5 => 'info',
|
|
6 => 'warning',
|
|
7 => 'danger',
|
|
8 => 'success',
|
|
];
|
|
|
|
public function shopping_order()
|
|
{
|
|
return $this->belongsTo(ShoppingOrder::class);
|
|
}
|
|
|
|
public function user_abo()
|
|
{
|
|
return $this->belongsTo(UserAbo::class);
|
|
}
|
|
|
|
public function getStatusFormated()
|
|
{
|
|
return '<span class="badge badge-pill badge-'.$this->getStatusColor().'">'.$this->getStatusType().'</span>';
|
|
}
|
|
|
|
public function getStatusType()
|
|
{
|
|
return isset(self::$statusTypes[$this->status]) ? __('abo.'.self::$statusTypes[$this->status]) : '';
|
|
}
|
|
|
|
public function getStatusColor()
|
|
{
|
|
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : 'default';
|
|
}
|
|
}
|