diff --git a/app/Controller/Payment/PaymentController.php b/app/Controller/Payment/PaymentController.php index 0cc1912..e0eadc4 100644 --- a/app/Controller/Payment/PaymentController.php +++ b/app/Controller/Payment/PaymentController.php @@ -75,6 +75,17 @@ class PaymentController extends AbstractController return $this->success(['url' => $url]); } + public function getBalance(RequestInterface $request) + { + [$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class); + $user = User::where('app_id', $app->app_id)->where('user_id', $data['userId'])->first(); + if (empty($user)) { + throw new BusinessException('用户不存在'); + } + $result = $this->userService->getBalance($user->member_id); + return $this->success(['result' => $result]); + } + public function payment(RequestInterface $request) { [$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class); $data = $this->paymentService->payment($data, $app, $token); diff --git a/config/routes.php b/config/routes.php index af963db..dc71d41 100644 --- a/config/routes.php +++ b/config/routes.php @@ -19,6 +19,7 @@ Router::addGroup('/payment',function () { Router::post('/pwd-forget', [PaymentController::class, 'pwdForget']); Router::post('/pwd-modify', [PaymentController::class, 'pwdModify']); Router::post('/payment', [PaymentController::class, 'payment']); + Router::post('/get-balance', [PaymentController::class, 'getBalance']); Router::post('/confirm-pay', [PaymentController::class, 'confirmPay']); Router::post('/query-order', [PaymentController::class, 'queryOrder']); Router::post('/transfer-pay', [PaymentController::class, 'transferPay']);