shish преди 5 години
родител
ревизия
b205985f6e
променени са 5 файла, в които са добавени 543 реда и са изтрити 537 реда
  1. 530 529
      app/pt/controllers/WxOpenController.php
  2. 1 1
      biz-hd/wx/models/WxBase.php
  3. 1 1
      biz-hd/wx/models/WxMiniBase.php
  4. 1 1
      biz/wx/models/WxMiniBase.php
  5. 10 5
      sql.sql

+ 530 - 529
app/pt/controllers/WxOpenController.php

@@ -22,535 +22,536 @@ use bizHd\wx\classes\WxOpenClass;
 
 class WxOpenController extends PublicController
 {
-	
-	public $guestAccessAction = ['bind-open'];
-	
-	//开放平台开始授权 shish 2020.1.16
-	public function actionBeginAuth()
-	{
-		$id = Yii::$app->request->get('id', 'hd');
-		$open = [];
-		if ($id == 'hd') {
-			$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
-		}
-		if ($id == 'ghs') {
-			$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
-		}
-		if (empty($open)) {
-			util::stop('没有找到平台信息');
-		}
-		//1只显示公众号 2只显示小程序  3显示公众号和小程序
-		$authType = Yii::$app->request->get('authType', 3);
-		$pre = wxUtil::getPreAuthCode($open);
-		$appId = $open['appId'];
-		$oData = [];
-		$oData['preAuthCodeTime'] = date("Y-m-d H:i:s");
-		//设置预授码过期,让下个用户可以获取新的预授码
-		xhWxOpenService::updateById(1, $oData);
-		$url = Yii::$app->params['ptHost'] . '/wx-open-callback/' . $id;
-		echo "<a href='https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$appId}&pre_auth_code={$pre}&redirect_uri={$url}&auth_type={$authType}'>授权</a>";
-	}
-	
-	//创建平台使用的公众号
-	public function actionCallback()
-	{
-		$get = Yii::$app->request->get();
-		if (isset($get['auth_code']) == false) {
-			util::stop('公众号授权回调未成功');
-		}
-		$id = $get['id'] ?? 'hd';
-		
-		$open = [];
-		if ($id == 'hd') {
-			$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
-		}
-		if ($id == 'ghs') {
-			$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
-		}
-		if (empty($open)) {
-			util::stop('没有找到平台信息');
-		}
-		
-		$code = $get['auth_code'];
-		//使用授权码换取公众号的接口调用凭据和授权信息
-		$authorize = wxUtil::getAuthorizer($code, $open);
-		if (isset($authorize['authorization_info']) == false) {
-			util::stop('未换取公众号的接口调用凭据和授权信息');
-		}
-		$info = $authorize['authorization_info'];
-		$authorizeAppId = $info['authorizer_appid'];
-		$authorize_access_token = $info['authorizer_access_token'];
-		$expires_in = $info['expires_in'];//7200
-		$authorize_refresh_token = $info['authorizer_refresh_token'];
-		//获取授权方的公众号帐号基本信息
-		$authorizeDetailInfo = wxUtil::getAuthorizerInfo($authorizeAppId, $open);
-		if (isset($authorizeDetailInfo['authorizer_info']) == false) {
-			util::stop('没有获取到公众号帐号基本信息');
-		}
-		$authorize_info = $authorizeDetailInfo['authorizer_info'];
-		//$nick_name = $authorize_info['nick_name'];
-		$head_img = $authorize_info['head_img'];
-		$service_type_info = $authorize_info['service_type_info'];
-		if ($service_type_info['id'] != 2) {
-			if (isset($authorize_info['MiniProgramInfo']) == false || empty($authorize_info['MiniProgramInfo'])) {
-				util::stop('公众号不是服务号');
-			}
-		}
-		$verify_type_info = $authorize_info['verify_type_info'];
-		if ($verify_type_info['id'] != 0) {
-			if (isset($authorize_info['MiniProgramInfo']) == false || empty($authorize_info['MiniProgramInfo'])) {
-				util::stop('公众号还没有认证哦');
-			}
-		}
-		$user_name = $authorize_info['user_name'];
-		$alias = $authorize_info['alias'];
-		$qrCodeUrl = $authorize_info['qrcode_url'];
-		$accessTokenTime = date("Y-m-d H:i:s", (time() + $expires_in - 100));//安全起见,将过期时间设置得比微信里还短100秒
-		
-		if ($id == 'ghs') {
-			//这是供货商
-			$sjWxInfo = WxOpenClass::getGhsWxInfo();
-		} elseif ($id == 'hd') {
-			//这是零售商
-			$sjWxInfo = WxOpenClass::getWxInfo();
-		} else {
-			util::stop('没有开放的通道');
-			$sjWxInfo = MerchantExtendClass::getByMerchantId($id);
-		}
-		
-		//如果授权的是小程序
-		if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
-			if (isset($sjWxInfo['miniAppId']) && !empty($sjWxInfo['miniAppId'])) {
-				if ($sjWxInfo['miniAppId'] != $authorizeAppId) {
-					util::stop('授权的小程序与商家已绑定的小程序不一致');
-				}
-			} else {
-				util::stop('数据库请先填写小程序 miniAppId miniAppSecret');
-			}
-			
-			$miniData = [
-				'miniAppId' => $authorizeAppId,
-				'miniAuth' => 1,
-				'miniAccessToken' => $authorize_access_token,
-				'miniAccessTokenTime' => $accessTokenTime,
-				'miniRefreshToken' => $authorize_refresh_token,
-			];
-			
-			if (is_numeric($id) == false) {
-				$wxMiniBaseId = 0;
-				$msg = '未知状态';
-				if ($id == 'ghs') {
-					//供货商
-					$wxMiniBaseId = $open['wxGhsMiniBaseId'] ?? 0;
-					$msg = '供货商小程序绑定成功';
-				} elseif ($id == 'hd') {
-					//零售店
-					$wxMiniBaseId = $open['wxMiniBaseId'] ?? 0;
-					$msg = '零售店小程序绑定成功';
-				}
-				if (empty($wxMiniBaseId)) {
-					util::stop('没有小程序信息...');
-				}
-				$miniInfo = WxMiniBaseClass::getById($wxMiniBaseId);
-				if (empty($miniInfo)) {
-					util::stop('没有小程序信息,请先配置:xhWxMiniBase表 和 xhWxOpen的相关字段');
-				}
-				WxMiniBaseClass::updateById($wxMiniBaseId, $miniData);
-				util::stop($msg);
-			} else {
-				xhMerchantExtendService::updateByMerchantId($id, $miniData);
-				MerchantService::updateById($id, ['miniAppId' => $authorizeAppId]);
-				Yii::info('小程序信息更新成功:' . json_encode($authorize_info));
-				util::stop("小程序信息更新成功");
-			}
-		} else {
-			
-			//如果授权的公众号
-			
-			if (isset($sjWxInfo['wxAppId']) && !empty($sjWxInfo['wxAppId'])) {
-				if ($sjWxInfo['wxAppId'] != $authorizeAppId) {
-					util::stop("授权的公众号与商家已绑定的公众号不一致,授权公众号appId:{$authorizeAppId} 商家公众号:{$sjWxInfo['wxAppId']}");
-				}
-			}
-			
-			$wxData = [];
-			$appData['wxUserName'] = $user_name;
-			$appData['wxAliasName'] = $alias;
-			//公众号logo
-			$wxData['logo'] = WxBaseClass::saveLogo($head_img, $id);
-			//公众号二维码
-			$wxData['wxQrCodeUrl'] = WxBaseClass::saveQrCode($qrCodeUrl, $id);
-			$wxData['wxAppId'] = $authorizeAppId;
-			$wxData['wxAccessToken'] = $authorize_access_token;
-			$wxData['wxAccessTokenTime'] = $accessTokenTime;
-			$wxData['wxRefreshToken'] = $authorize_refresh_token;
-			
-			
-			if (is_numeric($id) == false) {
-				
-				$wxBaseId = 0;
-				$msg = '未知状态';
-				if ($id == 'ghs') {
-					//供货商公众号
-					$wxBaseId = $open['wxGhsBaseId'] ?? 0;
-					$msg = '供货商公众号绑定成功';
-				} elseif ($id == 'hd') {
-					//零售商公众号
-					$wxBaseId = $open['wxBaseId'] ?? 0;
-					$msg = '零售商公众号绑定成功';
-				} else {
-				
-				}
-				if (empty($wxBaseId)) {
-					util::stop('没有公众号信息...');
-				}
-				WxBaseClass::updateById($wxBaseId, [
-					'wxAccessToken' => $authorize_access_token,
-					'wxRefreshToken' => $authorize_refresh_token,
-					'wxAccessTokenTime' => date("Y-m-d H:i:s", (time() + $expires_in - 100))
-				]);
-				echo $msg;
-				Yii::$app->end();
-			} else {
-				
-				$wxData['status'] = 1;//审核通过
-				xhMerchantService::updateById($id, $wxData);
-				MerchantExtendClass::updateByCondition(['merchantId' => $id], ['wxAppId' => $authorizeAppId, 'wxAuth' => 1]);
-				
-				//还没有完成初始化先进行初始化
-				if (isset($sjWxInfo['init']) && $sjWxInfo['init'] == 0) {
-					$data = ['merchantId' => $id];
-					$producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
-					$msg = serialize($data);
-					$producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
-				}
-				echo 'ok';
-			}
-		}
-		
-	}
-	
-	
-	//开放平台设置相关操作 shish 2020.1.18
-	public function actionBindOpen()
-	{
-		$isOpen = Yii::$app->request->get('isOpen', 1);
-		
-		$merchantId = 0;
-		if ($isOpen == 0) {
-			//其它
-			$merchantId = Yii::$app->request->get('account', 0);
-			$merchant = MerchantService::getById($merchantId);
-			if (empty($merchant)) {
-				util::fail('没有找到商家');
-			}
-			$wxAppId = $merchant['wxAppId'];
-			$miniAppId = $merchant['miniAppId'];
-			$openAppId = $merchant['openAppId'];
-		} elseif ($isOpen == 1) {
-			//零售
-			$merchant = WxOpenClass::getWxInfo();
-			$miniAppId = $merchant['miniAppId'];
-			$wxAppId = $merchant['wxAppId'];
-			$openAppId = $merchant['openAppId'];
-		} elseif ($isOpen == 2) {
-			//供货商
-			$merchant = WxOpenClass::getGhsWxInfo();
-			$miniAppId = $merchant['miniAppId'];
-			$wxAppId = $merchant['wxAppId'];
-			$openAppId = $merchant['openAppId'];
-		}
-		echo "<pre>";
-		
-		$id = Yii::$app->request->get('actId', 0);
-		
-		//创建平台,并将公众号绑定到平台
-		if ($id == 1) {
-			wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
-			$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-			print_r($return);
-			if ($return['errcode'] == 0) {
-				$openAppId = $return['open_appid'];
-				if ($isOpen == 0) {
-					xhMerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
-					MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
-				} elseif ($isOpen == 1) {
-					$open = WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
-					$wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
-					$wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
-					WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
-					WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
-				} elseif ($isOpen == 2) {
-					$open = WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
-					$wxMiniBaseId = isset($open['wxGhsMiniBaseId']) ? $open['wxGhsMiniBaseId'] : 0;
-					$wxBaseId = isset($open['wxGhsBaseId']) ? $open['wxGhsBaseId'] : 0;
-					WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
-					WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
-				}
-			}
-		}
-		//将小程序绑定到平台
-		if ($id == 2) {
-			$openAppId = $merchant['openAppId'];
-			$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
-			//MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
-			print_r($r);
-		}
-		//查询公众号 小程序的绑定情况
-		if ($id == 3) {
-			Yii::info("查询公众号 小程序的绑定情况 wxAppId:{$wxAppId} isOpen:{$isOpen}");
-			$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-			echo "公众号绑定情况:<br />";
-			print_r($return);
-			$return = wxUtil::getOpenAccount($miniAppId, $merchant, true, $isOpen);
-			echo "小程序绑定情况:<br />";
-			print_r($return);
-		}
-		
-		//设置小程序服务器域名
-		if ($id == 4) {
-			wxUtil::setDomain($merchant, $isOpen);
-			wxUtil::setWebViewDomain($merchant, $isOpen);
-		}
-		
-		//为授权的小程序帐号上传小程序代码
-		if ($id == 5) {
-			//模板id
-			$tId = Yii::$app->request->get('tId');
-			wxUtil::miniCommit($merchant, $tId, $isOpen);
-		}
-		
-		//获取小程序体验码
-		if ($id == 6) {
-			wxUtil::getExperienceQrCode($merchant, '', $isOpen);
-		}
-		
-		//获取授权小程序帐号已设置的类目
-		if ($id == 7) {
-			wxUtil::getMiniCategory($merchant, $isOpen);
-		}
-		
-		//获取小程序的第三方提交代码的页面配置
-		if ($id == 8) {
-			wxUtil::getMiniPage($merchant, $isOpen);
-		}
-		
-		//将第三方提交的代码包提交审核
-		if ($id == 9) {
-			wxUtil::miniSubmitAudit($merchant, '', $isOpen);
-		}
-		
-		//查询最新一次提交的审核状态
-		if ($id == 10) {
-			wxUtil::miniGetLatestAuditStatus($merchant, $isOpen);
-		}
-		
-		//发布已通过审核的小程序
-		if ($id == 11) {
-			$respond = wxUtil::miniRelease($merchant, $isOpen);
-			dd($respond);
-		}
-		
-		//撤回审核
-		if ($id == 12) {
-			wxUtil::rollbackCheck($merchant, $isOpen);
-		}
-		//生成 申请会员页 的小程序码
-		if ($id == 13) {
-			wxUtil::generateMemberCode($merchant, $isOpen);
-		}
-		//解绑小程序和公众号绑定的平台
-		if ($id == 14) {
-			echo '<pre>';
-			Yii::info("解绑信息:" . json_encode($merchant));
-			$r = wxUtil::unbindAccount($merchant, $isOpen);
-			print_r($r);
-			$r = wxUtil::unbindMiniProgram($merchant, $isOpen);
-			print_r($r);
-			Yii::$app->end();
-		}
-		Yii::$app->end();
-		
-		$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
-		print_r($r);
-		echo $miniAppId . ' ' . $openAppId . ' ';
-		
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-		print_r($return);
-		die;
-		
-		$return = wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
-		print_r($return);
-		die;
-		
-		$r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, false, $isOpen);
-		print_r($r);
-		echo $miniAppId . ' ' . $openAppId . ' ';
-		
-		$return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
-		print_r($return);
-		$return = wxUtil::getOpenAccount($miniAppId, $merchant, false, $isOpen);
-		print_r($return);
-	}
-	
-	
-	public function actionResult()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$merchant = xhMerchantService::getById($id);
-		$status = configDict::getConfig('merchantStatusName');
-		$orMechantId = configDict::getConfig('merchantId');
-		$originalMerchant = xhMerchantService::getById($orMechantId);
-		return $this->renderPartial('result', ['originalMerchant' => $originalMerchant, 'merchant' => $merchant, 'status' => $status]);
-	}
-	
-	public function actionCheckInviteCode()
-	{
-		$get = Yii::$app->request->get();
-		$code = isset($get['code']) ? $get['code'] : '';
-		$invite = xhInviteService::getByCode($code);
-		if (empty($invite)) {
-			util::fail('邀请码错误');
-		}
-		$now = time();
-		if ($now > $invite['deadline']) {
-			util::fail('邀请码已经失效');
-		}
-		if (!empty($invite['takeStatus'])) {
-			util::fail('邀请码已经使用');
-		}
-		util::success($invite);
-	}
-	
-	public function actionSelect()
-	{
-		$isWx = util::isWx();
-		if ($isWx == false) {
-			return $this->renderPartial('notWeixin');
-		}
-		return $this->renderPartial('select');
-	}
-	
-	public function actionApi()
-	{
-		$get = Yii::$app->request->get();
-		$style = $get['style'] ?? \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD;
-		$openData = file_get_contents('php://input');
-		if (isset ($openData) == false || empty($openData)) {
-			util::stop('has no post data');
-		}
-		$wxSecret = Yii::getAlias("@vendor/weixinSecret");
-		require_once($wxSecret . '/wxBizMsgCrypt.php');
-		$encryptMsg = $openData;
-		$open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => $style]);
-		$openId = $open['id'];
-		$encodingAesKey = $open['aesKey'];
-		$token = $open['token'];
-		$appId = $open['appId'];
-		$appSecret = $open['appSecret'];
-		$signature = isset($get['signature']) ? $get['signature'] : '';
-		$timestamp = isset($get['timestamp']) ? $get['timestamp'] : '';
-		$nonce = isset($get['nonce']) ? $get['nonce'] : '';
-		$encrypt_type = isset($get['encrypt_type']) ? $get['encrypt_type'] : '';
-		$msg_signature = isset($get['msg_signature']) ? $get['msg_signature'] : '';
-		$xml_tree = new \DOMDocument();
-		$xml_tree->loadXML($encryptMsg);
-		$array_e = $xml_tree->getElementsByTagName('Encrypt');
-		$encrypt = $array_e->item(0)->nodeValue;
-		$format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>";
-		$from_xml = sprintf($format, $encrypt);
-		
-		$formString = " token:" . $token . "\n encodingAesKey:" . $encodingAesKey . "\n appId:" . $appId . "\n msg_signature:" . $msg_signature . "\n appSecret:" . $appSecret . "\n timestamp:" . $timestamp . "\n nonce:" . $nonce;
-		Yii::warning($formString);
-		
-		$formString2 = "from_xml:" . $from_xml;
-		Yii::warning($formString2);
-		
-		//第三方收到公众号平台发送的消息
-		$pc = new \WXBizMsgCrypt($token, $encodingAesKey, $appId);
-		$msg = '';//解密后的消息
-		$errCode = $pc->decryptMsg($msg_signature, $timestamp, $nonce, $from_xml, $msg);
-		if ($errCode != 0) {
-			Yii::warning("解密未成功,错误代码:" . $errCode . "。(出现过的情况汇总:-40001 有可能token、encodingAesKey、appId等填写不对,请仔细核对每个值)");
-			util::stop();
-		}
-		$postObj = simplexml_load_string($msg, 'SimpleXMLElement', LIBXML_NOCDATA);
-		$infoType = $postObj->InfoType;
-		switch ($infoType) {
-			//推送 componentVerifyTicket
-			case 'component_verify_ticket':
-				$componentVerifyTicket = $postObj->ComponentVerifyTicket;
-				if (!empty($componentVerifyTicket)) {
-					$oData = [];
-					$oData['verifyTicket'] = (string)$componentVerifyTicket;
-					$oData['verifyTicketTime'] = date("Y-m-d H:i:s", $timestamp + 600);//每10分钟(600秒)推一次
-					xhWxOpenService::updateById($openId, $oData);
-					Yii::warning("component_verify_ticket:" . (string)$componentVerifyTicket);
-					util::stop('success');
-				}
-				break;
-			//取消授权通知
-			case 'unauthorized':
-				//这里没有往下操作,请看本文件callback()方法
-				break;
-			//授权成功通知
-			case 'authorized':
-				$AppId = $postObj->AppId;
-				$authorizeAppId = $postObj->AuthorizerAppid;
-				$CreateTime = $postObj->CreateTime;//公众号
-				$authorizeAppId = $postObj->AuthorizerAppid;//授权码,可用于换取公众号的接口调用凭据,详细见上面的说明
-				$AuthorizationCode = $postObj->AuthorizationCode;
-				$AuthorizationCodeExpiredTime = $postObj->AuthorizationCodeExpiredTime;//授权码过期时间
-				//这里没有往下操作,请看本文件callback()方法
-				break;
-			//授权更新通知
-			case 'updateauthorized':
-				$AppId = $postObj->AppId;
-				$authorizeAppId = $postObj->AuthorizerAppid;
-				$CreateTime = $postObj->CreateTime;
-				$authorizeAppId = $postObj->AuthorizerAppid;
-				$AuthorizationCode = $postObj->AuthorizationCode;
-				$AuthorizationCodeExpiredTime = $postObj->AuthorizationCodeExpiredTime;
-				//这里没有往下操作,请看本文件callback()方法
-				break;
-			default:
-		}
-		Yii::warning("---wx open data end--- \n");
-	}
-	
-	//平台没有绑定商家公众号时初始化一个商家 shish 2020.2.11
-	public function actionAddMerchant()
-	{
-		AdClass::initAdd(12362);
-		$return = MerchantService::initOpenMerchant();
-		dd($return);
-	}
-	
-	public function actionCheckMerchantName()
-	{
-		$get = Yii::$app->request->get();
-		$merchantName = isset($get['merchantName']) ? $get['merchantName'] : '';
-		$m = xhMerchantService::getByMerchantName($merchantName);
-		if (!empty($m)) {
-			util::fail('公众号名称已经使用');
-		}
-		util::complete();
-	}
-	
-	/**
-	 * 下载微信里的图片到服务器
-	 */
-	public function actionDownloadWxImg()
-	{
-		$get = Yii::$app->request->get();
-		$mediaId = isset($get['mediaId']) ? $get['mediaId'] : '';
-		$imgList = wxUtil::downloadmediaIdImg($this->merchant, $mediaId);
-		if (!empty($imgList)) {
-			util::success($imgList);
-		}
-		util::fail();
-	}
+
+    public $guestAccessAction = ['bind-open'];
+
+    //开放平台开始授权 shish 2020.1.16
+    public function actionBeginAuth()
+    {
+        $id = Yii::$app->request->get('id', 'hd');
+        $open = [];
+        if ($id == 'hd') {
+            $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
+        }
+        if ($id == 'ghs') {
+            $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
+        }
+        if (empty($open)) {
+            util::stop('没有找到平台信息');
+        }
+        //1只显示公众号 2只显示小程序  3显示公众号和小程序
+        $authType = Yii::$app->request->get('authType', 3);
+        $pre = wxUtil::getPreAuthCode($open);
+        $appId = $open['appId'];
+        $oData = [];
+        $oData['preAuthCodeTime'] = date("Y-m-d H:i:s");
+        //设置预授码过期,让下个用户可以获取新的预授码
+        xhWxOpenService::updateById(1, $oData);
+        $url = Yii::$app->params['ptHost'] . '/wx-open-callback/' . $id;
+        Yii::info('callbackUrl:' . $url);
+        echo "<a href='https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$appId}&pre_auth_code={$pre}&redirect_uri={$url}&auth_type={$authType}'>授权</a>";
+    }
+
+    //创建平台使用的公众号
+    public function actionCallback()
+    {
+        $get = Yii::$app->request->get();
+        if (isset($get['auth_code']) == false) {
+            util::stop('公众号授权回调未成功');
+        }
+        $id = $get['id'] ?? 'hd';
+
+        $open = [];
+        if ($id == 'hd') {
+            $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
+        }
+        if ($id == 'ghs') {
+            $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
+        }
+        if (empty($open)) {
+            util::stop('没有找到平台信息');
+        }
+
+        $code = $get['auth_code'];
+        //使用授权码换取公众号的接口调用凭据和授权信息
+        $authorize = wxUtil::getAuthorizer($code, $open);
+        if (isset($authorize['authorization_info']) == false) {
+            util::stop('未换取公众号的接口调用凭据和授权信息');
+        }
+        $info = $authorize['authorization_info'];
+        $authorizeAppId = $info['authorizer_appid'];
+        $authorize_access_token = $info['authorizer_access_token'];
+        $expires_in = $info['expires_in'];//7200
+        $authorize_refresh_token = $info['authorizer_refresh_token'];
+        //获取授权方的公众号帐号基本信息
+        $authorizeDetailInfo = wxUtil::getAuthorizerInfo($authorizeAppId, $open);
+        if (isset($authorizeDetailInfo['authorizer_info']) == false) {
+            util::stop('没有获取到公众号帐号基本信息');
+        }
+        $authorize_info = $authorizeDetailInfo['authorizer_info'];
+        //$nick_name = $authorize_info['nick_name'];
+        $head_img = $authorize_info['head_img'];
+        $service_type_info = $authorize_info['service_type_info'];
+        if ($service_type_info['id'] != 2) {
+            if (isset($authorize_info['MiniProgramInfo']) == false || empty($authorize_info['MiniProgramInfo'])) {
+                util::stop('公众号不是服务号');
+            }
+        }
+        $verify_type_info = $authorize_info['verify_type_info'];
+        if ($verify_type_info['id'] != 0) {
+            if (isset($authorize_info['MiniProgramInfo']) == false || empty($authorize_info['MiniProgramInfo'])) {
+                util::stop('公众号还没有认证哦');
+            }
+        }
+        $user_name = $authorize_info['user_name'];
+        $alias = $authorize_info['alias'];
+        $qrCodeUrl = $authorize_info['qrcode_url'];
+        $accessTokenTime = date("Y-m-d H:i:s", (time() + $expires_in - 100));//安全起见,将过期时间设置得比微信里还短100秒
+
+        if ($id == 'ghs') {
+            //这是供货商
+            $sjWxInfo = WxOpenClass::getGhsWxInfo();
+        } elseif ($id == 'hd') {
+            //这是零售商
+            $sjWxInfo = WxOpenClass::getWxInfo();
+        } else {
+            util::stop('没有开放的通道');
+            $sjWxInfo = MerchantExtendClass::getByMerchantId($id);
+        }
+
+        //如果授权的是小程序
+        if (isset($authorize_info['MiniProgramInfo']) && !empty($authorize_info['MiniProgramInfo'])) {
+            if (isset($sjWxInfo['miniAppId']) && !empty($sjWxInfo['miniAppId'])) {
+                if ($sjWxInfo['miniAppId'] != $authorizeAppId) {
+                    util::stop('授权的小程序与商家已绑定的小程序不一致');
+                }
+            } else {
+                util::stop('数据库请先填写小程序 miniAppId miniAppSecret');
+            }
+
+            $miniData = [
+                'miniAppId' => $authorizeAppId,
+                'miniAuth' => 1,
+                'miniAccessToken' => $authorize_access_token,
+                'miniAccessTokenTime' => $accessTokenTime,
+                'miniRefreshToken' => $authorize_refresh_token,
+            ];
+
+            if (is_numeric($id) == false) {
+                $wxMiniBaseId = 0;
+                $msg = '未知状态';
+                if ($id == 'ghs') {
+                    //供货商
+                    $wxMiniBaseId = $open['wxGhsMiniBaseId'] ?? 0;
+                    $msg = '供货商小程序绑定成功';
+                } elseif ($id == 'hd') {
+                    //零售店
+                    $wxMiniBaseId = $open['wxMiniBaseId'] ?? 0;
+                    $msg = '零售店小程序绑定成功';
+                }
+                if (empty($wxMiniBaseId)) {
+                    util::stop('没有小程序信息...');
+                }
+                $miniInfo = WxMiniBaseClass::getById($wxMiniBaseId);
+                if (empty($miniInfo)) {
+                    util::stop('没有小程序信息,请先配置:xhWxMiniBase表 和 xhWxOpen的相关字段');
+                }
+                WxMiniBaseClass::updateById($wxMiniBaseId, $miniData);
+                util::stop($msg);
+            } else {
+                xhMerchantExtendService::updateByMerchantId($id, $miniData);
+                MerchantService::updateById($id, ['miniAppId' => $authorizeAppId]);
+                Yii::info('小程序信息更新成功:' . json_encode($authorize_info));
+                util::stop("小程序信息更新成功");
+            }
+        } else {
+
+            //如果授权的公众号
+
+            if (isset($sjWxInfo['wxAppId']) && !empty($sjWxInfo['wxAppId'])) {
+                if ($sjWxInfo['wxAppId'] != $authorizeAppId) {
+                    util::stop("授权的公众号与商家已绑定的公众号不一致,授权公众号appId:{$authorizeAppId} 商家公众号:{$sjWxInfo['wxAppId']}");
+                }
+            }
+
+            $wxData = [];
+            $appData['wxUserName'] = $user_name;
+            $appData['wxAliasName'] = $alias;
+            //公众号logo
+            $wxData['logo'] = WxBaseClass::saveLogo($head_img, $id);
+            //公众号二维码
+            $wxData['wxQrCodeUrl'] = WxBaseClass::saveQrCode($qrCodeUrl, $id);
+            $wxData['wxAppId'] = $authorizeAppId;
+            $wxData['wxAccessToken'] = $authorize_access_token;
+            $wxData['wxAccessTokenTime'] = $accessTokenTime;
+            $wxData['wxRefreshToken'] = $authorize_refresh_token;
+
+
+            if (is_numeric($id) == false) {
+
+                $wxBaseId = 0;
+                $msg = '未知状态';
+                if ($id == 'ghs') {
+                    //供货商公众号
+                    $wxBaseId = $open['wxGhsBaseId'] ?? 0;
+                    $msg = '供货商公众号绑定成功';
+                } elseif ($id == 'hd') {
+                    //零售商公众号
+                    $wxBaseId = $open['wxBaseId'] ?? 0;
+                    $msg = '零售商公众号绑定成功';
+                } else {
+
+                }
+                if (empty($wxBaseId)) {
+                    util::stop('没有公众号信息...');
+                }
+                WxBaseClass::updateById($wxBaseId, [
+                    'wxAccessToken' => $authorize_access_token,
+                    'wxRefreshToken' => $authorize_refresh_token,
+                    'wxAccessTokenTime' => date("Y-m-d H:i:s", (time() + $expires_in - 100))
+                ]);
+                echo $msg;
+                Yii::$app->end();
+            } else {
+
+                $wxData['status'] = 1;//审核通过
+                xhMerchantService::updateById($id, $wxData);
+                MerchantExtendClass::updateByCondition(['merchantId' => $id], ['wxAppId' => $authorizeAppId, 'wxAuth' => 1]);
+
+                //还没有完成初始化先进行初始化
+                if (isset($sjWxInfo['init']) && $sjWxInfo['init'] == 0) {
+                    $data = ['merchantId' => $id];
+                    $producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
+                    $msg = serialize($data);
+                    $producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
+                }
+                echo 'ok';
+            }
+        }
+
+    }
+
+
+    //开放平台设置相关操作 shish 2020.1.18
+    public function actionBindOpen()
+    {
+        $isOpen = Yii::$app->request->get('isOpen', 1);
+
+        $merchantId = 0;
+        if ($isOpen == 0) {
+            //其它
+            $merchantId = Yii::$app->request->get('account', 0);
+            $merchant = MerchantService::getById($merchantId);
+            if (empty($merchant)) {
+                util::fail('没有找到商家');
+            }
+            $wxAppId = $merchant['wxAppId'];
+            $miniAppId = $merchant['miniAppId'];
+            $openAppId = $merchant['openAppId'];
+        } elseif ($isOpen == 1) {
+            //零售
+            $merchant = WxOpenClass::getWxInfo();
+            $miniAppId = $merchant['miniAppId'];
+            $wxAppId = $merchant['wxAppId'];
+            $openAppId = $merchant['openAppId'];
+        } elseif ($isOpen == 2) {
+            //供货商
+            $merchant = WxOpenClass::getGhsWxInfo();
+            $miniAppId = $merchant['miniAppId'];
+            $wxAppId = $merchant['wxAppId'];
+            $openAppId = $merchant['openAppId'];
+        }
+        echo "<pre>";
+
+        $id = Yii::$app->request->get('actId', 0);
+
+        //创建平台,并将公众号绑定到平台
+        if ($id == 1) {
+            wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
+            $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+            print_r($return);
+            if ($return['errcode'] == 0) {
+                $openAppId = $return['open_appid'];
+                if ($isOpen == 0) {
+                    xhMerchantService::updateById($merchantId, ['openAppId' => $openAppId]);
+                    MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppId' => $openAppId, 'openAppBind' => 1, 'wxAuth' => 1]);
+                } elseif ($isOpen == 1) {
+                    $open = WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD]);
+                    $wxMiniBaseId = isset($open['wxMiniBaseId']) ? $open['wxMiniBaseId'] : 0;
+                    $wxBaseId = isset($open['wxBaseId']) ? $open['wxBaseId'] : 0;
+                    WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
+                    WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
+                } elseif ($isOpen == 2) {
+                    $open = WxOpenClass::getByCondition(['style' => \biz\wx\classes\WxOpenClass::OPEN_STYLE_GHS]);
+                    $wxMiniBaseId = isset($open['wxGhsMiniBaseId']) ? $open['wxGhsMiniBaseId'] : 0;
+                    $wxBaseId = isset($open['wxGhsBaseId']) ? $open['wxGhsBaseId'] : 0;
+                    WxMiniBaseClass::updateById($wxMiniBaseId, ['openAppId' => $openAppId]);
+                    WxBaseClass::updateById($wxBaseId, ['openAppId' => $openAppId]);
+                }
+            }
+        }
+        //将小程序绑定到平台
+        if ($id == 2) {
+            $openAppId = $merchant['openAppId'];
+            $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
+            //MerchantExtendService::updateByCondition(['merchantId' => $merchantId], ['openAppBind' => 3, 'miniAuth' => 1]);
+            print_r($r);
+        }
+        //查询公众号 小程序的绑定情况
+        if ($id == 3) {
+            Yii::info("查询公众号 小程序的绑定情况 wxAppId:{$wxAppId} isOpen:{$isOpen}");
+            $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+            echo "公众号绑定情况:<br />";
+            print_r($return);
+            $return = wxUtil::getOpenAccount($miniAppId, $merchant, true, $isOpen);
+            echo "小程序绑定情况:<br />";
+            print_r($return);
+        }
+
+        //设置小程序服务器域名
+        if ($id == 4) {
+            wxUtil::setDomain($merchant, $isOpen);
+            wxUtil::setWebViewDomain($merchant, $isOpen);
+        }
+
+        //为授权的小程序帐号上传小程序代码
+        if ($id == 5) {
+            //模板id
+            $tId = Yii::$app->request->get('tId');
+            wxUtil::miniCommit($merchant, $tId, $isOpen);
+        }
+
+        //获取小程序体验码
+        if ($id == 6) {
+            wxUtil::getExperienceQrCode($merchant, '', $isOpen);
+        }
+
+        //获取授权小程序帐号已设置的类目
+        if ($id == 7) {
+            wxUtil::getMiniCategory($merchant, $isOpen);
+        }
+
+        //获取小程序的第三方提交代码的页面配置
+        if ($id == 8) {
+            wxUtil::getMiniPage($merchant, $isOpen);
+        }
+
+        //将第三方提交的代码包提交审核
+        if ($id == 9) {
+            wxUtil::miniSubmitAudit($merchant, '', $isOpen);
+        }
+
+        //查询最新一次提交的审核状态
+        if ($id == 10) {
+            wxUtil::miniGetLatestAuditStatus($merchant, $isOpen);
+        }
+
+        //发布已通过审核的小程序
+        if ($id == 11) {
+            $respond = wxUtil::miniRelease($merchant, $isOpen);
+            dd($respond);
+        }
+
+        //撤回审核
+        if ($id == 12) {
+            wxUtil::rollbackCheck($merchant, $isOpen);
+        }
+        //生成 申请会员页 的小程序码
+        if ($id == 13) {
+            wxUtil::generateMemberCode($merchant, $isOpen);
+        }
+        //解绑小程序和公众号绑定的平台
+        if ($id == 14) {
+            echo '<pre>';
+            Yii::info("解绑信息:" . json_encode($merchant));
+            $r = wxUtil::unbindAccount($merchant, $isOpen);
+            print_r($r);
+            $r = wxUtil::unbindMiniProgram($merchant, $isOpen);
+            print_r($r);
+            Yii::$app->end();
+        }
+        Yii::$app->end();
+
+        $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, true, $isOpen);
+        print_r($r);
+        echo $miniAppId . ' ' . $openAppId . ' ';
+
+        $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+        print_r($return);
+        die;
+
+        $return = wxUtil::createOpenAccount($wxAppId, $merchant, $isOpen);
+        print_r($return);
+        die;
+
+        $r = wxUtil::bindOpenAccount($miniAppId, $openAppId, $merchant, false, $isOpen);
+        print_r($r);
+        echo $miniAppId . ' ' . $openAppId . ' ';
+
+        $return = wxUtil::getOpenAccount($wxAppId, $merchant, false, $isOpen);
+        print_r($return);
+        $return = wxUtil::getOpenAccount($miniAppId, $merchant, false, $isOpen);
+        print_r($return);
+    }
+
+
+    public function actionResult()
+    {
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) ? $get['id'] : 0;
+        $merchant = xhMerchantService::getById($id);
+        $status = configDict::getConfig('merchantStatusName');
+        $orMechantId = configDict::getConfig('merchantId');
+        $originalMerchant = xhMerchantService::getById($orMechantId);
+        return $this->renderPartial('result', ['originalMerchant' => $originalMerchant, 'merchant' => $merchant, 'status' => $status]);
+    }
+
+    public function actionCheckInviteCode()
+    {
+        $get = Yii::$app->request->get();
+        $code = isset($get['code']) ? $get['code'] : '';
+        $invite = xhInviteService::getByCode($code);
+        if (empty($invite)) {
+            util::fail('邀请码错误');
+        }
+        $now = time();
+        if ($now > $invite['deadline']) {
+            util::fail('邀请码已经失效');
+        }
+        if (!empty($invite['takeStatus'])) {
+            util::fail('邀请码已经使用');
+        }
+        util::success($invite);
+    }
+
+    public function actionSelect()
+    {
+        $isWx = util::isWx();
+        if ($isWx == false) {
+            return $this->renderPartial('notWeixin');
+        }
+        return $this->renderPartial('select');
+    }
+
+    public function actionApi()
+    {
+        $get = Yii::$app->request->get();
+        $style = $get['style'] ?? \biz\wx\classes\WxOpenClass::OPEN_STYLE_HD;
+        $openData = file_get_contents('php://input');
+        if (isset ($openData) == false || empty($openData)) {
+            util::stop('has no post data');
+        }
+        $wxSecret = Yii::getAlias("@vendor/weixinSecret");
+        require_once($wxSecret . '/wxBizMsgCrypt.php');
+        $encryptMsg = $openData;
+        $open = \biz\wx\classes\WxOpenClass::getByCondition(['style' => $style]);
+        $openId = $open['id'];
+        $encodingAesKey = $open['aesKey'];
+        $token = $open['token'];
+        $appId = $open['appId'];
+        $appSecret = $open['appSecret'];
+        $signature = isset($get['signature']) ? $get['signature'] : '';
+        $timestamp = isset($get['timestamp']) ? $get['timestamp'] : '';
+        $nonce = isset($get['nonce']) ? $get['nonce'] : '';
+        $encrypt_type = isset($get['encrypt_type']) ? $get['encrypt_type'] : '';
+        $msg_signature = isset($get['msg_signature']) ? $get['msg_signature'] : '';
+        $xml_tree = new \DOMDocument();
+        $xml_tree->loadXML($encryptMsg);
+        $array_e = $xml_tree->getElementsByTagName('Encrypt');
+        $encrypt = $array_e->item(0)->nodeValue;
+        $format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>";
+        $from_xml = sprintf($format, $encrypt);
+
+        $formString = " token:" . $token . "\n encodingAesKey:" . $encodingAesKey . "\n appId:" . $appId . "\n msg_signature:" . $msg_signature . "\n appSecret:" . $appSecret . "\n timestamp:" . $timestamp . "\n nonce:" . $nonce;
+        Yii::warning($formString);
+
+        $formString2 = "from_xml:" . $from_xml;
+        Yii::warning($formString2);
+
+        //第三方收到公众号平台发送的消息
+        $pc = new \WXBizMsgCrypt($token, $encodingAesKey, $appId);
+        $msg = '';//解密后的消息
+        $errCode = $pc->decryptMsg($msg_signature, $timestamp, $nonce, $from_xml, $msg);
+        if ($errCode != 0) {
+            Yii::warning("解密未成功,错误代码:" . $errCode . "。(出现过的情况汇总:-40001 有可能token、encodingAesKey、appId等填写不对,请仔细核对每个值)");
+            util::stop();
+        }
+        $postObj = simplexml_load_string($msg, 'SimpleXMLElement', LIBXML_NOCDATA);
+        $infoType = $postObj->InfoType;
+        switch ($infoType) {
+            //推送 componentVerifyTicket
+            case 'component_verify_ticket':
+                $componentVerifyTicket = $postObj->ComponentVerifyTicket;
+                if (!empty($componentVerifyTicket)) {
+                    $oData = [];
+                    $oData['verifyTicket'] = (string)$componentVerifyTicket;
+                    $oData['verifyTicketTime'] = date("Y-m-d H:i:s", $timestamp + 600);//每10分钟(600秒)推一次
+                    xhWxOpenService::updateById($openId, $oData);
+                    Yii::warning("component_verify_ticket:" . (string)$componentVerifyTicket);
+                    util::stop('success');
+                }
+                break;
+            //取消授权通知
+            case 'unauthorized':
+                //这里没有往下操作,请看本文件callback()方法
+                break;
+            //授权成功通知
+            case 'authorized':
+                $AppId = $postObj->AppId;
+                $authorizeAppId = $postObj->AuthorizerAppid;
+                $CreateTime = $postObj->CreateTime;//公众号
+                $authorizeAppId = $postObj->AuthorizerAppid;//授权码,可用于换取公众号的接口调用凭据,详细见上面的说明
+                $AuthorizationCode = $postObj->AuthorizationCode;
+                $AuthorizationCodeExpiredTime = $postObj->AuthorizationCodeExpiredTime;//授权码过期时间
+                //这里没有往下操作,请看本文件callback()方法
+                break;
+            //授权更新通知
+            case 'updateauthorized':
+                $AppId = $postObj->AppId;
+                $authorizeAppId = $postObj->AuthorizerAppid;
+                $CreateTime = $postObj->CreateTime;
+                $authorizeAppId = $postObj->AuthorizerAppid;
+                $AuthorizationCode = $postObj->AuthorizationCode;
+                $AuthorizationCodeExpiredTime = $postObj->AuthorizationCodeExpiredTime;
+                //这里没有往下操作,请看本文件callback()方法
+                break;
+            default:
+        }
+        Yii::warning("---wx open data end--- \n");
+    }
+
+    //平台没有绑定商家公众号时初始化一个商家 shish 2020.2.11
+    public function actionAddMerchant()
+    {
+        AdClass::initAdd(12362);
+        $return = MerchantService::initOpenMerchant();
+        dd($return);
+    }
+
+    public function actionCheckMerchantName()
+    {
+        $get = Yii::$app->request->get();
+        $merchantName = isset($get['merchantName']) ? $get['merchantName'] : '';
+        $m = xhMerchantService::getByMerchantName($merchantName);
+        if (!empty($m)) {
+            util::fail('公众号名称已经使用');
+        }
+        util::complete();
+    }
+
+    /**
+     * 下载微信里的图片到服务器
+     */
+    public function actionDownloadWxImg()
+    {
+        $get = Yii::$app->request->get();
+        $mediaId = isset($get['mediaId']) ? $get['mediaId'] : '';
+        $imgList = wxUtil::downloadmediaIdImg($this->merchant, $mediaId);
+        if (!empty($imgList)) {
+            util::success($imgList);
+        }
+        util::fail();
+    }
 
     //获取平台信息 shish 2020.4.12
     public function actionGetWxOpen()

