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

56 lines
1.7 KiB
PHP

<?php
namespace App\Jobs\Wallet;
use App\Bean\Queue\Wallet\QueueWalletPlatformTransactionBean;
use App\Exceptions\QueueException;
use App\Models\Wallet\Wallet\WalletAddressTransactionModel;
use App\Service\PlatformRechargeService;
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 WalletPlatformTransactionQueue 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 QueueWalletPlatformTransactionBean($params);
$oWithdrawService = new PlatformWithdrawService();
$oRechargeSService = new PlatformRechargeService();
try {
$type = $bean->getType();
//提现
if ($type == WalletAddressTransactionModel::TYPE_WITHDRAW) {
$oWithdrawService->walletPlatformTransactionConsumer($bean);
}
//充值
if ($type == WalletAddressTransactionModel::TYPE_RECHARGE) {
$oRechargeSService->walletPlatformTransactionConsumer($bean);
}
} catch (\Exception $e) {
}
}
public static function putToQueue(QueueWalletPlatformTransactionBean $bean): \Illuminate\Foundation\Bus\PendingDispatch
{
return self::dispatch($bean->toArrayNotNull())->onQueue(QueueWalletPlatformTransactionBean::QUEUE_NAME);
}
}