shish 6 лет назад
Родитель
Сommit
3c10e171dc
2 измененных файлов с 29 добавлено и 14 удалено
  1. 13 13
      app/www/controllers/WxOpenController.php
  2. 16 1
      console/controllers/UpgradeController.php

+ 13 - 13
app/www/controllers/WxOpenController.php

@@ -129,23 +129,24 @@ class WxOpenController extends PublicController
 			WxOpenService::updateById(1, ['merchantId' => $id]);
 			WxOpenService::updateById(1, ['merchantId' => $id]);
 		}
 		}
 		
 		
-		$merchant = MerchantService::getMerchantById($id);
-		if (isset($merchant['wxAppId']) && !empty($merchant['wxAppId'])) {
-			if (isset($authorize_info['MiniProgramInfo']) == false || empty($authorize_info['MiniProgramInfo'])) {
-				if ($merchant['wxAppId'] != $authorizeAppId) {
-					util::stop('授权的公众号与商家已绑定的公众号不一致');
+		$extend = MerchantExtendClass::getByMerchantId($id);
+
+		if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
+			if (isset($extend['miniAppId']) && !empty($extend['miniAppId'])) {
+				if ($extend['miniAppId'] != $authorizeAppId) {
+					util::stop('授权的小程序与商家已绑定的小程序不一致');
 				}
 				}
+			}else{
+				util::stop('数据库请先填写小程序 miniAppId miniAppSecret');
 			}
 			}
-		}
-		
-		if (isset($merchant['miniAppId']) && !empty($merchant['miniAppId'])) {
-			if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
-				if ($merchant['miniAppId'] != $authorizeAppId) {
-					util::stop('授权的小程序与商家已绑定的小程序不一致');
+		}else{
+			if (isset($extend['wxAppId']) && !empty($extend['wxAppId'])) {
+				if ($extend['wxAppId'] != $authorizeAppId) {
+					util::stop('授权的公众号与商家已绑定的公众号不一致');
 				}
 				}
 			}
 			}
 		}
 		}
-		
+
 		//小程序
 		//小程序
 		if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
 		if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
 			xhMerchantExtendService::updateByMerchantId($id, ['miniAppId' => $authorizeAppId, 'miniAccessToken' => $authorize_access_token, 'miniAccessTokenTime' => $accessTokenTime, 'miniRefreshToken' => $authorize_refresh_token]);
 			xhMerchantExtendService::updateByMerchantId($id, ['miniAppId' => $authorizeAppId, 'miniAccessToken' => $authorize_access_token, 'miniAccessTokenTime' => $accessTokenTime, 'miniRefreshToken' => $authorize_refresh_token]);
@@ -168,7 +169,6 @@ class WxOpenController extends PublicController
 		MerchantExtendClass::updateByCondition(['merchantId' => $id], ['wxAppId' => $authorizeAppId,'wxAuth'=>1]);
 		MerchantExtendClass::updateByCondition(['merchantId' => $id], ['wxAppId' => $authorizeAppId,'wxAuth'=>1]);
 
 
 		//还没有完成初始化先进行初始化
 		//还没有完成初始化先进行初始化
-		$extend = MerchantExtendClass::getByMerchantId($id);
 		if (isset($extend['init']) && $extend['init'] == 0) {
 		if (isset($extend['init']) && $extend['init'] == 0) {
 			$data = ['merchantId' => $id];
 			$data = ['merchantId' => $id];
 			$producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
 			$producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');

+ 16 - 1
console/controllers/UpgradeController.php

@@ -1106,9 +1106,24 @@ update xhMerchant set merchantName='花店宝' where id=12358;update xhShop set
 		$sql = "update xhShop set openTime='08:00-22:00',telephone='18030142050',lat='24.46886',`long`='118.10708',province='福建省',city='厦门市',address='福建省厦门市思明区后埭溪路128-5号' where id in(15681,15680);update xhShop set telephone='15280215347' where id=15681;";
 		$sql = "update xhShop set openTime='08:00-22:00',telephone='18030142050',lat='24.46886',`long`='118.10708',province='福建省',city='厦门市',address='福建省厦门市思明区后埭溪路128-5号' where id in(15681,15680);update xhShop set telephone='15280215347' where id=15681;";
 		Yii::$app->db->createCommand($sql)->execute($sql);
 		Yii::$app->db->createCommand($sql)->execute($sql);
 
 
-		$sql = "UPDATE xhMerchant SET miniAppId='',wxAppId='',miniAppSecret='',openAppId='' WHERE id IN(12359,12358);UPDATE xhMerchantExtend SET miniAppId='',wxAppId='',openAppId='',wxAuth=0,miniAuth=0,init=0 WHERE merchantId IN(12359,12358);";
+		$sql = "UPDATE xhMerchant SET wxAppId='',openAppId='' WHERE id IN(12359,12358);UPDATE xhMerchantExtend SET wxAppId='',openAppId='',wxAuth=0,miniAuth=0,init=0 WHERE merchantId IN(12359,12358);";
 		Yii::$app->db->createCommand($sql)->execute($sql);
 		Yii::$app->db->createCommand($sql)->execute($sql);
 
 
+		//更换开发环境小程序的miniAppId、miniAppSecret
+		if ($env == 'dev') {
+			$sql = "UPDATE xhMerchant SET miniAppId='wxe41bd5816affd0ba',miniAppSecret='ad634457979bc6eb1fb0bc7f4f58d885' WHERE id=12358;UPDATE xhMerchantExtend SET miniAppId='wxe41bd5816affd0ba' WHERE merchantId=12358;";
+			Yii::$app->db->createCommand($sql)->execute($sql);
+			$sql = "UPDATE xhMerchant SET miniAppId='wxe4675bab299a52f7',miniAppSecret='12f90039b1245ba6abf2e4184462fb30' WHERE id=12359;UPDATE xhMerchantExtend SET miniAppId='wxe4675bab299a52f7' WHERE merchantId=12359;";
+			Yii::$app->db->createCommand($sql)->execute($sql);
+		}
+		//更换测试环境小程序的miniAppId、miniAppSecret
+		if ($env == 'test') {
+			$sql = "UPDATE xhMerchant SET miniAppId='wx36ca6b1d6e9ca2a4',miniAppSecret='b8227c6264785a233e67293f13b1b7b3' WHERE id=12358;UPDATE xhMerchantExtend SET miniAppId='wx36ca6b1d6e9ca2a4' WHERE merchantId=12358;";
+			Yii::$app->db->createCommand($sql)->execute($sql);
+			$sql = "UPDATE xhMerchant SET miniAppId='wx21b7c3ef12082099',miniAppSecret='fd21ef3ebbc70e89d5c3a5a3c013edb6' WHERE id=12359;UPDATE xhMerchantExtend SET miniAppId='wx21b7c3ef12082099' WHERE merchantId=12359;";
+			Yii::$app->db->createCommand($sql)->execute($sql);
+		}
+
 	}
 	}
 
 
 	//数据迁移 shish 2020.1.12
 	//数据迁移 shish 2020.1.12