You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/app/Controller/Payment/PaymentController.php

111 lines
3.9 KiB
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Controller\Payment;
1 year ago
use App\Request\BindCardRequest;
use App\Request\RegisterRequest;
use App\Request\UnbindCardRequest;
2 years ago
use Hyperf\HttpServer\Contract\RequestInterface;
use App\Service\PaymentService;
1 year ago
use App\Service\UserService;
use Hyperf\Context\Context;
2 years ago
1 year ago
class PaymentController extends AbstractController
2 years ago
{
1 year ago
private UserService $userService;
2 years ago
private PaymentService $paymentService;
1 year ago
public function __construct(PaymentService $paymentService, UserService $userService)
2 years ago
{
1 year ago
$this->userService = $userService;
2 years ago
$this->paymentService = $paymentService;
}
1 year ago
private function parseReqest($request, $requestClass)
2 years ago
{
1 year ago
$app = Context::get('app');
1 year ago
$requestLog = Context::get('requestLog');
1 year ago
$req = new $requestClass($request->all());
return [$app, $req->getData(), $requestLog->request_token];
2 years ago
}
1 year ago
public function companyRegister(RequestInterface $request)
2 years ago
{
1 year ago
[$app, $data, $token] = $this->parseReqest($request, RegisterRequest::class);
$result = $this->userService->companyRegister($data, $app, $token);
return $this->success(['result' => $result]);
2 years ago
}
1 year ago
public function register(RequestInterface $request)
2 years ago
{
1 year ago
[$app, $data, $token] = $this->parseReqest($request, RegisterRequest::class);
$url = $this->userService->register($data, $app, $token);
return $this->success(['url' => $url]);
2 years ago
}
1 year ago
public function bindCard(RequestInterface $request)
2 years ago
{
1 year ago
[$app, $data, $token] = $this->parseReqest($request, BindCardRequest::class);
$url = $this->userService->bindCard($data, $app, $token);
return $this->success(['url' => $url]);
2 years ago
}
1 year ago
public function unbindCard(RequestInterface $request)
2 years ago
{
1 year ago
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$data = $this->userService->unbindCard($data, $app);
1 year ago
return $this->success($data);
1 year ago
}
1 year ago
public function pwdForget(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$url = $this->userService->unbindCard($data, $app, $token);
return $this->success(['url' => $url]);
1 year ago
}
1 year ago
1 year ago
public function pwdModify(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$url = $this->userService->unbindCard($data, $app, $token);
return $this->success(['url' => $url]);
1 year ago
}
1 year ago
1 year ago
public function payment(RequestInterface $request) {
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
1 year ago
$this->paymentService->payment($data, $app, $token);
return $this->success();
1 year ago
}
1 year ago
public function refundApply(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$data = $this->paymentService->refundApply($app, $data);
return $this->success($data);
}
public function refundConfirm(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
1 year ago
$this->paymentService->refundConfirm($app, $data, $token);
return $this->success();
1 year ago
}
public function refundCancel(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$data = $this->paymentService->refundApply($app, $data);
1 year ago
return $this->success($data);
}
1 year ago
public function queryBindCards(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$this->userService->rsyncBankCards($data['userId']);
$records = $this->userService->getUserBankCards($data['userId'], $app);
return $this->success(['result' => $records]);
}
2 years ago
}