From 4c7d99a8948cb3748fac49758764dd0cc929f328 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sat, 19 Aug 2023 13:26:15 +0800 Subject: [PATCH] yh --- app/Command/MineCommand.php | 15 +++++++++- app/Controller/Payment/PaymentController.php | 12 ++++++++ app/Helper/Baofu/ApiList.php | 5 ++++ app/Helper/Baofu/Baofu.php | 7 +++++ app/Service/PaymentService.php | 31 ++++++++++++++++++++ config/routes.php | 1 + 6 files changed, 70 insertions(+), 1 deletion(-) diff --git a/app/Command/MineCommand.php b/app/Command/MineCommand.php index 3427777..432cfa8 100644 --- a/app/Command/MineCommand.php +++ b/app/Command/MineCommand.php @@ -45,7 +45,7 @@ class MineCommand extends HyperfCommand public function handle(): void { - $this->unionPay(); + $this->queryOrder(); return; // $this->notify('http://ceshi-shop.hkcpex.com/index.php/pay/notify/baofu_f_register', $this->getApp(), ['userId' => '30684']); $this->notify('http://ceshi-shop.hkcpex.com/index.php/pay/notify/baofu_f_bind_card', $this->getApp(), ['userId' => '23121', 'bindCardFlag' => true]); @@ -359,4 +359,17 @@ class MineCommand extends HyperfCommand $result = $paymentService->payment($data, $this->getApp(), $this->getToken()); var_dump($result); } + + public function queryOrder() + { + /** + * @var PaymentService $paymentService + */ + $paymentService = $this->container->make(PaymentService::class); + $data = [ + 'outOrderNo' => '2023081910162800001', + ]; + $order = $paymentService->queryOrder($data, $this->getApp()); + var_dump($order->toArray()); + } } \ No newline at end of file diff --git a/app/Controller/Payment/PaymentController.php b/app/Controller/Payment/PaymentController.php index b68742c..fb4b02f 100644 --- a/app/Controller/Payment/PaymentController.php +++ b/app/Controller/Payment/PaymentController.php @@ -145,4 +145,16 @@ class PaymentController extends AbstractController ]; return $this->success($result); } + + public function queryOrder(RequestInterface $request) + { + [$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class); + $order = $this->paymentService->queryOrder($data, $app); + $result = [ + 'finishTime' => $order->finished_at, + 'amount' => $order->amount, + 'status' => $order->status, + ]; + return $this->success($result); + } } diff --git a/app/Helper/Baofu/ApiList.php b/app/Helper/Baofu/ApiList.php index 8beedb6..70950ca 100644 --- a/app/Helper/Baofu/ApiList.php +++ b/app/Helper/Baofu/ApiList.php @@ -15,6 +15,11 @@ class ApiList 'url' => '/api/cust/v3.0.0/bindCard', 'signParams' => 'orgNo|merchantNo|terminalNo|loginNo|requestDate|cardNo|bankMobile', ], + 'query-order' => [ + 'description' => '交易订单信息查询', + 'url' => '/api/wallet/v3.0.0/queryOrder', + 'signParams' => 'orgNo|merchantNo|terminalNo|requestDate|tradeId', + ], 'bind-card-check' => [ 'description' => '个人银行卡签约-确认绑卡', 'url' => '/api/cust/v3.0.0/bindCardCheck', diff --git a/app/Helper/Baofu/Baofu.php b/app/Helper/Baofu/Baofu.php index 48b3f11..71a44d2 100644 --- a/app/Helper/Baofu/Baofu.php +++ b/app/Helper/Baofu/Baofu.php @@ -466,4 +466,11 @@ class Baofu $data['authContent'] = $params['authContent']; return $this->api('auth-bind', $data); } + + public function queryOrder($params){ + $data = []; + $data['loginNo'] = $params['loginNo']; + $data['tradeId'] = $params['tradeId']; + return $this->api('query-order', $data); + } } diff --git a/app/Service/PaymentService.php b/app/Service/PaymentService.php index acd696b..08a0a20 100644 --- a/app/Service/PaymentService.php +++ b/app/Service/PaymentService.php @@ -471,4 +471,35 @@ class PaymentService extends AbstractService throw $e; } } + + + public function queryOrder(array $data, App $app) + { + $order = Order::where('app_id', $app->app_id)->where('out_order_no', $data['outOrderNo'])->first(); + if (empty($order)) { + throw new BusinessException('订单不存在'); + } + try { + $baofu = new Baofu(); + $result = $baofu->queryOrder([ + 'loginNo' => $order->member_id, + 'tradeId' => $order->order_no, + ]); + + $info = [ + 'member_id' => $order->member_id, + 'order_no' => $order->order_no, + 'third_order_no' => $result['requestNo'] ?? '', + 'status' => $result['status'], + 'amount' => $result['amount'], + 'finished_at' => $result['finishDate'], + 'error_message' => $result['errorMsg'] ?? '', + 'transaction_id' => $result['transactionId'] ?? '', + 'out_transaction_id' => $result['outTransactionId'] ?? '', + ]; + return $this->updateOrder($info); + } catch (ApiException $e) { + throw $e; + } + } } diff --git a/config/routes.php b/config/routes.php index 2da0610..6b73a6b 100644 --- a/config/routes.php +++ b/config/routes.php @@ -20,6 +20,7 @@ Router::addGroup('/payment',function () { Router::post('/pwd-modify', [PaymentController::class, 'pwdModify']); Router::post('/payment', [PaymentController::class, 'payment']); Router::post('/confirm-pay', [PaymentController::class, 'payment']); + Router::post('/query-order', [PaymentController::class, 'queryOrder']); Router::post('/transfer-pay', [PaymentController::class, 'transferPay']); Router::post('/query-bind-cards', [PaymentController::class, 'queryBindCards']); Router::post('/query-user', [PaymentController::class, 'queryUser']);