user:make_abo_order nimmt nur Abos mit next_date = heute; faellt ein Lauf aus, bleibt ein Abo stillschweigend liegen (Abo 39: Termin 25.03.2026). abo:check-overdue meldet taeglich um 05:30 alle aktiven Abos mit Status okay und verstrichenem Termin per Mail an mivita (Link ins Admin-Abo) und ins abo_order-Log. Es wird bewusst nichts nachgebucht; --no-mail nur fuer die Ausgabe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Console\Commands\AboCheckOverdue;
|
|
use App\Models\UserAbo;
|
|
use App\Services\Util;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* Interne Warnung an mivita: laufende Abos, deren Termin verstrichen ist, ohne dass
|
|
* sie ausgeführt wurden ({@see AboCheckOverdue}).
|
|
*/
|
|
class AboOverdueAlertMail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
/**
|
|
* @param list<UserAbo> $overdueAbos
|
|
*/
|
|
public function __construct(public array $overdueAbos) {}
|
|
|
|
public function build(): self
|
|
{
|
|
$base = rtrim(Util::getMyMivitaUrl(), '/');
|
|
|
|
$rows = array_map(fn (UserAbo $abo) => [
|
|
'id' => $abo->id,
|
|
'is_for' => $abo->is_for === 'me' ? 'Berater-Abo' : 'Kundenabo',
|
|
'name' => $abo->is_for === 'me'
|
|
? trim($abo->user?->account?->first_name.' '.$abo->user?->account?->last_name)
|
|
: trim($abo->shopping_user?->billing_firstname.' '.$abo->shopping_user?->billing_lastname),
|
|
'next_date' => Carbon::parse($abo->next_date)->format('d.m.Y'),
|
|
'days' => (int) Carbon::parse($abo->next_date)->startOfDay()->diffInDays(now()->startOfDay()),
|
|
'url' => $base.'/admin/abos/detail/'.$abo->id,
|
|
], $this->overdueAbos);
|
|
|
|
return $this->subject('Überfällige Abos: '.count($rows))
|
|
->view('emails.abo_overdue_alert')
|
|
->with(['rows' => $rows]);
|
|
}
|
|
}
|