该功能为验货端用户提供订单统计服务,支持按日、月、年维度统计订单数据,包括验收订单、退回订单和售后订单的统计。
接口地址: /api/inspection/order/statistics
请求方式: GET
参数说明:
type
: 统计类型,可选值:day
(按日)、month
(按月)、year
(按年)date
: 统计日期,格式:YYYY-MM-DD
响应示例:
{
"code": 1,
"msg": "统计数据获取成功",
"data": {
"date": "07-14",
"type": "day",
"current_period": {
"inspection_count": 158,
"return_count": 12,
"aftersale_count": 2
},
"previous_period": {
"inspection_count": 145,
"return_count": 10,
"aftersale_count": 3
},
"growth_rate": {
"inspection_rate": 8.97,
"return_rate": 20.00,
"aftersale_rate": -33.33
},
"statistics": {
"inspection_count": 158,
"return_count": 12,
"aftersale_count": 2
}
}
}
接口地址: /api/inspection/order/getStatisticsDateRange
请求方式: GET
响应示例:
{
"code": 1,
"msg": "日期范围获取成功",
"data": {
"earliest_date": "2024-01-01",
"latest_date": "2025-01-14",
"current_date": "2025-01-14",
"current_month": "2025-01",
"current_year": "2025"
}
}
接口地址: /api/inspection/order/getTrendData
请求方式: GET
参数说明:
type
: 统计类型(目前支持day
)days
: 统计天数,默认7天,范围1-365响应示例:
{
"code": 1,
"msg": "趋势数据获取成功",
"data": [
{
"date": "2025-01-08",
"display_date": "01-08",
"inspection_count": 120,
"return_count": 8,
"aftersale_count": 1
},
{
"date": "2025-01-09",
"display_date": "01-09",
"inspection_count": 135,
"return_count": 10,
"aftersale_count": 2
}
]
}
ORDER_STATUS = 211
(验货通过)ORDER_STATUS = 212
(验货不通过)ORDER_STATUS IN (202, 203)
(退款、退款确认)MM-DD
YYYY-MM
YYYY年
// 获取今日统计数据
fetch('/api/inspection/order/statistics?type=day&date=2025-01-14')
.then(response => response.json())
.then(data => {
console.log('今日验收订单:', data.data.statistics.inspection_count);
console.log('今日退回订单:', data.data.statistics.return_count);
console.log('今日售后订单:', data.data.statistics.aftersale_count);
});
// 获取本月统计数据
fetch('/api/inspection/order/statistics?type=month&date=2025-01-14')
.then(response => response.json())
.then(data => {
console.log('本月统计:', data.data.statistics);
console.log('环比增长:', data.data.growth_rate);
});
// 获取最近7天趋势数据
fetch('/api/inspection/order/getTrendData?type=day&days=7')
.then(response => response.json())
.then(data => {
data.data.forEach(item => {
console.log(`${item.display_date}: 验收${item.inspection_count},退回${item.return_count},售后${item.aftersale_count}`);
});
});
YYYY-MM-DD
常见错误码:
400
: 参数验证失败401
: 未登录或登录已过期403
: 权限不足500
: 服务器内部错误错误响应示例:
{
"code": 0,
"msg": "统计类型只能是day、month、year",
"data": null
}