db->createCommand($sql)->execute(); } if (!\has_column('cyy_goods', 'is_front_centralize')) { $sql = 'ALTER TABLE `cyy_goods` ADD COLUMN `is_front_centralize` tinyint(1) NULL DEFAULT 0 ;'; \Yii::$app->db->createCommand($sql)->execute(); } if (!\has_column('cyy_share_holder_profit_goods_log', 'is_switch')) { $sql = 'ALTER TABLE `cyy_share_holder_profit_goods_log` ADD COLUMN `is_switch` tinyint(1) NULL DEFAULT 0;'; \Yii::$app->db->createCommand($sql)->execute(); } if (!\has_column('cyy_goods', 'agent_goods_status')) { $sql = "ALTER TABLE `cyy_goods` ADD COLUMN `agent_goods_status` tinyint(1) NULL DEFAULT 0 COMMENT '是否是云仓代理配送产品(配送方式只能为到店自提或快递 如果是可上门安装则为快递 如果不上门安装则为到店自提 大于0表示是代理配送商品 2表示需要上门安装)'"; \Yii::$app->db->createCommand($sql)->execute(); } } // 用于更新腾讯地图key public static function UpdateQQMapKey($oldKey = '') { try { $file = 'index.20ae380b.js'; // 每次更新需要修改这个文件名 $defaultKey = 'CHIDIAN-QQ-MAP-KEY'; // 默认key if (\Yii::$app->isSaas()) { $key = Option::get('tencent_map_key', 0, 'saas', '')['value']; } else { $key = Option::get(OptionSetting::TENCENT_MAP_KEY, DEFAULT_STORE_ID, 'pay', Option::get(OptionSetting::TENCENT_MAP_KEY, DEFAULT_STORE_ID, 'store', '')['value'])['value']; } if (empty($key)) { return; } $dirPath = \Yii::$app->basePath . '/h5/static/js'; // if ($handle = opendir($dirPath)) { // while (false !== ($entry = readdir($handle))) { // // 检查文件名是否符合模式 index.xxx.js // if (preg_match('/^index\.[a-zA-Z0-9]+\.js$/', $entry)) { // $file = $entry; // break; // } // } // closedir($handle); // } if (!\file_exists($dirPath . '/' . $file)) { return; } $fileContext = file_get_contents($dirPath . '/' . $file); if (empty($oldKey)) { $oldKey = $key; } $fileContext = \str_replace([$defaultKey, $oldKey], [$key, $key], $fileContext); file_put_contents($dirPath . '/' . $file, $fileContext); } catch (\Throwable $e) { // Todo } } }