shish vor 6 Jahren
Ursprung
Commit
0e5dfec31a

+ 10 - 4
app/saas/controllers/WxOpenController.php

@@ -27,11 +27,17 @@ class WxOpenController extends BaseController
 
     public function actionBindOpen()
     {
-        $merchantId = Yii::$app->request->get('merchantId', 0);
-        $merchant = MerchantService::getMerchantById($merchantId);
-        if (empty($merchant)) {
-            util::fail('没有找到商家');
+        $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('没有找到商家');
+            }
         }
+
         $wxAppId = $merchant['wxAppId'];
         $miniAppId = $merchant['miniAppId'];
         $open_appid = $merchant['openAppId'];

+ 67 - 55
biz/weixin/classes/WxOpenClass.php

@@ -9,59 +9,71 @@ use biz\base\classes\BaseClass;
 
 class WxOpenClass extends BaseClass
 {
-	
-	public static $baseFile = '\biz\weixin\models\WxOpen';
-	
-	//平台管理员的手机号
-	const ADMIN_MOBILE = 15280215347;
-	const PLATFORM_ACCOUNT = 12359;
-	const ID = 1;
-	
-	//取平台的帐号
-	public static function getPlatformAccount()
-	{
-		return self::PLATFORM_ACCOUNT;
-	}
-	
-	//获取平台基础信息 shish 2020.2.11
-	public static function getOpen()
-	{
-		return self::getById(self::ID);
-	}
-	
-	//获取平台管理员的手机号 shish 2020.3.4
-	public static function getAdminMobile()
-	{
-		return self::ADMIN_MOBILE;
-	}
-	
-	//获取平台微信信息
-	public static function getOpenInfo()
-	{
-		$open = self::getById(self::ID);
-		if (isset($open['merchantId']) && !empty($open['merchantId'])) {
-			$merchantId = $open['merchantId'];
-			return MerchantClass::getMerchantById($merchantId);
-		}
-		util::fail('没有找到平台信息');
-	}
-	
-	//更新开放平台信息 shish 2020.4.13
-	public static function updateOpen($data)
-	{
-		self::updateById(self::ID, $data);
-	}
-	
-	//平台小程序信息 shish 2020.4.13
-	public static function getWxMiniBase()
-	{
-		$open = self::getOpen();
-		$wx_mini_base_id = isset($open['wx_mini_base_id']) ? $open['wx_mini_base_id'] : 0;
-		$base = WxMiniBaseClass::getById($wx_mini_base_id);
-		if (empty($base)) {
-			util::fail('没有找到平台小程序信息');
-		}
-		return $base;
-	}
-	
+
+    public static $baseFile = '\biz\weixin\models\WxOpen';
+
+    //平台管理员的手机号
+    const ADMIN_MOBILE = 15280215347;
+    const PLATFORM_ACCOUNT = 12359;
+    const ID = 1;
+
+    //取平台的帐号
+    public static function getPlatformAccount()
+    {
+        return self::PLATFORM_ACCOUNT;
+    }
+
+    //获取平台基础信息 shish 2020.2.11
+    public static function getOpen()
+    {
+        return self::getById(self::ID);
+    }
+
+    //获取平台管理员的手机号 shish 2020.3.4
+    public static function getAdminMobile()
+    {
+        return self::ADMIN_MOBILE;
+    }
+
+    //获取平台微信信息
+    public static function getOpenInfo()
+    {
+        $open = self::getById(self::ID);
+        if (isset($open['merchantId']) && !empty($open['merchantId'])) {
+            $merchantId = $open['merchantId'];
+            return MerchantClass::getMerchantById($merchantId);
+        }
+        util::fail('没有找到平台信息');
+    }
+
+    //更新开放平台信息 shish 2020.4.13
+    public static function updateOpen($data)
+    {
+        self::updateById(self::ID, $data);
+    }
+
+    //平台小程序信息 shish 2020.4.13
+    public static function getWxMiniBase()
+    {
+        $open = self::getOpen();
+        $wx_mini_base_id = isset($open['wx_mini_base_id']) ? $open['wx_mini_base_id'] : 0;
+        $base = WxMiniBaseClass::getById($wx_mini_base_id);
+        if (empty($base)) {
+            util::fail('没有找到平台小程序信息');
+        }
+        return $base;
+    }
+
+    //公众号信息 shish 2020.4.14
+    public static function getWxBase()
+    {
+        $open = self::getOpen();
+        $wx_base_id = isset($open['wx_base_id']) ? $open['wx_base_id'] : 0;
+        $base = WxBaseClass::getById($wx_base_id);
+        if (empty($base)) {
+            util::fail('没有找到平台公众号信息');
+        }
+        return $base;
+    }
+
 }

+ 45 - 37
biz/weixin/services/WxOpenService.php

@@ -8,42 +8,50 @@ use Yii;
 
 class WxOpenService extends BaseService
 {
-	
-	public static $baseFile = '\biz\weixin\classes\WxOpenClass';
-	
-	//获取平台基础信息 shish 2020.2.11
-	public static function getOpen()
-	{
-		return WxOpenClass::getOpen();
-	}
-
-	public static function updateOpen($data)
-	{
-		return WxOpenClass::updateOpen($data);
-	}
-	
-	//获取平台管理员手机号 shish 2020.3.4
-	public static function getAdminMobile()
-	{
-		return WxOpenClass::getAdminMobile();
-	}
-	
-	//取平台帐号 shish 2020.3.7
-	public static function getPlatformAccount()
-	{
-		return WxOpenClass::getPlatformAccount();
-	}
-
-	//获取平台微信信息
-	public static function getOpenInfo()
-	{
-		return WxOpenClass::getOpenInfo();
-	}
-
-	//获取小程序信息 shish 2020.4.13
-	public static function getWxMiniBase()
-	{
-		return WxOpenClass::getWxMiniBase();
-	}
+
+    public static $baseFile = '\biz\weixin\classes\WxOpenClass';
+
+    //获取平台基础信息 shish 2020.2.11
+    public static function getOpen()
+    {
+        return WxOpenClass::getOpen();
+    }
+
+    public static function updateOpen($data)
+    {
+        return WxOpenClass::updateOpen($data);
+    }
+
+    //获取平台管理员手机号 shish 2020.3.4
+    public static function getAdminMobile()
+    {
+        return WxOpenClass::getAdminMobile();
+    }
+
+    //取平台帐号 shish 2020.3.7
+    public static function getPlatformAccount()
+    {
+        return WxOpenClass::getPlatformAccount();
+    }
+
+    //获取平台微信信息
+    public static function getOpenInfo()
+    {
+        return WxOpenClass::getOpenInfo();
+    }
+
+    //获取小程序信息 shish 2020.4.13
+    public static function getWxMiniBase()
+    {
+        return WxOpenClass::getWxMiniBase();
+    }
+
+    //获取微信和小程序信息 shish 2020.4.14
+    public static function getWxInfo()
+    {
+        $mini = WxOpenClass::getWxMiniBase();
+        $wx = WxOpenClass::getWxBase();
+        return array_merge($wx, $mini);
+    }
 
 }