agent-foundation/docs/ngp-performance-api.md
2026-09-09 13:27:11 +08:00

58 lines
1.7 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.

# NGP 业绩合计接口
## 请求
`POST /api/ngp/performance/total`
```json
{
"startDate": "2026-09-01",
"endDate": "2026-09-06",
"storeName": "兰教练(抖店)"
}
```
- `startDate`、`endDate` 必填,包含首尾日期,最多 31 天。
- `storeName` 选填;不传或传空字符串时查询全部网点。多个网点可用逗号分隔。
- 后端调用 NGP 时固定传入 `postState=800`(财务核算成功)和
`refundStatus=0`(无需退款),调用方不需要传这两个参数,也不能覆盖。
- NGP 每页最多查询 200 条;服务会读取全部页面后返回合计。
## 响应
```json
{
"success": true,
"startDate": "2026-09-01",
"endDate": "2026-09-06",
"storeName": "全部网点",
"totalAmount": 4908668.47,
"formattedTotal": "4,908,668.47",
"currency": "CNY"
}
```
缓存未准备好时返回 HTTP `202`,并在后台按天汇总:
```json
{
"success": false,
"status": "PROCESSING",
"message": "后台正在汇总 6 天的数据,请稍后重试",
"pendingDays": 6,
"retryAfterSeconds": 10
}
```
调用方应按照 `retryAfterSeconds` 重新发送相同请求。完成后的每日各网点金额保存到
MySQL 表 `ngp_performance_daily_total`,日期完成状态保存到
`ngp_performance_daily_status`。相同日期的并发请求只触发一次后台任务。
## 部署配置
NGP 的 AppKey、AppSecret、access token 和 refresh token 位于 `application.yml` 的
`foundation.ngp` 节点。access token 失效时服务会使用 refresh token 自动刷新,并在当前
进程内保存新 token。配置文件含明文凭据,只能保存在私有仓库并限制读取权限。
历史日期结果默认缓存 24 小时,包含今天的结果默认缓存 10 分钟。