thread-master/docs/product/demand-radar/tasks/T589-crm-stats-api-three-di...

52 lines
1.6 KiB
Markdown
Raw 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.

# T589 — crm-stats-api-three-dimensions
> Status: `done`
> Milestone: `M5`
> Kind: `feat`
> Est. change: `~200 lines`
## Goal
完成後系統應:`GET /api/v1/crm/stats` 回關鍵字轉換率、回覆版本成功率、成交來源三維度,樣本 < 5 只給絕對數並標樣本不足」。
## Depends on
- T548T572
## Inputs
- Spec`../spec.md` §4.8、§9.5ST-01ST-03
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/generate/api/crm.api` | edit | stats resp type三維度`insufficient_sample` 標記 |
| `apps/backend/internal/logic/crm/getCrmStatsLogic.go` | edit | 聚合查詢 |
| `apps/backend/internal/module/crm/usecase/stats.go` | add | 三維度計算與樣本門檻判斷 |
### 行為變更
- 關鍵字維度 watch `term` 為單位`won/accepted` acceptedrepliedwon 絕對數
- 回覆版本維度 `variant` 為單位`(replied + won) / used``used` 來自 T548 `MarkUsed`)。
- 來源維度`radar`既有海巡`manual_import` 的成交筆數P0 不含金額)。
- 任一維度樣本 < 5`insufficient_sample=true`**只回絕對數**,不回百分比與排名。
## Out of scope
- 金額維度P1
- 圖表T591 用既有元件
## Acceptance
- [x] ST-01accepted 8won 2 顯示轉換率與絕對數
- [x] ST-02樣本 3 `insufficient_sample=true` 且無百分比
- [x] ST-03三種來源分列
- [x] 指令
```bash
cd apps/backend && make gen-api && go test ./internal/logic/crm/... ./internal/module/crm/... -count=1
```