GET /api/v1/intents/{id}
查询单个采购意图的完整详细信息。
接口说明
- 需要认证 - 需要提供签名请求头
- 用途 - 获取采购意图的完整信息,包括所有字段和处理状态
- 权限 - 仅能查询自己 App 创建的意图
请求头
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
X-App-Id | string | 是 | 应用 ID |
X-Timestamp | string | 是 | 请求时间戳(毫秒) |
X-Signature | string | 是 | 请求签名 |
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 采购意图 ID,如:intent_67890 |
请求示例
cURL
curl -X GET "https://api.procure-core.com/api/v1/intents/intent_67890" \
-H "X-App-Id: dev_app_local" \
-H "X-Timestamp: 1708851000000" \
-H "X-Signature: abc123..."TypeScript / JavaScript
import { ProcureClient } from '@procure-core/sdk';
const client = new ProcureClient({
appId: 'your_app_id',
appSecret: 'your_app_secret',
baseURL: 'https://api.procure-core.com'
});
const intent = await client.intents.get('intent_67890');
console.log('意图状态:', intent.status);
console.log('商品标题:', intent.title);
console.log('总金额:', intent.totalAmount);Python
from procure_core import ProcureClient
client = ProcureClient(
app_id='your_app_id',
app_secret='your_app_secret',
base_url='https://api.procure-core.com'
)
intent = client.intents.get('intent_67890')
print(f'意图状态: {intent.status}')
print(f'商品标题: {intent.title}')
print(f'总金额: {intent.total_amount}')响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
code | number | 状态码,0 表示成功 |
message | string | 响应消息 |
data | object | 意图详细信息 |
data 对象结构
| 参数 | 类型 | 说明 |
|---|---|---|
id | string | 采购意图 ID |
userId | string | 用户 ID |
platform | string | 电商平台:TAOBAO / JD / PDD |
productUrl | string | 商品原始链接 |
title | string | 商品标题 |
price | number | 商品单价(元) |
quantity | number | 采购数量 |
totalAmount | number | 总金额(元) |
recipientName | string | 收货人姓名 |
address | string | 收货详细地址 |
phone | string | 收货人联系电话 |
remarks | string | 备注信息 |
status | string | 状态:DRAFT / SUBMITTED / PROCESSING / COMPLETED / FAILED / CANCELLED |
statusMessage | string | 状态说明 |
failureReason | string | 失败原因(仅在 status 为 FAILED 时存在) |
trackingNumber | string | 物流单号(仅在有物流信息时存在) |
trackingCompany | string | 物流公司(仅在有物流信息时存在) |
orderId | string | 电商平台订单号(仅在下单成功后存在) |
createdAt | string | 创建时间(ISO 8601 格式) |
updatedAt | string | 更新时间(ISO 8601 格式) |
submittedAt | string | 提交时间(ISO 8601 格式) |
completedAt | string | 完成时间(ISO 8601 格式,仅在完成时存在) |
响应示例
处理中的意图
{
"code": 0,
"message": "操作成功",
"data": {
"id": "intent_67890",
"userId": "user_001",
"platform": "TAOBAO",
"productUrl": "https://item.taobao.com/item.htm?id=123456",
"title": "Apple iPhone 15 Pro 256GB",
"price": 8999,
"quantity": 1,
"totalAmount": 8999,
"recipientName": "张三",
"address": "北京市朝阳区望京SOHO T1 1001",
"phone": "13800138000",
"remarks": "请在工作日送达",
"status": "PROCESSING",
"statusMessage": "正在处理采购订单",
"createdAt": "2026-02-25T10:30:00.000Z",
"updatedAt": "2026-02-25T10:35:00.000Z",
"submittedAt": "2026-02-25T10:30:00.000Z"
}
}已完成的意图
{
"code": 0,
"message": "操作成功",
"data": {
"id": "intent_67890",
"userId": "user_001",
"platform": "TAOBAO",
"productUrl": "https://item.taobao.com/item.htm?id=123456",
"title": "Apple iPhone 15 Pro 256GB",
"price": 8999,
"quantity": 1,
"totalAmount": 8999,
"recipientName": "张三",
"address": "北京市朝阳区望京SOHO T1 1001",
"phone": "13800138000",
"remarks": "请在工作日送达",
"status": "COMPLETED",
"statusMessage": "采购订单已完成",
"orderId": "TB2026022512345678",
"trackingNumber": "SF1234567890",
"trackingCompany": "顺丰速运",
"createdAt": "2026-02-25T10:30:00.000Z",
"updatedAt": "2026-02-26T15:20:00.000Z",
"submittedAt": "2026-02-25T10:30:00.000Z",
"completedAt": "2026-02-26T15:20:00.000Z"
}
}失败的意图
{
"code": 0,
"message": "操作成功",
"data": {
"id": "intent_67890",
"userId": "user_001",
"platform": "TAOBAO",
"productUrl": "https://item.taobao.com/item.htm?id=123456",
"title": "Apple iPhone 15 Pro 256GB",
"price": 8999,
"quantity": 1,
"totalAmount": 8999,
"recipientName": "张三",
"address": "北京市朝阳区望京SOHO T1 1001",
"phone": "13800138000",
"status": "FAILED",
"statusMessage": "采购失败",
"failureReason": "商品已下架",
"createdAt": "2026-02-25T10:30:00.000Z",
"updatedAt": "2026-02-25T11:00:00.000Z",
"submittedAt": "2026-02-25T10:30:00.000Z"
}
}错误响应
意图不存在
状态码: 404 Not Found
{
"code": 40401,
"message": "采购意图不存在",
"data": null
}无权访问
状态码: 403 Forbidden
{
"code": 40301,
"message": "无权访问该资源",
"data": null
}使用场景
1. 轮询查询状态
async function waitForCompletion(intentId: string, timeout = 300000) {
const startTime = Date.now();
while (Date.now() - startTime < timeout) {
const intent = await client.intents.get(intentId);
if (intent.status === 'COMPLETED') {
console.log('采购完成!');
return intent;
}
if (intent.status === 'FAILED') {
throw new Error(`采购失败: ${intent.failureReason}`);
}
// 等待 5 秒后再次查询
await new Promise(resolve => setTimeout(resolve, 5000));
}
throw new Error('查询超时');
}2. 获取物流信息
async function getTrackingInfo(intentId: string) {
const intent = await client.intents.get(intentId);
if (intent.trackingNumber) {
return {
number: intent.trackingNumber,
company: intent.trackingCompany,
url: `https://tracking.example.com/${intent.trackingNumber}`
};
}
return null;
}3. 状态展示
function getStatusDisplay(status: string): { text: string; color: string } {
const statusMap = {
DRAFT: { text: '草稿', color: 'gray' },
SUBMITTED: { text: '已提交', color: 'blue' },
PROCESSING: { text: '处理中', color: 'yellow' },
COMPLETED: { text: '已完成', color: 'green' },
FAILED: { text: '失败', color: 'red' },
CANCELLED: { text: '已取消', color: 'gray' }
};
return statusMap[status] || { text: '未知', color: 'gray' };
}
const intent = await client.intents.get('intent_67890');
const display = getStatusDisplay(intent.status);
console.log(`状态: ${display.text} (${display.color})`);状态说明
| 状态 | 说明 | 可执行操作 |
|---|---|---|
| DRAFT | 草稿 | 更新、删除、提交 |
| SUBMITTED | 已提交 | 取消、查询 |
| PROCESSING | 处理中 | 取消、查询 |
| COMPLETED | 已完成 | 查询 |
| FAILED | 失败 | 查询、删除 |
| CANCELLED | 已取消 | 查询、删除 |
常见错误
| 错误码 | 错误消息 | 解决方案 |
|---|---|---|
| 40401 | 采购意图不存在 | 检查意图 ID 是否正确 |
| 40301 | 无权访问该资源 | 确认该意图属于当前 App |
| 40101 | 签名验证失败 | 检查签名算法和密钥 |
| 42901 | 请求过于频繁 | 降低轮询频率 |
性能优化建议
- 轮询间隔 - 建议设置合理的轮询间隔(5-10 秒)
- Webhook 通知 - 建议使用 Webhook 接收状态变更通知(未来版本支持)
- 缓存策略 - 对已完成的意图可以进行缓存
注意事项
- 权限控制 - 只能查询自己 App 创建的意图
- 速率限制 - 100 次/秒(单个 App ID)
- 敏感信息 - 手机号等敏感信息会部分脱敏显示