shish 6 лет назад
Родитель
Сommit
0465bc3919

+ 153 - 154
app/saas/controllers/WxOpenController.php

@@ -21,152 +21,152 @@ use common\services\xhWxOpenService;
 class WxOpenController extends PublicController
 {
 
-	public $withoutLogin = ['bind-open'];
-	
-	public function actionBindOpen()
-	{
-		$merchantId = Yii::$app->request->get('merchantId', 0);
-		$merchant = MerchantService::getMerchantById($merchantId);
-		if (empty($merchant)) {
-			util::fail('没有找到商家');
-		}
-		$wxAppId = $merchant['wxAppId'];
-		$miniAppId = $merchant['miniAppId'];
-		$open_appid = $merchant['openAppId'];
-		
-		echo "<pre>";
-		
-		$id = Yii::$app->request->get('id', 0);
-		//创建平台,并将公众号绑定到平台
-		if ($id == 1) {
-			wxUtil::createOpenAccount($wxAppId, $merchant);
-			$return = wxUtil::getOpenAccount($wxAppId, $merchant);
-			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 ($id == 2) {
-			$openAppId = $merchant['openAppId'];
-			$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
-			MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
-			print_r($r);
-		}
-		//查询公众号 小程序的绑定情况
-		if ($id == 3) {
-			$return = wxUtil::getOpenAccount($wxAppId, $merchant);
-			print_r($return);
-			$return = wxUtil::getOpenAccount($miniAppId, $merchant, true);
-			print_r($return);
-		}
-		
-		//设置小程序服务器域名
-		if ($id == 4) {
-			wxUtil::setDomain($merchant);
-			wxUtil::setWebViewDomain($merchant);
-		}
-		
-		//为授权的小程序帐号上传小程序代码
-		if ($id == 5) {
-			$tId = $_GET['tId'];
-			wxUtil::miniCommit($merchant, $tId);
-		}
-		
-		//获取小程序体验码
-		if ($id == 6) {
-			wxUtil::getExperienceQrCode($merchant);
-		}
-		
-		//获取授权小程序帐号已设置的类目
-		if ($id == 7) {
-			wxUtil::getMiniCategory($merchant);
-		}
-		
-		//获取小程序的第三方提交代码的页面配置
-		if ($id == 8) {
-			wxUtil::getMiniPage($merchant);
-		}
-		
-		//将第三方提交的代码包提交审核
-		if ($id == 9) {
-			wxUtil::miniSubmitAudit($merchant);
-		}
-		
-		//查询最新一次提交的审核状态
-		if ($id == 10) {
-			wxUtil::miniGetLatestAuditStatus($merchant);
-		}
-		
-		//发布已通过审核的小程序
-		if ($id == 11) {
-			$r = MiniProgramService::release($merchant);
-			print_r($r);
-		}
-		
-		//撤回审核
-		if ($id == 12) {
-			wxUtil::rollbackCheck($merchant);
-		}
-		//生成 申请会员页 的小程序码
-		if ($id == 13) {
-			wxUtil::generateMemberCode($merchant);
-		}
-		//解绑小程序和公众号绑定的平台
-		if ($id == 14) {
-			wxUtil::unbindAccount($merchant);
-			wxUtil::unbindMiniProgram($merchant);
-		}
-		Yii::$app->end();
-		
-		$r = wxUtil::bindOpenAccount($miniAppId, $open_appid, $merchant, true);
-		print_r($r);
-		echo $miniAppId . ' ' . $open_appid . ' ';
-		
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant);
-		print_r($return);
-		die;
-		
-		$return = wxUtil::createOpenAccount($wxAppId, $merchant);
-		print_r($return);
-		die;
-		
-		$r = wxUtil::bindOpenAccount($miniAppId, $open_appid, $merchant);
-		print_r($r);
-		echo $miniAppId . ' ' . $open_appid . ' ';
-		
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant);
-		print_r($return);
-		$return = wxUtil::getOpenAccount($miniAppId, $merchant);
-		print_r($return);
-		die;
-		
-		if ($return['errcode'] == 0) {
-			$open_appid = isset($return['open_appid']) ? $return['open_appid'] : '';
-		} else {
-			$return = wxUtil::createOpenAccount($wxAppId, $merchant);
-			if ($return['errcode'] == 0) {
-				$open_appid = isset($return['open_appid']) ? $return['open_appid'] : '';
-			}
-		}
-		echo "<br />open_appid:" . $open_appid . "<br />";
-		if (!empty($open_appid)) {
-			xhMerchantService::updateById($merchantId, ['openAppId' => $open_appid]);
-			MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $open_appid, 'openAppBind' => 3, 'miniAuth' => 1]);
-			$r = wxUtil::bindOpenAccount($miniAppId, $open_appid, $merchant);
-			echo "绑定小程序结果:<br />";
-			print_r($r);
-		}
-		echo "<br /><br />";
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant);
-		echo "微信appId:{$wxAppId}<br />";
-		print_r($return);
-		$return = wxUtil::getOpenAccount($miniAppId, $merchant);
-		echo "<br />小程序appId:{$miniAppId}<br />";
-		print_r($return);
-	}
+    public $withoutLogin = ['bind-open'];
+
+    public function actionBindOpen()
+    {
+        $merchantId = Yii::$app->request->get('merchantId', 0);
+        $merchant = MerchantService::getMerchantById($merchantId);
+        if (empty($merchant)) {
+            util::fail('没有找到商家');
+        }
+        $wxAppId = $merchant['wxAppId'];
+        $miniAppId = $merchant['miniAppId'];
+        $open_appid = $merchant['openAppId'];
+
+        echo "<pre>";
+
+        $id = Yii::$app->request->get('id', 0);
+        //创建平台,并将公众号绑定到平台
+        if ($id == 1) {
+            wxUtil::createOpenAccount($wxAppId, $merchant);
+            $return = wxUtil::getOpenAccount($wxAppId, $merchant);
+            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 ($id == 2) {
+            $openAppId = $merchant['openAppId'];
+            $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true);
+            MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
+            print_r($r);
+        }
+        //查询公众号 小程序的绑定情况
+        if ($id == 3) {
+            $return = wxUtil::getOpenAccount($wxAppId, $merchant);
+            print_r($return);
+            $return = wxUtil::getOpenAccount($miniAppId, $merchant, true);
+            print_r($return);
+        }
+
+        //设置小程序服务器域名
+        if ($id == 4) {
+            wxUtil::setDomain($merchant);
+            wxUtil::setWebViewDomain($merchant);
+        }
+
+        //为授权的小程序帐号上传小程序代码
+        if ($id == 5) {
+            $tId = $_GET['tId'];
+            wxUtil::miniCommit($merchant, $tId);
+        }
+
+        //获取小程序体验码
+        if ($id == 6) {
+            wxUtil::getExperienceQrCode($merchant);
+        }
+
+        //获取授权小程序帐号已设置的类目
+        if ($id == 7) {
+            wxUtil::getMiniCategory($merchant);
+        }
+
+        //获取小程序的第三方提交代码的页面配置
+        if ($id == 8) {
+            wxUtil::getMiniPage($merchant);
+        }
+
+        //将第三方提交的代码包提交审核
+        if ($id == 9) {
+            wxUtil::miniSubmitAudit($merchant);
+        }
+
+        //查询最新一次提交的审核状态
+        if ($id == 10) {
+            wxUtil::miniGetLatestAuditStatus($merchant);
+        }
+
+        //发布已通过审核的小程序
+        if ($id == 11) {
+            $r = MiniProgramService::release($merchant);
+            print_r($r);
+        }
+
+        //撤回审核
+        if ($id == 12) {
+            wxUtil::rollbackCheck($merchant);
+        }
+        //生成 申请会员页 的小程序码
+        if ($id == 13) {
+            wxUtil::generateMemberCode($merchant);
+        }
+        //解绑小程序和公众号绑定的平台
+        if ($id == 14) {
+            wxUtil::unbindAccount($merchant);
+            wxUtil::unbindMiniProgram($merchant);
+        }
+        Yii::$app->end();
+
+        $r = wxUtil::bindOpenAccount($miniAppId, $open_appid, $merchant, true);
+        print_r($r);
+        echo $miniAppId . ' ' . $open_appid . ' ';
+
+        $return = wxUtil::getOpenAccount($wxAppId, $merchant);
+        print_r($return);
+        die;
+
+        $return = wxUtil::createOpenAccount($wxAppId, $merchant);
+        print_r($return);
+        die;
+
+        $r = wxUtil::bindOpenAccount($miniAppId, $open_appid, $merchant);
+        print_r($r);
+        echo $miniAppId . ' ' . $open_appid . ' ';
+
+        $return = wxUtil::getOpenAccount($wxAppId, $merchant);
+        print_r($return);
+        $return = wxUtil::getOpenAccount($miniAppId, $merchant);
+        print_r($return);
+        die;
+
+        if ($return['errcode'] == 0) {
+            $open_appid = isset($return['open_appid']) ? $return['open_appid'] : '';
+        } else {
+            $return = wxUtil::createOpenAccount($wxAppId, $merchant);
+            if ($return['errcode'] == 0) {
+                $open_appid = isset($return['open_appid']) ? $return['open_appid'] : '';
+            }
+        }
+        echo "<br />open_appid:" . $open_appid . "<br />";
+        if (!empty($open_appid)) {
+            xhMerchantService::updateById($merchantId, ['openAppId' => $open_appid]);
+            MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $open_appid, 'openAppBind' => 3, 'miniAuth' => 1]);
+            $r = wxUtil::bindOpenAccount($miniAppId, $open_appid, $merchant);
+            echo "绑定小程序结果:<br />";
+            print_r($r);
+        }
+        echo "<br /><br />";
+        $return = wxUtil::getOpenAccount($wxAppId, $merchant);
+        echo "微信appId:{$wxAppId}<br />";
+        print_r($return);
+        $return = wxUtil::getOpenAccount($miniAppId, $merchant);
+        echo "<br />小程序appId:{$miniAppId}<br />";
+        print_r($return);
+    }
 
     //开放平台开始授权 shish 2020.1.16
     public function actionBeginAuth()
@@ -275,10 +275,10 @@ class WxOpenController extends PublicController
                 if ($extend['miniAppId'] != $authorizeAppId) {
                     util::stop('授权的小程序与商家已绑定的小程序不一致');
                 }
-            }else{
+            } else {
                 util::stop('数据库请先填写小程序 miniAppId miniAppSecret');
             }
-        }else{
+        } else {
             if (isset($extend['wxAppId']) && !empty($extend['wxAppId'])) {
                 if ($extend['wxAppId'] != $authorizeAppId) {
                     util::stop('授权的公众号与商家已绑定的公众号不一致');
@@ -288,7 +288,7 @@ class WxOpenController extends PublicController
 
         //小程序
         if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
-            xhMerchantExtendService::updateByMerchantId($id, ['miniAppId' => $authorizeAppId,'miniAuth'=>1, 'miniAccessToken' => $authorize_access_token, 'miniAccessTokenTime' => $accessTokenTime, 'miniRefreshToken' => $authorize_refresh_token]);
+            xhMerchantExtendService::updateByMerchantId($id, ['miniAppId' => $authorizeAppId, 'miniAuth' => 1, 'miniAccessToken' => $authorize_access_token, 'miniAccessTokenTime' => $accessTokenTime, 'miniRefreshToken' => $authorize_refresh_token]);
             MerchantService::updateById($id, ['miniAppId' => $authorizeAppId]);
             Yii::info('小程序信息更新成功:' . json_encode($authorize_info));
             util::stop("小程序信息更新成功");
@@ -298,16 +298,16 @@ class WxOpenController extends PublicController
         $appData['wxUserName'] = $user_name;
         $appData['wxAliasName'] = $alias;
         //公众号logo
-        $upData['logo'] = WxBaseClass::saveLogo($head_img,$id);
+        $upData['logo'] = WxBaseClass::saveLogo($head_img, $id);
         //公众号二维码
-        $upData['wxQrCodeUrl'] = WxBaseClass::saveQrCode($qrCodeUrl,$id);
+        $upData['wxQrCodeUrl'] = WxBaseClass::saveQrCode($qrCodeUrl, $id);
         $upData['wxAppId'] = $authorizeAppId;
         $upData['wxAccessToken'] = $authorize_access_token;
         $upData['wxAccessTokenTime'] = $accessTokenTime;
         $upData['wxRefreshToken'] = $authorize_refresh_token;
         $upData['status'] = 1;//审核通过
         xhMerchantService::updateById($id, $upData);
-        MerchantExtendClass::updateByCondition(['merchantId' => $id], ['wxAppId' => $authorizeAppId,'wxAuth'=>1]);
+        MerchantExtendClass::updateByCondition(['merchantId' => $id], ['wxAppId' => $authorizeAppId, 'wxAuth' => 1]);
 
         //还没有完成初始化先进行初始化
         if (isset($extend['init']) && $extend['init'] == 0) {
@@ -393,8 +393,7 @@ class WxOpenController extends PublicController
         $msg = '';//解密后的消息
         $errCode = $pc->decryptMsg($msg_signature, $timestamp, $nonce, $from_xml, $msg);
         if ($errCode != 0) {
-            Yii::warning("解密未成功,错误代码:" . $errCode);
-            Yii::$app->end();
+            util::stop("解密未成功,错误代码:" . $errCode);
         }
         $postObj = simplexml_load_string($msg, 'SimpleXMLElement', LIBXML_NOCDATA);
         $infoType = $postObj->InfoType;

+ 0 - 1
common/config/bootstrap.php

@@ -4,5 +4,4 @@ Yii::setAlias('@mall', dirname(dirname(__DIR__)) . '/app/mall');
 Yii::setAlias('@shop', dirname(dirname(__DIR__)) . '/app/shop');
 Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
 Yii::setAlias('@saas', dirname(dirname(__DIR__)) . '/app/saas');
-Yii::setAlias('@www', dirname(dirname(__DIR__)) . '/app/www');
 Yii::setAlias('@biz', dirname(dirname(__DIR__)) . '/biz');

+ 2 - 2
console/controllers/UpgradeController.php

@@ -38,9 +38,9 @@ class UpgradeController extends Controller
 	public function actionInit()
 	{
 		if (getenv('YII_ENV') == 'dev') {
-			util::stop('开发环境不允许初始化');
+			//util::stop('开发环境不允许初始化');
 		}
-		
+
 		//更新积分 shish 2019.11.22
 		$sql = "ALTER TABLE xhUserAsset ADD growth INT NOT NULL DEFAULT 0 COMMENT '成长值' AFTER `point`;";
 		$sql .= "UPDATE `xhUserAsset` SET `growth`=`integral`;";