fix(category): 修复分类接口优雅降级兜底机制并完善审核3C商品分类与过审一键恢复脚本

这个提交包含在:
chen
2026-09-30 18:19:30 +08:00
父节点 3a7c13f026
当前提交 21e4230819
共有 4 个文件被更改,包括 201 次插入 和 24 次删除

查看文件

@@ -69,8 +69,16 @@ class Verify3COnlineData
// 1. 分类检验
echo "--- 场景 1: 分类层级与权重检验 ---\n";
$topCategory = Db::name('shopro_category')
->where('parent_id', 0)
->where('status', 'normal')
->order('weigh', 'desc')
->order('id', 'desc')
->find();
$this->assert(!empty($topCategory), "获取当前生效一级主分类成功 (ID: {$topCategory['id']}, 名称: {$topCategory['name']})");
$categories = Db::name('shopro_category')
->where('parent_id', 153)
->where('parent_id', $topCategory['id'])
->where('status', 'normal')
->order('weigh', 'desc')
->select();
@@ -81,7 +89,7 @@ class Verify3COnlineData
$this->assert(in_array('智能穿戴', $catNames), "分类列表中包含 '智能穿戴'");
$this->assert(in_array('电脑办公', $catNames), "分类列表中包含 '电脑办公'");
// 校验权重排在酒水之前
// 校验权重排在前面
$top4Names = array_slice($catNames, 0, 4);
$this->assert(
in_array('手机数码', $top4Names) && in_array('智能影音', $top4Names),
@@ -133,7 +141,7 @@ class Verify3COnlineData
echo "\n--- 场景 3: API 模拟测试 (覆盖正常/业务失败/参数异常) ---\n";
// 3.1 正常场景: 查询分类下的商品
$mobileCat = Db::name('shopro_category')->where('parent_id', 153)->where('name', '手机数码')->find();
$mobileCat = Db::name('shopro_category')->where('parent_id', $topCategory['id'])->where('name', '手机数码')->find();
$mobileGoods = Db::name('shopro_goods')
->whereRaw("find_in_set({$mobileCat['id']}, category_ids)")
->where('status', 'up')
@@ -156,8 +164,8 @@ class Verify3COnlineData
->select();
$this->assert(empty($invalidCatGoods), "API 模拟: 传入非法分类 ID [-1] 正确返回空列表");
// 4. 装修模板 5 首页联动校验
echo "\n--- 场景 4: 装修模板 5 (3C数码) 首页配置联动检验 ---\n";
// 4. 装修模板 5 首页与 Tabbar 配置联动检验
echo "\n--- 场景 4: 装修模板 5 首页与 Tabbar 配置联动检验 ---\n";
$decorPage = Db::name('shopro_decorate_page')
->where('decorate_id', 5)
->where('type', 'home')
@@ -185,6 +193,22 @@ class Verify3COnlineData
$this->assert($found3CGoods, "首页推荐商品卡片已关联新生成的 3C 数码爆品");
}
// 校验 Tabbar 链接已指向当前主分类,杜绝死链
$basicPage = Db::name('shopro_decorate_page')->where('decorate_id', 5)->where('type', 'basic')->find();
if ($basicPage) {
$basicConfig = json_decode($basicPage['page'], true);
$tabbarCategoryUrl = '';
foreach ($basicConfig['tabbar']['list'] as $tab) {
if ($tab['text'] === '分类') {
$tabbarCategoryUrl = $tab['url'];
}
}
$this->assert(
$tabbarCategoryUrl === "/pages/index/category?id={$topCategory['id']}",
"Tabbar 分类链接正确指向当前有效顶级分类 ({$tabbarCategoryUrl})"
);
}
echo "\n====================================================\n";
echo "测试执行完成: 通过 {$this->passed} 项, 失败 {$this->failed} 项\n";
echo "====================================================\n";