12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
92
app/Console/Commands/ReportLegacyApiCustomers.php
Normal file
92
app/Console/Commands/ReportLegacyApiCustomers.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Api\LegacyApiCustomerReporter;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ReportLegacyApiCustomers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'api:legacy-customers-report
|
||||
{--portal=all : Portal (presseecho|businessportal24|both|all)}
|
||||
{--classification=all : Filter (eligible|needs_review|blocked|all)}
|
||||
{--no-report : Keinen JSON-Report schreiben}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Ermittelt Legacy-API-Kunden aus migrierten Daten und letzter bezahlter Rechnung.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(LegacyApiCustomerReporter $reporter): int
|
||||
{
|
||||
$portal = (string) $this->option('portal');
|
||||
$classification = (string) $this->option('classification');
|
||||
|
||||
if (! in_array($portal, ['presseecho', 'businessportal24', 'both', 'all'], true)) {
|
||||
$this->error("Unbekanntes Portal: {$portal}");
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
if (! in_array($classification, ['eligible', 'needs_review', 'blocked', 'all'], true)) {
|
||||
$this->error("Unbekannte Klassifizierung: {$classification}");
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$report = $reporter->report($portal);
|
||||
$customers = collect($report['customers']);
|
||||
|
||||
if ($classification !== 'all') {
|
||||
$customers = $customers
|
||||
->where('classification', $classification)
|
||||
->values();
|
||||
}
|
||||
|
||||
$this->info('Legacy-API-Kundenreport');
|
||||
$this->newLine();
|
||||
$this->line("Portal: {$portal}");
|
||||
$this->line("Kandidaten: {$report['summary']['total_candidates']}");
|
||||
$this->line("Freigabefähig: {$report['summary']['eligible']}");
|
||||
$this->line("Manuell prüfen: {$report['summary']['needs_review']}");
|
||||
$this->line("Gesperrt: {$report['summary']['blocked']}");
|
||||
|
||||
if ($customers->isNotEmpty()) {
|
||||
$this->newLine();
|
||||
$this->table(
|
||||
['ID', 'E-Mail', 'Portal', 'Letzte Rechnung', 'Status', 'Klassifizierung'],
|
||||
$customers
|
||||
->take(25)
|
||||
->map(fn (array $customer): array => [
|
||||
$customer['user_id'],
|
||||
$customer['email'],
|
||||
$customer['portal'],
|
||||
$customer['latest_legacy_invoice']['number'] ?? '-',
|
||||
$customer['latest_legacy_invoice']['status'] ?? '-',
|
||||
$customer['classification'],
|
||||
])
|
||||
->all()
|
||||
);
|
||||
}
|
||||
|
||||
if (! (bool) $this->option('no-report')) {
|
||||
$path = 'migration/legacy-api-customers-'.now()->format('Ymd-His').'.json';
|
||||
Storage::disk('local')->put($path, json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
$this->newLine();
|
||||
$this->line("Report geschrieben: storage/app/private/{$path}");
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue