feat(store): 添加门店、门店验证

This commit is contained in:
R524809
2026-09-04 10:27:29 +08:00
parent 66ca8b496c
commit 70d9d5b92a
19 changed files with 602 additions and 26 deletions
+28 -1
View File
@@ -13,6 +13,7 @@
"code": "OZON",
"name": "Ozon",
"supported_currencies": ["CNY", "RUB"],
"default_currency_code": "CNY",
"default_market_code": "RU",
"default_locale": "ru-RU"
}]
@@ -81,7 +82,7 @@ Headers:`Idempotency-Key` 必填。
}
```
校验 `currency_code` 是否为目标平台可用币种。服务端立即把 API Key 信封加密保存、创建 `status=verifying` 的店铺,随后投递“低风险凭据验证 + 仓库同步”操作;不得将 Key 放入任务 payload、日志或响应。
校验 `currency_code` 是否为目标平台可用币种。服务端立即把 API Key 信封加密保存、创建 `status=verifying` 的店铺,并投递低风险凭据验证操作;不得将 Key 放入任务 payload、日志或响应。仓库同步是独立的后续操作,不随创建自动触发。
返回 `202 Accepted`:
@@ -96,6 +97,32 @@ Headers:`Idempotency-Key` 必填。
首家未删除店铺强制为默认。对已有店铺提交 `is_default=true` 时,服务端在同一事务取消旧默认店铺;校验失败不把店铺置为 `active`,失败原因以可展示的脱敏 `last_error` 摘要(`code`、`message`、`at`)返回给后续读取接口。
### 4.1 Ozon 凭据验证与前端展示
Worker 只调用一个无写副作用的 Ozon Seller API 探针:
```http
POST /v1/description-category/tree
Client-Id: <store platform_client_id>
Api-Key: <decrypted secret, worker memory only>
Content-Type: application/json
{ "language": "ZH_HANS" }
```
该调用只用于验证 Ozon 是否接受当前 Client ID 与 API Key,不创建、修改或同步任何 Ozon 数据。它不携带 API Key 至队列、日志、operation 或 HTTP 响应。
| Worker 结果 | 店铺最终状态 | 前端文案与行为 |
|---|---|---|
| operation 为 `queued` / `running` | `status=verifying`、`credential_status=unknown` | 仅显示“验证中”;不要同时展示“未验证”。可轮询 operation,并在终态后刷新店铺列表。 |
| Ozon 返回 2xx | `active` / `valid` | 显示“正常”。 |
| Ozon 返回 401 | `credential_invalid` / `invalid` | 显示“凭据无效”,提示用户核对 Client ID 与 API Key。 |
| Ozon 返回 403 | `credential_invalid` / `invalid` | 显示“访问被拒绝”,提示 Client ID 与 API Key 必须属于同一账户,且密钥需要读取权限。 |
| Ozon 返回其他确定性 4xx | `sync_error` / 保留当前凭据状态 | 显示 `last_error.message`;该状态**不代表 API Key 无效**。 |
| 网络超时、429 或 5xx | 保持验证中,Worker 重试;重试耗尽后为 `sync_error` | 显示“暂时无法验证,请稍后重试”。 |
页面最终以 `GET /api/stores` 返回的店铺状态为准;`GET /api/operations/{operation_id}` 只用于得知异步过程是否结束及读取脱敏错误。点击“重新验证凭据”会重新发起上述一次类目树请求。
## 5. 编辑、默认店铺、验证与删除
`PATCH /api/stores/{store_id}`