From bc52aa15bd90b72d00808c3bac83af0dd005863f Mon Sep 17 00:00:00 2001 From: ljl Date: Wed, 27 Dec 2023 11:23:39 +0800 Subject: [PATCH] yh --- app/Command/WithdrawCommand.php | 97 +++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 app/Command/WithdrawCommand.php diff --git a/app/Command/WithdrawCommand.php b/app/Command/WithdrawCommand.php new file mode 100644 index 0000000..cfaf302 --- /dev/null +++ b/app/Command/WithdrawCommand.php @@ -0,0 +1,97 @@ +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); + } +} \ No newline at end of file