Files
cycle_api/app/Jobs/Wallet/WalletPlatformWithdrawTransferQueue.php
2024-03-25 06:15:36 +08:00

48 lines
1.3 KiB
PHP

<?php
namespace App\Jobs\Wallet;
use App\Bean\Queue\Wallet\QueueWalletPlatformWithdrawTransferBean;
use App\Exceptions\QueueException;
use App\Service\PlatformWithdrawService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class WalletPlatformWithdrawTransferQueue implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct()
{
//处理提现任务
}
/**
* Execute the job.
*/
public function handle(array $params): void
{
$bean = new QueueWalletPlatformWithdrawTransferBean($params);
$oService = new PlatformWithdrawService();
try {
$oService->withdrawTransferConsumer($bean);
} catch (\Exception $e) {
}
}
public static function putToQueue(QueueWalletPlatformWithdrawTransferBean $bean, $delaySec = null): \Illuminate\Foundation\Bus\PendingDispatch
{
$queue = self::dispatch($bean->toArrayNotNull())->onQueue(QueueWalletPlatformWithdrawTransferBean::QUEUE_NAME);
if(!empty($delaySec)){
$queue->delay(now()->addSeconds($delaySec));
}
return $queue;
}
}