From e363a30efc759bcfe0ea0e14ef95eb433a074950 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Thu, 21 Dec 2023 23:49:37 +0800 Subject: [PATCH] yh --- app/Command/PaymentCommand.php | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 app/Command/PaymentCommand.php diff --git a/app/Command/PaymentCommand.php b/app/Command/PaymentCommand.php new file mode 100644 index 0000000..b7095fd --- /dev/null +++ b/app/Command/PaymentCommand.php @@ -0,0 +1,74 @@ +container = $container; + + parent::__construct('payment'); + } + + 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); + $fiveMinute = date('Y-m-d H:i:s', time() - 6*60); + $orders = Order::where('updated_at', '<=', $fiveMinute)->where('status', 'SUCCESS')->get(); + foreach ($orders as $order) { + if ($order->user_id != 'ELF1990') { + continue; + } + $userId = $order->user_id; + $requestLog = $this->createRequestLog(['userId' => $userId, 'oldOutOrderNo' => $order->out_order_no, 'amount' => $order->amount]); + $result = $paymentService->confirmPay($requestLog->getData(), $requestLog->app, $requestLog->request_token); + } + } + + 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