e-scooter-rental-system/seed-dispute.js

123 lines
5.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/e-scooter-rental')
.then(async () => {
console.log('✅ MongoDB 连接成功');
const Dispute = require('./server/models/Dispute');
const Conflict = require('./server/models/Conflict');
const Store = require('./server/models/Store');
const Payment = require('./server/models/Payment');
// 清空纠纷和冲突数据
await Dispute.deleteMany({});
await Conflict.deleteMany({});
console.log('🧹 已清空纠纷协调数据');
const stores = await Store.find();
// 纠纷数据 (门店之间)
if (stores.length >= 2) {
await Dispute.insertMany([
{
disputeId: 'DISP001',
storeA: stores[0]._id, storeAName: stores[0].name,
storeB: stores[1]._id, storeBName: stores[1].name,
type: '订单纠纷',
title: '跨区订单归属争议',
content: '客户在A门店租车在B门店还车订单归属产生争议',
status: '处理中',
handler: '总部协调员'
},
{
disputeId: 'DISP002',
storeA: stores[2]._id, storeAName: stores[2].name,
storeB: stores[3]._id, storeBName: stores[3].name,
type: '费用纠纷',
title: '车辆维修费用分摊',
content: '跨区车辆维修费用分摊比例未达成一致',
status: '待处理'
},
{
disputeId: 'DISP003',
storeA: stores[0]._id, storeAName: stores[0].name,
storeB: stores[4]._id, storeBName: stores[4].name,
type: '区域纠纷',
title: '经营范围重叠',
content: '两家门店服务区域划分不明确',
status: '已解决',
result: '已重新划分服务区域',
handler: '区域经理'
}
]);
console.log('✅ 门店纠纷: 3 条');
}
// 冲突数据 (骑手门店/门店公司)
await Conflict.insertMany([
{
conflictId: 'CONF001',
type: '骑手门店',
title: '骑手租金拖欠',
content: '骑手张某拖欠门店租车租金共计500元',
partyA: '骑手张某',
partyB: '朝阳区总店',
status: '处理中',
handler: '王店长'
},
{
conflictId: 'CONF002',
type: '骑手门店',
title: '车辆损坏赔偿',
content: '骑手归还车辆时发现车身刮擦,双方对赔偿金额有争议',
partyA: '骑手李某',
partyB: '海淀区一分店',
status: '已解决',
result: '骑手承担200元维修费用',
handler: '李店长'
},
{
conflictId: 'CONF003',
type: '门店公司',
title: '总部扣款异议',
content: '门店对公司月度扣款有异议,认为计算有误',
partyA: '西城区二分店',
partyB: '公司总部',
status: '待处理'
},
{
conflictId: 'CONF004',
type: '骑手门店',
title: '头盔丢失',
content: '骑手归还车辆时遗失头盔一个',
partyA: '骑手赵某',
partyB: '东城区三分店',
status: '处理中',
handler: '赵店长'
}
]);
console.log('✅ 骑手/门店冲突: 4 条');
// 打款/财务数据 (使用正确的枚举值)
await Payment.insertMany([
{ paymentId: 'PAY006', type: '支出', party: '门店A', amount: 12000, method: '银行卡', category: '房租', remark: '3月房租', operator: '财务' },
{ paymentId: 'PAY007', type: '支出', party: '物业', amount: 1500, method: '银行卡', category: '水电', remark: '2月水电费', operator: '行政' },
{ paymentId: 'PAY008', type: '支出', party: '维修店', amount: 800, method: '微信', category: '维修', remark: '车辆维修', operator: '王店长' },
{ paymentId: 'PAY009', type: '收入', party: '骑手张某', amount: 500, method: '微信', category: '租金收入', remark: '骑手租金', operator: '系统' },
{ paymentId: 'PAY010', type: '支出', party: '员工B', amount: 4500, method: '银行卡', category: '工资', remark: '2月工资', operator: '财务' },
{ paymentId: 'PAY011', type: '收入', party: '骑手李某', amount: 300, method: '支付宝', category: '租金收入', remark: '骑手租金', operator: '系统' },
{ paymentId: 'PAY012', type: '支出', party: '供应商', amount: 3500, method: '银行卡', category: '其他', remark: '采购电池', operator: '采购' }
]);
console.log('✅ 打款/财务记录: 7 条');
console.log('\n🎉 纠纷协调和打款数据创建完成!');
console.log('📊 数据汇总:');
console.log(' - 门店纠纷: 3 条');
console.log(' - 骑手/门店冲突: 4 条');
console.log(' - 打款记录: 7 条');
mongoose.disconnect();
process.exit(0);
})
.catch(err => console.error('❌ 错误:', err));