From fc07c2ece6ef06663b829f58d4f1a2943e534a4a Mon Sep 17 00:00:00 2001 From: Council Date: Tue, 21 Apr 2026 12:54:42 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=88=A0=E9=99=A4=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/plugins/vr_ticket/regenerate_spec.php | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 shopxo/app/plugins/vr_ticket/regenerate_spec.php diff --git a/shopxo/app/plugins/vr_ticket/regenerate_spec.php b/shopxo/app/plugins/vr_ticket/regenerate_spec.php deleted file mode 100644 index 3cf57cd..0000000 --- a/shopxo/app/plugins/vr_ticket/regenerate_spec.php +++ /dev/null @@ -1,111 +0,0 @@ - 'mysql', - 'connections' => [ - 'mysql' => [ - 'type' => 'mysql', - 'hostname' => '127.0.0.1', - 'hostport' => '10001', - 'database' => 'vrticket', - 'username' => 'root', - 'password' => 'shopxo_root_2024', - 'charset' => 'utf8mb4', - 'prefix' => 'vrt_', - ] - ] -]); - -$goodsId = 118; - -// 1. 读取商品配置 -$goods = Db::name('goods')->find($goodsId); -if (!$goods) { - echo "Goods {$goodsId} not found\n"; - exit(1); -} - -echo "Goods: {$goods['title']}\n"; -echo "Item type: {$goods['item_type']}\n"; - -// 2. 解析 vr_goods_config -$configData = $goods['spec_base'] ?? ''; -if (empty($configData)) { - echo "No spec_base found for goods {$goodsId}\n"; - exit(1); -} - -// 尝试解析 JSON(spec_base 可能是 JSON 字符串) -$configs = json_decode($configData, true); -if (json_last_error() !== JSON_ERROR_NONE || !is_array($configs)) { - echo "Invalid spec_base JSON for goods {$goodsId}\n"; - exit(1); -} - -echo "Found " . count($configs) . " config(s)\n"; - -// 3. 清空现有规格数据 -echo "Clearing existing spec data...\n"; -Db::name('GoodsSpecType')->where('goods_id', $goodsId)->delete(); -Db::name('GoodsSpecBase')->where('goods_id', $goodsId)->delete(); -Db::name('GoodsSpecValue')->where('goods_id', $goodsId)->delete(); - -// 4. 重新生成 SKU -foreach ($configs as $idx => $config) { - $templateId = intval($config['template_id'] ?? 0); - if ($templateId <= 0) { - echo "Skipping config {$idx}: no template_id\n"; - continue; - } - - $selectedRooms = $config['selected_rooms'] ?? []; - $selectedSections = $config['selected_sections'] ?? []; - $sessions = $config['sessions'] ?? []; - - echo "Generating SKU for template {$templateId}...\n"; - $result = SeatSkuService::BatchGenerate( - $goodsId, $templateId, - $selectedRooms, $selectedSections, $sessions - ); - - if ($result['code'] === 0) { - echo " Generated: {$result['data']['generated']} seats\n"; - } else { - echo " Error: {$result['msg']}\n"; - } -} - -// 5. 刷新商品基础信息 -echo "Refreshing goods base info...\n"; -SeatSkuService::refreshGoodsBase($goodsId); - -// 6. 验证结果 -$specCount = Db::name('GoodsSpecBase')->where('goods_id', $goodsId)->count(); -$valueCount = Db::name('GoodsSpecValue')->where('goods_id', $goodsId)->count(); -$typeCount = Db::name('GoodsSpecType')->where('goods_id', $goodsId)->count(); - -echo "\nDone!\n"; -echo "GoodsSpecBase: {$specCount}\n"; -echo "GoodsSpecValue: {$valueCount}\n"; -echo "GoodsSpecType: {$typeCount}\n"; - -// 7. 显示 sample 数据 -echo "\nSample GoodsSpecBase (first 3):\n"; -$sample = Db::name('GoodsSpecBase') - ->where('goods_id', $goodsId) - ->limit(3) - ->select() - ->toArray(); -foreach ($sample as $spec) { - echo " ID: {$spec['id']}, extends: {$spec['extends']}\n"; -}