thirdpayment
ljl 11 months ago
parent 32318040ea
commit bc52aa15bd

@ -0,0 +1,97 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Helper\StringHelper;
use App\Model\BankCard;
use App\Model\Order;
use App\Model\User;
use App\Service\PaymentService;
use App\Service\RequestService;
use App\Service\UserService;
use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Contract\ContainerInterface;
/**
* @Command
*/
class WithdrawCommand extends HyperfCommand
{
/**
* @var ContainerInterface
*/
protected $container;
protected $admin;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
parent::__construct('withdraw');
}
public function configure(): void
{
parent::configure();
$this->setDescription('提现');
}
public function handle(): void
{
$this->confirmPay();
}
public function confirmPay()
{
/**
* @var PaymentService $paymentService
*/
$paymentService = $this->container->make(PaymentService::class);
/**
* @var UserService $userService
*/
$userService = $this->container->make(UserService::class);
$user = User::where('user_id', 'ACT_5')->first();
$balance = $userService->getBalance($user->member_id);
$bankCard = BankCard::where('user_id', $user->user_id)->first();
var_dump([
'userId' => $user->user_id,
'withdrawType' => 'entrust',
'agreementNo' => $bankCard->agreement_no,
'outWithdrawNo' => StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_WITHDRAW_NO),
'amount' => $balance
]);
return;
$requestLog = $this->createRequestLog([
'userId' => $user->user_id,
'withdrawType' => 'entrust',
'agreementNo' => $order->out_order_no,
'outWithdrawNo' => $order->amount,
'amount' => $balance
]);
$url = $paymentService->withdraw($requestLog->getData(), $requestLog->app, $requestLog->request_token);
echo $url;
}
private function createRequestLog($data) {
/**
* @var RequestService $requestService
*/
$requestService = $this->container->make(RequestService::class);
$params = [
'app_id' => '202308070000001',
'data' => json_encode($data),
];
return $requestService->createRequestLog('', $params);
}
}
Loading…
Cancel
Save