|
|
@@ -27,11 +27,11 @@ class WxOpenController extends BaseController
|
|
|
|
|
|
public function actionBindOpen()
|
|
|
{
|
|
|
+ $merchantId = Yii::$app->request->get('merchantId', 0);
|
|
|
$isOpen = Yii::$app->request->get('isOpen', 0);
|
|
|
if ($isOpen == 1) {
|
|
|
$merchant = WxOpenService::getWxInfo();
|
|
|
} else {
|
|
|
- $merchantId = Yii::$app->request->get('merchantId', 0);
|
|
|
$merchant = MerchantService::getMerchantById($merchantId);
|
|
|
if (empty($merchant)) {
|
|
|
util::fail('没有找到商家');
|
|
|
@@ -52,15 +52,29 @@ class WxOpenController extends BaseController
|
|
|
print_r($return);
|
|
|
if ($return['errcode'] == 0) {
|
|
|
$openAppId = $return['open_appid'];
|
|
|
- MerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
|
|
|
- MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
|
|
|
+
|
|
|
+ if ($isOpen == 1) {
|
|
|
+ WxOpenService::updateOpen(['appIdCreated' => $openAppId, 'openAppBind' => 1]);
|
|
|
+ } else {
|
|
|
+ MerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
|
|
|
+ MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//将小程序绑定到平台
|
|
|
if ($id == 2) {
|
|
|
$openAppId = $merchant['openAppId'];
|
|
|
$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
|
|
|
- MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
|
|
|
+
|
|
|
+ if ($isOpen == 1) {
|
|
|
+ WxOpenService::updateOpen(['appIdCreated' => $openAppId, 'openAppBind' => 3]);
|
|
|
+ } else {
|
|
|
+ MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
print_r($r);
|
|
|
}
|
|
|
//查询公众号 小程序的绑定情况
|