diff --git a/src/Core/BaseService.php b/src/Core/BaseService.php index 0e3b1af..23758a2 100644 --- a/src/Core/BaseService.php +++ b/src/Core/BaseService.php @@ -319,14 +319,17 @@ public function imouSystemParams() public function getCloudAccessToken() { $cacheKey = $this->getCacheKey(self::$config); - $accessToken = CacheAdapter::getInstance()->getItem($cacheKey); + $accessToken = self::getInstance()->getItem($cacheKey); if (!$accessToken->isHit()) { $result = $this->refreshCloudAccessToken(); if (!empty($result)) { + if (!$result['success']){ + throw new \Exception($result['code'].' '.$result['errMsg']); + } $this->cloud_access_token = $result['access_token']; $accessToken->set($result); $accessToken->expiresAfter((int) $result['expires_in'] - 3); - CacheAdapter::getInstance()->save($accessToken); + self::getInstance()->save($accessToken); return $result; } } else { @@ -356,18 +359,17 @@ public function refreshCloudAccessToken() public function requestImouAccessToken() { $cacheKey = $this->getLcCacheKey(self::$config); - $accessToken = CacheAdapter::getInstance()->getItem($cacheKey); + $accessToken = self::getInstance()->getItem($cacheKey); if (!$accessToken->isHit()) { echo "没有命中缓存~"; $result = $this->refreshImouAccessToken(); $result = \json_decode($result,true); - var_dump($result); if (!empty($result) && (int)$result['result']['code'] === 0) { $data = $result['result']['data']; $this->cloud_imou_token = $data['accessToken']; $accessToken->set($data); $accessToken->expiresAfter((int) $data['expireTime'] - 3); - CacheAdapter::getInstance()->save($accessToken); + self::getInstance()->save($accessToken); return $data; } return $result; diff --git a/src/Core/Container.php b/src/Core/Container.php index 9557df4..d815df6 100644 --- a/src/Core/Container.php +++ b/src/Core/Container.php @@ -34,6 +34,7 @@ class Container implements \ArrayAccess */ public $register; + #[\ReturnTypeWillChange] public function offsetExists($offset) { // TODO: Implement offsetExists() method. @@ -44,6 +45,7 @@ public function offsetExists($offset) * * @return $this|mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { if (isset($this->instances[$offset])) { @@ -61,11 +63,13 @@ public function offsetGet($offset) * @param mixed $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->values[$offset] = $value; } + #[\ReturnTypeWillChange] public function offsetUnset($offset) { // TODO: Implement offsetUnset() method. diff --git a/src/Mixed/Mixed.php b/src/Mixed/MixedApi.php similarity index 92% rename from src/Mixed/Mixed.php rename to src/Mixed/MixedApi.php index 5557ba9..0bf95ac 100644 --- a/src/Mixed/Mixed.php +++ b/src/Mixed/MixedApi.php @@ -13,13 +13,13 @@ use GuzzleHttp\Exception\BadResponseException; use Imactool\DahuaCloud\Core\BaseService; - class Mixed extends BaseService + class MixedApi extends BaseService { /** * AI -> 根据任务id获取相关信息 * @param $taskId * - * @return mixed + * @return mixed * @author cc */ public function getAinfoByTaskId($taskId) @@ -32,7 +32,7 @@ public function getAinfoByTaskId($taskId) * 微信管理 -> 根据微信授权码code获取openid * @param $code * - * @return mixed + * @return mixed * @author cc */ public function getWxOpenidByCode($code) @@ -45,7 +45,7 @@ public function getWxOpenidByCode($code) * 微信管理 -> 获取微信签名 * @param $code * - * @return mixed + * @return mixed * @author cc */ public function getWxSignature($url) @@ -58,7 +58,7 @@ public function getWxSignature($url) * 流媒体相关 -> 获取乐橙userToken * @param $code * - * @return mixed + * @return mixed * @author cc */ public function getLeChengUserToken() @@ -70,7 +70,7 @@ public function getLeChengUserToken() * 单点登录 -> 免密登陆接口 * @param $code * - * @return mixed + * @return mixed * @author cc */ public function userToken($telephone) @@ -84,7 +84,7 @@ public function userToken($telephone) * AI热度分析 -> 区域客流热度数据 * @param $code * - * @return mixed + * @return mixed * @author cc */ public function aiAreaFlow(array $params) @@ -96,7 +96,7 @@ public function aiAreaFlow(array $params) * AI热度分析 -> AI热度图绘制数据接口 * @param $code * - * @return mixed + * @return mixed * @author cc */ public function aiHeatMap(array $params) @@ -108,7 +108,7 @@ public function aiHeatMap(array $params) * 视频追溯 -> 上传视频追溯单据 * @param array $params * - * @return mixed + * @return mixed * @author cc */ public function videoUploadTicket(array $params) @@ -120,7 +120,7 @@ public function videoUploadTicket(array $params) * 物流追溯 -> 上传物流单据 * @param array $params * - * @return mixed + * @return mixed * @author cc */ public function wlOrderUpload(array $params) @@ -132,7 +132,7 @@ public function wlOrderUpload(array $params) * 收银监督子系统 -> 上传小票数据 * @param array $params * - * @return mixed + * @return mixed * @author cc */ public function postTicketUpload(array $params) @@ -144,7 +144,7 @@ public function postTicketUpload(array $params) * 收银监督子系统 -> 删除pos机和通道关联关系 * @param array $params * - * @return mixed + * @return mixed * @author cc */ public function deletePosDevChannelRel(array $params) @@ -156,7 +156,7 @@ public function deletePosDevChannelRel(array $params) * 收银监督子系统 -> 添加pos机和通道绑定关系 * @param array $params * - * @return mixed + * @return mixed * @author cc */ public function addPosDevChannelRel(array $params) @@ -168,7 +168,7 @@ public function addPosDevChannelRel(array $params) * 巡检考评子系统 -> 上传事件考评图片 * @param string $pictureBase64 图片base64编码 * - * @return mixed + * @return mixed * @author cc */ public function captureEvaluation(string $pictureBase64) @@ -181,7 +181,7 @@ public function captureEvaluation(string $pictureBase64) * 巡检考评子系统 -> 处理事件考评 * @param string $messageId * - * @return mixed + * @return mixed * @author cc */ public function evaluationMessage(string $messageId) @@ -193,7 +193,7 @@ public function evaluationMessage(string $messageId) * 巡检考评子系统 -> 店铺员工复议 * @param array $params * - * @return mixed + * @return mixed * @author cc */ public function onlineQuestion(array $params) @@ -205,7 +205,7 @@ public function onlineQuestion(array $params) * 巡检考评子系统 -> 查询事件考评详情 * @param string $messageId * - * @return mixed + * @return mixed * @author cc */ public function evaluationMessageInfo(string $messageId) @@ -216,7 +216,7 @@ public function evaluationMessageInfo(string $messageId) /** * 基础功能 -> 文件上传 - * @return mixed + * @return mixed * @author cc */ public function getStoreMap() @@ -230,7 +230,7 @@ public function getStoreMap() * 刷新OSS图片有效期 * @param string $photoUrl * - * @return mixed|string + * @return mixed|string * @author cc */ public function refreshOssImg(string $photoUrl) @@ -247,7 +247,7 @@ public function refreshOssImg(string $photoUrl) * 查询通道是否开通云存储 * @param $devChnIds * - * @return mixed + * @return mixed * @author cc */ public function getStorageStrategy($devChnIds) @@ -259,7 +259,7 @@ public function getStorageStrategy($devChnIds) * 可视对讲 - 纯云app注册sip * @param $phone * - * @return mixed + * @return mixed * @author cc */ public function registerChunYunSip($phone) diff --git a/src/Mixed/MixedProvider.php b/src/Mixed/MixedProvider.php index c316be8..f7f6a48 100644 --- a/src/Mixed/MixedProvider.php +++ b/src/Mixed/MixedProvider.php @@ -18,7 +18,7 @@ class MixedProvider implements Provider public function serviceProvider (Container $container) { $container['Mixed'] = function ($container) { - return new Mixed($container); + return new MixedApi($container); }; } } \ No newline at end of file diff --git a/src/Support/Config.php b/src/Support/Config.php index fbc5207..fb9f61b 100644 --- a/src/Support/Config.php +++ b/src/Support/Config.php @@ -42,16 +42,19 @@ public function get($key, $default = null) return $config; } + #[\ReturnTypeWillChange] public function offsetExists($offset) { return array_key_exists($offset, $this->config); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (isset($this->config[$offset])) { @@ -59,6 +62,7 @@ public function offsetSet($offset, $value) } } + #[\ReturnTypeWillChange] public function offsetUnset($offset) { if (isset($this->config[$offset])) {