|
|
@@ -29,7 +29,7 @@ class WxOpenController extends PublicController
|
|
|
//开放平台开始授权 shish 2020.1.16
|
|
|
public function actionBeginAuth()
|
|
|
{
|
|
|
- $sjId = Yii::$app->request->get('id', 0);
|
|
|
+ $sjId = Yii::$app->request->get('id', 'hd');
|
|
|
$open = WxOpenService::getOpen();
|
|
|
//1只显示公众号 2只显示小程序 3显示公众号和小程序
|
|
|
$authType = Yii::$app->request->get('authType', 3);
|
|
|
@@ -50,7 +50,7 @@ class WxOpenController extends PublicController
|
|
|
if (isset($get['auth_code']) == false) {
|
|
|
util::stop('公众号授权回调未成功');
|
|
|
}
|
|
|
- $id = $get['id'] ?? 0;
|
|
|
+ $id = $get['id'] ?? 'hd';
|
|
|
|
|
|
$code = $get['auth_code'];
|
|
|
//使用授权码换取公众号的接口调用凭据和授权信息
|
|
|
@@ -88,10 +88,10 @@ class WxOpenController extends PublicController
|
|
|
$qrCodeUrl = $authorize_info['qrcode_url'];
|
|
|
$accessTokenTime = date("Y-m-d H:i:s", (time() + $expires_in - 100));//安全起见,将过期时间设置得比微信里还短100秒
|
|
|
|
|
|
- if ($id == 0) {
|
|
|
+ if ($id == 'ghs') {
|
|
|
//这是供货商
|
|
|
$sjWxInfo = WxOpenClass::getGhsWxInfo();
|
|
|
- } elseif ($id == -1) {
|
|
|
+ } elseif ($id == 'hd') {
|
|
|
//这是零售商
|
|
|
$sjWxInfo = WxOpenClass::getWxInfo();
|
|
|
} else {
|
|
|
@@ -119,14 +119,14 @@ class WxOpenController extends PublicController
|
|
|
'miniRefreshToken' => $authorize_refresh_token,
|
|
|
];
|
|
|
|
|
|
- if ($id <= 0) {
|
|
|
+ if (is_numeric($id) == false) {
|
|
|
$wxMiniBaseId = 0;
|
|
|
$msg = '未知状态';
|
|
|
- if ($id == 0) {
|
|
|
+ if ($id == 'ghs') {
|
|
|
//供货商
|
|
|
$wxMiniBaseId = $open['wxGhsMiniBaseId'] ?? 0;
|
|
|
$msg = '供货商小程序绑定成功';
|
|
|
- } elseif ($id == -1) {
|
|
|
+ } elseif ($id == 'hd') {
|
|
|
//零售店
|
|
|
$wxMiniBaseId = $open['wxMiniBaseId'] ?? 0;
|
|
|
$msg = '零售店小程序绑定成功';
|
|
|
@@ -152,7 +152,7 @@ class WxOpenController extends PublicController
|
|
|
|
|
|
if (isset($sjWxInfo['wxAppId']) && !empty($sjWxInfo['wxAppId'])) {
|
|
|
if ($sjWxInfo['wxAppId'] != $authorizeAppId) {
|
|
|
- util::stop('授权的公众号与商家已绑定的公众号不一致');
|
|
|
+ util::stop("授权的公众号与商家已绑定的公众号不一致,授权公众号appId:{$authorizeAppId} 商家公众号:{$sjWxInfo['wxAppId']}");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -169,15 +169,15 @@ class WxOpenController extends PublicController
|
|
|
$wxData['wxRefreshToken'] = $authorize_refresh_token;
|
|
|
|
|
|
|
|
|
- if ($id <= 0) {
|
|
|
+ if (is_numeric($id) == false) {
|
|
|
|
|
|
$wxBaseId = 0;
|
|
|
$msg = '未知状态';
|
|
|
- if ($id == 0) {
|
|
|
+ if ($id == 'ghs') {
|
|
|
//供货商公众号
|
|
|
$wxBaseId = $open['wxGhsBaseId'] ?? 0;
|
|
|
$msg = '供货商公众号绑定成功';
|
|
|
- } elseif ($id == -1) {
|
|
|
+ } elseif ($id == 'hd') {
|
|
|
//零售商公众号
|
|
|
$wxBaseId = $open['wxBaseId'] ?? 0;
|
|
|
$msg = '零售商公众号绑定成功';
|