diff --git a/app/Controller/CouponController.php b/app/Controller/CouponController.php index 43abfbf..bbdd384 100644 --- a/app/Controller/CouponController.php +++ b/app/Controller/CouponController.php @@ -245,7 +245,7 @@ class CouponController extends BaseController $notAvailable = []; foreach ($data as $key => &$item) { if (in_array($item->id, $couponIds)) { - $notAvailable[] = $item; + $notAvailable[$item->id] = $item; } else { $available[] = $item; } @@ -253,7 +253,7 @@ class CouponController extends BaseController return $this->success([ 'available' => $available, - 'not_available' => $notAvailable + 'not_available' => array_values($notAvailable) ]); } diff --git a/app/Middleware/Auth/ApiMiddleware.php b/app/Middleware/Auth/ApiMiddleware.php index de2a720..80b70cb 100644 --- a/app/Middleware/Auth/ApiMiddleware.php +++ b/app/Middleware/Auth/ApiMiddleware.php @@ -39,9 +39,9 @@ class ApiMiddleware implements MiddlewareInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { - if (env('APP_ENV') == 'dev') { - return $handler->handle($request); - } + // if (env('APP_ENV') == 'dev') { + // return $handler->handle($request); + // } // 签名校验 @@ -82,18 +82,22 @@ class ApiMiddleware implements MiddlewareInterface unset($params['sign']); $timestamp = $params['timestamp']; - if (empty($sign) || ($timestamp+config('autoload.auth.api.sign.expire')) < time()) { + if (empty($sign) || ($timestamp+config('auth.api.sign.expire_time')) < time()) { return false; } - ksort($params); - $params = http_build_query($params); - return $sign == $this->signature($params); } - private function signature($http_query) + private function signature($params) { - return sha1(md5($http_query).config('autoload.auth.api.sign.secret_key')); + 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')); } } \ No newline at end of file