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/Service/RequestService.php

34 lines
1.0 KiB
PHTML

1 year ago
<?php
declare(strict_types=1);
namespace App\Service;
1 year ago
use App\Exception\BusinessException;
1 year ago
use App\Helper\StringHelper;
1 year ago
use App\Model\RequestLog;
class RequestService extends AbstractService
{
1 year ago
public function getRequestLogByToken($token): RequestLog
1 year ago
{
1 year ago
$requestLog = RequestLog::where('request_token', $token)->first();
if (is_null($requestLog)) {
throw new BusinessException('token不存在');
}
return $requestLog;
1 year ago
}
1 year ago
public function createRequestLog($requestUri, $params): RequestLog
{
$requestLog = new RequestLog();
$requestLog->app_id = $params['app_id'] ?? 0;
$requestLog->request_id = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_REQUEST_ID);
$requestLog->request_token = $requestLog->generateToken();
$requestLog->request_uri = $requestUri;
1 year ago
$requestLog->request_data = $params;
1 year ago
$requestLog->request_time = date('Y-m-d H:i:s');
$requestLog->save();
return $requestLog;
}
1 year ago
}