From 5e5f1e872284c656877c34c948ace8914811e18b Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sat, 12 Aug 2023 01:06:07 +0800 Subject: [PATCH] yh --- app/Command/MineCommand.php | 15 ++++++++++++++- app/Model/RequestLog.php | 6 +++++- app/Service/RequestService.php | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/Command/MineCommand.php b/app/Command/MineCommand.php index 1741942..329897e 100644 --- a/app/Command/MineCommand.php +++ b/app/Command/MineCommand.php @@ -10,6 +10,7 @@ use App\Model\App; use App\Service\AppService; use App\Service\MerchantService; use App\Service\PaymentService; +use App\Service\RequestService; use App\Service\UserService; use Hyperf\Command\Annotation\Command; use Hyperf\Command\Command as HyperfCommand; @@ -42,7 +43,7 @@ class MineCommand extends HyperfCommand public function handle(): void { - $this->payment(); + $this->getRequestLog(); } protected function generateToken() { @@ -194,4 +195,16 @@ class MineCommand extends HyperfCommand $result = $userService->pwdModify(['userId' => 'ELF1990'], $this->getApp(), $this->getToken()); var_dump($result); } + + public function getRequestLog() + { + /** + * @var RequestService $requestService + */ + $requestService = $this->container->make(RequestService::class); + $requestLog = $requestService->getRequestLogByToken('21a640fdfc8dad25ad44512b22da9324'); + + $userId = $requestLog->getDataValue('userId'); + var_dump($userId); + } } \ No newline at end of file diff --git a/app/Model/RequestLog.php b/app/Model/RequestLog.php index 92c4b52..642be05 100644 --- a/app/Model/RequestLog.php +++ b/app/Model/RequestLog.php @@ -8,6 +8,10 @@ class RequestLog extends Model { protected $table = 'request_logs'; + protected $casts = [ + 'request_data' => 'array', + ]; + public function generateToken() { return md5($this->app_id . '_' . $this->request_id); } @@ -18,7 +22,7 @@ class RequestLog extends Model } public function getData() { - $data = $this->request_data['data'] ?: null; + $data = $this->request_data['data'] ?? null; if ($data) { return json_decode($data, true); } diff --git a/app/Service/RequestService.php b/app/Service/RequestService.php index 890b39b..6432033 100644 --- a/app/Service/RequestService.php +++ b/app/Service/RequestService.php @@ -26,7 +26,7 @@ class RequestService extends AbstractService $requestLog->request_id = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_REQUEST_ID); $requestLog->request_token = $requestLog->generateToken(); $requestLog->request_uri = $requestUri; - $requestLog->request_data = json_encode($params, JSON_UNESCAPED_UNICODE); + $requestLog->request_data = $params; $requestLog->request_time = date('Y-m-d H:i:s'); $requestLog->save(); return $requestLog;