Files
portal-api/app/Console/Commands/ReconcileServiceExpiry.php

29 lines
963 B
PHP

<?php
namespace App\Console\Commands;
use App\Services\ServiceExpiryReconciler;
use Illuminate\Console\Command;
class ReconcileServiceExpiry extends Command
{
protected $signature = 'service:reconcile-expiry {--dry-run : Chỉ thống kê, không ghi dữ liệu}';
protected $description = 'Đồng bộ module_vmware.next_due_date theo services.expires_at (nguồn hạn dùng duy nhất)';
public function handle(ServiceExpiryReconciler $reconciler): int
{
$dryRun = (bool) $this->option('dry-run');
$stats = $reconciler->run($dryRun);
$this->info(sprintf(
'service:reconcile-expiry%s | lệch module_vmware: %d | service thiếu expires_at được bù: %d | VM không gắn dịch vụ: %d',
$dryRun ? ' (dry-run)' : '',
$stats['synced_vmware'],
$stats['backfilled_services'],
$stats['orphan_vms'],
));
return Command::SUCCESS;
}
}