pull/5/head
wanghousheng 6 months ago
parent ea54f95df5
commit 97d19c6539
  1. 4
      app/admin/controller/Wxwholesaler.php
  2. 10
      app/common/library/wxserver/Wholesaler.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('操作失败');
}

@ -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];
}
/**

Loading…
Cancel
Save