import { Client } from 'ssh2'; const conn = new Client(); conn.on('ready', () => { console.log('=== 检查订单数据 ===\n'); console.log('1. 获取所有订单:'); conn.exec('curl -s http://localhost:4000/api/orders', (err, stream) => { if (err) { console.log('ERR:', err); conn.end(); return; } let output = ''; stream.on('data', (d) => output += d.toString()); stream.on('close', () => { try { const result = JSON.parse(output); const orders = result.data || []; console.log(`总订单数: ${orders.length}`); const ids = orders.map(o => o.id); console.log('订单ID列表:', ids.join(', ')); const uniqueIds = [...new Set(ids)]; if (uniqueIds.length !== ids.length) { console.log('\n⚠️ 发现重复订单ID!'); const duplicates = ids.filter((id, index) => ids.indexOf(id) !== index); console.log('重复的ID:', [...new Set(duplicates)]); } console.log('\n2. 检查数据文件:'); conn.exec('cat /www/huishou/server/data/orders.json | head -200', (err, stream2) => { if (err) { console.log('ERR:', err); conn.end(); return; } let output2 = ''; stream2.on('data', (d) => output2 += d.toString()); stream2.on('close', () => { console.log('orders.json内容:', output2); conn.end(); }); }); } catch (e) { console.log('解析错误:', e.message); console.log('输出:', output); conn.end(); } }); }); }); conn.on('error', (err) => { console.log('连接错误:', err.message); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });