feat(integration): 實作並測試 POS 與販賣機訂單同步 API
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 56s

主要變更:
- 實作 POS 與販賣機訂單同步邏輯,支援多租戶與 Sanctum 驗證。
- 修正多租戶識別中間件與 Sanctum 驗證順序問題。
- 切換快取驅動至 Redis 以支援 Tenancy 標籤功能。
- 新增商品同步 API (Upsert) 及相關單元測試。
- 新增手動測試腳本 tests/manual/test_integration_api.sh。
- 前端新增銷售訂單來源篩選與欄位顯示。
This commit is contained in:
2026-02-23 13:27:12 +08:00
parent 904132e460
commit 2f30a78118
23 changed files with 1429 additions and 100 deletions

View File

@@ -140,6 +140,37 @@ Star ERP 系統提供外部整合 API (Integration API) 供電商前台、POS
}
```
#### 錯誤回應 (HTTP 422 Unprocessable Entity - 驗證失敗)
當傳入資料格式有誤、商品編號不存在,或是該訂單正在處理中被系統鎖定時返回。
- **`message`** (字串): 錯誤摘要。
- **`errors`** (物件): 具體的錯誤明細列表,能一次性回報多個商品不存在或其它欄位錯誤。
```json
{
"message": "Validation failed",
"errors": {
"items": [
"The following products are not found: POS-999, POS-888. Please sync products first."
],
"external_order_id": [
"The order ORD-01 is currently being processed by another transaction. Please try again later."
]
}
}
```
#### 錯誤回應 (HTTP 500 Internal Server Error - 伺服器異常)
當系統發生預期外的錯誤(如資料庫連線失敗)時返回。
```json
{
"message": "Sync failed: An unexpected error occurred."
}
```
---
## 幂等性說明 (Idempotency)