joy-cli/docs/ops/manhuang-procurement-radar.md
feibisi 4bd5c2abab feat(manhuang): demand CD 钉、货架通知滤噪、成交回填入口
- ensure-cd-watches:默认并入 DEMAND_WATCHES(Plati/GGSel/FunPay 需求页)
- notify-chain:忽略 noise 价差;推送 sold_out/restock 等货架高信号
- record-shop-outcome.sh + 总览三利害卡;post-pay 可接 MANHUANG_SHOP_ID
2026-07-13 15:30:53 +08:00

200 lines
8.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 蛮荒 · 采购雷达(货架事件 / 信任 / 黑市面板)
> 2026-07-13 · SKU 通用(不绑某一产品)· 运维向
> 总手册:[manhuang-handbook.md](./manhuang-handbook.md) · 索引:[manhuang-README.md](./manhuang-README.md)
> 代码:`src/joy/dashboard/manhuang_shelf.py` · `scripts/manhuang/build-tab-caches.py` · 黑市 UI `manhuang.js`
## 0. 立场与边界
| 域 | 标准 |
|----|------|
| **神州** | 合规 / 道德 / 生产红线(本文件不改神州策略) |
| **蛮荒** | 弱肉强食、皆为利往:比价、缺口、信任、信号——**为决策服务** |
铁律(不变):
- **不成交**:系统内不代下单、不自动付款、不登录暗网商城下单。
- **SKU 通用**:缺口 → 采集 → 差分 → 事件 → 信任 → 面板;产品名只是 `sku_id`
- **黑市 ≠ 鬼市**:黑市 = 明面货架真价;鬼市 = opaque 信号与风险,默认不当成交真价。
---
## 1. 业务闭环(一图)
```
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ 能力缺口 │ │ 采集层 │ │ 差分 / 事件 │
│ demand gap │────►│ L1 CD 变页 │────►│ history 双快照 │
│ (号池/额度/ │ │ L2 结构化探针 │ │ price_up/down │
│ 支付轨…) │ │ L3 shops 账本 │ │ sold_out/listed │
└─────────────┘ └──────────────┘ │ unknown≠sold_out│
└────────┬────────┘
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ 人决策成交 │◄────│ 黑市面板 │◄────│ 信任分 │
│ (浏览器) │ │ 事件条+Δ+demand│ │ platform+ours │
│ post-hoc 回填│ │ shops 徽章 │ │ risk band │
└─────────────┘ └──────────────┘ └─────────────────┘
```
| 步骤 | 输入 | 输出 | 频率 |
|------|------|------|------|
| 1 缺口 | miling/pool/ops 状态 | demand / demand-first 旗 | collect + 探针 |
| 2 L1 CD | 商品/目录 URL | changed 计数 | ai-team CD |
| 3 L2 探针 | channels + SKU probes | quotes + history 行 | launchd ~30min |
| 4 差分 | 相邻 history best 图 | `price_moves` + `shelf_events` | build-tab-caches |
| 5 信任 | shops.json trust/risk/成交 | `trust.score` / `band` | collect / tab-caches |
| 6 面板 | tab_caches + blackmarket | 货架事件条、价差、demand、店徽章 | joy dashboard |
| 7 成交 | 人浏览器 | 可选回填 ours | 人工 |
---
## 2. 数据流与产物
| 路径 | 内容 |
|------|------|
| `~/.cache/manhuang/quotes/ai-accounts.json` | 当前 SKU 盘 best / market |
| `~/.cache/manhuang/quotes/history/YYYYMMDD.jsonl` | 每轮摘要:`best[sku]={p,ch,tier,av?,seller?}` |
| `~/.cache/manhuang/tab-caches.json` | `price_moves` · **`shelf_events`** · `demand_probe` · **`shops_trust`** · 新鲜度 |
| `~/.config/manhuang/shops.json` | 店账本:`risk` · `sku_for` · **`trust`** |
| CD `changedetection/status.json` | watches / changed变页雷达 |
**RSS 角色(写死):**
- 平台货架 **价/库存几乎无官方 RSS****自采**(探针 + CD
- RSS / RSSHub / Miniflux → **频道/社区/威胁信号**,不当 best 价账本。
- 中转价优先 **JSON/YAML 直链**,优于 RSS。
---
## 3. 货架事件契约
由纯函数 `derive_shelf_events(prev_best, cur_best)` 产出(可单测、无网)。
| type | 条件(摘要) |
|------|----------------|
| `price_up` / `price_down` | 两侧均有有效价且数值变化 |
| `sold_out` / `delist` | **仅当** cur 显式 `av` ∈ {sold_out, delist}(或等价 availability |
| `listed` / `restock` | prev 无货/售罄 → cur `in_stock` 且有价 |
| `channel_switch` | 同 SKU 有价渠道 ch 变化(可选附带) |
**铁律:`unknown` / 探针失败 / 缺字段 ≠ `sold_out`。**
CF/429/超时只能记 `av=unknown`,禁止当售罄推采购。
事件字段建议:
```json
{
"sku_id": "openai",
"type": "price_down",
"prev": 8.5,
"cur": 7.2,
"delta": -1.3,
"ch": "FunPay",
"prev_av": "in_stock",
"cur_av": "in_stock",
"ts": "ISO-8601"
}
```
`price_moves` 保留为价差子集(兼容旧 UI`shelf_events` 为完整事件流。
---
## 4. 商家信任模型
挂在 **shops 账本**(黑市可引用;鬼市默认 high risk
| 分量 | 字段 | 权重(默认) |
|------|------|----------------|
| 平台分 | `trust.platform.rating`05 或 0100`sales_n` | 30% |
| 我方履约 | `trust.ours.orders_ok` / `orders_fail` / `dispute` / `quality` | 50% |
| 风险 | 顶层 `risk` low/mid/high + dispute | 20% |
输出:
```json
{
"score": 0-100,
"band": "high|mid|low|block|unproven",
"platform": {...},
"ours": {...},
"inputs_used": ["risk", "ours", ...]
}
```
规则:
- `dispute``band=block` → 不进推荐采购。
- 仅有平台分、无我方单 → 最多 `unproven` / mid忌全仓跟。
- 鬼市 TG 默认 `risk=high`,信任分压低。
---
## 5. 面板(黑市)体现
| 块 | 数据 |
|----|------|
| demand 金边 / 需求单 | 已有 |
| **货架事件 24h 类** | `blackmarket.shelf_events` / `tab_caches.shelf_events` |
| 价差变动 | `price_moves`(兼容) |
| SKU 行 | 可选 trust 徽章best 渠道对应 shop |
| 店信任 | `shops_trust` / shops 行 `trust` |
鬼市:继续威胁 / shops signal**不成交**。
---
## 6. 你没点名但很关键的点
1. **假售罄**:墙/CF/解析失败 → 必须 `unknown`,否则误导补货。
2. **控频与封禁**全站日扫不可取demand-first + CD 定点SLEEP/轮换。
3. **币种 / 面值**:礼品卡 face range ≠ 单价;`price_flag` 防捆绑误读。
4. **多 listing 去重**:同 SKU 多商品取 best事件按 sku_id 聚合,避免刷屏。
5. **通知噪声**:仅 demand SKU 或 |Δ| 超阈再推 konqi否则面板静默。
6. **我方信任 > 平台星**:平台可刷;履约回填才是蛮荒真分。
7. **历史污染**subset 探针合并缓存history 应标 probed 集,避免「没扫到」当下架(当前用 unknown 兜底)。
8. **法律/账号风险**:观察与自用决策边界在操作者;系统不自动化社工或欺诈工具链。
---
## 7. 运维入口
```bash
# 差分 + 事件 + 信任摘要(无外网)
python3 scripts/manhuang/build-tab-caches.py
# 探针(有网时)写 history.av
python3 scripts/manhuang/probe-ai-account-quotes.py --demand-first --force
# 成交回填我方信任(系统外成交后)
python3 scripts/manhuang/ensure-shops.py --record-outcome <shop_id> --ok
python3 scripts/manhuang/ensure-shops.py --record-outcome <shop_id> --fail
python3 scripts/manhuang/ensure-shops.py --record-outcome <shop_id> --dispute
# 单测(纯逻辑;无 pytest 时直接跑)
cd ~/Projects/joy-cli && PYTHONPATH=src python3 tests/test_manhuang_shelf.py
```
配置店:`~/.config/manhuang/shops.json`(模板 `configs/manhuang/shops.example.json`)。
**噪声**:礼品卡等 `face_vs_listing` 极端价差会标 `noise=true`(仍保留事件,面板降权显示,勿当真降价采购)。
### 运维续接2026-07-13
| 动作 | 命令 |
|------|------|
| 钉 demand 货架 + 店CD | `python3 scripts/manhuang/ensure-cd-watches.py --all`CD 在 ai-team `:5000` |
| 货架高信号 → konqi | `run-quote-probe` 末尾 `notify-chain.sh`**滤 noise**;含 sold_out/restock |
| 成交回填信任 | `bash scripts/manhuang/record-shop-outcome.sh <shop_id> --ok` |
| 付款入池后自动回填 | `MANHUANG_SHOP_ID=<id> bash ~/data/opencode/bin/post-pay-apply.sh --all --yes` |
---
## 8. 非目标(本雷达)
- 自动下单 / 自动代付
- 全站爬虫 / 暗网登录货架
- 发明平台官方 RSS
- 神州合规 UI
- 绑定某一具体 SKU 为唯一交付物