72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
|
|
// 前端调试脚本:检查报表数据加载问题
|
||
|
|
const axios = require('axios');
|
||
|
|
const moment = require('moment');
|
||
|
|
|
||
|
|
async function debugReportIssue() {
|
||
|
|
try {
|
||
|
|
console.log('=== 报表数据加载问题调试 ===');
|
||
|
|
|
||
|
|
// 1. 检查当前时间范围的数据
|
||
|
|
const todayStart = moment().startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||
|
|
const todayEnd = moment().endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||
|
|
|
||
|
|
console.log(`\n1. 当前日期范围: ${todayStart} 至 ${todayEnd}`);
|
||
|
|
|
||
|
|
// 2. 测试后端API
|
||
|
|
console.log('\n2. 测试后端订单统计接口:');
|
||
|
|
const statsParams = {
|
||
|
|
start_date: todayStart,
|
||
|
|
end_date: todayEnd
|
||
|
|
};
|
||
|
|
|
||
|
|
console.log('请求参数:', statsParams);
|
||
|
|
const statsResponse = await axios.get('http://localhost:3002/api/orders/stats', {
|
||
|
|
params: statsParams
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('响应数据:', statsResponse.data);
|
||
|
|
|
||
|
|
// 3. 检查订单列表
|
||
|
|
console.log('\n3. 检查订单列表:');
|
||
|
|
const ordersResponse = await axios.get('http://localhost:3002/api/orders');
|
||
|
|
console.log(`订单总数: ${ordersResponse.data.data.length}`);
|
||
|
|
|
||
|
|
// 4. 检查今天是否有订单
|
||
|
|
const todayOrdersResponse = await axios.get('http://localhost:3002/api/orders', {
|
||
|
|
params: {
|
||
|
|
start_date: todayStart,
|
||
|
|
end_date: todayEnd
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log(`今天订单数: ${todayOrdersResponse.data.data.length}`);
|
||
|
|
if (todayOrdersResponse.data.data.length > 0) {
|
||
|
|
console.log('最近一个订单:', todayOrdersResponse.data.data[0]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 5. 检查特定日期的数据
|
||
|
|
console.log('\n4. 检查特定日期(2025-11-11)的数据:');
|
||
|
|
const specificDateStart = '2025-11-11 00:00:00';
|
||
|
|
const specificDateEnd = '2025-11-11 23:59:59';
|
||
|
|
|
||
|
|
const specificStatsResponse = await axios.get('http://localhost:3002/api/orders/stats', {
|
||
|
|
params: {
|
||
|
|
start_date: specificDateStart,
|
||
|
|
end_date: specificDateEnd
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('特定日期统计:', specificStatsResponse.data);
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
console.error('调试过程中发生错误:', error.message);
|
||
|
|
if (error.response) {
|
||
|
|
console.error('错误响应:', {
|
||
|
|
status: error.response.status,
|
||
|
|
data: error.response.data
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
debugReportIssue();
|