metric_calibers 注册表,逻辑写死代码+门断言。LLM 只做咨询不进工作流。租户可自助注册→验证→子域自动签发→品牌开户(管道注册表驱动全链路自动)→项目/团队/计费自助;账户/品牌/国家/平台四维数据绝对隔离(第 5 节)。图 1-1 分层总图:请求自上而下过权限链落到模块端点与数据表;图 1-2 模块泳道:基座+9 模块各一条「页面→端点逻辑→数据」纵切,层与图 1-1 对齐;✔ = 09-26 A~D 批已修复项(见第 8 节表)
flowchart TB U["👤 用户层 · 三租户子域
zipforce / onno / fittinggoals.zipforcehub.com
角色三级: owner/admin(豁免员工授权·全活跃品牌)
member(需 user_modules 授权 + user_brands 圈定, 空=哨兵'-' 零可见)"] GW["🔒 网关层 · Caddy(mars)
子域路由 · on-demand TLS(只为 active 租户签发)
HTML 缓存(仅网关层) · admin off"] WEB["🖥 展示层 · web 容器 Next.js · 26 实页 · 导航 5 组 30 项
基座页(登录即得): 工作台/今日/排名/产品/映射/团队/计费/设置
报表=5页挂载卡片(工作台/财务/广告/库存/订单, 无独立路由·09-26勘误)
模块页(按 tenant_modules 门控渲染, 未开通不进导航):
sourcing·listings·ads+promotion·orders·finance+settlement+noon
logistics·inventory+po·collab(projects/documents/training/upload/feishu)·ai
本币+USD 双列 · ✔P2-8 导出全量 · ✔P2-2 chips双数 · ✔P3-4 取消态显式"] PCHAIN["🔑 权限链(每请求横切服务层, 五步)
① 子域 cookie → Redis sess 解析: 实时读角色/租户模块/员工授权/品牌范围
② 13 无会话端点自带鉴权: 注册流·价目·Stripe HMAC·MCP 密钥·internal 内网
③ require_module×9 双层: 租户开通(tenant_modules) AND 员工授权(user_modules)
④ adminOnly×41: owner/admin 专属(租户级)
⑤ brand_scope 横切 → RLS 落库(tenant_conn SET app.tenant_id + brand_scope)"] API["⚙ 服务层 · api 容器 FastAPI · 27 router
255 端点 = 201 模块/会话门控 + 41 adminOnly + 13 无会话
基座: dashboard/today/rankings/products/mapping/reports(38字段4域, 域门✔C)
业务: sourcing+verdicts · listing×23 · ads+promotion · orders
finance+settlement+noon · logistics+vnlin+yanwen · inventory_po+po
collab(pm/documents/training/upload/feishu) · ai×6(零写入)
管理: auth/org/onboarding/settings/billing/mcp/collab
✔P3-2 北京日切 · ✔P3-16 投稿审计"] DB[("🗄 数据层 · db 容器 Postgres saas_registry
public 121(源头镜像+注册表+会话表, 活体)
注册表群(唯一事实源): tenant_brands·tenant_modules·user_modules·user_brands
brands_source(管道) · marketplaces(amazon 19国+noon SA/AE) · platforms(amazon/noon=active, emag=planned)
metric_calibers 口径 10 行 · sku_mapping(成本权威) · collection_schedule(调度注册表, 2026-10-02)
audit 98 = cleaned_* 97 + dirty_data_log · RLS 键型 114 租户键+82 品牌键+23 全局无策略 ✔P3-5(未覆盖47→0) · ✔P3-13 cost对账门 · 逐表见 §11 附录C")] WK["🔁 异步层 · worker 容器(arq)
sync_mercury 每日 02:00/03:30(三分支 42 列对齐
回款口径统一 ✔A: onno 异常 526→245 · zf 848→868)
ads_import_pump 每分钟(Redis 锁+SKIP LOCKED)
clean_audit 原子换名 · daily_fx_rates 汇率锚"] RD[("⚡ Redis
会话 · AI日配额 · 幂等锁/任务锁")] MER["🛰 mercury 数据中台(104.194.81.222)
amazon_analytics 库 · 三品牌 schema + 视图
v_order_master / v_fg_order_finance / v_onno_unified"] VEN["🛰 venus 采集机(104.194.95.213)
onno/fg Sales · onno 断流 ES4d/FR5d/IT14d"] EXT["🌐 外部系统
亚马逊 SP-API · Amazon Ads API · Stripe
Vnlin 物流(两步下单+幂等校验 ✔B P2-4) · LLM 咨询(零写入) · 飞书"] U --> GW --> WEB --> PCHAIN --> API --> DB WK <--> DB API <--> RD WK <--> RD WK --> MER WK --> VEN API --> EXT classDef user fill:#eef0fe,stroke:#6366f1,color:#1e1b4b classDef app fill:#eef0fe,stroke:#6366f1,color:#1e1b4b classDef data fill:#e6f6f3,stroke:#0e9384,color:#134e4a classDef store fill:#f5f3ff,stroke:#7c3aed,color:#2e1065 classDef ext fill:#fdf3e7,stroke:#b45309,color:#451a03 class U,GW,WEB,PCHAIN,API user class WK data class DB,RD store class MER,VEN,EXT ext
flowchart LR
subgraph B0["🧭 基座(无键, 登录即得)"]
b1["📄 页面
/ · /today · /rankings · /products
/mapping · /team · /billing · /settings"] --> b2["⚙ 端点+逻辑
KPI 池 19 卡 · 趋势 81 图 · 今日实时盘
BSR 排名(LIMIT 60 显式标注✔D)
产品 30 天聚合 · 映射编辑(2000 上限预警✔D)
报表引擎(38 字段 4 域白名单, 域门✔C)"] --> b3["🗄 数据
amazon/noon 聚合 · BSR/关键词排名
sku_mapping(成本权威)"]
end
subgraph S1["🔍 sourcing"]
s1["📄 /sourcing"] --> s2["⚙ ABA 词库(9表)→候选池→keepa 快照
verdict 决策: advisory lock+幂等重放
AI 只建议不决策"] --> s3["🗄 sourcing 9 表
decision_audit 全审计"]
end
subgraph L1["📝 listing"]
l1["📄 /listings"] --> l2["⚙ 模板库→规则引擎文案→人工审
→SP-API 提交→事件回放(PT市场/bind-pt)"] --> l3["🗄 模板/事件表
23 端点全门控"]
end
subgraph A1["📣 ads"]
a1["📄 /ads · /promotion"] --> a2["⚙ 6 源矩阵(自动×2/手动×4)→队列
→pump 每分钟→UPSERT 后传胜
否词/分时/预算→决策台(幂等三件套)"] --> a3["🗄 ads_sku_daily
amazon/noon_ads_daily
投稿审计✔D"]
end
subgraph O1["🛒 orders"]
o1["📄 /orders"] --> o2["⚙ 三分支 42 列→清洗→状态五 tab
北京日切✔D · 取消态显式「—」✔D
取消单双拼写对齐✔D"] --> o3["🗄 cleaned_amazon_orders
(品牌键 RLS)"]
end
subgraph F1["💰 finance"]
f1["📄 /finance · /settlement · /noon"] --> f2["⚙ finance_monthly+noon PL 源表直读
回款三分支统一✔A·铃铛自愈(868=868/245=245)
成本权威=sku_mapping · cost 对账门✔D"] --> f3["🗄 finance_monthly
noon_sku_pl_monthly
metric_calibers 口径 10 行"]
end
subgraph G1["🚚 logistics"]
g1["📄 /logistics"] --> g2["⚙ 船票导入(UPSERT 幂等)→轨迹徽章
KPI 实时聚合自明细✔B
Vnlin 两步校验+幂等锁✔B · 燕文报价(as-of 已显)"] --> g3["🗄 shipments · 轨迹事件
报价表"]
end
subgraph I1["🏭 inventory"]
i1["📄 /inventory · /po"] --> i2["⚙ FBA 快照→健康(chips 双数✔C)
→预警(汇总吃国家✔D)→PO 状态机
→收货自动 GRN→台账(移动加权/红冲/盘点)
导出全量不截断✔B"] --> i3["🗄 FBA 快照 · po/grn · 台账"]
end
subgraph C1["🤝 collab"]
c1["📄 /projects · /documents
/training · /upload · /feishu"] --> c2["⚙ PM 产品/任务 CRUD→文档树协作
上传预览→确认两段式
数据浏览器敏感表黑名单✔D"] --> c3["🗄 pm_* · docs 表"]
end
subgraph N1["🤖 ai"]
n1["📄 /ai"] --> n2["⚙ 6 端点→llm_chat 纯咨询
租户日配额(默认 50/日)
未配置→503 显式不显 0"] --> n3["🗄 零业务表写入(铁律)"]
end
铁律:只查 rawdata→cleandata→api→web 四层;事实进注册表、口径写死代码、门断言防衰减
flowchart LR
subgraph SRC["① 源头层 mercury/venus"]
M["mercury 品牌视图
zf: v_order_master
fg: v_fg_order_finance_detail
onno: v_onno_orders_unified
✔A days_waiting/is_abnormal 三分支已统一"]
V["venus 采集落库
onno/fg Sales·广告报表
(ES/FR/IT 断流追踪中)"]
AU["自动通道
zf/fg Amazon Ads API
02:00 / 03:30"]
HU["手动通道 · 应用内上传
Amazon=zip · noon=单日xlsx+选国
预览→确认→按日+国整体替换"]
end
subgraph ING["② 同步层 worker"]
SY["sync_mercury · ingest_all
全量或定向(ADS_IMPORT_TARGETS)
_ORDERS_UNION 三分支合并对齐 42 列"]
PU["ads_import_pump · 每分钟
Redis 锁 + SKIP LOCKED 单任务
适配器解析 → UPSERT 后传胜"]
end
subgraph STO["③ 存储层 db"]
RM["public 镜像表(原始落地)"]
CL["audit 98 = cleaned_* 97 + dirty_data_log
clean_audit 全镜像+原子换名+RLS
✔P3-5 死镜像补RLS · 逐表见 §11 附录C"]
end
subgraph SVC["④ 服务层 api"]
EP["口径写死 SQL · 对齐 metric_calibers 10 行
RLS: tenant_conn SET app.tenant_id + brand_scope
✔P2-5 reports 白名单引擎已按域挂门"]
end
subgraph UIS["⑤ 展示层 web"]
PG["KPI/表格/图表 · 双币列 · 空态显式
✔P2-2 chips在库/在管双数
✔P2-3 物流KPI实时聚合 · ✔P2-8 导出全量(t3 8809行)"]
end
M --> SY
V --> SY
AU --> PU
HU --> PU
SY --> RM
PU --> RM
RM --> CL
CL --> EP
EP --> PG
| 流 | 路径 | 口径要点 |
|---|---|---|
| 订单→回款 | mercury 三视图 → _ORDERS_UNION 42 列对齐 → cleaned_amazon_orders → /api/settlement · /api/orders → 回款页/订单页/铃铛 | ✔A(09-26 已统一):起点=coalesce(发货日,下单日)·一律要求未回款;onno 异常 526→245(实测=审计预测一字不差)、zf 848→868 统一口径,铃铛同源自愈 |
| 广告 6 源 | 自动(Ads API)/手动(上传)→ ads_imports 队列 → pump → 适配器 → 定向同步 2~3 张表 → clean → 重算按钮全 6 表 | 模式矩阵事实源=mars 采集 config.CAPABILITY;zf/amazon 自动·zf/noon 手动·fg/amazon 自动·fg/noon 无通道·onno 双手动 |
| 财务月度 | finance_monthly(AMZ 结算) + noon pl_monthly(对账单) → /api/finance 7 接口源表直读 → 财务页 | 成本权威=sku_mapping(2026-09-26 拍板「sku mapping是对的」后翻转);X2 采购价三处已全部对齐 ¥95(今日完成) |
九个模块咬合成一个闭环;箭头=业务先后,闭环=库存预警自动回到采购
flowchart LR SEL["🔍 选品 sourcing
✔29轮已审"] LIS["📝 listing 上架
SP-API 提交
✔门控23/23"] PO["📦 采购 /po
draft→submitted→confirmed
→in_transit→received
收货自动GRN入库"] SHP["🚚 物流 /logistics
轨迹·报价·Vnlin下单
✔P2-4 两步校验+幂等锁
✔P2-3 KPI实时聚合"] INV["🏭 库存 /inventory
FBA+FBN+单据台账
移动加权·红冲·盘点闭环
✔P2-2 chips双数 · ✔P2-8 导出全量"] ORD["🛒 订单 /orders
状态五tab·时间窗
✔P3-2 北京日切"] SET["💰 回款 /settlement
待回款/异常/已回款
✔A 三品牌统一口径"] FIN["📊 财务 /finance · /noon
月度毛利·全平台KPI墙
✔32轮已审"] ADS["📣 广告 /ads · /promotion
6源矩阵·否词·分时·决策台
✔G/④A已审"] WARN["⏰ 预警环
补货算法→下PO预填
顶栏铃铛4类"] SEL --> LIS --> PO --> SHP --> INV --> ORD --> SET --> FIN ADS -.驱动.-> ORD FIN -.复盘.-> ADS INV --> WARN --> PO
| 租户(子域) | 可见品牌(tenant_brands) | 模块开关(tenant_modules 9键) | 审计备注 |
|---|---|---|---|
| t1 zipforce(内部) | zipforce(active);fittingirls/onno(inactive) | 9 键全 true(09-26 listing 曾被误触关闭,同日经计费台接口重开,留审计) | 库存可见 139 行;回款异常 868(A 批统一口径后实测) |
| t2 onno(内部) | onno + brainnews(均 active) | 9 键全 true | 库存 10 行;onno 异常 526→245(A 批修复实测=预测) |
| t3 fittinggoals(真实客户) | fittingirls(active) | 9 键全 true | 库存 8809 行 → P2-8 导出丢 3809 行的实际受害者 |
RLS 双键(活体 219 表逐表实证,见 §11 附录C):114 张 tenant_id 键;82 张品牌键——amazon_orders / logistics_shipments / noon_orders / sku_mapping 等无 tenant_id 列的表走 brand ∈ 租户活跃品牌 ∩ brand_scope 等效隔离;23 张无策略=全局参考表及其镜像。四维隔离=账户/品牌/国家/平台,LLM 不进任何工作流。
租户从注册到品牌开户到团队计费的完整自助链;国家/平台是全局注册表(运营方管理,emag 已 planned 排队)
flowchart LR A["📝 自助注册 /register
注册开关 registration-status
(展示+403 硬门双层)"] A --> B["📧 邮箱验证 /verify
24h token · 可重发"] B --> C["🌐 子域自动签发
Caddy on-demand TLS ask
只为 active 租户发证书"] C --> D["🏛 品牌开户 /onboarding
一个事务 · 幂等:
品牌授权 tenant_brands
+ 管道注册 brands_source
+ 站点校验(platforms×marketplaces)
+ 默认仓种子 + 渠道登记"] D --> E["⚙ 管道自动装配
注册表驱动 · 新品牌一行
数据到位→全站自动带出"] E --> F["🏃 品牌运营
archive 停用可恢复
permanent 彻底删(两步·保留1活跃)
ShopConfigUpdated 事件
全停→租户调度自动暂停"] B --> G["👥 团队 /team
成员 CRUD · 角色分配"] B --> H["💳 计费 /billing
Stripe checkout · 模块开关 9 键"] I["📋 项目 /projects
产品·任务自助 CRUD"] -.经营并列.-> F
| 自主能力 | 入口 | 谁能操作 | 现状 |
|---|---|---|---|
| 租户注册 | /register → /verify | 任何人(注册开关控制) | ✓ 自助已上线 邮箱验证+子域 TLS 自动签发 |
| 添加品牌 | /onboarding 品牌开户(含管道注册/站点选择/默认仓/渠道)+ /api/tenant/brands | 租户 owner/admin(_require_admin=租户级角色) | ✓ 自助已上线 品牌名规则校验·幂等·审计全有 |
| 品牌停用/恢复/彻底删 | /api/tenant/brands DELETE(archive|permanent) / activate | 租户 owner/admin | ✓ 两步定稿(09-22) 停用可恢复;彻底删按依赖顺序清数+至少留 1 活跃品牌 |
| 添加项目 | /projects(产品+任务) | 团队成员 | ✓ 自助已上线 全 CRUD+审计 |
| 添加国家 | — | 平台运营方(DB 级) | 全局注册表 marketplaces:amazon 19 国 · noon SA/AE · emag RO/BG;租户开户时从中选择,不可自增 |
| 添加平台 | — | 平台运营方(DB 级) | 全局注册表 platforms:amazon/noon=active · emag=planned 排队;新平台=采集适配器+清洗+页面全套工程,非开关 |
| 维度 | 隔离机制 | 备注 |
|---|---|---|
| 🏢 账户(租户)间 | RLS 双键:每请求 tenant_conn SET app.tenant_id;多数表 tenant_id 键,orders/logistics 无租户列走品牌键;WITH CHECK 只能写本租户 | 绝对——跨租户探针三租户实测互不可见;21 张死镜像已补 RLS(✔D P3-5,未覆盖 47→0) |
| 🏷 品牌间 | 品牌键 RLS(brand ∈ 租户活跃品牌 ∩ 会话 brand_scope)+ API 显式品牌参数 | 绝对;跨品牌聚合仅审计基准等显式白名单场景 |
| 🌍 国家间 | country 数据字段 + 页面筛选;不做跨国聚合除非显式 | 数据级隔离;预警汇总吃国家=✔D P3-6 已修 |
| 🛒 平台间 | 表域分离(amazon_* 与 noon_* 两族表)+ reports 域白名单 + platform 字段校验 | 结构级隔离——amazon 花费不会算进 noon;新平台接入=新表族+新域 |
255 个 API 端点 = 201 模块/会话门控 + 41 adminOnly + 13 无会话(各有自带鉴权或设计公开);角色三级 × 模块 9 键 × 品牌范围三层叠加
flowchart TB BR["👤 浏览器请求(子域 cookie)
zipforce/onno/fittinggoals.zipforcehub.com"] SES["🎫 会话层 current_user
Redis sess:{sid} 解析 · users.status=active
实时读库: 角色/租户模块/员工授权/品牌范围
(管理员改授权下一请求即生效)"] G0["🔓 无会话 13 端点(各自带鉴权)
注册流5(开关注视+403硬门) · 计划页1
Stripe webhook(HMAC签名) · MCP(Bearer mk_*→sha256)
internal×5(X-Tenant-Id头+内网) · tenant/exists"] G1["🎫 会话门 current_user
基座页: 工作台/今日/排名/产品/映射
团队/计费/设置/报表引擎(域级另挂)"] G2["🧩 模块门 require_module×9 / require_module_any
双层: 租户开通 tenant_modules
AND 员工授权 user_modules(owner/admin豁免)
未开通→403 unpurchased · 未授权→403 forbidden"] G3["👑 adminOnly _require_admin ×41
owner/admin 角色专属(租户级)"] BS["🏷 品牌范围 brand_scope(横切所有门)
owner/admin=租户全部活跃品牌
员工=user_brands∩活跃品牌 · 零授权=哨兵'-'看不到任何品牌行"] RLS["🔒 RLS 落库(tenant_conn 每请求 SET app.tenant_id+brand_scope)
键1 tenant_id / 键2 brand∈活跃∩scope · WITH CHECK 防跨写"] BR --> SES SES -->|无会话端点| G0 SES -->|基座| G1 SES -->|模块端点| G2 SES -->|管理端点| G3 G1 --> BS G2 --> BS G3 --> BS BS --> RLS classDef gate fill:#eef0fe,stroke:#6366f1,color:#1e1b4b classDef store fill:#f5f3ff,stroke:#7c3aed,color:#2e1065 class G0,G1,G2,G3 gate class SES,BS,RLS store class BR gate
| 角色 | 来源 | 模块门 | 管理面(adminOnly 41) | 品牌范围 |
|---|---|---|---|---|
| owner | 注册/开户创建 | 随租户开通全通行 | ✓ 全部 | 全部活跃品牌 |
| admin | 团队页授予 | 随租户开通全通行 | ✓ 全部 | 全部活跃品牌 |
| member | 团队页邀请 | 需逐模块授权(user_modules) | ✗(仅自己档案/会话管理) | user_brands 圈定(空=看不到任何品牌) |
模块开关(tenant_modules 9键)是租户级计费决策,员工授权(user_modules)是租户内再分配——两层独立,先开后授。
| 端点群 | 鉴权方式 | 定性 |
|---|---|---|
| auth 注册流×5(register/verify/resend/registration-status/tenant-exists) | 注册开关+24h token | 设计公开SaaS 入口 |
| /api/billing/plans | 无(价目表) | 设计公开无敏感数据 |
| /api/billing/webhook | Stripe HMAC 签名校验 | 签名即鉴权 |
| /mcp | Bearer mk_* → mcp_keys.sha256 → RLS | 密钥即鉴权四维隔离不下放 LLM |
| /internal/api/v1/* ×5 | X-Tenant-Id 头+内网通道 | 内部通道mercury 侧回读 |
| 路由器 | 数 | 管什么 | 路由器 | 数 | 管什么 |
|---|---|---|---|---|---|
| settings | 6 | 系统设置/参数 | org(团队) | 5 | 成员 CRUD/角色分配/邀请 |
| auth | 4 | 会话管理/互踢/档案 | onboarding | 4 | 品牌开户/管道注册 |
| listing | 4 | 模板/批量操作 | collab | 3 | 数据浏览器/敏感表黑名单 |
| mcp | 3 | MCP 密钥管理 | ads | 3 | 广告配置/规则 |
| billing | 1 | 计费台(模块开关) | verdicts/settings 等 | 8 | 决策审计/杂项 |
会话细节:每子域独立 cookie;Redis sess:{sid} + sess_user:{slug}:{uid} 双键,互踢=revoke-other-sessions;TOTP 2FA 端点已除役(2026-09-26 D批P3-11——只写标志登录不校验=假信号,真 2FA 挑战流挂账)。
第 3 节看闭环咬合,本节逐模块展开:页面 → 端点群 → 数据流 → 关键护栏;所有模块同受第 6 节权限层横切
| 模块(9键) | 页面 | 业务流(输入→处理→输出) | 关键护栏 |
|---|---|---|---|
| 基座(无键,登录即得) | / · /today · /rankings · /products · /mapping · /team · /billing · /settings | 工作台KPI池81图→今日实时盘→BSR排名(前60标注D批)→产品30天聚合→SKU映射编辑(2000上限预警D批)→团队→计费台→设置→自定义报表卡片(工作台/财务/广告/库存/订单 5 页挂载, 38字段4域白名单, C批按域挂门) | 会话+RLS+brand_scope 横切; 排名 LIMIT60 显式标注; 映射分支守卫防串品牌 |
| sourcing 选品情报 | /sourcing | ABA 词库(9表)→候选池→keepa 快照→verdict 决策(advisory lock+幂等重放表)→ verdict 落库 → 转入 listing/products | 决策全审计(sourcing_decision_audit); 幂等键16-128字符; AI 只做建议不做决策 |
| listing Listing工作台 | /listings | 模板库→生成文案(规则引擎)→人工审→approve→SP-API 提交→事件回放(events)→PT 市场/bind-pt 关联 | 23/23 端点全门控; 提交前人工审批强制; 事件全审计 |
| ads 广告与推广 | /ads · /promotion | 6源矩阵(自动 Ads API×2 / 手动上传×4)→ads_imports 队列→pump 每分钟(Redis锁+SKIP LOCKED)→适配器→UPSERT 后传胜→否词/分时/预算规则→决策台执行(X-Idempotency-Key+重放表)→投稿记录(promotion, D批补审计) | 上传预览→确认两段式; 按日+国整体替换; 决策幂等三件套; 投稿审计 |
| orders 订单 | /orders | 三分支合并 42 列(zf/fg/onno)→清洗→状态五tab→搜索/筛选→导出; 取消单显式「—」(D批 P3-4) | 北京时区日切(D批 P3-2); 取消双拼写对齐(P3-1); 时间窗可调 |
| finance 财务 | /finance · /settlement · /noon | finance_monthly(AMZ结算)+noon pl_monthly(对账单) 源表直读 7 接口→月度毛利矩阵→全平台 KPI 墙; 回款跟踪: 三分支统一口径(A批 P1-1)待回款/异常>14天/已回款→铃铛自愈; noon 全平台视图 | 成本权威=sku_mapping(cost对账门 D批 P3-13); 汇率锚定 registry#6; 本币+USD 双列 |
| logistics 物流 | /logistics | 船票导入(列名映射+UPSERT幂等)→轨迹事件→徽章(TRANSIT/DELIVERED/EXCEPTION/CUSTOMS/AWAITING)→KPI 实时聚合自明细(B批 P2-3)→Vnlin 两步下单(B2B+箱单, 幂等锁+两步校验 B批 P2-4)→燕文报价(2026-08-08 版, as-of 已显) | 导入重复上传幂等; 下单 10 分钟同参防双击; 箱单失败显式 502 带单号 |
| inventory 进销存 | /inventory · /po | FBA 快照每日 ingest→清洗→健康页(国家 chips 在库/在管双数 C批)→补货预警(35/90天覆盖线, 汇总吃国家 D批 P3-6)→下PO(prefill 联动)→PO 状态机 draft→received→收货自动 GRN 入库→单据台账(移动加权/红冲/盘点)→FBN noon 库存 | 预警汇总与明细同参; PO 在途关联带市场维(P3-7); 导出动态翻页不截断(P2-8); 台账红冲可逆 |
| collab 文档协作 | /projects · /documents · /training · /upload · /feishu | PM 产品/任务 CRUD→文档节点树协作→培训材料→上传中心(预览→确认)→飞书集成 | 数据浏览器敏感表黑名单 11 张(D批 P3-15 刷新: 凭证/计费身份全拦) |
| ai AI 助手 | /ai | 6 端点→llm_chat 咨询(选品建议/文案/答疑)→Redis 按租户日配额(默认50/日)→纯文本返回 | 零业务表写入(铁律); 未配置 LLM→503 显式「未配置」不显 0 |
完整证据链见 audit-fullstack-2026-09-26.md;本表=一图速览
| 级 | 编号 | 落位(层·页·文件) | 一句话问题 | 批次 |
|---|---|---|---|---|
| P1 | P1-1 | 同步层 sync_mercury.py 三分支 → 回款页/订单页/铃铛 | 「回款异常>14天」三品牌三种口径:onno 不看回款状态(虚高2.15×)、zf 起点用数据更新时间、同列三义 | ✔A(09-26 落地) |
| P2 | P2-8 | 展示层 /inventory 导出 | 导出循环 5000 行上限静默截断,t3 实测丢 3809 行(43%) | ✔B(09-26 落地) |
| P2 | P2-3 | 数据层 logistics_stats → /logistics KPI | KPI 快照停 09-05,手动导入只刷明细不刷 stats;t2/t3 无 stats 行 KPI 空无说明 | ✔B(09-26 落地) |
| P2 | P2-4 | 服务层 logistics.py Vnlin 两步下单 | 第二步箱单失败仍返回成功;无幂等(双击=两笔真实运单) | ✔B(09-26 落地) |
| P2 | P2-2 | 服务+展示 /inventory 国家chips | 计数=上架行数、文案=有库存数(stocked 字段前端从未用,US 虚高5.25×) | ✔C(09-26 落地) |
| P2 | P2-5 | 服务层 reports.py 8 端点 | 自定义图表引擎无模块门,可跨模块拉数据(当前无受害=潜伏) | ✔C(09-26 落地) |
| P2 | P2-1 | 展示层 /settlement 注记 | 「历史快照固化」表述失实(随 P1-1 一并修) | ✔A(09-26 落地) |
| P3 | 16 项 | 分散 8 文件 | UTC日切×2 · 取消单双拼写 · onno状态中文空 · 取消页$0 · 21死镜像 · 预警不吃国家 · PO在途无国家 · 报价无截至 · rankings前60无标注 · MFA孤儿 · 粘贴2000上限 · cost副本无断言 · 注释漂移 · 表黑名单陈旧 · 投稿无审计 · billing死条目 | ✔D(09-26 落地, P3-9 实证已满足/P3-3 顺手在A批) |
另有 6 条疑似经实证撤销(RLS 装饰性/mapping 与 promotion 无审计/注入可达/webhook 笔误致害/截断归因 zf)——撤销留痕见审计报告 §6.3。
成本美元=cost_rmb/6.7963;利润率=(price−cost/6.7963−0.12·price)/price×100,0.12=平台佣金近似。
实测:onno 异常 526→245(=预测一字不差)、zf 848→868 统一口径;铃铛同源自愈(双租户 868=868 / 245=245 实证)。
销速取 90 天窗;下 PO 预填联动 /po?prefill=。✔D P3-6 汇总吃国家、P3-7 关联带市场维。
mercury 采购表退居镜像;X2 三处已对齐 95(mercury 40→95 今日执行,sku_mapping 本就 95,UI 不变)。✔D P3-13 cost 对账门已立(dashboard_audit)。
listing 23/23、ai 6/6、业务端点全覆盖;模块开关=用户数据决策,403 非回归不擅翻。/promotion 挂 ads、/po 挂 inventory、/settlement+/noon 挂 finance。
API 每请求 tenant_conn 注入;四维=账户/品牌/国家/平台。21 张死镜像已补 RLS(✔D P3-5)。
广告上传/重算/PO 收货自动 GRN 全幂等;Vnlin 下单护栏已补齐(✔B P2-4 幂等锁+两步校验)。
Redis 按租户日配额(默认50);未配置 LLM → 503 显式「未配置」,不显示误导性 0。
从注册到终态的总流程 → 数据管道横切 → 基座权限链 → 九模块流程 · 每步四要素:入口·触发 / 函数·端点 / 写表·产物 / 护栏 · 本节=流程视角,与 §1~§9 结构视角互补
auth.py / onboarding.py / org.py / billing.py 逐函数实据 · 虚线=守卫判定 · 圆柱=落表
flowchart TD
subgraph SG0["0 · 入口探测"]
A0["访客打开注册页 /register"] --> A1{"GET /api/auth/registration-status
注册开关开?"}
A1 -->|"关→403 硬门"| A9["拒绝注册(前端也隐藏入口)"]
A1 -->|"开"| A2{"GET /api/tenant/exists
子域占用?"}
A2 -->|"已占"| A9
A2 -->|"可用"| B0
end
subgraph SG1["1 · 注册与验证 auth.py::register/verify"]
B0["POST /api/auth/register
register( )"] --> B1{"一次性邮箱域?
DISPOSABLE_DOMAINS"}
B1 -->|"是"| A9
B1 -->|"否"| B2{"同邮箱 pending 租户?
_pending_tenant_for( )"}
B2 -->|"有→复用"| B3
B2 -->|"无"| B3["INSERT tenants
status=pending_verification
slug=公司名+hex(2)"]
B3 --> B4["提交租户后另开租户连接:
INSERT users role=owner scrypt 加密
INSERT tenant_brands slug 占位行
INSERT tenant_modules 默认模块"]
B4 --> B5["_issue_signup_token
Redis signup:token (24h)
_send_verification_email"]
B5 --> C0{"GET /api/auth/verify?token"}
C0 -->|"无效/过期"| C1["POST /api/auth/resend 重发"]
C1 --> C0
C0 -->|"有效"| C2["UPDATE tenants
SET status=active"]
end
subgraph SG2["2 · 子域与登录"]
C2 --> D0["Caddy on-demand TLS
ask 端点只为 active 租户签发
slug.zipforcehub.com"]
D0 --> D1{"POST /api/auth/login
users.status=active 且 scrypt 通过?"}
D1 -->|"失败"| D2["audit login.failure
不设会话"]
D1 -->|"通过"| D3["audit login.success
UPDATE last_login_at
set_cookie zf_saas_slug
httponly·secure·lax·SESSION_TTL"]
end
subgraph SG3["3 · 每请求权限链 core.py::current_user(见 §10.3 五步)"]
D3 --> E0["权限链横切全部后续端点
模块门×2 层 + adminOnly×41 + brand_scope + RLS"]
end
subgraph SG4["4 · 开户装配 onboarding.py(一个事务)"]
E0 --> F0{"POST /api/onboarding/brand
platforms WHERE status=active?"}
F0 -->|"校验过"| F1["单事务四写:
tenant_brands 授权 + brands_source 管道注册
+ inv_warehouses 主仓种子 + brand_channels 渠道"]
F1 --> F2["POST /api/onboarding/category
product_categories UPSERT"]
F2 --> F3["POST /api/onboarding/skus
sku_mapping + products UPSERT"]
F3 --> F4["后续 ingest/clean 自动带出新品牌
(brands_source.source_map 驱动, 零手工)"]
end
subgraph SG5["5 · 组织与计费"]
F4 --> G0["POST /api/team/users 建成员
role+user_modules+user_brands 授权
改授权即 _revoke_user_sessions 撤会话"]
G0 --> G1["POST /api/billing/checkout→Stripe
webhook HMAC 手工验签
completed→改 plan+billing_events
canceled/unpaid→降 trial"]
end
subgraph SG6["6 · 日常运营闭环(§10.4~§10.12 九模块)"]
G1 --> H0["数据管道(§10.2)持续供数 → 九模块日常运营
→ 预警回环(铃铛/邮件报警)"]
end
subgraph SG7["7 · 品牌与租户终态 auth.py"]
H0 --> I0{"品牌处置 DELETE /api/tenant/brands"}
I0 -->|"archive 默认"| I1["is_active=false 归档可恢复
保底 ≥1 活跃品牌
全停自动暂停调度②C·A4"]
I0 -->|"permanent 二次确认"| I2["级联清理 7 表:
cleaned_amazon_orders·sales_daily
·inventory_health·products·sku_mapping
·user_brands·tenant_brands"]
I1 --> J0["成员停用: users.status=disabled
→ _revoke_user_sessions 立即下线"]
I2 --> J0
end
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
classDef io fill:#eef0fe,stroke:#4f46e5,color:#101319
class A1,A2,B1,B2,C0,D1,F0,I0 guard
class B3,B4,F1,F2,F3 io
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 注册开关探测 | 访客 /register | GET /api/auth/registration-status registration_status | 无(读配置) | 双层:API 403 硬门 + 前端隐藏入口 |
| 2 | 子域占用探测 | 注册页输公司名 | GET /api/tenant/exists tenant_exists | 无 | 占用即拒绝,slug 冲突前置拦截 |
| 3 | 注册建租户 | 提交注册表单 | POST /api/auth/register register | tenants(pending_verification) + users(owner·scrypt) + tenant_brands(slug占位) + tenant_modules(默认) | 一次性邮箱域黑名单 · pending 查重复用 · 租户先提交再开租户连接写 RLS 表 |
| 4 | 邮件验证 | 点验证链接 | GET /api/auth/verify verify · POST /api/auth/resend | UPDATE tenants→active | Redis signup:token 24h · 仅 pending_verification 可转 active |
| 5 | 子域签发 | 验证通过后 | Caddy on-demand TLS ask | 证书 | 只为 active 租户签发 |
| 6 | 登录发会话 | {slug}.zipforcehub.com/login | POST /api/auth/login login | audit_log(login.success/failure) · UPDATE last_login_at · cookie zf_saas_{slug} | status=active 且 scrypt 通过 · httponly/secure/lax · SESSION_TTL · 成功失败都审计 |
| 7 | 每请求权限链 | 全部 255 端点横切 | core.py current_user → require_module/_any → _require_admin | request.state(身份/模块/brand_scope) | 五步(§10.3 拆解)· 权限实时读库改授权下一请求生效 |
| 8 | 品牌开户装配 | owner /onboarding | POST /api/onboarding/brand onboarding_brand | tenant_brands + brands_source + inv_warehouses('MAIN') + brand_channels(一事务) | platforms active 校验 · ON CONFLICT 幂等可重放 · 后续管道自动带出 |
| 9 | 品类与 SKU 底座 | /onboarding 后续步 | POST /api/onboarding/category·/skus | product_categories + sku_mapping + products | ON CONFLICT UPSERT 幂等 |
| 10 | 建成员授权 | owner /team | POST /api/team/users team_user_create | users + user_modules + user_brands + audit_log | role 三级 · 改授权 _revoke_user_sessions 即撤会话 · 全审计 |
| 11 | 计费升配 | /billing | POST /api/billing/checkout→/billing/webhook | UPDATE tenants.plan + billing_events | HMAC 手工验签(不引 SDK) · canceled/unpaid→trial 自动降 |
| 12 | 品牌/成员终态 | /account 品牌管理 | PUT .../activate · DELETE /api/tenant/brands/{brand} · users.status=disabled | archive: is_active=false · permanent: 级联删 7 表 · 撤会话 | archive 保底 1 活跃 · 全停自动暂停调度 · 二次确认才 permanent · 停用即撤会话 |
tasks.py 27 cron + sync_mercury.ingest_all + tools/audit_clean_all.py 逐函数实据 · 源头 mercury/venus → mars 生产库
flowchart LR
subgraph SRC["源头层(不属本系统, 只读拉取)"]
M1[("mercury 104.194.81.222
fg v2 / zf / noon 库")]
M2[("venus 104.194.95.213
onno 源")]
end
subgraph COL["采集层 · mars worker cron(写源头库)"]
C1["collection_cycle 时:50
Amazon 订单独占"]
C2["collection_noon_orders 15min
+noon_deep/cycle_noon 6h"]
C3["collection_cycle_ads 05:00
槽位含 onno zip 手动通道"]
C4["collection_cycle_inventory 08:00
FBA 快照"]
C5["collection_finances_deep 周日03:20
45 天深窗兜底重拉"]
C6["sourcing_dispatcher_tick
宿主 crontab SSH mercury"]
end
subgraph ING["同步层 · ingest_mercury_daily 04:30 / weekly 六 02:00 全量 / today_incremental 每2h:43"]
I0["ingest_all(full_orders, tables)"] --> I1["_refresh_dynamic_specs
brands_source.source_map 驱动
品牌分支 SQL 动态拼装"]
I1 --> I2["逐表: qmercury 拉数 → _upsert
ON CONFLICT 后传胜"]
I2 --> I3{"单表失败?"}
I3 -->|"是"| I4["SAVEPOINT 回滚该表
错误进返回值, 不阻塞其余表"]
I3 -->|"否"| I5{"全量模式对账"}
I5 --> I6["orders: 键集临时表删幽灵行
sales_hourly: 60 天窗口对账"]
end
subgraph CLN["清洗层 · tools/audit_clean_all.run(原子换名, 表永远在线)"]
K1["每表构建 cleaned_新表
全列+标记列 issues/is_valid"] --> K2["_swap 原子换名
new→正名, 旧表→old"]
K2 --> K3["_grant_and_rls
ENABLE RLS+策略"] --> K4[("audit.cleaned_* 97
+ dirty_data_log 残账")]
end
subgraph SRV["服务层"]
S1["API tenant_conn
SET app.tenant_id + brand_scope"] --> S2[("RLS 双键过滤
114 tenant_id + 82 品牌键")]
S2 --> S3["web 页面/导出"]
end
M1 --> C1 & C2 & C3 & C4 & C5
M2 --> C3
C1 & C2 & C3 & C4 & C5 --> I0
I6 --> K1
K4 --> S1
subgraph ALM["每日报警护栏 06:15/06:20/06:30"]
L1["daily_pipe_alarm 泊松断流"]
L2["fee_coverage_alarm 费用覆盖
→ fee_backfill_targeted 定向回填"]
L3["source_drift_check 源漂移
(advertised_sku 断供案)"]
end
I6 -.-> L1 & L2 & L3
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class I3,I5 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | Amazon 订单采集 | cron 时:50 每小时 | collection_cycle | mercury 订单库 | 三期收编后独占(fg v2/onno 旧 cron 已停) |
| 2 | Noon 采集 | 15min 增量 + 6h 全量×2 | collection_noon_orders / noon_deep / cycle_noon | mercury noon 域 | UPSERT 幂等,双品牌 |
| 3 | 广告采集 | 每日 05:00 | collection_cycle_ads | mercury 广告域 | 槽位含 onno zip 手动通道(zip 08-31 停后改应用内上传,§10.4 手动流) |
| 4 | 库存/财务深拉 | 08:00 / 周日 03:20 | collection_cycle_inventory / collection_finances_deep | mercury FBA / 财务 | 45 天深窗覆盖结算周期 · UPSERT 键=order+sku+posted_date 零副作用 |
| 5 | 选品分发 | 每分钟 | sourcing_dispatcher_tick | mercury 选品域 | 容器无 SSH → 宿主 crontab 执行(worker 内占位) |
| 6 | 动态 spec 装配 | ingest_all 入口 | _refresh_dynamic_specs | finance_monthly/noon_* 动态 SQL | 注册表驱动:新品牌插 brands_source 一行全链路自动带出(唯一事实源) |
| 7 | 拉数 UPSERT | 04:30 日增 / 02:00 周全量 / 每2h:43 今日 | ingest_mercury_daily / weekly / ingest_today_incremental → ingest_all | public 121 源表 | SAVEPOINT 单表失败不阻塞 · ON CONFLICT 后传胜 · /ssh/222_key 缺失显式告警跳过 |
| 8 | 对账删除 | 仅全量模式 | ingest_all 内 orders 键集临时表 / _snapshot_reconcile | 删幽灵行 | 2026-09-21 修复版:本地键集对账(旧版内嵌 mercury 视图必报错) |
| 9 | 清洗原子换名 | ingest 后链式触发 | tools/audit_clean_all.run → _swap → _grant_and_rls → log_dirty | audit.cleaned_* 97 + dirty_data_log | RENAME 原子换名表永远在线 · ENABLE RLS+策略 · 残账进 dirty_data_log 可追溯 |
| 10 | 三报警护栏 | 06:15 / 06:20 / 06:30 | daily_pipe_alarm / fee_coverage_alarm / source_drift_check | 邮件报警 + fee_backfill_targeted | 泊松断流检测 · 费用覆盖触发定向回填 · 源表结构漂移比基线(缺列/改型=ALARM) |
| 11 | 辅助流 | 00:05 / 锚日更 / 常驻 | daily_usage_rollup(Redis→usage_daily 计费) · daily_fx_rates(锚定三币除外) · _handle_domain_event(Redis Streams 消费者组 ②C) | usage_daily / fx_rates | 全代码执行零 LLM |
core.py current_user 逐行拆解 · 无模块键,登录即得
flowchart TD R0["任意请求
cookie zf_saas_{slug}"] --> R1{"parse_token 有效?
uid+sid"} R1 -->|"否"| R9["401 not authenticated"] R1 -->|"是"| R2{"users 行存在
且 status=active?"} R2 -->|"否"| R9 R2 -->|"是"| R3["①身份: request.state.user
role 三级 owner/admin/member"] R3 --> R4["②租户模块: tenant_modules
WHERE enabled → 模块门第一层"] R4 --> R5{"员工?(非 owner/admin)"} R5 -->|"是"| R6["③员工授权: user_modules 授予集
④品牌范围: user_brands→CSV
零授权=哨兵 - (看不到任何品牌)"] R5 -->|"否"| R7["scope='' 不限"] R6 --> R8["⑤∩ tenant_brands is_active=true
停用品牌一次性全隐藏(09-22)"] R7 --> R8 R8 --> P1{"require_module(key)
端点声明哪层?"} P1 -->|"租户未开通"| P9["403 unpurchased(owner 也受限)"] P1 -->|"员工未授予"| P8["403 forbidden"] P1 -->|"通过"| P2{"函数体 _require_admin?"} P2 -->|"是且非 owner/admin"| P9 P2 -->|"通过"| P3["tenant_conn SET app.tenant_id
+ brand_scope → RLS 双键过滤 → 数据"] P3 --> W0["工作台读流: KPI 池 19 卡·81 图
/today 实时盘·BSR rankings(LIMIT 60 显式标注)
products 30 天·mapping 编辑·layout 偏好"] W0 --> W1["GET /api/notifications/summary
PO 在途 + settle_abnormal 同源铃铛"] classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319 class R1,R2,R5,P1,P2 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 会话解析 | 每请求 | core.py parse_token + current_user | request.state.sid/uid | Redis sess:{sid} 可撤(改授权/停用立即生效) |
| 2 | 身份与状态 | 每请求 | SELECT role,name,status FROM users | request.state.user | status≠active → 401 |
| 3 | 租户模块层 | 每请求 | SELECT tenant_modules WHERE enabled | request.state.tenant_modules | 模块门第一层:未开通 403 unpurchased |
| 4 | 员工双层授权 | member 角色 | user_modules + user_brands | grants + brand_scope | 零授权=哨兵 - 看不到任何品牌行 |
| 5 | 活跃品牌交集 | 每请求 | ∩ tenant_brands is_active | 最终 brand_scope | 停用品牌全页一次性隐藏 |
| 6 | adminOnly 判定 | 41 端点 | _require_admin(函数体内调用) | — | owner/admin 三级角色制 |
| 7 | RLS 落库 | 每个查询 | tenant_conn SET app.tenant_id | 219 表键型 114+82+23 | WITH CHECK 防跨租户写 |
| 8 | 工作台 KPI/图表 | / 首页 | dashboard.py 11 端点(filters/kpi/charts/today/merged-kpi/sku-sales) | 读聚合表 | KPI 卡偏好 PUT kpi-cards 按人存 |
| 9 | BSR 排名 | /rankings | rankings_list / history / markets | 读 rankings_daily | LIMIT 60 显式标注(✔D) |
| 10 | SKU 映射编辑 | /mapping | ops.py mapping_edit_save / import | sku_mapping | 粘贴 2000 行上限预警(✔D)· 分支守卫防串品牌 |
| 11 | 铃铛同源 | 全站右上角 | GET /api/notifications/summary | 读 cleaned_amazon_orders.is_abnormal + PO 在途 | 与 /api/settlement 同源 → 重跑自动对齐(868=868/245=245 实证) |
ads.py 41 端点 + tasks.py ads_import_pump/daily_ads_rules 逐函数实据
flowchart TD
subgraph IN["输入 · 6 源矩阵"]
N1["自动: Amazon Ads API ×2(zf/onno)"]
N2["手动: 应用内上传 ×4(含 onno zip 停后通道)"]
end
N2 --> U1{"POST /api/ads/upload/preview
两段式第一步"}
U1 -->|"解析预览"| U2{"POST /api/ads/upload
确认提交?"}
U2 --> U3["校验 brand ∈ 活跃品牌
INSERT ads_imports status=pending"]
N1 --> U3
U3 --> P1["ads_import_pump 每分钟
Redis 锁单实例 + SELECT FOR UPDATE SKIP LOCKED
认领一条 → status=running"]
P1 --> P2["适配器按 kind 解析
文件落投递目录(与 05:00 cron 同约定)"]
P2 --> P3{"成功?"}
P3 -->|"是"| P4["status=done + detail"]
P3 -->|"否"| P5["status=error + detail(可 recompute 重算)"]
P4 --> P6["手动流定向同步(09-26):
适配器写完 mercury 后
ingest_all(tables=[广告域])+清洗
不动订单域"]
P6 --> D1[("ads_sku_daily · amazon_ads_daily
noon_ads_daily · ads_keywords_daily")]
D1 --> R1["daily_ads_rules 05:40
三窗口 1d/7d/30d 零 LLM 规则
→ ads_recommendations 建议"]
R1 --> X0{"决策台人工执行
POST /execute"}
X0 --> X1["① 校验 X-Idempotency-Key 16-128 字符"]
X1 --> X2["② pg_advisory_xact_lock(hashtext(key))"]
X2 --> X3{"③ ads_decision_request 重放表
同 key 同 payload?"}
X3 -->|"同 hash"| X4["直接返缓存响应"]
X3 -->|"异 payload"| X5["409 拒绝"]
X3 -->|"新 key"| X6["④ 执行规则动作 → ⑤ ads_decision_audit 全审计
→ request COMPLETED/FAILED + 回写 recommendations"]
X6 --> F1["POST /api/ads/optlog/{id}/feedback
执行反馈回流"]
R1 -.->|"否词/分时/预算规则面"| NG["neg-keywords CRUD · rule-config · dayparting · keyword-bids"]
subgraph PROMO["推广投稿域"]
PR1["promo_tasks/channels/orders
KOL outreach + 分析"]
PR2["POST /api/promotion/submission
→ submissions 列表(✔D 补审计)"]
end
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class U1,U2,X0,X3 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 六源矩阵汇入 | 自动 cron + 手动上传 | collection_cycle_ads / ads_upload | mercury 广告域 | 自动×2 + 手动×4(onno zip 08-31 停 → 应用内通道) |
| 2 | 上传两段式 | /ads 上传页 | POST /api/ads/upload/preview → POST /api/ads/upload | ads_imports(pending) | 预览→确认,防误传 |
| 3 | 品牌校验 | upload 入口 | SELECT tenant_brands WHERE is_active | — | 非活跃品牌拒收 |
| 4 | 泵认领 | 每分钟 | ads_import_pump | ads_imports→running | Redis 锁单实例 + FOR UPDATE SKIP LOCKED 单任务(不双跑不漏跑) |
| 5 | 适配解析 | 认领后 | 按 kind 适配器 | mercury 广告表 + status=done/error | 失败 detail 落库可 recompute |
| 6 | 定向同步+清洗 | 手动流(09-26) | ingest_all(tables=[广告域]) → audit_clean_all | public/audit 广告表 | 只动广告域,订单/毛利回填等全量副作用跳过 |
| 7 | 日表入库 | 同步后 | _upsert ON CONFLICT | ads_sku_daily 等 4 日表 | 后传胜,按日+国整体替换 |
| 8 | 规则引擎生建议 | 每日 05:40 | daily_ads_rules | ads_recommendations | 三窗口 1d/7d/30d · 零 LLM 纯代码规则 |
| 9 | 决策执行幂等五件套 | 决策台点执行 | POST /api/ads/recommendations/{rid}/execute ads_recommendation_execute | ads_decision_request + ads_decision_audit + recommendations 回写 | Key 校验 16-128 → advisory_xact_lock → 重放表同 hash 返缓存/异 payload 409 → 执行 → 审计 |
| 10 | 反馈回流 | 执行后 | POST /api/ads/optlog/{log_id}/feedback | ads_optimization_log | 闭环:建议→执行→效果→下一轮规则 |
| 11 | 规则配置面 | /ads 配置页 | neg-keywords CRUD / rule-config / dayparting / keyword-bids | neg_keywords · ads_rule_config | rule_config 全局行 brand='' 放行(RLS 特例) |
| 12 | 推广投稿 | /promotion | promo_tasks/orders/kol/submission 16 端点 | promotion_* 9 表 | 投稿审计(✔D 补)· 订单 approve 流 |
ops.py orders_list + finance.py settlement_tracker + A 批统一口径实据
flowchart LR
subgraph IN["采集增量"]
A1["时:50 Amazon 订单"] --> A2["每2h:43 今日增量
(今日订单+小时销量)"]
end
A2 --> B1["ingest 三分支 UNION 42 列
zf / fg / onno 品牌分支"]
B1 --> B2[("public.amazon_orders
品牌键 RLS")]
B2 --> C1["清洗: 北京时区日切(✔D)
取消单双拼写对齐(✔D)"]
C1 --> C2[("audit.cleaned_amazon_orders
is_abnormal 回款标志")]
C2 --> D1{"GET /api/orders
五态 tab"}
D1 --> D2["全部/未发货/已发货
/Pending/取消(取消显式「—」)"]
D2 --> D3["搜索·国家·品牌筛选·导出"]
C2 --> E1["GET /api/settlement 回款跟踪
统一口径: days=now−coalesce(发货日,下单日)
且一律要求未回款(✔A)"]
E1 --> E2{"异常判定
days>14 且未回款?"}
E2 -->|"是"| E3["abnormal 计数
zf 868 / onno 245(实测)"]
E2 -->|"否"| E4["待回款/已回款分桶
onno 回款=订单金额入账推导"]
E3 --> F1["铃铛同源(§10.3 步 11)"]
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class D1,E2 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 采集与增量 | 时:50 + 每 2h | collection_cycle / ingest_today_incremental | mercury→public.amazon_orders | UPSERT 幂等 |
| 2 | 三分支合并 | ingest_all | 订单 spec UNION zf/fg/onno 42 列 | amazon_orders | 品牌分支由注册表驱动 |
| 3 | 清洗日切 | ingest 后 | audit_clean_all 订单清洗 | cleaned_amazon_orders | 北京时区日切(✔D P3-2)· 取消双拼写对齐(✔D P3-1) |
| 4 | 五态浏览 | /orders | GET /api/orders orders_list | 读 cleaned | 取消单显式「—」不显 0(✔D)· 时间窗可调 |
| 5 | 筛选导出 | /orders | orders_list 参数 | 导出文件 | 与列表同参 |
| 6 | 回款统一口径 | /settlement | GET /api/settlement settlement_tracker | 读 is_abnormal/is_settled | 三分支一字不差同口径(✔A):days=now−coalesce(发货日,下单日)·一律未回款 |
| 7 | onno 回款推导 | 同上 | 金额入账 COALESCE 链 | — | 回款信号=订单金额入账推导(无独立回款字段) |
| 8 | 异常分桶 | 同上 | is_abnormal 重算 | zf 868/onno 245(A 批实测) | 已回款 430 全非异常·取消 44 清零(=审计预测一字不差) |
| 9 | 铃铛同源 | 全站 | notifications_summary | — | 与 settlement 同源读 → 全量重跑自动对齐(868=868/245=245) |
sync_mercury 动态分支 + finance.py 12 端点 + metric_calibers 口径注册表
flowchart TD
subgraph SRC["源表构建(ingest 时动态拼装)"]
S1["_refresh_dynamic_specs:
finance_monthly = 各品牌分支 UNION
(finances_view 或 schema 分支)"]
S2["noon 域: noon_monthly·noon_sku_pl
·noon_statement·noon_procurement_cost
(嵌在 amazon 行的 zf noon + 独立 onno 行)"]
S1 --> S3[("public.finance_monthly · noon_* 品牌键 RLS")]
S2 --> S3
end
S3 --> C1[("audit.cleaned_finance_monthly
cleaned_monthly_pl 等")]
C1 --> R1{"finance.py 12 端点
源表直读(非二次加工)"}
R1 --> R2["summary/sku-profit/monthly/profit-matrix
kpi-wall/full/onno/noon-sku/noon-pnl/product-pl"]
R1 --> R3["GET /api/settlement 回款(§10.5)"]
R2 --> V1["口径裁决: metric_calibers 10 行
authoritative_source/fallback_source
成本权威=sku_mapping"]
V1 --> V2{"cost 对账门(✔D)
sku_mapping 与 cleaned 副本双有值?"}
V2 -->|"不等"| V3["FAIL 当天门拦截(X2 型单边改价)"]
V2 -->|"权威缺失"| V4["WARN 欠账提示(5 产品挂账)"]
V2 -->|"相等"| V5["放行"]
R2 --> FX["daily_fx_rates 日更
锚定 SAR 3.75 / AED 3.6725 锚定除外
本币+USD 双列"]
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class R1,V2 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 动态分支拼装 | ingest_all 入口 | _refresh_dynamic_specs | finance_monthly/noon_* 动态 SQL | brands_source.source_map 驱动——onno 漏数根因修复(09-18) |
| 2 | 源表入库 | 04:30/周日深拉 | ingest + collection_finances_deep 45 天 | finance_monthly + noon 4 表 | UPSERT 键=order+sku+posted_date |
| 3 | 清洗 | ingest 后 | audit_clean_all | cleaned_finance_monthly/monthly_pl 等 | 原子换名+RLS |
| 4 | 源表直读 12 端点 | /finance /noon /settlement | finance_summary/sku/monthly/matrix/kpi_wall/full/onno/noon_sku/noon_pnl/product_pl/settlement | 读 cleaned 源表 | 7 接口源表直读口径写死(09-18 改造,monthly 保留对账口径) |
| 5 | 口径注册表裁决 | 读数时 | metric_calibers 10 行 | — | authoritative/fallback 双源写死·拍板日留痕(唯一事实源) |
| 6 | 成本权威链 | ingest 全量尾部 | UPDATE products SET cost FROM sku_mapping | products.cost 兜底回填 | 权威=sku_mapping,products 只是镜像 |
| 7 | cost 对账门 | dashboard_audit 每跑 | 双有值必相等断言 | — | 不等=FAIL 拦截;权威缺失=WARN 欠账(S-988 Pro 等 5 产品挂账) |
| 8 | 汇率日更 | 每日 | daily_fx_rates + _FX_PEG | fx_rates | 锚定三币除外(SAR/AED 固定锚) |
| 9 | 本币双列 | 全部财务页 | _noon_usd 折算 | — | 本币+USD 双列呈现(09-18 框架) |
| 10 | 回款跟踪 | /settlement | settlement_tracker(§10.5 步 6~8) | — | 统一口径+铃铛同源 |
inventory_po.py + inv.py 25 端点逐函数实据
flowchart TD
A1["collection_cycle_inventory 08:00"] --> A2["ingest FBA 快照"] --> A3[("inventory_health
品牌键 RLS")]
A3 --> B1{"GET /api/inventory/health
国家 chips"}
B1 --> B2["chips 双数(✔C): 在库 SKU 数 / 在管行数
两数并列(不推翻 09-22 拍板)"]
A3 --> C1{"GET /api/inventory/alert
覆盖线判定"}
C1 --> C2["35/90 天覆盖线预警
汇总吃国家(✔D)·PO 在途带市场维(✔D)"]
C2 --> D1["POST /api/po/create
draft + items + total_cost_rmb
(prefill 预警联动)"]
D1 --> E1["POST /api/po/{pid}/status
draft→submitted→confirmed→in_transit"]
E1 --> F1{"POST /api/po/{pid}/receive
po_receive"}
F1 --> F2["qty_received=least(到货, 订购)
全部到齐→received 否则 in_transit"]
F2 --> G1["收货自动建 GRN 单据
POST /api/inv/docs"]
G1 --> H1{"POST /api/inv/docs/{did}/approve
过账"}
H1 --> I1[("inv_stock_ledger 台账
移动加权·红冲可逆·盘点 stocktake")]
I1 --> J1[("inv_stock_balance 余额
inv_doc_heads/items 单据")]
A3 --> K1["GET /api/inventory 导出
动态翻页(✔B) t3 实测 8809 行全量"]
subgraph FBN["FBN noon 域"]
N1[("noon_inventory 品牌键
/api/noon-inventory")]
end
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class B1,C1,F1,H1 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | FBA 快照采集 | 每日 08:00 | collection_cycle_inventory | mercury 库存域 | UPSERT 幂等 |
| 2 | 入库清洗 | 04:30 ingest | ingest_all → audit_clean_all | inventory_health(品牌键) | RLS 品牌键+brand_scope |
| 3 | 健康页 chips | /inventory | GET /api/inventory/health inventory_health | 读聚合 | 双数口径:主数=在库 SKU·/后=在管行数(✔C,33/259·US 4/21 实测) |
| 4 | 补货预警 | /inventory 预警区 | GET /api/inventory/alert inventory_alert | 预警清单 | 35/90 天覆盖线 · 汇总与明细同参吃国家(✔D P3-6) |
| 5 | 下 PO | /po | POST /api/po/create po_create | purchase_orders(draft)+items+total | po_no 服务端生成 hex(8) |
| 6 | PO 状态机 | /po 操作 | POST /api/po/{pid}/status po_status | status 流转 | draft→submitted→confirmed→in_transit→received 线性状态机 |
| 7 | 收货 | /po 收货 | POST /api/po/{pid}/receive po_receive | qty_received=least(...)·状态 | least 防超收 · 部分到货留 in_transit |
| 8 | GRN 单据 | 收货联动 | POST /api/inv/docs inv_doc_create | inv_doc_heads/items | 单据类型 GRN |
| 9 | 过账审批 | /inventory 台账 | POST /api/inv/docs/{did}/approve / cancel | inv_stock_ledger 流水 | approve 才过账 · cancel 红冲可逆 |
| 10 | 台账三能力 | /inventory | inv_ledger / inv_stock / inv_stocktake_plan | ledger+balance | 移动加权 · 红冲 · 盘点三件套 |
| 11 | 导出全量 | /inventory 导出 | inv_report 动态翻页 | 导出文件 | 动态翻页不截断(✔B:原丢 43%,t3 8809 行实测全量) |
| 12 | FBN noon 库存 | /noon | GET /api/noon-inventory | noon_inventory | 品牌键 RLS |
logistics.py 8 端点 + B 批两步校验/幂等锁实据
flowchart TD
subgraph IMP["船票导入"]
A1{"POST /api/logistics/shipments/import
上传船票文件"}
A1 --> A2["列名映射解析
ON CONFLICT (brand, awb) UPSERT"]
A2 --> A3[("logistics_shipments
品牌键 RLS")]
A3 --> A4["重复上传幂等(同键更新)"]
end
A3 --> B1["GET /api/logistics/shipments 列表
+ 轨迹事件流"]
B1 --> B2["徽章五态:
TRANSIT/DELIVERED/EXCEPTION
/CUSTOMS/AWAITING"]
B2 --> C1["KPI 实时聚合自 shipments 明细(✔B)
(旧 logistics_stats 快照 09-05 退役)"]
A3 --> D1["GET /api/logistics/pricing 燕文报价
2026-08-08 版·as-of 截至显式(✔D)"]
subgraph VNL["Vnlin 两步下单 B2B(✔B)"]
E0{"POST /api/logistics/create
logistics_create"}
E0 --> E1["指纹=完整下单体(含解析后地址)
Redis SET NX 10 分钟锁"]
E1 --> E2{"第一步 r1: POST OMS
/doubleClearance/create"}
E2 -->|"status 缺 orderId"| E9["502 显式报错(不下箱单)"]
E2 -->|"成功+orderId"| E3{"第二步 r2: POST OMS
/doubleClearance/packageBox"}
E3 -->|"box_ok"| E4["返回运单号·落库"]
E3 -->|"失败"| E5["502 显式失败带单号(✔B)"]
end
E1 -.->|"同指纹 10 分钟内"| E6["防双击: 两笔真实运单绝不允许"]
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class A1,E0,E2,E3 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 船票导入 | /logistics 导入 | POST /api/logistics/shipments/import logistics_shipments_import | logistics_shipments | 列名映射 + ON CONFLICT (brand,awb) UPSERT——重复上传幂等 |
| 2 | 列表与轨迹 | /logistics | GET /api/logistics/shipments | 读明细 | 品牌键 RLS |
| 3 | 徽章五态 | 列表渲染 | 前端按轨迹推导 | — | TRANSIT/DELIVERED/EXCEPTION/CUSTOMS/AWAITING |
| 4 | KPI 实时聚合 | /logistics KPI 区 | 列表端点内聚合 | 读 shipments 明细 | 实时聚合自明细(✔B P2-3),快照停更退役——t2/t3 不再空 |
| 5 | 报价查询 | 下单前 | GET /api/logistics/pricing + appendix | 读报价表 | 2026-08-08 版·截至时间显式标注(✔D) |
| 6 | 参数配置 | /logistics 设置 | params get/save | logistics_params | tenant_id RLS |
| 7 | 两步下单·指纹锁 | /logistics 下单 | POST /api/logistics/create logistics_create 第 1 段 | Redis 指纹键 | 完整下单体指纹 SET NX 10 分钟——同参双击直接拦(✔B P2-4) |
| 8 | 第一步 B2B | 锁通过后 | httpx POST /doubleClearance/create | orderId | 校验 status=true 且 orderId 存在,缺即 502 不进第二步 |
| 9 | 第二步箱单 | 第一步成功 | httpx POST /doubleClearance/packageBox | 运单+箱单 | box_ok 校验,失败显式 502 带单号(✔B——旧版假成功已修) |
verdicts.py + sourcing.py 18 端点逐函数实据
flowchart LR
A1[("ABA 词库 9 表
aba_* · radar ×6")] --> B0{"POST /api/sourcing/verdicts/materialize
verdicts_materialize"}
B0 --> B1["Redis 锁 10 分钟冷却
(429 带 TTL·force 需 owner/admin)"]
B1 --> C1["candidates 两级物化:
radar 高分 + term 词级
ON CONFLICT 幂等"]
C1 --> D1[("sourcing_candidates
sourcing_verdicts(machine_rec)")]
D1 --> E1["keepa_watch 播种
ON CONFLICT DO NOTHING"]
E1 --> F1["refresh_keepa_watch 05:10
watch 池刷新采集"]
F1 --> G1[("keepa_daily
watch_isolation RLS:
EXISTS 同租户同 ASIN")]
G1 --> H1["查询面: search/product/explorer
aba overview/chart/ledger/radar
keepa-history/watchlist"]
D1 --> I0{"POST /api/sourcing/verdicts/decision
verdicts_decision"}
I0 --> I1["SELECT ... FOR UPDATE 锁行"]
I1 --> I2["UPDATE state(进/杀/候补)
owner_uid·kill_reason"]
I2 --> I3[("sourcing_decision_audit
from/to/actor/evidence 全审计")]
I3 --> J1["通过候选 → 转入 listing(§10.10)
/ products 域"]
H1 -.-> K1["AI 辅助: POST /api/ai/sourcing
require_module_any(sourcing,ai)·只建议"]
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class B0,I0 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | ABA 词库供给 | aba_snapshot cron | 采集→ingest→clean | aba_* 9 表(tenant 键) | RLS tenant_id |
| 2 | 候选物化限频 | 手动触发 | POST /api/sourcing/verdicts/materialize verdicts_materialize | sourcing_candidates 两级 | 全表扫描重 → Redis 锁 10 分钟冷却 429 带 TTL;force 跳过需 owner/admin |
| 3 | verdict 初判 | 物化内 | 同上 | sourcing_verdicts(machine_rec) | 机器只出建议,state 由人改 |
| 4 | keepa 播种 | 物化内 | 同上 | keepa_watch | ON CONFLICT DO NOTHING 幂等 |
| 5 | watch 刷新 | 每日 05:10 | refresh_keepa_watch | keepa_daily + keepa_pull_log | token 消耗落 pull_log 可审计 |
| 6 | watch 隔离 | 读 keepa_daily | RLS watch_isolation | — | EXISTS 同租户同 ASIN 同 domain——租户只看自己 watch 池价格 |
| 7 | 查询面 | /sourcing | search/product/explorer/explore/aba 4 端点/radar/keepa-history/watchlist | 读各表 | require_module(sourcing) |
| 8 | 人工决策 | 决策台 | POST /api/sourcing/verdicts/decision verdicts_decision | UPDATE verdicts + decision_audit | FOR UPDATE 行锁防并发双改 · from/to/actor/evidence 全审计 |
| 9 | 决策审计回看 | 审计页 | pareto/candidates/legacy 查询 | 读 audit 表 | 决策可回溯(谁在何时凭何证据) |
| 10 | AI 只建议 | /ai 联动 | POST /api/ai/sourcing | 无业务表写入 | require_module_any(sourcing,ai) 开源流(F3-6)· LLM 不决策铁律 |
listing.py 23 端点全门控逐函数实据
flowchart TD A1["POST /api/listing/specs
upload_spec 规格上传
(或 models/spec 按型号)"] --> A2["GET skus-by-model
型号聚合取 SKU"] A2 --> B1["POST /api/listing/tasks
create_task → draft"] B1 --> C1{"POST /{tid}/generate
规则引擎生成文案
仅 draft/failed 可生成"} C1 -->|"ready 状态"| C9["409 请先撤回"] C1 -->|"生成"| C2["title/bullets/description/attrs
写入 task"] C2 --> D1["PUT /{tid} edit_task 人工改稿"] D1 --> E1{"POST /{tid}/approve
人工审批(仅 draft→ready)"} E1 -->|"非 draft"| E9["409 拒绝"] E1 -->|"批准"| E2["status=ready
approved_by+approved_at 留痕"] E2 --> F1{"POST /{tid}/submit
仅 ready 可提交"} F1 -->|"其他状态"| F9["409 不可提交"] F1 -->|"提交"| F2["SP-API 推送 Amazon"] F2 --> G1["POST /import_results 回填结果"] G1 --> H1[("listing_events 全事件审计
tasks 状态推进")] B1 -.->|"撤回"| I1["POST /{tid}/revert ready→draft"] subgraph PT["PTEX 市场域"] P1["pt-search/pt-schema/pt-markets 查询"] P2{"POST /{tid}/bind_pt 绑定
仅 draft/failed"} P2 --> P3[("listing_category_meta
brand+market+product_type")] end J1["batch 批量 + health 健康检查
+ export 导出"] classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319 class C1,E1,F1,P2 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 规格上传 | /listings 规格页 | POST /api/listing/specs upload_spec / upload_spec_model | listing_specs(品牌键) | ON CONFLICT 幂等 |
| 2 | 建任务 | 选型号 | POST /api/listing/tasks create_task | listing_tasks(draft) | 23/23 端点全门控 require_module(listing) |
| 3 | 规则引擎生成 | 任务页生成 | POST /{tid}/generate generate | title/bullets/desc/attrs | 仅 draft/failed(ready 先撤回 409)· 规则引擎非 LLM |
| 4 | 人工改稿 | 编辑器 | PUT /{tid} edit_task | task 内容 | 留 updated_at |
| 5 | 撤回 | 需返工 | POST /{tid}/revert | ready→draft | 可逆流转 |
| 6 | 人工审批 | 审批按钮 | POST /{tid}/approve approve | status=ready + approved_by/at | 仅 draft 可批(409)· 提交前人工审批强制——AI/规则不代发 |
| 7 | SP-API 提交 | 提交按钮 | POST /{tid}/submit submit_task | Amazon listing | 仅 ready(409)——状态机硬门 |
| 8 | 结果回填 | 提交后 | POST /import-results import_results | tasks 状态推进 | 事件全审计 |
| 9 | 事件回放 | 任务详情 | GET /api/listing/events list_events | listing_events | 每步留痕可追溯 |
| 10 | PT 市场绑定 | PT 页 | POST /{tid}/bind-pt bind_pt + pt-search/schema/markets | listing_category_meta | 仅 draft/failed 可绑 · (brand,market,product_type) 唯一 UPSERT |
| 11 | 批量与体检 | 工具区 | batch_tasks / listing_health / export | — | 同门控 |
projects.py + collab.py 26 端点逐函数实据
flowchart TD
subgraph PM["PM 项目域 /projects"]
A1["POST /api/pm/products CRUD
pm_products_create/update/delete"]
A1 --> A2["POST /{pid}/tasks 任务 CRUD
pm_tasks_create/update/delete"]
A2 --> A3["POST /{pid}/chain 链路视图"]
A3 --> A4["GET /api/pm/export · POST import
导出导入闭环"]
end
subgraph DOC["文档域 /documents /training"]
B1["GET /api/documents/tree
documents_tree 节点树"]
B1 --> B2[("documents_nodes
协作编辑")]
B2 --> B3["培训材料 /training"]
end
subgraph UPL["上传域 /upload 两段式"]
C1{"POST /api/upload
upload_file"}
C1 -->|"第一步"| C2["预览: 解析+暂存"]
C2 -->|"第二步确认"| C3[("upload_files")]
C3 --> C4["GET files 列表 / raw 原文 / DELETE"]
end
subgraph OPS["运维面板 /pipeline /database"]
D1["GET /api/pipeline/status+audit
管道状态与审计"]
D1 --> D2{"POST /api/pipeline/run/{func}
手动触发管道任务"}
D2 --> D3["GET /api/db/tables → table/rows
数据浏览器"]
D3 --> D4["敏感表黑名单 11 张(✔D 刷新)
凭证/计费身份全拦"]
end
E1["GET /api/dictionary + /glossary
数据字典·术语表"]
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class C1,D2 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | PM 产品 CRUD | /projects | /api/pm/products 5 端点 | pm_products | tenant_id RLS |
| 2 | 任务挂产品 | 产品详情 | POST /{pid}/tasks + update/delete | pm_tasks | 产品-任务两级归属 |
| 3 | 链路与导入导出 | 链路页 | pm_chain / pm_export / pm_import | 读/写 pm 表 | 导入幂等 |
| 4 | 文档树协作 | /documents | GET /api/documents/tree | documents_nodes | 节点树结构·tenant RLS |
| 5 | 上传两段式 | /upload | POST /api/upload upload_file | upload_files | 预览→确认两段(与 ads 上传同设计) |
| 6 | 文件管理 | /upload 列表 | files 列表 / raw / DELETE | upload_files | 租户隔离 |
| 7 | 管道运维 | /pipeline | status / audit / POST run/{func} | 触发 §10.2 任务 | adminOnly 手动触发留审计 |
| 8 | 数据浏览器 | /database | db_tables / table/{t} / rows | 读任意非黑名单表 | 敏感表黑名单 11 张(✔D P3-15:凭证/计费/身份全拦) |
| 9 | 字典术语 | /dictionary | data_dictionary / glossary | 读快照 | tools/gen_data_dictionary 生成 |
| 10 | 飞书集成 | /feishu | 飞书侧配置 | — | 协作外链 |
ai.py 6 端点逐函数实据
flowchart LR
A0{"六端点统一入口
require_module(ai) 或 any"}
A0 --> A1["POST /ask 通用咨询
POST /insight 数据洞察
POST /adcopy 文案
POST /sourcing 选品建议(any 开源流)
POST /ads-optimize 广告优化建议
POST /page-chat 页面级对话"]
A1 --> B1{"Redis 租户日配额
PLAN_AI_QUOTA
trial10/starter50
growth200/enterprise500"}
B1 -->|"超限"| B9["429 显式限额"]
B1 -->|"额度内"| C1{"LLM 已配置?"}
C1 -->|"未配置"| C9["503 显式「未配置」不显 0"]
C1 -->|"已配置"| D1["llm_chat 调用
纯文本返回"]
D1 --> E1["零业务表写入(铁律)
不进任何工作流决策
决策全在 §10.4/§10.9 由规则+人完成"]
classDef guard fill:#fdeaea,stroke:#dc2626,color:#101319
class A0,B1,C1 guard
| # | 步骤 | 入口·触发 | 函数·端点 | 写表·产物 | 护栏 |
|---|---|---|---|---|---|
| 1 | 模块门 | 每端点 | require_module(ai) / require_module_any(sourcing,ai) | — | 租户未开通 403 unpurchased |
| 2 | 六端点分流 | /ai 页 | ask / insight / adcopy / sourcing / ads-optimize / page-chat | — | 纯咨询语义,无写动作 |
| 3 | 租户日配额 | 每调用 | Redis 计数 × PLAN_AI_QUOTA | Redis 键 | trial 10/starter 50/growth 200/enterprise 500,超限 429 显式 |
| 4 | 未配置兜底 | LLM 缺配置 | 503 | — | 显式「未配置」不显误导性 0(铁律) |
| 5 | 纯文本返回 | 调用成功 | llm_chat | 无业务表写入 | 零写入铁律:LLM 不进工作流,全代码执行 |
| 6 | 用量落账 | 00:05 日终 | daily_usage_rollup | usage_daily | 计费与限额依据(§10.2 步 11) |
| 7 | 配额升配 | /billing | plan 变更(§10.1 步 11) | tenants.plan | webhook 验签后生效 |
AST + 活库普查(2026-09-26 · tools 生成非手工誊写,可复跑对源)· 附录 A~E 每行可点验
| # | 方法 | 路径 | 门 | 模块 | 鉴权机制 | router 文件 |
|---|---|---|---|---|---|---|
| ads.py · 41 端点(36 会话/模块门控 + 5 adminOnly) | ||||||
| 1 | GET | /api/ads/campaigns | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 2 | GET | /api/ads/analysis | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 3 | GET | /api/ads/optlog | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 4 | POST | /api/ads/optlog/{log_id}/feedback | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 5 | GET | /api/promotion/channels | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 6 | GET | /api/promotion/summary | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 7 | GET | /api/ads/platform | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 8 | GET | /api/ads/charts | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 9 | GET | /api/ads/search-terms | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 10 | GET | /api/ads/keyword-bids | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 11 | GET | /api/ads/dayparting | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 12 | GET | /api/ads/recommendations | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 13 | POST | /api/ads/recommendations/{rid}/decision | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 14 | GET | /api/ads/neg-keywords | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 15 | POST | /api/ads/neg-keywords | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 16 | PATCH | /api/ads/neg-keywords/{nid} | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 17 | DELETE | /api/ads/neg-keywords/{nid} | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 18 | POST | /api/ads/recommendations/run | adminOnly | — | _require_admin(函数体) | ads.py |
| 19 | GET | /api/ads/rule-config | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 20 | POST | /api/ads/rule-config | adminOnly | — | _require_admin(函数体) | ads.py |
| 21 | DELETE | /api/ads/rule-config/{key} | adminOnly | — | _require_admin(函数体) | ads.py |
| 22 | POST | /api/ads/recommendations/{rid}/execute | adminOnly | — | _require_admin(函数体) | ads.py |
| 23 | GET | /api/promotion/tasks | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 24 | POST | /api/promotion/tasks | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 25 | POST | /api/promotion/tasks/{tid}/status | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 26 | DELETE | /api/promotion/tasks/{tid} | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 27 | POST | /api/promotion/channels/{cid}/status | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 28 | GET | /api/promotion/orders | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 29 | POST | /api/promotion/orders | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 30 | POST | /api/promotion/orders/{oid}/approve | adminOnly | — | _require_admin(函数体) | ads.py |
| 31 | POST | /api/promotion/kol/{kind}/{kid}/outreach | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 32 | GET | /api/promotion/kol | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 33 | GET | /api/promotion/kol-analysis | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 34 | POST | /api/promotion/submission | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 35 | GET | /api/promotion/submissions | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 36 | POST | /api/ads/upload/preview | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 37 | POST | /api/ads/upload | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 38 | GET | /api/ads/imports | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 39 | POST | /api/ads/imports/recompute | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 40 | GET | /api/ads/sources | 会话/模块门控 | ads | require_module(ads) | ads.py |
| 41 | POST | /api/ads/reattribute | 会话/模块门控 | ads | require_module(ads) | ads.py |
| ai.py · 6 端点(6 会话/模块门控) | ||||||
| 42 | POST | /api/ai/ask | 会话/模块门控 | ai | require_module(ai) | ai.py |
| 43 | POST | /api/ai/insight | 会话/模块门控 | ai | require_module(ai) | ai.py |
| 44 | POST | /api/ai/adcopy | 会话/模块门控 | ai | require_module(ai) | ai.py |
| 45 | POST | /api/ai/sourcing | 会话/模块门控 | ai+sourcing | require_module(ai+sourcing) | ai.py |
| 46 | POST | /api/ai/ads-optimize | 会话/模块门控 | ai | require_module(ai) | ai.py |
| 47 | POST | /api/ai/page-chat | 会话/模块门控 | ai | require_module(ai) | ai.py |
| aplus.py · 8 端点(8 会话/模块门控) | ||||||
| 48 | GET | /api/aplus/meta | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 49 | GET | /api/aplus/media | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 50 | POST | /api/aplus/media | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 51 | DELETE | /api/aplus/media/{mid} | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 52 | POST | /api/aplus/draft | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 53 | DELETE | /api/aplus/docs/{did} | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 54 | GET | /api/aplus/documents | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| 55 | GET | /api/aplus/history | 会话/模块门控 | 基座 | current_user 会话 | aplus.py |
| auth.py · 16 端点(6 会话/模块门控 + 5 adminOnly + 5 无会话) | ||||||
| 56 | GET | /api/tenant/exists | 无会话 | 无 | 自带鉴权/设计公开 | auth.py |
| 57 | POST | /api/auth/login | 会话/模块门控 | 基座 | auth 会话建立/注销 | auth.py |
| 58 | POST | /api/auth/logout | 会话/模块门控 | 基座 | auth 会话建立/注销 | auth.py |
| 59 | GET | /api/auth/sessions | 会话/模块门控 | 基座 | current_user 会话 | auth.py |
| 60 | POST | /api/auth/logout-all | 会话/模块门控 | 基座 | current_user 会话 | auth.py |
| 61 | GET | /api/auth/registration-status | 无会话 | 无 | 自带鉴权/设计公开 | auth.py |
| 62 | POST | /api/auth/register | 无会话 | 无 | 自带鉴权/设计公开 | auth.py |
| 63 | GET | /api/auth/verify | 无会话 | 无 | 自带鉴权/设计公开 | auth.py |
| 64 | POST | /api/auth/resend | 无会话 | 无 | 自带鉴权/设计公开 | auth.py |
| 65 | GET | /api/tenant/info | 会话/模块门控 | 基座 | current_user 会话 | auth.py |
| 66 | GET | /api/tenant/brands | adminOnly | — | _require_admin(函数体) | auth.py |
| 67 | POST | /api/tenant/brands | adminOnly | — | _require_admin(函数体) | auth.py |
| 68 | DELETE | /api/tenant/brands/{brand} | adminOnly | — | _require_admin(函数体) | auth.py |
| 69 | PUT | /api/tenant/brands/{brand}/activate | adminOnly | — | _require_admin(函数体) | auth.py |
| 70 | GET | /api/tenant/jobs | adminOnly | — | _require_admin(函数体) | auth.py |
| 71 | POST | /api/auth/password | 会话/模块门控 | 基座 | current_user 会话 | auth.py |
| billing.py · 6 端点(3 会话/模块门控 + 1 adminOnly + 2 无会话) | ||||||
| 72 | GET | /api/billing/plans | 无会话 | 无 | 自带鉴权/设计公开 | billing.py |
| 73 | GET | /api/billing/status | 会话/模块门控 | 基座 | current_user 会话 | billing.py |
| 74 | GET | /api/billing/modules | 会话/模块门控 | 基座 | current_user 会话 | billing.py |
| 75 | POST | /api/billing/modules/toggle | adminOnly | — | _require_admin(函数体) | billing.py |
| 76 | POST | /api/billing/checkout | 会话/模块门控 | 基座 | current_user 会话 | billing.py |
| 77 | POST | /api/billing/webhook | 无会话 | 无 | 自带鉴权/设计公开 | billing.py |
| brandboard.py · 5 端点(5 会话/模块门控) | ||||||
| 78 | GET | /api/brandboard/orders | 会话/模块门控 | 基座 | current_user 会话 | brandboard.py |
| 79 | GET | /api/brandboard/country-sku | 会话/模块门控 | 基座 | current_user 会话 | brandboard.py |
| 80 | GET | /api/brandboard/noon | 会话/模块门控 | 基座 | current_user 会话 | brandboard.py |
| 81 | GET | /api/noon-inventory | 会话/模块门控 | 基座 | current_user 会话 | brandboard.py |
| 82 | GET | /api/brandboard/product-drill | 会话/模块门控 | 基座 | current_user 会话 | brandboard.py |
| collab.py · 15 端点(11 会话/模块门控 + 4 adminOnly) | ||||||
| 83 | GET | /api/mapping/skus | 会话/模块门控 | 基座 | current_user 会话 | collab.py |
| 84 | GET | /api/documents/tree | 会话/模块门控 | collab | require_module(collab) | collab.py |
| 85 | GET | /api/mapping/api-fields | 会话/模块门控 | 基座 | current_user 会话 | collab.py |
| 86 | POST | /api/upload | 会话/模块门控 | collab | require_module(collab) | collab.py |
| 87 | GET | /api/upload/files | 会话/模块门控 | collab | require_module(collab) | collab.py |
| 88 | DELETE | /api/upload/files/{fid} | 会话/模块门控 | collab | require_module(collab) | collab.py |
| 89 | GET | /api/pipeline/status | 会话/模块门控 | 基座 | current_user 会话 | collab.py |
| 90 | GET | /api/pipeline/audit | 会话/模块门控 | 基座 | current_user 会话 | collab.py |
| 91 | POST | /api/pipeline/run/{func_name} | adminOnly | — | _require_admin(函数体) | collab.py |
| 92 | GET | /api/db/tables | adminOnly | — | _require_admin(函数体) | collab.py |
| 93 | GET | /api/db/table/{table_name} | adminOnly | — | _require_admin(函数体) | collab.py |
| 94 | GET | /api/db/table/{table_name}/rows | adminOnly | — | _require_admin(函数体) | collab.py |
| 95 | GET | /api/collab/files/{fid}/raw | 会话/模块门控 | collab | require_module(collab) | collab.py |
| 96 | GET | /api/dictionary | 会话/模块门控 | 基座 | current_user 会话 | collab.py |
| 97 | GET | /api/glossary | 会话/模块门控 | 基座 | current_user 会话 | collab.py |
| dashboard.py · 11 端点(11 会话/模块门控) | ||||||
| 98 | GET | /api/dashboard/filters | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 99 | GET | /api/dashboard/kpi | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 100 | GET | /api/dashboard/kpi-cards | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 101 | PUT | /api/dashboard/kpi-cards | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 102 | GET | /api/dashboard/charts | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 103 | GET | /api/today | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 104 | GET | /api/rankings/markets | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 105 | GET | /api/rankings | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 106 | GET | /api/rankings/history | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 107 | GET | /api/dashboard/merged-kpi | 会话/模块门控 | orders | require_module(orders) | dashboard.py |
| 108 | GET | /api/dashboard/sku-sales | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| finance.py · 12 端点(12 会话/模块门控) | ||||||
| 109 | GET | /api/finance/summary | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 110 | GET | /api/finance/sku-profit | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 111 | GET | /api/settlement | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 112 | GET | /api/noon/summary | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 113 | GET | /api/finance/kpi-wall | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 114 | GET | /api/finance/full | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 115 | GET | /api/finance/product-pl | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 116 | GET | /api/finance/noon-sku | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 117 | GET | /api/finance/monthly | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 118 | GET | /api/finance/profit-matrix | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 119 | GET | /api/finance/onno | 会话/模块门控 | finance | require_module(finance) | finance.py |
| 120 | GET | /api/finance/noon-pnl | 会话/模块门控 | finance | require_module(finance) | finance.py |
| internal.py · 5 端点(5 无会话) | ||||||
| 121 | GET | /internal/api/v1/order/sku-aggregate | 无会话 | 无 | 自带鉴权/设计公开 | internal.py |
| 122 | GET | /internal/api/v1/order/status | 无会话 | 无 | 自带鉴权/设计公开 | internal.py |
| 123 | GET | /internal/api/v1/ads/spend | 无会话 | 无 | 自带鉴权/设计公开 | internal.py |
| 124 | GET | /internal/api/v1/finance/monthly | 无会话 | 无 | 自带鉴权/设计公开 | internal.py |
| 125 | GET | /internal/api/v1/shared/fx-rate | 无会话 | 无 | 自带鉴权/设计公开 | internal.py |
| inv.py · 13 端点(13 会话/模块门控) | ||||||
| 126 | GET | /api/inv/warehouses | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 127 | POST | /api/inv/warehouses | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 128 | GET | /api/inv/docs | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 129 | GET | /api/inv/docs/{did} | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 130 | POST | /api/inv/docs | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 131 | POST | /api/inv/docs/{did}/approve | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 132 | POST | /api/inv/docs/{did}/cancel | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 133 | GET | /api/inv/stocktake/plan | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 134 | GET | /api/inv/stock | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 135 | GET | /api/inv/ledger | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 136 | GET | /api/inv/products | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 137 | POST | /api/inv/products | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| 138 | GET | /api/inv/report | 会话/模块门控 | inventory | require_module(inventory) | inv.py |
| inventory_po.py · 12 端点(12 会话/模块门控) | ||||||
| 139 | GET | /api/inventory/health | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 140 | GET | /api/inventory/alert | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 141 | GET | /api/po/suppliers | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 142 | POST | /api/po/suppliers | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 143 | DELETE | /api/po/suppliers/{sid} | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 144 | GET | /api/po/list | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 145 | POST | /api/po/create | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 146 | GET | /api/po/{pid} | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 147 | PUT | /api/po/{pid} | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 148 | DELETE | /api/po/{pid} | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 149 | POST | /api/po/{pid}/status | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| 150 | POST | /api/po/{pid}/receive | 会话/模块门控 | inventory | require_module(inventory) | inventory_po.py |
| layout.py · 3 端点(3 会话/模块门控) | ||||||
| 151 | GET | /api/layout | 会话/模块门控 | 基座 | current_user 会话 | layout.py |
| 152 | POST | /api/layout | 会话/模块门控 | 基座 | current_user 会话 | layout.py |
| 153 | POST | /api/layout/reset | 会话/模块门控 | 基座 | current_user 会话 | layout.py |
| listing.py · 23 端点(16 会话/模块门控 + 7 adminOnly) | ||||||
| 154 | GET | /api/listing/meta | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 155 | GET | /api/listing/skus-by-model | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 156 | POST | /api/listing/specs | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 157 | POST | /api/listing/models/spec | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 158 | GET | /api/listing/specs | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 159 | POST | /api/listing/tasks | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 160 | GET | /api/listing/tasks | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 161 | GET | /api/listing/tasks/{tid} | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 162 | POST | /api/listing/tasks/{tid}/generate | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 163 | PUT | /api/listing/tasks/{tid} | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 164 | POST | /api/listing/tasks/{tid}/approve | adminOnly | — | _require_admin(函数体) | listing.py |
| 165 | POST | /api/listing/tasks/{tid}/revert | adminOnly | — | _require_admin(函数体) | listing.py |
| 166 | DELETE | /api/listing/tasks/{tid} | adminOnly | — | _require_admin(函数体) | listing.py |
| 167 | GET | /api/listing/export | adminOnly | — | _require_admin(函数体) | listing.py |
| 168 | POST | /api/listing/import-results | adminOnly | — | _require_admin(函数体) | listing.py |
| 169 | GET | /api/listing/events | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 170 | GET | /api/listing/pt-markets | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 171 | GET | /api/listing/pt-search | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 172 | GET | /api/listing/pt-schema | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 173 | POST | /api/listing/tasks/{tid}/bind-pt | 会话/模块门控 | listing | require_module(listing) | listing.py |
| 174 | POST | /api/listing/tasks/{tid}/submit | adminOnly | — | _require_admin(函数体) | listing.py |
| 175 | POST | /api/listing/tasks/batch | adminOnly | — | _require_admin(函数体) | listing.py |
| 176 | GET | /api/listing/health | 会话/模块门控 | listing | require_module(listing) | listing.py |
| logistics.py · 8 端点(8 会话/模块门控) | ||||||
| 177 | POST | /api/logistics/shipments/import | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 178 | GET | /api/logistics/shipments | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 179 | GET | /api/logistics/products | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 180 | GET | /api/logistics/params | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 181 | POST | /api/logistics/params | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 182 | GET | /api/logistics/pricing | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 183 | GET | /api/logistics/appendix | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| 184 | POST | /api/logistics/create | 会话/模块门控 | logistics | require_module(logistics) | logistics.py |
| matrix.py · 3 端点(3 会话/模块门控) | ||||||
| 185 | GET | /api/matrix/dimensions | 会话/模块门控 | 基座 | current_user 会话 | matrix.py |
| 186 | GET | /api/matrix/data | 会话/模块门控 | 基座 | current_user 会话 | matrix.py |
| 187 | GET | /api/matrix/charts | 会话/模块门控 | 基座 | current_user 会话 | matrix.py |
| mcp.py · 4 端点(3 adminOnly + 1 无会话) | ||||||
| 188 | POST | /api/mcp/keys | adminOnly | — | _require_admin(函数体) | mcp.py |
| 189 | GET | /api/mcp/keys | adminOnly | — | _require_admin(函数体) | mcp.py |
| 190 | DELETE | /api/mcp/keys/{kid} | adminOnly | — | _require_admin(函数体) | mcp.py |
| 191 | POST | /mcp | 无会话 | 无 | 自带鉴权/设计公开 | mcp.py |
| notify.py · 1 端点(1 会话/模块门控) | ||||||
| 192 | GET | /api/notifications/summary | 会话/模块门控 | 基座 | current_user 会话 | notify.py |
| onboarding.py · 5 端点(1 会话/模块门控 + 4 adminOnly) | ||||||
| 193 | GET | /api/onboarding/meta | adminOnly | — | _require_admin(函数体) | onboarding.py |
| 194 | POST | /api/onboarding/brand | adminOnly | — | _require_admin(函数体) | onboarding.py |
| 195 | POST | /api/onboarding/category | adminOnly | — | _require_admin(函数体) | onboarding.py |
| 196 | POST | /api/onboarding/skus | adminOnly | — | _require_admin(函数体) | onboarding.py |
| 197 | GET | /api/onboarding/pipeline | 会话/模块门控 | 基座 | current_user 会话 | onboarding.py |
| ops.py · 5 端点(5 会话/模块门控) | ||||||
| 198 | GET | /api/products | 会话/模块门控 | 基座 | current_user 会话 | ops.py |
| 199 | GET | /api/orders | 会话/模块门控 | orders | require_module(orders) | ops.py |
| 200 | GET | /api/mapping/edit | 会话/模块门控 | 基座 | current_user 会话 | ops.py |
| 201 | POST | /api/mapping/edit/import | 会话/模块门控 | 基座 | current_user 会话 | ops.py |
| 202 | POST | /api/mapping/edit | 会话/模块门控 | 基座 | current_user 会话 | ops.py |
| org.py · 5 端点(5 adminOnly) | ||||||
| 203 | GET | /api/team/meta | adminOnly | — | _require_admin(函数体) | org.py |
| 204 | GET | /api/team/users | adminOnly | — | _require_admin(函数体) | org.py |
| 205 | POST | /api/team/users | adminOnly | — | _require_admin(函数体) | org.py |
| 206 | PUT | /api/team/users/{mid} | adminOnly | — | _require_admin(函数体) | org.py |
| 207 | DELETE | /api/team/users/{mid} | adminOnly | — | _require_admin(函数体) | org.py |
| po_pdf.py · 3 端点(3 会话/模块门控) | ||||||
| 208 | GET | /api/po/{pid}/pdf | 会话/模块门控 | inventory | require_module(inventory) | po_pdf.py |
| 209 | POST | /api/po/{pid}/pdf | 会话/模块门控 | inventory | require_module(inventory) | po_pdf.py |
| 210 | POST | /api/po/{pid}/mail | 会话/模块门控 | inventory | require_module(inventory) | po_pdf.py |
| projects.py · 11 端点(11 会话/模块门控) | ||||||
| 211 | GET | /api/pm/products | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 212 | POST | /api/pm/products | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 213 | GET | /api/pm/products/{pid} | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 214 | PUT | /api/pm/products/{pid} | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 215 | DELETE | /api/pm/products/{pid} | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 216 | POST | /api/pm/products/{pid}/tasks | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 217 | PUT | /api/pm/tasks/{tid} | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 218 | DELETE | /api/pm/tasks/{tid} | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 219 | POST | /api/pm/products/{pid}/chain | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 220 | GET | /api/pm/export | 会话/模块门控 | collab | require_module(collab) | projects.py |
| 221 | POST | /api/pm/import | 会话/模块门控 | collab | require_module(collab) | projects.py |
| reports.py · 8 端点(8 会话/模块门控) | ||||||
| 222 | GET | /api/reports/fields | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 223 | POST | /api/reports/query | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 224 | GET | /api/reports/defs | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 225 | POST | /api/reports/defs | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 226 | DELETE | /api/reports/defs/{rid} | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 227 | POST | /api/reports/landed-cost | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 228 | GET | /api/reports/backend-keywords/{sku} | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| 229 | PUT | /api/reports/backend-keywords/{sku} | 会话/模块门控 | 基座 | current_user 会话 | reports.py |
| settings.py · 6 端点(6 adminOnly) | ||||||
| 230 | GET | /api/settings/providers | adminOnly | — | _require_admin(函数体) | settings.py |
| 231 | GET | /api/settings/credentials | adminOnly | — | _require_admin(函数体) | settings.py |
| 232 | POST | /api/settings/credentials | adminOnly | — | _require_admin(函数体) | settings.py |
| 233 | PUT | /api/settings/credentials/{cid} | adminOnly | — | _require_admin(函数体) | settings.py |
| 234 | DELETE | /api/settings/credentials/{cid} | adminOnly | — | _require_admin(函数体) | settings.py |
| 235 | POST | /api/settings/credentials/{cid}/verify | adminOnly | — | _require_admin(函数体) | settings.py |
| sourcing.py · 13 端点(13 会话/模块门控) | ||||||
| 236 | GET | /api/sourcing/search | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 237 | GET | /api/sourcing/keepa-history | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 238 | GET | /api/sourcing/watchlist | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 239 | POST | /api/sourcing/watch | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 240 | DELETE | /api/sourcing/watch/{wid} | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 241 | GET | /api/sourcing/product | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 242 | GET | /api/sourcing/explorer | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 243 | GET | /api/sourcing/explore/fields | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 244 | GET | /api/sourcing/explore | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 245 | GET | /api/sourcing/aba/overview | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 246 | GET | /api/sourcing/aba/chart | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 247 | GET | /api/sourcing/aba/ledger | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| 248 | GET | /api/sourcing/radar | 会话/模块门控 | sourcing | require_module(sourcing) | sourcing.py |
| verdicts.py · 5 端点(4 会话/模块门控 + 1 adminOnly) | ||||||
| 249 | POST | /api/sourcing/verdicts/materialize | adminOnly | — | _require_admin(函数体) | verdicts.py |
| 250 | GET | /api/sourcing/verdicts/candidates | 会话/模块门控 | sourcing | require_module(sourcing) | verdicts.py |
| 251 | GET | /api/sourcing/verdicts/pareto | 会话/模块门控 | sourcing | require_module(sourcing) | verdicts.py |
| 252 | POST | /api/sourcing/verdicts/decision | 会话/模块门控 | sourcing | require_module(sourcing) | verdicts.py |
| 253 | GET | /api/sourcing/verdicts/legacy | 会话/模块门控 | sourcing | require_module(sourcing) | verdicts.py |
| 254 | GET | /api/dashboard/chart-order | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| 255 | PUT | /api/dashboard/chart-order | 会话/模块门控 | 基座 | current_user 会话 | dashboard.py |
| # | 路由 | 组 · 模块 | 行数 | 消费的 API 端点 |
|---|---|---|---|---|
| 1 | /ai | 协作·ai | 111 | /api/ai/ |
| 2 | /documents | 协作·collab | 139 | /api/documents/tree |
| 3 | /feishu | 协作·collab | 79 | /api/documents/tree |
| 4 | /training | 协作·collab | 93 | —(零直接引用) |
| 5 | /upload | 协作·collab | 7 | —(零直接引用) |
| 6 | /database | 数据·collab(adminOnly) | 182 | /api/db/table/ · /api/db/tables |
| 7 | /noon | 数据·finance | 256 | /api/noon/summary |
| 8 | /dictionary | 数据·基座 | 146 | /api/dictionary · /api/glossary |
| 9 | /mapping | 数据·基座 | 305 | /api/mapping/edit · /api/mapping/edit/import · /api/mapping/skus |
| 10 | /pipeline | 数据·基座(运维) | 311 | /api/glossary · /api/pipeline/audit · /api/pipeline/run/ · /api/pipeline/status |
| 11 | /dashboard/[brand] | 旧路由(遗留) | 33 | /api/brandboard · /api/dashboard/charts |
| 12 | /dashboard/noon/[brand] | 旧路由(遗留) | 33 | —(零直接引用) |
| 13 | /account | 系统·基座 | 112 | /api/auth/logout-all · /api/auth/password · /api/auth/sessions |
| 14 | /billing | 系统·基座 | 206 | /api/billing/checkout · /api/billing/modules · /api/billing/modules/toggle · /api/billing/plans · /api/billing/status |
| 15 | /settings | 系统·基座(adminOnly) | 175 | /api/settings/credentials · /api/settings/credentials/ · /api/settings/providers |
| 16 | /team | 系统·基座(org) | 248 | /api/team/meta · /api/team/users · /api/team/users/ · /api/tenant/brands · /api/tenant/brands/ |
| 17 | /ads | 经营·ads | 2044 | /api/ads/analysis · /api/ads/campaigns · /api/ads/charts · /api/ads/dayparting · /api/ads/imports · /api/ads/imports/recompute · /api/ads/keyword-bids · /api/ads/neg-keywords · /api/ads/neg-keywords/ · /api/ads/optlog · /api/ads/optlog/ · /api/ads/platform · /api/ads/reattribute · /api/ads/recommendations · /api/ads/recommendations/ · /api/ads/recommendations/run · /api/ads/rule-config · /api/ads/rule-config/ · /api/ads/search-terms · /api/ads/sources · /api/ads/upload · /api/ads/upload/preview |
| 18 | /finance | 经营·finance | 1409 | /api/finance/full · /api/finance/kpi-wall · /api/finance/monthly · /api/finance/noon-pnl · /api/finance/noon-sku · /api/finance/product-pl · /api/finance/profit-matrix |
| 19 | /sourcing | 经营·sourcing | 858 | /api/ai/sourcing · /api/sourcing/aba/ledger · /api/sourcing/aba/overview · /api/sourcing/explore · /api/sourcing/explore/fields · /api/sourcing/explorer · /api/sourcing/radar |
| 20 | /rankings | 经营·基座 | 237 | /api/rankings · /api/rankings/history · /api/rankings/markets |
| 21 | /today | 经营·基座 | 460 | /api/dashboard/filters · /api/today |
| 22 | / | 经营·基座(工作台) | 691 | /api/dashboard/charts · /api/dashboard/filters · /api/dashboard/kpi · /api/dashboard/merged-kpi · /api/dashboard/sku-sales |
| 23 | /onboarding | 认证·品牌开户 | 312 | /api/onboarding/brand · /api/onboarding/category · /api/onboarding/meta · /api/onboarding/pipeline · /api/onboarding/skus |
| 24 | /welcome | 认证·引导 | 114 | —(零直接引用) |
| 25 | /login | 认证·无会话 | 76 | /api/auth/login |
| 26 | /register | 认证·无会话 | 121 | /api/auth/register · /api/auth/resend |
| 27 | /verify | 认证·无会话 | 57 | /api/auth/verify |
| 28 | /promotion | 运营·ads | 374 | /api/promotion/channels · /api/promotion/orders · /api/promotion/submission · /api/promotion/summary |
| 29 | /projects | 运营·collab | 710 | /api/pm/export · /api/pm/import · /api/pm/products · /api/pm/products/ · /api/pm/tasks/ |
| 30 | /settlement | 运营·finance | 130 | /api/settlement |
| 31 | /inventory | 运营·inventory | 266 | /api/inventory/alert · /api/inventory/health · /api/noon-inventory |
| 32 | /po | 运营·inventory | 414 | /api/inventory/alert · /api/po/ · /api/po/create · /api/po/list · /api/po/suppliers · /api/po/suppliers/ · /api/products |
| 33 | /listings | 运营·listing | 1138 | /api/listing/export · /api/listing/health · /api/listing/import-results · /api/listing/meta · /api/listing/models/spec · /api/listing/pt-markets · /api/listing/pt-search · /api/listing/skus-by-model · /api/listing/specs · /api/listing/tasks · /api/listing/tasks/ · /api/listing/tasks/batch |
| 34 | /logistics | 运营·logistics | 759 | /api/logistics/appendix · /api/logistics/create · /api/logistics/params · /api/logistics/pricing · /api/logistics/products · /api/logistics/shipments · /api/logistics/shipments/import |
| 35 | /orders | 运营·orders | 148 | /api/orders |
| 36 | /products | 运营·基座 | 262 | /api/brandboard/product-drill · /api/products |
| 37 | /en | 静态 | 116 | —(零直接引用) |
| 38 | /privacy | 静态 | 138 | —(零直接引用) |
| 39 | /terms | 静态 | 124 | —(零直接引用) |
| # | schema | 表名 | RLS 键 | 对偶 / 注记 |
|---|---|---|---|---|
| public 121(源头镜像 + 注册表 + 会话/系统表) · 键型 {'tenant': 69, '品牌': 38, '无': 14} | ||||
| 1 | public | aba_country_catalog | tenant_id | → audit.cleaned_* 对偶 |
| 2 | public | aba_keepa_full | tenant_id | → audit.cleaned_* 对偶 |
| 3 | public | aba_meta | tenant_id | → audit.cleaned_* 对偶 |
| 4 | public | aba_radar_basket | tenant_id | → audit.cleaned_* 对偶 |
| 5 | public | aba_radar_fragmented | tenant_id | → audit.cleaned_* 对偶 |
| 6 | public | aba_radar_gem | tenant_id | → audit.cleaned_* 对偶 |
| 7 | public | aba_radar_repeat | tenant_id | → audit.cleaned_* 对偶 |
| 8 | public | aba_radar_rising | tenant_id | → audit.cleaned_* 对偶 |
| 9 | public | aba_search_terms | tenant_id | → audit.cleaned_* 对偶 |
| 10 | public | aba_term_universe | tenant_id | → audit.cleaned_* 对偶 |
| 11 | public | ad_campaigns | 品牌键 | → audit.cleaned_* 对偶 |
| 12 | public | ads_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 13 | public | ads_decision_audit | tenant_id | → audit.cleaned_* 对偶 |
| 14 | public | ads_decision_request | tenant_id | → audit.cleaned_* 对偶 |
| 15 | public | ads_imports | tenant_id | → audit.cleaned_* 对偶 |
| 16 | public | ads_keywords_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 17 | public | ads_optimization_log | 品牌键 | → audit.cleaned_* 对偶 |
| 18 | public | ads_recommendations | 品牌键 | → audit.cleaned_* 对偶 |
| 19 | public | ads_rule_config | 品牌键 | → audit.cleaned_* 对偶 |
| 20 | public | ads_search_terms_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 21 | public | ads_sku_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 22 | public | amazon_ads_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 23 | public | amazon_orders | 品牌键 | → audit.cleaned_* 对偶 |
| 24 | public | amazon_refund_monthly | 品牌键 | → audit.cleaned_* 对偶 |
| 25 | public | amazon_settlement_monthly | 品牌键 | → audit.cleaned_* 对偶 |
| 26 | public | api_fields_catalog | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 27 | public | aplus_docs | tenant_id | → audit.cleaned_* 对偶 |
| 28 | public | aplus_history | tenant_id | → audit.cleaned_* 对偶 |
| 29 | public | aplus_media | tenant_id | → audit.cleaned_* 对偶 |
| 30 | public | audit_baselines | 无策略(全局) | → audit.cleaned_* 对偶 |
| 31 | public | audit_known_issues | 无策略(全局) | → audit.cleaned_* 对偶 |
| 32 | public | audit_log | tenant_id | 无镜像(注册表/会话/系统表) |
| 33 | public | audit_results | 无策略(全局) | → audit.cleaned_* 对偶 |
| 34 | public | audit_thresholds | 无策略(全局) | → audit.cleaned_* 对偶 |
| 35 | public | autocomplete_terms | 品牌键 | → audit.cleaned_* 对偶 |
| 36 | public | billing_events | tenant_id | 无镜像(注册表/会话/系统表) |
| 37 | public | brand_channels | tenant_id | 无镜像(注册表/会话/系统表) |
| 38 | public | brands_source | tenant_id | 无镜像(注册表/会话/系统表) |
| 39 | public | credentials | tenant_id | 无镜像(注册表/会话/系统表) |
| 40 | public | documents_nodes | tenant_id | → audit.cleaned_* 对偶 |
| 41 | public | finance_monthly | 品牌键 | → audit.cleaned_* 对偶 |
| 42 | public | fx_rates | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 43 | public | inv_doc_heads | tenant_id | → audit.cleaned_* 对偶 |
| 44 | public | inv_doc_items | tenant_id | → audit.cleaned_* 对偶 |
| 45 | public | inv_products | tenant_id | → audit.cleaned_* 对偶 |
| 46 | public | inv_stock_balance | tenant_id | → audit.cleaned_* 对偶 |
| 47 | public | inv_stock_ledger | tenant_id | → audit.cleaned_* 对偶 |
| 48 | public | inv_warehouses | tenant_id | → audit.cleaned_* 对偶 |
| 49 | public | inventory_health | 品牌键 | → audit.cleaned_* 对偶 |
| 50 | public | keepa_daily | tenant_id | watch_isolation(EXISTS keepa_watch 同租户同 ASIN) |
| 51 | public | keepa_pull_log | tenant_id | 无镜像(注册表/会话/系统表) |
| 52 | public | keepa_watch | tenant_id | → audit.cleaned_* 对偶 |
| 53 | public | listing_backend_keywords | tenant_id | → audit.cleaned_* 对偶 |
| 54 | public | listing_category_meta | 品牌键 | → audit.cleaned_* 对偶 |
| 55 | public | listing_events | tenant_id | → audit.cleaned_* 对偶 |
| 56 | public | listing_pt_suggest | 品牌键 | → audit.cleaned_* 对偶 |
| 57 | public | listing_specs | tenant_id | → audit.cleaned_* 对偶 |
| 58 | public | listing_tasks | tenant_id | → audit.cleaned_* 对偶 |
| 59 | public | listing_templates | tenant_id | → audit.cleaned_* 对偶 |
| 60 | public | logistics_params | tenant_id | → audit.cleaned_* 对偶 |
| 61 | public | logistics_shipments | 品牌键 | → audit.cleaned_* 对偶 |
| 62 | public | logistics_stats | 品牌键 | → audit.cleaned_* 对偶 |
| 63 | public | marketplaces | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 64 | public | mcp_keys | tenant_id | → audit.cleaned_* 对偶 |
| 65 | public | metric_calibers | 无策略(全局) | → audit.cleaned_* 对偶 |
| 66 | public | monthly_pl | 品牌键 | → audit.cleaned_* 对偶 |
| 67 | public | neg_keywords | tenant_id | → audit.cleaned_* 对偶 |
| 68 | public | noon_ads_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 69 | public | noon_inventory | 品牌键 | → audit.cleaned_* 对偶 |
| 70 | public | noon_monthly | 品牌键 | → audit.cleaned_* 对偶 |
| 71 | public | noon_orders | 品牌键 | → audit.cleaned_* 对偶 |
| 72 | public | noon_procurement_cost | 品牌键 | → audit.cleaned_* 对偶 |
| 73 | public | noon_sku_ads | 品牌键 | → audit.cleaned_* 对偶 |
| 74 | public | noon_sku_pl | 品牌键 | → audit.cleaned_* 对偶 |
| 75 | public | noon_sku_pl_monthly | 品牌键 | → audit.cleaned_* 对偶 |
| 76 | public | noon_sku_status | 品牌键 | → audit.cleaned_* 对偶 |
| 77 | public | noon_sku_unsaleable | 品牌键 | → audit.cleaned_* 对偶 |
| 78 | public | noon_statement | 品牌键 | → audit.cleaned_* 对偶 |
| 79 | public | order_fees | 品牌键 | → audit.cleaned_* 对偶 |
| 80 | public | pipe_domains | 无策略(全局) | → audit.cleaned_* 对偶 |
| 81 | public | platforms | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 82 | public | pm_products | tenant_id | → audit.cleaned_* 对偶 |
| 83 | public | pm_tasks | tenant_id | → audit.cleaned_* 对偶 |
| 84 | public | product_categories | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 85 | public | product_reviews | 品牌键 | → audit.cleaned_* 对偶 |
| 86 | public | products | 品牌键 | → audit.cleaned_* 对偶 |
| 87 | public | promotion_channels | tenant_id | → audit.cleaned_* 对偶 |
| 88 | public | promotion_crawl_stats | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 89 | public | promotion_kol_channels | tenant_id | → audit.cleaned_* 对偶 |
| 90 | public | promotion_kol_high | tenant_id | → audit.cleaned_* 对偶 |
| 91 | public | promotion_orders | tenant_id | → audit.cleaned_* 对偶 |
| 92 | public | promotion_products | tenant_id | → audit.cleaned_* 对偶 |
| 93 | public | promotion_review_sites | tenant_id | → audit.cleaned_* 对偶 |
| 94 | public | promotion_submissions | tenant_id | → audit.cleaned_* 对偶 |
| 95 | public | promotion_tasks | tenant_id | → audit.cleaned_* 对偶 |
| 96 | public | provisioning_log | tenant_id | 无镜像(注册表/会话/系统表) |
| 97 | public | purchase_order_items | tenant_id | → audit.cleaned_* 对偶 |
| 98 | public | purchase_orders | tenant_id | → audit.cleaned_* 对偶 |
| 99 | public | rankings_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 100 | public | report_defs | tenant_id | → audit.cleaned_* 对偶 |
| 101 | public | sales_daily | 品牌键 | → audit.cleaned_* 对偶 |
| 102 | public | sales_hourly | 品牌键 | → audit.cleaned_* 对偶 |
| 103 | public | sku_mapping | 品牌键 | → audit.cleaned_* 对偶 |
| 104 | public | sourcing_candidates | tenant_id | → audit.cleaned_* 对偶 |
| 105 | public | sourcing_decision_audit | tenant_id | → audit.cleaned_* 对偶 |
| 106 | public | sourcing_verdicts | tenant_id | → audit.cleaned_* 对偶 |
| 107 | public | sourcing_verdicts_legacy | tenant_id | → audit.cleaned_* 对偶 |
| 108 | public | subscriptions | tenant_id | 无镜像(注册表/会话/系统表) |
| 109 | public | suppliers | tenant_id | → audit.cleaned_* 对偶 |
| 110 | public | tenant_brands | tenant_id | 无镜像(注册表/会话/系统表) |
| 111 | public | tenant_credential_events | tenant_id | 无镜像(注册表/会话/系统表) |
| 112 | public | tenant_credentials | tenant_id | 无镜像(注册表/会话/系统表) |
| 113 | public | tenant_modules | tenant_id | 无镜像(注册表/会话/系统表) |
| 114 | public | tenants | 无策略(全局) | 无镜像(注册表/会话/系统表) |
| 115 | public | term_field_map | 无策略(全局) | → audit.cleaned_* 对偶 |
| 116 | public | upload_files | tenant_id | → audit.cleaned_* 对偶 |
| 117 | public | usage_daily | tenant_id | 无镜像(注册表/会话/系统表) |
| 118 | public | user_brands | tenant_id | 无镜像(注册表/会话/系统表) |
| 119 | public | user_dashboard_prefs | tenant_id | 无镜像(注册表/会话/系统表) |
| 120 | public | user_modules | tenant_id | 无镜像(注册表/会话/系统表) |
| 121 | public | users | tenant_id | 无镜像(注册表/会话/系统表) |
| audit 98(cleaned_* 97 + dirty_data_log) · 键型 {'tenant': 45, '品牌': 44, '无': 9} | ||||
| 122 | audit | cleaned_aba_country_catalog | tenant_id | ← public.aba_country_catalog 源 |
| 123 | audit | cleaned_aba_keepa_full | 品牌键 | ← public.aba_keepa_full 源 |
| 124 | audit | cleaned_aba_meta | tenant_id | ← public.aba_meta 源 |
| 125 | audit | cleaned_aba_radar_basket | tenant_id | ← public.aba_radar_basket 源 |
| 126 | audit | cleaned_aba_radar_fragmented | tenant_id | ← public.aba_radar_fragmented 源 |
| 127 | audit | cleaned_aba_radar_gem | tenant_id | ← public.aba_radar_gem 源 |
| 128 | audit | cleaned_aba_radar_repeat | tenant_id | ← public.aba_radar_repeat 源 |
| 129 | audit | cleaned_aba_radar_rising | tenant_id | ← public.aba_radar_rising 源 |
| 130 | audit | cleaned_aba_search_terms | tenant_id | ← public.aba_search_terms 源 |
| 131 | audit | cleaned_aba_term_universe | tenant_id | ← public.aba_term_universe 源 |
| 132 | audit | cleaned_ad_campaigns | 品牌键 | ← public.ad_campaigns 源 |
| 133 | audit | cleaned_ads_daily | 品牌键 | ← public.ads_daily 源 |
| 134 | audit | cleaned_ads_decision_audit | tenant_id | ← public.ads_decision_audit 源 |
| 135 | audit | cleaned_ads_decision_request | tenant_id | ← public.ads_decision_request 源 |
| 136 | audit | cleaned_ads_imports | 品牌键 | ← public.ads_imports 源 |
| 137 | audit | cleaned_ads_keywords_daily | 品牌键 | ← public.ads_keywords_daily 源 |
| 138 | audit | cleaned_ads_optimization_log | 品牌键 | ← public.ads_optimization_log 源 |
| 139 | audit | cleaned_ads_recommendations | 品牌键 | ← public.ads_recommendations 源 |
| 140 | audit | cleaned_ads_rule_config | 品牌键 | ← public.ads_rule_config 源 |
| 141 | audit | cleaned_ads_search_terms_daily | 品牌键 | ← public.ads_search_terms_daily 源 |
| 142 | audit | cleaned_ads_sku_daily | 品牌键 | ← public.ads_sku_daily 源 |
| 143 | audit | cleaned_amazon_ads_daily | 品牌键 | ← public.amazon_ads_daily 源 |
| 144 | audit | cleaned_amazon_orders | 品牌键 | ← public.amazon_orders 源 |
| 145 | audit | cleaned_amazon_refund_monthly | 品牌键 | ← public.amazon_refund_monthly 源 |
| 146 | audit | cleaned_amazon_settlement_monthly | 品牌键 | ← public.amazon_settlement_monthly 源 |
| 147 | audit | cleaned_aplus_docs | tenant_id | ← public.aplus_docs 源 |
| 148 | audit | cleaned_aplus_history | tenant_id | ← public.aplus_history 源 |
| 149 | audit | cleaned_aplus_media | tenant_id | ← public.aplus_media 源 |
| 150 | audit | cleaned_audit_baselines | 无策略(全局) | ← public.audit_baselines 源 |
| 151 | audit | cleaned_audit_known_issues | 无策略(全局) | ← public.audit_known_issues 源 |
| 152 | audit | cleaned_audit_results | 无策略(全局) | ← public.audit_results 源 |
| 153 | audit | cleaned_audit_thresholds | 无策略(全局) | ← public.audit_thresholds 源 |
| 154 | audit | cleaned_autocomplete_terms | 品牌键 | ← public.autocomplete_terms 源 |
| 155 | audit | cleaned_documents_nodes | tenant_id | ← public.documents_nodes 源 |
| 156 | audit | cleaned_finance_monthly | 品牌键 | ← public.finance_monthly 源 |
| 157 | audit | cleaned_inv_doc_heads | tenant_id | ← public.inv_doc_heads 源 |
| 158 | audit | cleaned_inv_doc_items | tenant_id | ← public.inv_doc_items 源 |
| 159 | audit | cleaned_inv_products | tenant_id | ← public.inv_products 源 |
| 160 | audit | cleaned_inv_stock_balance | tenant_id | ← public.inv_stock_balance 源 |
| 161 | audit | cleaned_inv_stock_ledger | tenant_id | ← public.inv_stock_ledger 源 |
| 162 | audit | cleaned_inv_warehouses | tenant_id | ← public.inv_warehouses 源 |
| 163 | audit | cleaned_inventory_health | 品牌键 | ← public.inventory_health 源 |
| 164 | audit | cleaned_keepa_daily | 无策略(全局) | 镜像无策略 · 0 端点引用(grep 实证) |
| 165 | audit | cleaned_keepa_watch | tenant_id | ← public.keepa_watch 源 |
| 166 | audit | cleaned_listing_backend_keywords | tenant_id | ← public.listing_backend_keywords 源 |
| 167 | audit | cleaned_listing_category_meta | 品牌键 | ← public.listing_category_meta 源 |
| 168 | audit | cleaned_listing_events | tenant_id | ← public.listing_events 源 |
| 169 | audit | cleaned_listing_pt_suggest | 品牌键 | ← public.listing_pt_suggest 源 |
| 170 | audit | cleaned_listing_specs | 品牌键 | ← public.listing_specs 源 |
| 171 | audit | cleaned_listing_tasks | 品牌键 | ← public.listing_tasks 源 |
| 172 | audit | cleaned_listing_templates | tenant_id | ← public.listing_templates 源 |
| 173 | audit | cleaned_logistics_params | tenant_id | ← public.logistics_params 源 |
| 174 | audit | cleaned_logistics_shipments | 品牌键 | ← public.logistics_shipments 源 |
| 175 | audit | cleaned_logistics_stats | 品牌键 | ← public.logistics_stats 源 |
| 176 | audit | cleaned_mcp_keys | tenant_id | ← public.mcp_keys 源 |
| 177 | audit | cleaned_metric_calibers | 无策略(全局) | ← public.metric_calibers 源 |
| 178 | audit | cleaned_monthly_pl | 品牌键 | ← public.monthly_pl 源 |
| 179 | audit | cleaned_neg_keywords | 品牌键 | ← public.neg_keywords 源 |
| 180 | audit | cleaned_noon_ads_daily | 品牌键 | ← public.noon_ads_daily 源 |
| 181 | audit | cleaned_noon_inventory | 品牌键 | ← public.noon_inventory 源 |
| 182 | audit | cleaned_noon_monthly | 品牌键 | ← public.noon_monthly 源 |
| 183 | audit | cleaned_noon_orders | 品牌键 | ← public.noon_orders 源 |
| 184 | audit | cleaned_noon_procurement_cost | 品牌键 | ← public.noon_procurement_cost 源 |
| 185 | audit | cleaned_noon_sku_ads | 品牌键 | ← public.noon_sku_ads 源 |
| 186 | audit | cleaned_noon_sku_pl | 品牌键 | ← public.noon_sku_pl 源 |
| 187 | audit | cleaned_noon_sku_pl_monthly | 品牌键 | ← public.noon_sku_pl_monthly 源 |
| 188 | audit | cleaned_noon_sku_status | 品牌键 | ← public.noon_sku_status 源 |
| 189 | audit | cleaned_noon_sku_unsaleable | 品牌键 | ← public.noon_sku_unsaleable 源 |
| 190 | audit | cleaned_noon_statement | 品牌键 | ← public.noon_statement 源 |
| 191 | audit | cleaned_order_fees | 品牌键 | ← public.order_fees 源 |
| 192 | audit | cleaned_pipe_domains | 无策略(全局) | ← public.pipe_domains 源 |
| 193 | audit | cleaned_pm_products | tenant_id | ← public.pm_products 源 |
| 194 | audit | cleaned_pm_tasks | tenant_id | ← public.pm_tasks 源 |
| 195 | audit | cleaned_product_reviews | 品牌键 | ← public.product_reviews 源 |
| 196 | audit | cleaned_products | 品牌键 | ← public.products 源 |
| 197 | audit | cleaned_promotion_channels | tenant_id | ← public.promotion_channels 源 |
| 198 | audit | cleaned_promotion_kol_channels | tenant_id | ← public.promotion_kol_channels 源 |
| 199 | audit | cleaned_promotion_kol_high | tenant_id | ← public.promotion_kol_high 源 |
| 200 | audit | cleaned_promotion_orders | tenant_id | ← public.promotion_orders 源 |
| 201 | audit | cleaned_promotion_products | tenant_id | ← public.promotion_products 源 |
| 202 | audit | cleaned_promotion_review_sites | tenant_id | ← public.promotion_review_sites 源 |
| 203 | audit | cleaned_promotion_submissions | tenant_id | ← public.promotion_submissions 源 |
| 204 | audit | cleaned_promotion_tasks | tenant_id | ← public.promotion_tasks 源 |
| 205 | audit | cleaned_purchase_order_items | 品牌键 | ← public.purchase_order_items 源 |
| 206 | audit | cleaned_purchase_orders | tenant_id | ← public.purchase_orders 源 |
| 207 | audit | cleaned_rankings_daily | 品牌键 | ← public.rankings_daily 源 |
| 208 | audit | cleaned_report_defs | tenant_id | ← public.report_defs 源 |
| 209 | audit | cleaned_sales_daily | 品牌键 | ← public.sales_daily 源 |
| 210 | audit | cleaned_sales_hourly | 品牌键 | ← public.sales_hourly 源 |
| 211 | audit | cleaned_sku_mapping | 品牌键 | ← public.sku_mapping 源 |
| 212 | audit | cleaned_sourcing_candidates | tenant_id | ← public.sourcing_candidates 源 |
| 213 | audit | cleaned_sourcing_decision_audit | tenant_id | ← public.sourcing_decision_audit 源 |
| 214 | audit | cleaned_sourcing_verdicts | tenant_id | ← public.sourcing_verdicts 源 |
| 215 | audit | cleaned_sourcing_verdicts_legacy | tenant_id | ← public.sourcing_verdicts_legacy 源 |
| 216 | audit | cleaned_suppliers | tenant_id | ← public.suppliers 源 |
| 217 | audit | cleaned_term_field_map | 无策略(全局) | ← public.term_field_map 源 |
| 218 | audit | cleaned_upload_files | tenant_id | ← public.upload_files 源 |
| 219 | audit | dirty_data_log | 无策略(全局) | 清洗残账 · 无策略 |
| # | 任务函数 | 调度(arq cron) | 机制/说明 |
|---|---|---|---|
| 1 | daily_usage_rollup | hour=0, minute=5 | — |
| 2 | ingest_mercury_daily | hour=4, minute=30 | 每日全量 · 04:30 北京 |
| 3 | ingest_mercury_weekly | hour=2, minute=0, weekday=6 | 周六 02:00 · 周度深同步 |
| 4 | ingest_today_incremental | minute=43, hour=set(range(0, 24, 2)) | 每 2 小时 · 当日增量 |
| 5 | refresh_keepa_watch | hour=5, minute=10 | watch 池播种刷新 |
| 6 | daily_ads_rules | hour=5, minute=40 | — |
| 7 | daily_pipe_alarm | hour=6, minute=15 | 管道断流泊松报警 |
| 8 | fee_coverage_alarm | hour=6, minute=20 | — |
| 9 | collection_finances_deep | hour=3, minute=20, weekday=6 | — |
| 10 | collection_cycle | minute=50 | — |
| 11 | collection_cycle_noon | minute=20, hour={0, 6, 12, 18} | — |
| 12 | source_drift_check | hour=6, minute=30 | 源漂移检查 |
| 13 | sourcing_dispatcher_tick | 无参=默认每分钟 | 默认每分钟(arq 无参=每分钟) · 分发器 |
| 14 | label_price_status | minute={5, 35} | — |
| 15 | align_zf_fg_schema | hour=4, minute=0 | — |
| 16 | collection_cycle_finances | minute=40, hour={0, 6, 12, 18} | — |
| 17 | collection_noon_orders | minute={3, 18, 33, 48} | — |
| 18 | collection_noon_deep | minute=53, hour={1, 7, 13, 19} | — |
| 19 | collection_cycle_ads | minute=0, hour={2, 3, 4, 5} | 05:00 槽位含 onno zip 手动通道 |
| 20 | collection_cycle_sales | minute=0, hour={1, 3} | — |
| 21 | collection_cycle_settlements | minute=10, hour=4 | — |
| 22 | collection_cycle_inventory | minute=0, hour=8 | — |
| 23 | collection_cycle_ads_snapshot | minute=30, hour=0 | — |
| 24 | collection_cycle_ads_audit | minute=0, hour=8 | — |
| 25 | daily_fx_rates | hour=6, minute=5 | 汇率锚日更(其余币种, 锚定三币除外) |
| 26 | daily_amazon_rankings_keepa | hour=5, minute=20 | BSR 榜单采集 |
| 27 | ads_import_pump | minute=set(range(60)) | 每分钟 · Redis 锁+FOR UPDATE SKIP LOCKED 单任务 |
| 28 | collection_scheduler(宿主 cron) | * * * * * | 统一调度器(2026-10-02 方案A 数据库驱动):读 collection_schedule 注册表→到点触发。每半点订单/ads 近1小时增量+每天 02:00 回访/快照+每整点推送+每天 04:30 站外推广只读库;新租户/品牌触发器自动建任务 |
非 cron 任务函数 9 个(API 触发/事件消费/内部调用):_pool · _rollup_one · _mercury_conn · fee_backfill_targeted · _ads_import_targets · _notify_fx · _handle_domain_event · _events_consumer_thread · _on_worker_startup。宿主侧另有 collection_scheduler(统一调度器,注册表驱动)+ 5 个 .sh 脚本+12 条宿主 crontab(见系统手册)。
| metric_calibers · 口径注册表(10 行,全局无 RLS·portal_app 只读) | |||||
|---|---|---|---|---|---|
| # | metric | platform | authoritative_source | fallback_source | 拍板日 |
| 1 | ad_spend | amazon | audit.cleaned_ads_sku_daily(SKU级) UNION ALL audit.cleaned_amazon_ads_daily(账户级) | — | 2026-09-26 |
| 2 | ad_spend | noon | noon_ads_daily(单源, 全品牌) | — | 2026-09-26 |
| 3 | cost | — | public.sku_mapping.cost_rmb(映射优先) | audit.cleaned_noon_procurement_cost(采购表回退, 两者皆无计 0 该型号利润偏高) | 2026-09-26 |
| 4 | orders | amazon | audit.cleaned_amazon_orders | — | 2026-09-25 |
| 5 | orders | noon | audit.cleaned_noon_orders(实时日级) | — | 2026-09-26 |
| 6 | fx_pegged | — | 锚定汇率(冻结): SAR=3.75 / AED=3.6725 / RMB→USD=6.7963 | fx_rates(其余币种, daily_fx_rates 日更) | 2026-09-18 |
| 7 | settle_days_waiting | amazon | sync_mercury._ORDERS_UNION 按品牌起点列: zf=last_update_date(Amazon无发货列,OrderLastUpdatedAt≈发货时点,实测与下单日差11单) / fg=coalesce(shipped_date,order_date) / onno=purchase_date(源无发货列) | 每分支单列, 无跨列 fallback | 2026-09-26 |
| 8 | settle_abnormal | amazon | is_abnormal = order_status=Shipped AND NOT 已回款 AND days_waiting>14 | 已回款信号: zf=has_finance / fg=settlement_status<>已回款 / onno=订单金额入账(st.settled) | 2026-09-26 |
| 9 | inventory_by_country | amazon | chips 主数=stocked(该国有库存SKU数,与文案一致); 辅注=在管上架行数count | count=上架即统计口径保留(2026-09-22拍板) | 2026-09-26 |
| 10 | logistics_kpi | all | /api/logistics/shipments KPI=明细表 logistics_shipments 实时聚合(同源同筛选同RLS) | 无(旧 logistics_stats 快照表退役留档, 停在2026-09-05) | 2026-09-26 |
| platforms · 平台能力(3) | marketplaces · 站点(23 国) | ||
|---|---|---|---|
| amazon=active · noon=active · emag=planned emag=planned 已排队(接入=采集适配器+清洗+页面全套工程) | amazon 19 站 · emag 2 站 · noon 2 站(amazon 19 / noon SA·AE / emag RO·BG) |
| brands_source · 管道注册表(活库 9 行 = 3 租户 × 6 组(品牌,平台),下表按(品牌,平台)去重展示 · enabled=管道级,与租户停用(tenant_brands.is_active)分层) | |||
|---|---|---|---|
| 品牌 | 平台 | enabled | 说明 |
| brainnews | amazon | t | source_map 驱动动态分支 |
| fittingirls | amazon | t | source_map 驱动动态分支 |
| onno | amazon | t | source_map 驱动动态分支 |
| onno | noon | t | source_map 驱动动态分支 |
| zipforce | amazon | t | source_map 驱动动态分支 |
| zipforce | noon | t | source_map 驱动动态分支 |
| tenants · 租户(3,均 active) | ||
|---|---|---|
| t1 | zipforce | active |
| t2 | onno | active |
| t3 | fittingirls | active |
| collection_schedule · 调度注册表(14 行,2026-10-02 统一调度器方案A · 新租户/品牌触发器自动插行) | |||
|---|---|---|---|
| task_type | cron | 行数 | 说明 |
| collect | */30 * * * * | 5 | 每半点订单/ads 近1小时增量(zf/onno/fg-amazon --hours 1 + noon-*-inc --days 1) |
| collect | 0 2 * * * | 3 | 每天 02:00 回访(订单窗拉长 amazon --hours 24/noon --days 7)+库存快照(noon-inventory/amz-fba/sales-fba) |
| daily_readonly | 30 4 * * * | 3 | 每天 04:30 站外推广只读库更新(promotion_refresh,物理共享仅 tenant=1 跑) |
| push | 0 * * * * | 3 | 每整点推送 api→web(删租户 redis 缓存键=数据新鲜度) |