55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\Wallet;
|
|
|
|
use App\Bean\Queue\Wallet\QueueWalletPlatformTransactionBean;
|
|
use App\Models\Wallet\Wallet\WalletAddressTransactionModel;
|
|
use App\Service\Wallet\PlatformRechargeService;
|
|
use App\Service\Wallet\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);
|
|
}
|
|
}
|