|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace www\controllers;
|
|
|
|
|
|
+use biz\merchant\classes\MerchantClass;
|
|
|
use common\services\xhMerchantExtendService;
|
|
|
use common\services\xhTMessageService;
|
|
|
use Yii;
|
|
|
@@ -68,7 +69,7 @@ class WxOpenController extends PublicController
|
|
|
}
|
|
|
util::fail();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//创建平台使用的公众号
|
|
|
public function actionCallback()
|
|
|
{
|
|
|
@@ -76,6 +77,7 @@ class WxOpenController extends PublicController
|
|
|
if (isset($get['auth_code']) == false) {
|
|
|
util::stop('公众号授权回调未成功');
|
|
|
}
|
|
|
+ $id = isset($get['id']) ? $get['id'] : 0;
|
|
|
$code = $get['auth_code'];
|
|
|
//使用授权码换取公众号的接口调用凭据和授权信息
|
|
|
$authorize = wxUtil::getAuthorizer($code);
|
|
|
@@ -113,7 +115,10 @@ class WxOpenController extends PublicController
|
|
|
if (!empty($merchant)) {
|
|
|
util::stop('此公众号或小程序已经授权过了');
|
|
|
}
|
|
|
-
|
|
|
+ $one = MerchantClass::getOne();
|
|
|
+ if (!empty($one) && empty($id)) {
|
|
|
+ util::stop('平台公众号已经创建过了,不能重复创建');
|
|
|
+ }
|
|
|
//小程序
|
|
|
if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
|
|
|
$merchant = xhMerchantService::getByCondition(['miniAppId' => $authorizeAppId]);
|
|
|
@@ -126,7 +131,7 @@ class WxOpenController extends PublicController
|
|
|
Yii::info('小程序信息更新成功:' . json_encode($authorize_info));
|
|
|
util::stop("小程序信息更新成功");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$merchant = xhMerchantService::getByAppId($authorizeAppId);
|
|
|
Yii::info('appId:' . $authorizeAppId);
|
|
|
$set = xhSetMealService::getRandOne();
|
|
|
@@ -182,12 +187,12 @@ class WxOpenController extends PublicController
|
|
|
xhWxOpenService::updateById($wxOpenId, ['merchantId' => $merchantId]);
|
|
|
$platform = 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$data = ['merchantId' => $merchantId, 'platform' => $platform];
|
|
|
$producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
|
|
|
$msg = serialize($data);
|
|
|
$producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
$cData = [];
|
|
|
@@ -203,7 +208,7 @@ class WxOpenController extends PublicController
|
|
|
echo 'ok';
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function actionResult()
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|