Files
services_core/app/Jobs/ReconcileCustomerNasAccount.php
T
2026-08-07 09:16:13 +07:00

16 lines
867 B
PHP

<?php
namespace App\Jobs;
use App\Models\CustomerNasAccount;
use App\Services\Nas\CustomerAccountReconciliationService;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Throwable;
class ReconcileCustomerNasAccount implements ShouldQueue, ShouldBeUnique
{
use Queueable; public int $tries=1; public int $timeout=30; public int $uniqueFor=240;
public function __construct(public int $accountId){$this->onQueue('nas-reconciliation');}
public function uniqueId(): string{return (string)$this->accountId;}
public function handle(CustomerAccountReconciliationService $service): void { $a=CustomerNasAccount::find($this->accountId); if(!$a)return; try{$service->reconcile($a);}catch(Throwable $e){$a->update(['last_reconciled_at'=>now(),'last_sync_error'=>$e->getMessage()]);} }
}