+ 1 - 1
biz-hd/wx/models/WxBase.php

@@ -7,7 +7,7 @@ class WxBase extends Base
 
 	public static function tableName()
 	{
-		return 'xhWxBase';
+		return 'xhWxGzh';
 	}
 
 }

+ 1 - 1
biz-hd/wx/models/WxMiniBase.php

@@ -7,7 +7,7 @@ class WxMiniBase extends Base
 
 	public static function tableName()
 	{
-		return 'xhWxMiniBase';
+		return 'xhWxMini';
 	}
 
 }

+ 1 - 1
biz/wx/models/WxMiniBase.php

@@ -9,7 +9,7 @@ class WxMiniBase extends Base
 	
 	public static function tableName()
 	{
-		return 'xhWxMiniBase';
+		return 'xhWxMini';
 	}
 	
 }

+ 10 - 5
sql.sql

@@ -1,3 +1,8 @@
+========================以下内容请将下面的数据库同步了再操作======================
+
+将 销花宝 花卉宝 花掌柜 花美玲 的公众号和小程序 绑定到同一个开放平台下
+将供货商和零售店的公众号和小程序绑定到自我开放平台下 并且更新 xhWxGzh 和 xhWxMini 下的openAppId值 和其它相关信息 二个公众号要补齐
+
 1.补充供货商的wxopen信息 包括appSecret style = 2 其它内容参考开放平台里的数据
 2.api.pt.hzghd.com nginx要指向到pt目录 并且开通api.pt.hzghd.com的https
 3.api.shop.hzghd.com 指向到ghs目录 并且开通api.shop.hzghd.com的https
