|
|
@@ -26,14 +26,15 @@ use yii\console\Controller;
|
|
|
|
|
|
class UpgradeController extends Controller
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
+ //执行脚本方式
|
|
|
// ./yii upgrade/init
|
|
|
public function actionInit()
|
|
|
{
|
|
|
if (getenv('YII_ENV') == 'dev') {
|
|
|
util::stop('开发环境不允许初始化');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//更新积分 shish 2019.11.22
|
|
|
$sql = "ALTER TABLE xhUserAsset ADD growth INT NOT NULL DEFAULT 0 COMMENT '成长值' AFTER `point`;";
|
|
|
$sql .= "UPDATE `xhUserAsset` SET `growth`=`integral`;";
|
|
|
@@ -943,110 +944,7 @@ CREATE TABLE `xhStatViewMonth` (
|
|
|
//删除收入来源数据统计的键名
|
|
|
$sql = "ALTER TABLE `xhStatIncomeSourceMonth` DROP INDEX `income`;";
|
|
|
Yii::$app->db->createCommand($sql)->execute();
|
|
|
-
|
|
|
- //继续执行
|
|
|
- $this->actionInit2();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public function actionInit2()
|
|
|
- {
|
|
|
- //更新管理员
|
|
|
- $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;
|
|
|
- }
|
|
|
- $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";
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- $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;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!empty($member)) {
|
|
|
- UserAssetService::updateByUserId($id, ['member' => $member]);
|
|
|
- UserService::updateById($id, ['member' => $member]);
|
|
|
- echo '客户id:' . $id . '会员等级:' . $member . "已更新\n";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //会员头像是否正确一致
|
|
|
- $this->actionSyncAvatar();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
$sql = "ALTER TABLE xhGoods ADD `briefContent` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '简单内容介绍,移动端添加商品' AFTER `content`;";
|
|
|
Yii::$app->db->createCommand($sql)->execute();
|
|
|
|
|
|
@@ -1149,19 +1047,104 @@ ALTER TABLE `xhCategory` ADD INDEX `merchant`(`merchantId`,`delStatus`);";
|
|
|
Yii::$app->db->createCommand($sql)->execute();
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- //重新拉取并保存国兰客户的头像和图片 shish 2020.1.12
|
|
|
- public function actionSyncAvatar()
|
|
|
+
|
|
|
+ //数据迁移 shish 2020.1.12
|
|
|
+ public function actionSync()
|
|
|
{
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+ $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";
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($member)) {
|
|
|
+ UserAssetService::updateByUserId($id, ['member' => $member]);
|
|
|
+ UserService::updateById($id, ['member' => $member]);
|
|
|
+ echo '客户id:' . $id . '会员等级:' . $member . "已更新\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
UserService::syncAvatar(12358);
|
|
|
}
|
|
|
-
|
|
|
- //可以重复初始化的一些东西 shish 2020.1.21
|
|
|
- public function actionRepeatInit($id)
|
|
|
+
|
|
|
+ //微信菜单初始化或重置,可以重复执行 ./yii upgrade/menu-init 12358 shish 2020.3.5
|
|
|
+ public function actionMenuInit($id)
|
|
|
{
|
|
|
- //初始化微信菜单
|
|
|
+ echo $id;die;
|
|
|
$merchant = xhMerchantService::getById($id);
|
|
|
xhWxMenuService::applyInit($merchant);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|