<?php
namespace App\Jobs;
use App\Models\Invoice;
use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels;
final class DispatchOpenInvoicePollingJob implements ShouldQueue { use Dispatchable,InteractsWithQueue,Queueable,SerializesModels; public function __construct(public string $environment){$this->onQueue('reconciliation');} public function handle():void{Invoice::where('environment',$this->environment)->whereIn('status',['waiting','confirming','underpaid'])->whereHas('asset',fn($q)=>$q->where('network','tron')->where('enabled',true))->select('id')->chunkById(100,fn($rows)=>$rows->each(fn($i)=>PollOpenInvoiceAddressJob::dispatch($i->id)->onQueue('reconciliation')));}}