@@ -6,7 +11,7 @@
 
 确认app模块下的hd ghs pt里的runtime有没创建成功 web里的assets是否创建成功
 
-上线前将花卉宝和销花宝绑定到开放平台下面
+=============================================================================
 
 CREATE TABLE xhItem(
 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -1011,8 +1016,6 @@ ALTER TABLE `xhUnionUser` DROP COLUMN `updateTime`;
 ALTER TABLE `xhUnionUser` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER `mobile`;
 ALTER TABLE `xhUnionUser` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间' AFTER `addTime`;
 
-将 销花宝 花卉宝 花掌柜 花美玲 的公众号和小程序 绑定到同一个开放平台下
-
 ALTER TABLE `xhApply` MODIFY `from` TINYINT NOT NULL DEFAULT 1 COMMENT '来源平台 1零售平台 2供货商平台';
 ALTER TABLE `xhApplyExtend` ADD applyId INT NOT NULL DEFAULT 0 COMMENT '申请id' AFTER `id`;
 ALTER TABLE `xhApply` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1审核中 2审核通过,试用中 3审核未通过 4已付费,使用中 5试用到期失效';
@@ -1100,7 +1103,7 @@ CREATE TABLE `xhExpressLocal` (
 =========
 == shish 2021-2-2
 
-将供货商和零售店的公众号和小程序绑定到自我开放平台下 并且更新 xhWxBase 和 xhWxMiniBase 下的openAppId值
+
 
 ===========
 == shish 20201-2-4
@@ -1406,4 +1409,6 @@ ALTER TABLE `xhOrder` MODIFY `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '
 ALTER TABLE xhPxTeacher CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id';
 ALTER TABLE xhPxUserCourse CHANGE `merchantId` `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id';
 ALTER TABLE `xhAdmin` ADD `style` TINYINT NOT NULL DEFAULT 1 COMMENT '类型 1花店的 2供货商的' AFTER `identity`;
-RENAME TABLE `xhStaff` TO `xhPtAdmin`;
+RENAME TABLE `xhStaff` TO `xhPtAdmin`;
+RENAME TABLE `xhWxBase` TO `xhWxGzh`;
+RENAME TABLE `xhWxMiniBase` TO `xhWxMini`;