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

+ 6 - 5
app/shop/controllers/AuthController.php

@@ -4,6 +4,7 @@ namespace shop\controllers;
 
 use biz\admin\services\AdminService;
 use biz\auth\services\AuthService;
+use biz\weixin\services\WxOpenService;
 use common\components\httpUtil;
 use common\components\jwt;
 use common\components\util;
@@ -161,15 +162,15 @@ class AuthController extends PublicController
 		if (empty($code)) {
 			util::fail('没有CODE信息');
 		}
-		$merchant = $this->merchant;
-		$account = $this->merchantId;
+		$merchant = WxOpenService::getOpenInfo();
+		$account = $merchant['id'];
 		$appId = $merchant['miniAppId'];
 		$appSecret = $merchant['miniAppSecret'];
 		if (empty($appSecret)) {
 			util::fail('没有找到小程序的密钥');
 		}
 		$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
-		
+
 		$curl = new curl\Curl();
 		$result = $curl->get($url);
 		$arr = Json::decode($result);
@@ -187,11 +188,11 @@ class AuthController extends PublicController
 			Yii::info(json_encode($userInfo));
 			$user = UserService::replaceUser($userInfo, $userSource, $account);
 		}
-		$cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
+		$cacheKey = 'MALL_MINI_SESSION_KEY_' . $openid;
 		Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
 		$userId = $user['id'];
 		$token = jwt::getNewToken($userId);
 		util::success(['token' => $token, 'user' => $user]);
 	}
-
+	
 }

+ 4 - 2
biz/merchant/services/MerchantService.php

@@ -178,10 +178,10 @@ class MerchantService extends BaseService
 			
 			//完成初始化标识
 			MerchantExtendClass::updateByCondition(['merchantId' => $merchantId], ['init' => 1]);
-
+			
 			//代理资产
 			AgentAssetClass::add(['merchantId' => $merchantId]);
-
+			
 			$transaction->commit();
 			return true;
 		} catch (Exception $e) {
@@ -233,4 +233,6 @@ class MerchantService extends BaseService
 		return MerchantClass::generateMerchant($data);
 	}
 	
+
+
 }

+ 17 - 4
biz/weixin/classes/WxOpenClass.php

@@ -2,6 +2,8 @@
 
 namespace biz\weixin\classes;
 
+use biz\merchant\classes\MerchantClass;
+use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -14,23 +16,34 @@ class WxOpenClass extends BaseClass
 	const ADMIN_MOBILE = 15280215347;
 	const PLATFORM_ACCOUNT = 12359;
 	const ID = 1;
-
+	
 	//取平台的帐号
 	public static function getPlatformAccount()
 	{
 		return self::PLATFORM_ACCOUNT;
 	}
 
-	//获取开放平台 shish 2020.2.11
+	//获取平台基础信息 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('没有找到平台信息');
+	}
+
 }

+ 6 - 0
biz/weixin/services/WxOpenService.php

@@ -28,5 +28,11 @@ class WxOpenService extends BaseService
 	{
 		return WxOpenClass::getPlatformAccount();
 	}
+
+	//获取平台的商家
+	public static function getOpenInfo()
+	{
+		return WxOpenClass::getOpenInfo();
+	}
 	
 }

+ 2 - 0
console/controllers/UpgradeController.php

@@ -1289,6 +1289,8 @@ distance DECIMAL(6,1) NOT NULL DEFAULT 0.0 COMMENT '距离',
 		$sql = "ALTER TABLE `xhAdminRole` ADD `delStatus` TINYINT NOT NULL DEFAULT 0 COMMENT '删除状态 0未删除 1已删除' AFTER `addTime`;";
 		Yii::$app->db->createCommand($sql)->execute($sql);
 
+		$sql = "ALTER TABLE `xhMerchant` ADD `platform` TINYINT NOT NULL DEFAULT 0 COMMENT '0普遍商家1平台使用的商家' AFTER `deadline`;";
+		Yii::$app->db->createCommand($sql)->execute($sql);
 	}
 	
 	//数据迁移 shish 2020.1.12