You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Commons;
|
|
|
|
use Hyperf\HttpServer\Request;
|
|
use Hyperf\Utils\Context;
|
|
|
|
class LanzuRequest extends Request
|
|
{
|
|
// protected function getInputData(): array
|
|
// {
|
|
|
|
// return $this->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'));
|
|
}
|
|
}
|