shish 6 سال پیش
والد
کامیت
2333680eb9
2فایلهای تغییر یافته به همراه23 افزوده شده و 15 حذف شده
  1. 13 13
      common/services/xhWxMenuService.php
  2. 10 2
      console/controllers/UpgradeController.php

+ 13 - 13
common/services/xhWxMenuService.php

@@ -15,7 +15,7 @@ class xhWxMenuService
 	/**
 	 * 初始化菜单
 	 */
-	public static function applyInit($merchant)
+	public static function applyInit($merchant, $isOpen = 0)
 	{
 		$merchantId = isset($merchant['id']) ? $merchant['id'] : 0;
 		//删除之前存在的菜单
@@ -23,32 +23,32 @@ class xhWxMenuService
 		$menuOption = configDict::getConfig('wxMenuOption');
 		$mallDomain = Yii::$app->params['mallDomain'];
 		$shopDomain = Yii::$app->params['shopDomain'];
-		//强制使用https方式
+		//强制转成https方式
 		if (strpos($mallDomain, 'https') === false) {
 			$mallDomain = str_replace('http', 'https', $mallDomain);
 			$shopDomain = str_replace('http', 'https', $shopDomain);
 		}
+		if ($isOpen == 0) {
 //		$button = [
 //			["type" => 'view', "name" => "鲜花速递", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
 //			["type" => 'view', "name" => "会员服务", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
 //			["type" => 'view', "name" => "我的订单", "menuOption" => $menuOption['redirectToCommonUseUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
 //		];
-		$button = [
-			["type" => 'miniprogram', "name" => "鲜花速递", "appid" => $merchant['miniAppId'], "pagepath" => "pages/home/index", "url" => $mallDomain . '/#/?account=' . $merchantId,],
-			["type" => 'miniprogram', "name" => "会员服务", "appid" => $merchant['miniAppId'], "pagepath" => "pages/home/user", "url" => $mallDomain . '/#/?account=' . $merchantId,],
-			["type" => 'miniprogram', "name" => "我的订单", "appid" => $merchant['miniAppId'], "pagepath" => "pages/order/list", "url" => $mallDomain . '/#/?account=' . $merchantId,],
-		];
-		$open = WxOpenService::getById(1);
-		//平台使用的公众号菜单与花店公众号菜单不一样
-		if (isset($open['merchantId']) && $open['merchantId'] == $merchantId) {
+			$button = [
+				["type" => 'miniprogram', "name" => "鲜花速递", "appid" => $merchant['miniAppId'], "pagepath" => "pages/home/index", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "会员服务", "appid" => $merchant['miniAppId'], "pagepath" => "pages/home/user", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "我的订单", "appid" => $merchant['miniAppId'], "pagepath" => "pages/order/list", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+			];
+			
+		} else {
 //			$button = [
 //				["type" => "view", "name" => "官网", "menuOption" => $menuOption['redirectToCustomUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
 //				["type" => "view", "name" => "后台", "menuOption" => $menuOption['redirectToCustomUrl'], "url" => $mallDomain . '/#/?account=' . $merchantId,],
 //			];
 			$button = [
-				["type" => 'miniprogram', "name" => "官网", "appid" => $merchant['miniAppId'], "pagepath" => "", "url" => $mallDomain . '/#/?account=' . $merchantId,],
-				["type" => 'miniprogram', "name" => "申请", "appid" => $merchant['miniAppId'], "pagepath" => "", "url" => $mallDomain . '/#/?account=' . $merchantId,],
-				["type" => 'miniprogram', "name" => "后台", "appid" => $merchant['miniAppId'], "pagepath" => "", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "官网", "appid" => $merchant['miniAppId'], "pagepath" => "admin/home/console", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "申请", "appid" => $merchant['miniAppId'], "pagepath" => "admin/home/console", "url" => $mallDomain . '/#/?account=' . $merchantId,],
+				["type" => 'miniprogram', "name" => "后台", "appid" => $merchant['miniAppId'], "pagepath" => "admin/home/console", "url" => $mallDomain . '/#/?account=' . $merchantId,],
 			];
 		}
 		$wxUtil = new wxUtil($merchant);

+ 10 - 2
console/controllers/UpgradeController.php

@@ -23,6 +23,7 @@ use biz\user\services\UserGrowthService;
 use biz\user\services\UserService;
 use biz\wx\classes\WxBaseClass;
 use biz\wx\services\WxMenuService;
+use biz\wx\services\WxOpenService;
 use common\components\dirUtil;
 use common\components\util;
 use common\components\wxUtil;
@@ -1408,9 +1409,9 @@ ALTER TABLE `xhStatOrderMonth` ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店
 ALTER TABLE `xhStatOut` ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id' AFTER merchantId;
 ALTER TABLE `xhStatOutMonth` ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id' AFTER merchantId;";
 		Yii::$app->db->createCommand($sql)->execute($sql);
-
+		
 	}
-
+	
 	//数据迁移 shish 2020.1.12
 	//./yii upgrade/sync
 	public function actionSync()
@@ -1530,6 +1531,13 @@ ALTER TABLE `xhStatOutMonth` ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id
 		xhWxMenuService::applyInit($merchant);
 	}
 	
+	//平台微信菜单重置 shish 2020.4.24
+	public function actionOpenMenuInit()
+	{
+		$merchant = WxOpenService::getWxInfo();
+		xhWxMenuService::applyInit($merchant);
+	}
+	
 	//测试生成头像有没问题
 	public function actionAddAvatar($id)
 	{