'down') * 2. 隐藏 3C 数码临时分类 (status => 'hidden') * 3. 恢复原本的实体业务商品 (莫高飞天、飞天盛世、驼奶粉、生物护肤品等) 为正常上架 (status => 'up') * 4. 恢复原本的商品分类权重 (恒链好物、好物品鉴等) * 5. 将生效装修模板一键无缝切回原有正式旗舰商城模板 (模板 2: 恒链数通 · 旗舰臻选) */ define('APP_PATH', __DIR__ . '/../application/'); define('ROOT_PATH', dirname(realpath(APP_PATH)) . '/'); require_once __DIR__ . '/../thinkphp/base.php'; require_once __DIR__ . '/../thinkphp/helper.php'; require_once __DIR__ . '/../application/common.php'; if (is_file(ROOT_PATH . '.env')) { $env = parse_ini_file(ROOT_PATH . '.env', true); foreach ($env as $key => $val) { $name = 'PHP_' . strtoupper($key); if (is_array($val)) { foreach ($val as $k => $v) { putenv("{$name}_" . strtoupper($k) . "={$v}"); } } else { putenv("{$name}={$val}"); } } } \think\Config::set(\think\Config::load(APP_PATH . 'config.php')); $dbConfig = [ 'type' => 'mysql', 'hostname' => '127.0.0.1', 'database' => 'henglianshutong', 'username' => 'henglianshutong', 'password' => 'henglianshutong', 'hostport' => '3306', 'prefix' => 'hla_', ]; \think\Config::set('database', $dbConfig); use think\Db; class RestoreAfterAudit { public function run() { echo "====================================================\n"; echo "开始执行小程序过审后业务一键恢复...\n"; echo "====================================================\n\n"; Db::startTrans(); try { $now = time(); // 1. 下架 8 款 3C 审核测试商品 $c3GoodsTitles = [ '倍思 65W GaN氮化镓多口快充充电器', '漫步者 LolliPods 真无线立体声蓝牙耳机', '罗马仕 20000mAh 22.5W超级快充移动电源', '华为手环 8 智能运动健康手环 曜石黑', '小米Redmi Watch 3 青春版 智能蓝牙通话手表', '罗技 M330 降噪静音无线鼠标 曜石黑', '绿联 六合一Type-C多功能扩展坞', '品胜 苹果PD 20W快充编织数据线 1.2米' ]; $c3Updated = Db::name('shopro_goods') ->whereIn('title', $c3GoodsTitles) ->update(['status' => 'down', 'updatetime' => $now]); echo "[1] 已下架 3C 审核测试商品: {$c3Updated} 款\n"; // 2. 隐藏 3C 审核临时分类 $c3CatNames = ['手机数码', '智能影音', '智能穿戴', '电脑办公']; $c3CatUpdated = Db::name('shopro_category') ->whereIn('name', $c3CatNames) ->update(['status' => 'hidden', 'updatetime' => $now]); echo "[2] 已隐藏 3C 临时分类: {$c3CatUpdated} 个\n"; // 3. 恢复原本的白酒、驼奶粉、护肤品等业务商品全部正常上架 $bizGoodsIds = [32, 33, 34, 35, 36, 37]; $bizGoodsList = Db::name('shopro_goods')->whereIn('id', $bizGoodsIds)->select(); $bizGoodsUpdated = 0; foreach ($bizGoodsList as $bg) { $cIds = explode(',', (string)$bg['category_ids']); if (!in_array('172', $cIds)) { array_unshift($cIds, '172'); } $newCIds = implode(',', array_unique(array_filter($cIds))); Db::name('shopro_goods')->where('id', $bg['id'])->update([ 'category_ids' => $newCIds, 'status' => 'up', 'deletetime' => null, 'updatetime' => $now ]); $bizGoodsUpdated++; } echo "[3] 已成功恢复原有核心业务商品正常上架 (莫高飞天、飞天盛世、驼奶粉等): {$bizGoodsUpdated} 款\n"; // 4. 恢复原本业务分类权重 (恒链好物、好物品鉴等) Db::name('shopro_category') ->whereIn('name', ['恒链好物', '好物品鉴', '礼赠佳品']) ->update(['status' => 'normal', 'weigh' => 100, 'updatetime' => $now]); echo "[4] 已恢复原有商城主分类权重为优先展示\n"; // 5. 切换生效模板为正式旗舰商城模板 (模板 2: 恒链数通 · 旗舰臻选) Db::name('shopro_decorate')->where('id', 5)->update(['status' => 'disabled', 'updatetime' => $now]); Db::name('shopro_decorate')->where('id', 2)->update(['status' => 'enable', 'deletetime' => null, 'updatetime' => $now]); // 确保模板 2 的 basic 页面 Tabbar 分类链接正确指向当前顶级分类 172 $t2Basic = Db::name('shopro_decorate_page')->where('decorate_id', 2)->where('type', 'basic')->find(); if ($t2Basic) { $t2Config = json_decode($t2Basic['page'], true); if (isset($t2Config['tabbar']['list']) && is_array($t2Config['tabbar']['list'])) { foreach ($t2Config['tabbar']['list'] as &$tab) { if (isset($tab['text']) && $tab['text'] === '分类') { $tab['url'] = "/pages/index/category?id=172"; } } unset($tab); Db::name('shopro_decorate_page')->where('id', $t2Basic['id'])->update([ 'page' => json_encode($t2Config, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ]); } } echo "[5] 已将启用模板从 [3C数码] 一键切换为正式模板 [恒链数通 · 旗舰臻选],并校验Tabbar链接正常\n"; Db::commit(); echo "\n====================================================\n"; echo "业务环境已完全恢复正常运行状态!\n"; echo "====================================================\n"; } catch (\Exception $e) { Db::rollback(); echo "\n[ERROR] 恢复失败: " . $e->getMessage() . "\n"; exit(1); } } } $task = new RestoreAfterAudit(); $task->run();