diff --git a/app/Commons/LanzuRequest.php b/app/Commons/LanzuRequest.php new file mode 100644 index 0000000..38e4ce0 --- /dev/null +++ b/app/Commons/LanzuRequest.php @@ -0,0 +1,61 @@ +storeParsedData(function () { + // $request = $this->getRequest(); + // if (is_array($request->getParsedBody())) { + // $data = $request->getParsedBody(); + // } else { + // $data = []; + // } + + // return array_merge($data, $request->getQueryParams()); + // }); + // } + + protected function storeParsedData(callable $callback) + { + if (! Context::has($this->contextkeys['parsedData'])) { + return Context::set($this->contextkeys['parsedData'], call($callback)); + } + + // var_dump(Context::get($this->contextkeys['parsedData'])); + + $preDatas = Context::get($this->contextkeys['parsedData']); + + if(isset($preDatas['market_id'])){ + if($preDatas['market_id']==-1){ + $preDatas['market_id'] = 0; + unset($preDatas['sign']); + $sign = $this->signature($preDatas); + $preDatas['sign'] = $sign; + Context::set($this->contextkeys['parsedData'],$preDatas); + } + } + + return Context::get($this->contextkeys['parsedData']); + } + + private function signature($params) + { + ksort($params); + + $http_query = []; + foreach ($params as $key => $value) { + $http_query[] = $key.'='.$value; + } + + return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); + } +} diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index 412b76d..949ae87 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -11,6 +11,7 @@ declare(strict_types=1); */ return [ + \Hyperf\HttpServer\Contract\RequestInterface::class => \App\Commons\LanzuRequest::class, \App\Service\ServiceEvaluateServiceInterface::class => \App\Service\ServiceEvaluateService::class, \App\Service\AttachmentServiceInterface::class => \App\Service\AttachmentService::class, \App\Service\ParamsTokenServiceInterface::class => \App\Service\ParamsTokenSsdbService::class,