From 97d19c6539fa922cf457cc45118b44529cf92530 Mon Sep 17 00:00:00 2001 From: wanghousheng Date: Tue, 23 Jul 2024 17:52:02 +0800 Subject: [PATCH] 1 --- app/admin/controller/Wxwholesaler.php | 4 +++- app/common/library/wxserver/Wholesaler.php | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/admin/controller/Wxwholesaler.php b/app/admin/controller/Wxwholesaler.php index 2058fa0a..d59a4ba4 100644 --- a/app/admin/controller/Wxwholesaler.php +++ b/app/admin/controller/Wxwholesaler.php @@ -212,9 +212,11 @@ class Wxwholesaler extends Controller $appid = $this->request->get('appid'); if ($appid) { $obj = new Wholesaler(); - if ($obj->getVersioninfo($appid)) { + $res = $obj->getVersioninfo($appid); + if ($res['code']) { return $this->renderSuccess('success'); } + return $this->renderError($res['msg']); } return $this->renderError('操作失败'); } diff --git a/app/common/library/wxserver/Wholesaler.php b/app/common/library/wxserver/Wholesaler.php index 82325cc6..f3ca3d0b 100644 --- a/app/common/library/wxserver/Wholesaler.php +++ b/app/common/library/wxserver/Wholesaler.php @@ -277,17 +277,20 @@ class Wholesaler /** * @notes:获取版本信息 * @param $appid - * @return bool + * @return array * @author: wanghousheng */ - public function getVersioninfo($appid): bool + public function getVersioninfo($appid): array { + $msg = '操作失败'; + $code = 0; $access_token = $this->authorizerAccessToken($appid); $url = 'https://api.weixin.qq.com/wxa/getversioninfo?access_token=' . $access_token; $result = $this->curlPost($url, '{}'); $result = json_decode($result, true); if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') { $up = []; + $code = 1; if (!empty($result['exp_info'])) { $up['exp_info'] = json_encode($result['exp_info']); } @@ -298,9 +301,8 @@ class Wholesaler $model = new WxwholesalerAccount(); $model->update($up, ['appid' => $appid]); } - return true; } - return false; + return ['code' => $code, 'msg' => !empty($result['errmsg']) ? $result['errmsg'] : $msg]; } /**