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

142 lines
5.2 KiB
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Controller\Payment;
1 year ago
use App\Exception\BusinessException;
use App\Model\User;
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);
1 year ago
$url = $this->userService->pwdForget($data, $app, $token);
1 year ago
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);
1 year ago
$url = $this->userService->pwdModify($data, $app, $token);
1 year ago
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
$url = $this->paymentService->payment($data, $app, $token);
return $this->success(['url' => $url]);
1 year ago
}
1 year ago
public function transferPay(RequestInterface $request) {
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$acsNo = $this->paymentService->transferPay($data, $app, $token);
return $this->success(['acsNo' => $acsNo]);
}
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);
1 year ago
$user = User::where('app_id', $app->app_id)->where('user_id', $data['userId'])->first();
if (empty($user)) {
throw new BusinessException('用户不存在');
}
$this->userService->rsyncBankCards($user->member_id);
1 year ago
$records = $this->userService->getUserBankCards($data['userId'], $app);
return $this->success(['result' => $records]);
}
1 year ago
public function queryUser(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('用户不存在');
}
$user = $this->userService->rsyncUser($user->member_id);
$result = [
'realnameFlag' => $user->realname_flag;
'bindCardFlag' => $user->bind_bard_flag;
'setPwdFlag' => $user->set_pwd_flag;
'email' => $user->email;
'mobile' => $user->mobile;
'certificateNo' => $user->certificate_no;
];
return $this->success($result);
}
2 years ago
}