41 lines
917 B
PHP
41 lines
917 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\WalletAddress;
|
|
use App\Services\AutoTransferService;
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
|
|
class AutoTransferAddress implements ShouldQueue, ShouldBeUnique
|
|
{
|
|
use Queueable;
|
|
|
|
public int $tries = 1;
|
|
|
|
public int $timeout = 180;
|
|
|
|
public int $uniqueFor = 180;
|
|
|
|
public function __construct(
|
|
public int $walletAddressId,
|
|
public string $reason = 'cron',
|
|
) {}
|
|
|
|
public function uniqueId(): string
|
|
{
|
|
return 'auto-transfer:'.$this->walletAddressId;
|
|
}
|
|
|
|
public function handle(AutoTransferService $autoTransfer): void
|
|
{
|
|
$address = WalletAddress::query()->find($this->walletAddressId);
|
|
if ($address === null) {
|
|
return;
|
|
}
|
|
|
|
$autoTransfer->evaluate($address, $this->reason);
|
|
}
|
|
}
|