shish 6 vuotta sitten
vanhempi
commit
0d6a72b600
1 muutettua tiedostoa jossa 91 lisäystä ja 89 poistoa
  1. 91 89
      console/controllers/UpgradeController.php

+ 91 - 89
console/controllers/UpgradeController.php

@@ -26,7 +26,7 @@ use yii\console\Controller;
 
 class UpgradeController extends Controller
 {
-
+	
 	//正式环境 shish
 	//yii upgrade/init 2
 	//不管是否线上都可以这样执行,我们要仿最终上线的状态
@@ -870,7 +870,7 @@ CREATE TABLE `xhInformUser` (
 		//省市区表字段变更
 		$sql = "ALTER TABLE `xhDistrict` CHANGE `shortName` `name` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '简称';";
 		Yii::$app->db->createCommand($sql)->execute();
-
+		
 		$sql = "DROP TABLE IF EXISTS `xhStatView`;
 CREATE TABLE `xhStatView` (
   `id` INT(11) NOT NULL AUTO_INCREMENT,
@@ -894,7 +894,7 @@ CREATE TABLE `xhStatViewMonth` (
   UNIQUE KEY `num` (`merchantId`,`time`)
 ) COMMENT='每月增加访问次数,非访问ip数';";
 		Yii::$app->db->createCommand($sql)->execute();
-
+		
 		//统计相关
 		//xhStatIncomeMonth
 		$list = StatIncomeMonthService::getAllByCondition([], null, '*');
@@ -938,22 +938,16 @@ CREATE TABLE `xhStatViewMonth` (
 				StatOrderMonthService::updateById($id, ['time' => $date]);
 			}
 		}
-
+		
 		$sql = "ALTER TABLE `xhMerchantAsset` ADD totalView INT NOT NULL DEFAULT 0 COMMENT '累计访问次数' AFTER `totalVisit`;ALTER TABLE `xhMerchantAsset` MODIFY `totalVisit` INT NOT NULL DEFAULT 0 COMMENT '累计访客数';";
 		Yii::$app->db->createCommand($sql)->execute();
-
+		
 		//删除收入来源数据统计的键名
 		$sql = "ALTER TABLE `xhStatIncomeSourceMonth` DROP INDEX `income`;";
 		Yii::$app->db->createCommand($sql)->execute();
-
-		if ($num == 2) {
-			$this->actionInit2();
-		}
 		
-		if ($num == 3) {
-			$this->actionInit2();
-			$this->actionSyncAvatar();
-		}
+		//继续执行
+		$this->actionInit2();
 		
 	}
 	
@@ -963,94 +957,102 @@ CREATE TABLE `xhStatViewMonth` (
 		$sql = 'update `xhAdmin` set password="' . password_hash('123456', PASSWORD_BCRYPT) . '",confirmPassword="' . password_hash('123456', PASSWORD_BCRYPT) . '";update `xhAdmin` set merchantId=12358,platUserId=12543212 where id=1;update `xhAdmin` set merchantId=12359,platUserId=12540901 where id=3;update `xhAdmin` set merchantId=12360 where id=4;update `xhAdmin` set merchantId=12361,platUserId=12540861 where id=5;update `xhStaff` set `password`="' . password_hash('123456', PASSWORD_BCRYPT) . '"';
 		Yii::$app->db->createCommand($sql)->execute();
 		
-		//生产环境国兰密码要更新进去
+		//生产环境才要做的操作
 		if (getenv('YII_ENV') == 'production') {
 			$password = password_hash('glhs610000', PASSWORD_BCRYPT);
 			$confirmPassword = password_hash('454588', PASSWORD_BCRYPT);
 			$sql = "update `xhAdmin` set password='{$password}',confirmPassowrd='{$confirmPassword}' where id=1";
 			Yii::$app->db->createCommand($sql)->execute();
-		}
-		
-		//国兰老客户导入
-		$oldUserList = Yii::$app->db2->createCommand('select * from xhUserOldData where `status`=0')->queryAll();
-		if (!empty($oldUserList)) {
-			foreach ($oldUserList as $user) {
-				$mobile = $user['mobile'];
-				$exists = UserService::getByCondition(['mobile' => $mobile, 'merchantId' => 12358]);
-				if (!empty($exists)) {
-					echo "老客户:'.$mobile.'已经导入过了。\n";
-					continue;
+			
+			//国兰老客户导入
+			$oldUserList = Yii::$app->db2->createCommand('select * from xhUserOldData where `status`=0')->queryAll();
+			if (!empty($oldUserList)) {
+				foreach ($oldUserList as $user) {
+					$mobile = $user['mobile'];
+					$exists = UserService::getByCondition(['mobile' => $mobile, 'merchantId' => 12358]);
+					if (!empty($exists)) {
+						echo "老客户:'.$mobile.'已经导入过了。\n";
+						continue;
+					}
+					$user['realName'] = $user['userName'];
+					$user['growth'] = $user['integral'];
+					$insertUser = UserService::addUser($user);
+					$id = $user['id'];
+					Yii::$app->db2->createCommand("update xhUserOldData set `status`=1 where id={$id}")->execute();
+					echo "老客户导入生成userId:" . $insertUser['id'] . "\n";
 				}
-				$user['realName'] = $user['userName'];
-				$user['growth'] = $user['integral'];
-				$insertUser = UserService::addUser($user);
-				$id = $user['id'];
-				Yii::$app->db2->createCommand("update xhUserOldData set `status`=1 where id={$id}")->execute();
-				echo "老客户导入生成userId:" . $insertUser['id'] . "\n";
 			}
-		}
-		
-		//更新国兰的菜单分类
-		$sql = "truncate `xhCategory`;insert  into `xhCategory`(`id`,`parentId`,`merchantId`,`categoryName`,`description`,`img`,`goodsNum`,`sold`,`inTurn`,`status`) values (1,0,12358,'花束','唯美花束','',0,0,15,1),(2,0,12358,'花盒','时尚花盒','',0,0,14,1),(3,0,12358,'开业花篮','开业花篮','',0,0,0,1),(4,0,12358,'婚礼用花','婚礼用花','',0,0,0,1),(5,0,12358,'会议用花','会议用花','',0,0,0,1),(9,0,12358,'蝴蝶兰专区','蝴蝶兰','',0,0,4,1),(87,0,12358,'花篮','时尚礼篮','',0,0,4,1),(88,0,12358,'植物-微景观','植物-微景观','',0,0,4,1);";
-		Yii::$app->db->createCommand($sql)->execute();
-		
-		//更新国兰分类与商品对应关系
-		Yii::$app->db->createCommand("truncate `xhGoodsCategory`;")->execute();
-		$goodsCategory = Yii::$app->db2->createCommand('select * from `xhGoodsCategory` where `merchantId`=12358')->queryAll();
-		if (!empty($goodsCategory)) {
-			foreach ($goodsCategory as $val) {
-				$cId = $val['cId'];
-				$gId = $val['gId'];
-				$inTurn = $val['inTurn'];
-				$merchantId = $val['merchantId'];
-				GoodsCategoryService::add(['gId' => $gId, 'cId' => $cId, 'inTurn' => $inTurn, 'status' => 1, 'merchantId' => $merchantId]);
-				echo $cId . ' ' . $gId . "\n";
-				
+			
+			//更新国兰的菜单分类
+			$sql = "truncate `xhCategory`;insert  into `xhCategory`(`id`,`parentId`,`merchantId`,`categoryName`,`description`,`img`,`goodsNum`,`sold`,`inTurn`,`status`) values (1,0,12358,'花束','唯美花束','',0,0,15,1),(2,0,12358,'花盒','时尚花盒','',0,0,14,1),(3,0,12358,'开业花篮','开业花篮','',0,0,0,1),(4,0,12358,'婚礼用花','婚礼用花','',0,0,0,1),(5,0,12358,'会议用花','会议用花','',0,0,0,1),(9,0,12358,'蝴蝶兰专区','蝴蝶兰','',0,0,4,1),(87,0,12358,'花篮','时尚礼篮','',0,0,4,1),(88,0,12358,'植物-微景观','植物-微景观','',0,0,4,1);";
+			Yii::$app->db->createCommand($sql)->execute();
+			
+			//更新国兰分类与商品对应关系
+			Yii::$app->db->createCommand("truncate `xhGoodsCategory`;")->execute();
+			$goodsCategory = Yii::$app->db2->createCommand('select * from `xhGoodsCategory` where `merchantId`=12358')->queryAll();
+			if (!empty($goodsCategory)) {
+				foreach ($goodsCategory as $val) {
+					$cId = $val['cId'];
+					$gId = $val['gId'];
+					$inTurn = $val['inTurn'];
+					$merchantId = $val['merchantId'];
+					GoodsCategoryService::add(['gId' => $gId, 'cId' => $cId, 'inTurn' => $inTurn, 'status' => 1, 'merchantId' => $merchantId]);
+					echo $cId . ' ' . $gId . "\n";
+					
+				}
 			}
-		}
-		$goodsUsage = Yii::$app->db2->createCommand('select * from `xhGoodsUsage` where `merchantId`=12358')->queryAll();
-		if (!empty($goodsUsage)) {
-			foreach ($goodsUsage as $val) {
-				$usageId = $val['usageId'];
-				$goodsId = $val['goodsId'];
-				$inTurn = $val['inTurn'];
-				$merchantId = $val['merchantId'];
-				GoodsCategoryService::add(['gId' => $goodsId, 'cId' => $usageId, 'inTurn' => $inTurn, 'status' => 1, 'merchantId' => $merchantId]);
-				echo $usageId . ' ' . $goodsId . "\n";
+			$goodsUsage = Yii::$app->db2->createCommand('select * from `xhGoodsUsage` where `merchantId`=12358')->queryAll();
+			if (!empty($goodsUsage)) {
+				foreach ($goodsUsage as $val) {
+					$usageId = $val['usageId'];
+					$goodsId = $val['goodsId'];
+					$inTurn = $val['inTurn'];
+					$merchantId = $val['merchantId'];
+					GoodsCategoryService::add(['gId' => $goodsId, 'cId' => $usageId, 'inTurn' => $inTurn, 'status' => 1, 'merchantId' => $merchantId]);
+					echo $usageId . ' ' . $goodsId . "\n";
+				}
 			}
-		}
-		
-		//会员打折和会员等级要同步,要先导老客户 shish 2020.1.12
-		$merchantList = MerchantExtendService::getAllByCondition([], null, '*', 'merchantId');
-		$userAssetList = UserAssetService::getAllByCondition([], null, '*');
-		if (!empty($userAssetList)) {
-			foreach ($userAssetList as $asset) {
-				$id = $asset['userId'];
-				$merchantId = $asset['merchantId'];
-				$growth = $asset['growth'];
-				$currentMember = $asset['member'];
-				UserService::updateById($id, ['member' => $currentMember]);
-				if (!empty($merchantId) && isset($merchantList[$merchantId])) {
-					$extend = $merchantList[$merchantId];
-					if (!empty($extend)) {
-						$gradeList = MerchantExtendService::getGradeList($extend);
-						$member = null;
-						foreach ($gradeList as $grade) {
-							if ($grade['growth'] < $growth) {
-								$member = $grade['level'];
-								continue;
+			
+			//会员打折和会员等级要同步,要先导老客户 shish 2020.1.12
+			$merchantList = MerchantExtendService::getAllByCondition([], null, '*', 'merchantId');
+			$userAssetList = UserAssetService::getAllByCondition([], null, '*');
+			if (!empty($userAssetList)) {
+				foreach ($userAssetList as $asset) {
+					$id = $asset['userId'];
+					$merchantId = $asset['merchantId'];
+					$growth = $asset['growth'];
+					$currentMember = $asset['member'];
+					UserService::updateById($id, ['member' => $currentMember]);
+					if (!empty($merchantId) && isset($merchantList[$merchantId])) {
+						$extend = $merchantList[$merchantId];
+						if (!empty($extend)) {
+							$gradeList = MerchantExtendService::getGradeList($extend);
+							$member = null;
+							foreach ($gradeList as $grade) {
+								if ($grade['growth'] < $growth) {
+									$member = $grade['level'];
+									continue;
+								}
+							}
+							if (!empty($member)) {
+								UserAssetService::updateByUserId($id, ['member' => $member]);
+								UserService::updateById($id, ['member' => $member]);
+								echo '客户id:' . $id . '会员等级:' . $member . "已更新\n";
 							}
-						}
-						if (!empty($member)) {
-							UserAssetService::updateByUserId($id, ['member' => $member]);
-							UserService::updateById($id, ['member' => $member]);
-							echo '客户id:' . $id . '会员等级:' . $member . "已更新\n";
 						}
 					}
 				}
 			}
+			
+			//会员头像是否正确一致
+			$this->actionSyncAvatar();
+
+		} else {
+			//如果非生产环境则进行一些用户、公众号菜单等的初始化
+
+
 		}
-		
+
 		$sql = "ALTER TABLE xhGoods ADD `briefContent` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '简单内容介绍,移动端添加商品' AFTER `content`;";
 		Yii::$app->db->createCommand($sql)->execute();
 		
@@ -1069,13 +1071,13 @@ CREATE TABLE `xhStatViewMonth` (
 			Yii::$app->db->createCommand($sql)->execute();
 		}
 	}
-	
+
 	//重新拉取并保存国兰客户的头像和图片 shish 2020.1.12
 	public function actionSyncAvatar()
 	{
 		UserService::syncAvatar(12358);
 	}
-	
+
 	//可以重复初始化的一些东西 shish 2020.1.21
 	public function actionRepeatInit($id)
 	{
@@ -1083,5 +1085,5 @@ CREATE TABLE `xhStatViewMonth` (
 		$merchant = xhMerchantService::getById($id);
 		xhWxMenuService::applyInit($merchant);
 	}
-	
+
 }