# Plan: pickup-geocode-amap-compat (revised)

**Author:** planner  
**Updated:** 2026-08-14  
**Approach:** Amap adapter wraps under `result`; facade keeps `$response['result']`.

## Work Objectives

Align Amap `getLatAndLngByPosition` with the facade’s `$response['result']` contract; remove facade null-coalesce.

## Acceptance & Test Cases

| ID | WHEN / THEN |
|----|-------------|
| A1 | WHEN Amap adapter succeeds THEN return is `['result' => <geocodes list>]` |
| A2 | WHEN Amap empty address or failed status THEN return is `['result' => []]` |
| A3 | WHEN facade gets Amap-shaped `['result'=>[['location'=>'lng,lat']]]` THEN MapData has lng/lat |
| A4 | WHEN facade gets Tencent envelope THEN MapData has lng/lat (unchanged) |
| A5 | WHEN facade gets `['result'=>[]]` THEN empty MapData, no undefined-key error |
| A6 | WHEN inspect production diff THEN facade has no `?? $response`; Amap returns include `result` |

| 用例 | 对应 | 描述 |
|------|------|------|
| TC-1 | A3 | Facade mock Amap-with-result → lng/lat |
| TC-2 | A4 | Facade mock Tencent envelope → lng/lat |
| TC-3 | A5 | Facade mock `['result'=>[]]` → empty MapData |
| TC-4 | A1,A2,A6 | Code/review: Amap wrap + empty paths; facade reverted |

## TODOs

### TODO-R1 [RED→GREEN] Update facade tests for Amap-with-result; revert facade `??`

- Change TC-1 mock to `['result' => [['location' => '113.123456,22.654321']]]`
- Change TC-3 mock to `['result' => []]`
- Revert `MapService::getLatAndLng` to `handleLatAndLngByPosition($response['result'])`
- All three facade tests green

### TODO-R2 [GREEN] Amap adapter wrap `result`

- Empty address → `['result' => []]`
- Failed status → `['result' => []]`
- Success → `['result' => (array)($result['geocodes'] ?? [])]`
- Re-run facade tests (still green); confirm A6 via read/diff

## Must NOT

- Change Tencent adapter or PickupLocationService
- Bypass tdd-guard
- Commit unless asked
