|
@@ -30,6 +30,7 @@ class WxOpenController extends PublicController
|
|
|
public function actionBeginAuth()
|
|
public function actionBeginAuth()
|
|
|
{
|
|
{
|
|
|
$id = 1;
|
|
$id = 1;
|
|
|
|
|
+ $merchantId = Yii::$app->request->get('id', 0);
|
|
|
$open = xhWxOpenService::getById($id);
|
|
$open = xhWxOpenService::getById($id);
|
|
|
$pre = wxUtil::getPreAuthCode($open);
|
|
$pre = wxUtil::getPreAuthCode($open);
|
|
|
$appId = $open['appId'];
|
|
$appId = $open['appId'];
|
|
@@ -37,7 +38,7 @@ class WxOpenController extends PublicController
|
|
|
$oData['preAuthCodeTime'] = date("Y-m-d H:i:s");
|
|
$oData['preAuthCodeTime'] = date("Y-m-d H:i:s");
|
|
|
//设置预授码过期,让下个用户可以获取新的预授码
|
|
//设置预授码过期,让下个用户可以获取新的预授码
|
|
|
xhWxOpenService::updateById($id, $oData);
|
|
xhWxOpenService::updateById($id, $oData);
|
|
|
- $url = Yii::$app->params['wHost'] . '/wx-open/callback';
|
|
|
|
|
|
|
+ $url = Yii::$app->params['wHost'] . '/wx-open-callback/' . $merchantId;
|
|
|
echo "<a href='https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$appId}&pre_auth_code={$pre}&redirect_uri={$url}'>授权</a>";
|
|
echo "<a href='https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$appId}&pre_auth_code={$pre}&redirect_uri={$url}'>授权</a>";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -123,7 +124,7 @@ class WxOpenController extends PublicController
|
|
|
Yii::info('小程序信息更新成功:' . json_encode($authorize_info));
|
|
Yii::info('小程序信息更新成功:' . json_encode($authorize_info));
|
|
|
util::stop("小程序信息更新成功");
|
|
util::stop("小程序信息更新成功");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$merchant = xhMerchantService::getByAppId($authorizeAppId);
|
|
$merchant = xhMerchantService::getByAppId($authorizeAppId);
|
|
|
Yii::info('appId:' . $authorizeAppId);
|
|
Yii::info('appId:' . $authorizeAppId);
|
|
|
$set = xhSetMealService::getRandOne();
|
|
$set = xhSetMealService::getRandOne();
|
|
@@ -171,20 +172,20 @@ class WxOpenController extends PublicController
|
|
|
$appData['agentLevel'] = 1;//默认设置为代理商
|
|
$appData['agentLevel'] = 1;//默认设置为代理商
|
|
|
$merchant = xhMerchantService::applyCreateMerchant($appData);
|
|
$merchant = xhMerchantService::applyCreateMerchant($appData);
|
|
|
$merchantId = $merchant['id'];
|
|
$merchantId = $merchant['id'];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$wxOpenId = configDict::getConfig('openId');
|
|
$wxOpenId = configDict::getConfig('openId');
|
|
|
$open = xhWxOpenService::getById($wxOpenId);
|
|
$open = xhWxOpenService::getById($wxOpenId);
|
|
|
- if(isset($open['merchantId']) && !empty($open['merchantId'])){
|
|
|
|
|
|
|
+ if (isset($open['merchantId']) && !empty($open['merchantId'])) {
|
|
|
xhWxOpenService::updateById($wxOpenId, ['merchantId' => $merchantId]);
|
|
xhWxOpenService::updateById($wxOpenId, ['merchantId' => $merchantId]);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$data = ['merchantId' => $merchantId, 'platform' => 1];
|
|
$data = ['merchantId' => $merchantId, 'platform' => 1];
|
|
|
$producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
|
|
$producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
|
|
|
$msg = serialize($data);
|
|
$msg = serialize($data);
|
|
|
$producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
|
|
$producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$cData = [];
|
|
$cData = [];
|
|
|
$cData['wxAccessToken'] = $authorize_access_token;
|
|
$cData['wxAccessToken'] = $authorize_access_token;
|
|
|
$cData['wxAccessTokenTime'] = $accessTokenTime;
|
|
$cData['wxAccessTokenTime'] = $accessTokenTime;
|
|
@@ -193,7 +194,7 @@ class WxOpenController extends PublicController
|
|
|
$cData['status'] = 1;
|
|
$cData['status'] = 1;
|
|
|
$merchantId = $merchant['id'];
|
|
$merchantId = $merchant['id'];
|
|
|
xhMerchantService::updateById($merchantId, $cData);
|
|
xhMerchantService::updateById($merchantId, $cData);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
echo 'ok';
|
|
echo 'ok';
|
|
|
|
|
|