Entwicklungsplan September, B2 (Protokoll 08.09., Rueckmeldung 14.09., R3): - Ablauftag + 2 Kalendertage (Nachtlauf): Team, Kunden, Kundenabos und Portal-Logins gehen umkehrbar an den naechsten aktiven Sponsor, jede Umhaengung in consultant_suspension_transfers protokolliert. Kurzinfo an den Sponsor ohne Listen, keine Mail an das Firmenkonto. - Zahlung bis Tag 27: Berater aktiv, Team und Kundendaten zurueck (nur was noch beim Sponsor liegt); Umsaetze der Zwischenzeit bleiben dort. - Tag 28: was noch am Berater haengt geht endgueltig an den Sponsor, Berater wird dessen Kunde (ohne Duplikat) und geloescht; Listen-Mail mit Vorname, Nachname, Telefon, E-Mail an jeden haltenden Sponsor. - Cron, Zahlungseingang und Admin-Ablaufdatum laufen ueber ConsultantSuspensionService; user:cleanup --dry-run listet beide Stufen. - Mail 35 und Dashboard nennen Pausentag und Frist; Fristen in config/mivita.php (cleanup_suspend_days, cleanup_delete_days). - Nebenbefunde: Kernel referenziert UserCleanUp, user:restore aus der User-Bereinigung laeuft nur noch einmal. - Testschema: shopping_users.auth_user_id nullable wie auf Produktion (Migration aendert nur, wo die Spalte noch NOT NULL ist). - Uebersicht fuer die Kundin: dev/_tickets/2026-09-23-mitgliedschaft- ablauf-uebersicht.md. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\ConsultantSuspensionService;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* Ein Kundendatensatz, der beim Pausieren eines Beraters an den Sponsor ging
|
|
* (Entwicklungsplan B2, {@see ConsultantSuspensionService}).
|
|
*
|
|
* @property int $id
|
|
* @property int $consultant_id
|
|
* @property int $sponsor_id
|
|
* @property string $record_type
|
|
* @property int $record_id
|
|
* @property Carbon|null $returned_at
|
|
*/
|
|
class ConsultantSuspensionTransfer extends Model
|
|
{
|
|
public const TYPE_SHOPPING_USER = 'shopping_user';
|
|
|
|
public const TYPE_USER_ABO = 'user_abo';
|
|
|
|
public const TYPE_CUSTOMER = 'customer';
|
|
|
|
protected $fillable = [
|
|
'consultant_id',
|
|
'sponsor_id',
|
|
'record_type',
|
|
'record_id',
|
|
'returned_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'consultant_id' => 'int',
|
|
'sponsor_id' => 'int',
|
|
'record_id' => 'int',
|
|
'returned_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function consultant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'consultant_id')->withTrashed();
|
|
}
|
|
|
|
public function sponsor(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'sponsor_id')->withTrashed();
|
|
}
|
|
|
|
/**
|
|
* Noch beim Sponsor liegende Datensätze eines Beraters.
|
|
*
|
|
* @param Builder<self> $query
|
|
* @return Builder<self>
|
|
*/
|
|
public function scopeOpenFor(Builder $query, int $consultantId): Builder
|
|
{
|
|
return $query->where('consultant_id', $consultantId)->whereNull('returned_at');
|
|
}
|
|
}
|