e-scooter-rental-system/server/seed-new.js

52 lines
2.3 KiB
JavaScript

const axios = require('axios');
async function seed() {
// 门店数据
const stores = [
{ storeId: 'STORE001', name: '旗舰店A', address: '北京市朝阳区', phone: '010-12345678', manager: '张三', status: '营业中' },
{ storeId: 'STORE002', name: '旗舰店B', address: '上海市浦东新区', phone: '021-87654321', manager: '李四', status: '营业中' },
{ storeId: 'STORE003', name: '加盟店C', address: '广州市天河区', phone: '020-11112222', manager: '王五', status: '装修中' }
];
for (const s of stores) {
await axios.post('http://localhost:3000/api/stores', s);
}
console.log('✅ 门店数据');
// 客服投诉
const complaints = [
{ complaintId: 'COMP001', type: '服务态度', content: '客户投诉店员态度不好', handler: '张三', status: '处理中' },
{ complaintId: 'COMP002', type: '车辆问题', content: '电动车电量不足', handler: '李四', status: '已解决' },
{ complaintId: 'COMP003', type: '费用问题', content: '费用计算有误', handler: '王五', status: '待处理' }
];
for (const c of complaints) {
await axios.post('http://localhost:3000/api/complaints', c);
}
console.log('✅ 客服投诉');
// 审批
const approvals = [
{ approvalId: 'APPR001', type: '订单退款', title: '客户申请退款', applicant: '张三', status: '待审批' },
{ approvalId: 'APPR002', type: '车辆报废', title: '旧车报废申请', applicant: '李四', status: '已通过' },
{ approvalId: 'APPR003', type: '押金退还', title: '押金退还审批', applicant: '王五', status: '待审批' }
];
for (const a of approvals) {
await axios.post('http://localhost:3000/api/approvals', a);
}
console.log('✅ 审批数据');
// 打款
const payments = [
{ paymentId: 'PAY001', type: '退款', amount: 200, method: '微信', account: 'wx123456', status: '待打款' },
{ paymentId: 'PAY002', type: '押金退还', amount: 500, method: '支付宝', account: 'ali@xx.com', status: '已打款' },
{ paymentId: 'PAY003', type: '分成', amount: 300, method: '银行卡', account: '6222***1234', status: '打款中' }
];
for (const p of payments) {
await axios.post('http://localhost:3000/api/payments', p);
}
console.log('✅ 打款数据');
console.log('🎉 测试数据添加完成!');
}
seed().catch(console.error);