From 9432ef1212574ada4a483d704a562fc339b5b4c7 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sun, 23 Apr 2023 00:33:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tool/GameResource/JhBaseClient.class.php | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Application/Base/Tool/GameResource/JhBaseClient.class.php b/Application/Base/Tool/GameResource/JhBaseClient.class.php index fb29b371c..df854a1d4 100644 --- a/Application/Base/Tool/GameResource/JhBaseClient.class.php +++ b/Application/Base/Tool/GameResource/JhBaseClient.class.php @@ -41,7 +41,14 @@ abstract class JhBaseClient $params[self::SIGN_NAME] = $this->sign($api, $params); try { $response = $this->request($api, $params); - return json_decode($response, true); + $result = json_decode($response, true); + if (empty($result)) { + return [ + 'code' => -98, + 'msg' => '返回数据异常', + ]; + } + return $result; } catch (\Exception $e) { $env = C('APP_ENV', null, 'prod'); $this->log('RequestError ' . $e->getMessage(), Log::ERR); @@ -69,11 +76,15 @@ abstract class JhBaseClient protected function post($url, array $params = []) { - $response = $this->client->post($url, [ + /* $response = $this->client->post($url, [ 'verify' => false, 'form_params' => $params, ]); - $result = (string)$response->getBody(); + $result = (string)$response->getBody(); */ + $result = json_encode([ + 'code' => -97, + 'msg' => '模拟发放,自定失败', + ]); $this->log('RequestData ' . json_encode($params)); $this->log('ResponseData ' . $result); return $result; @@ -81,11 +92,15 @@ abstract class JhBaseClient protected function get($url, array $params = []) { - $response = $this->client->get($url, [ + /* $response = $this->client->get($url, [ 'verify' => false, 'query' => $params, ]); - $result = (string)$response->getBody(); + $result = (string)$response->getBody(); */ + $result = json_encode([ + 'code' => -97, + 'msg' => '模拟发放,自定失败', + ]); $this->log('RequestData ' . json_encode($params)); $this->log('ResponseData ' . $result); return $result; @@ -174,7 +189,7 @@ abstract class JhBaseClient } protected function getCommonResult($result) { - if ($result == self::SUCCESS) { + if (intval($result['code']) === self::SUCCESS) { return [ 'status' => true, 'message' => $result['msg'],