50 lines
1.5 KiB
Markdown
50 lines
1.5 KiB
Markdown
|
|
# T567 — accept-binds-or-creates-contact
|
|||
|
|
|
|||
|
|
> Status: `done`
|
|||
|
|
> Milestone: `M4`
|
|||
|
|
> Kind: `feat`
|
|||
|
|
> Est. change: `~150 lines`
|
|||
|
|
|
|||
|
|
## Goal
|
|||
|
|
|
|||
|
|
完成後系統應:商機 accept 時綁定或建立 Contact(`stage=new_found`),同一作者多筆商機收斂在同一 Contact。
|
|||
|
|
|
|||
|
|
## Depends on
|
|||
|
|
|
|||
|
|
- T547、T565、T566
|
|||
|
|
|
|||
|
|
## Inputs
|
|||
|
|
|
|||
|
|
- Spec:`../spec.md` §4.6.1、§4.6.2、§9.4(CR-01、CR-02)
|
|||
|
|
|
|||
|
|
## Outputs
|
|||
|
|
|
|||
|
|
### 程式變更(預期路徑)
|
|||
|
|
|
|||
|
|
| 路徑 | 動作 | 說明 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| `apps/backend/internal/logic/radar/acceptOpportunityLogic.go` | edit | 呼叫 CRM usecase,回應加 `contact_id` |
|
|||
|
|
| `apps/backend/internal/module/crm/usecase/intake.go` | add | 依(platform+handle+owner)FindOrCreate、AttachOpportunity、寫 `stage` touch |
|
|||
|
|
| `apps/backend/internal/module/radar/repository/opportunity_mongo.go` | edit | 回寫 `contact_id` |
|
|||
|
|
|
|||
|
|
### 行為變更
|
|||
|
|
|
|||
|
|
- 已 accept 過的商機重複 accept 為 idempotent(回同一 `contact_id`,不重複建 touch)。
|
|||
|
|
- 新建 Contact 寫一筆 `stage` touch(`from_stage` 空 → `new_found`)。
|
|||
|
|
- 第二筆商機 accept:掛上同一 Contact,時間軸出現兩筆。
|
|||
|
|
|
|||
|
|
## Out of scope
|
|||
|
|
|
|||
|
|
- 階段推進 API(T568/T570)
|
|||
|
|
- 前端(T574)
|
|||
|
|
|
|||
|
|
## Acceptance
|
|||
|
|
|
|||
|
|
- [x] CR-01:accept → Contact 建立、`stage=new_found`
|
|||
|
|
- [x] CR-02:同作者第二筆 → 同一 Contact、時間軸兩筆
|
|||
|
|
- [x] 指令:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd apps/backend && go test ./internal/logic/radar/... ./internal/module/crm/... -count=1
|
|||
|
|
```
|