28 lines
993 B
JavaScript
28 lines
993 B
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const disputeSchema = new mongoose.Schema({
|
|
disputeId: { type: String, required: true, unique: true },
|
|
storeA: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
|
|
storeAName: { type: String },
|
|
storeB: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
|
|
storeBName: { type: String },
|
|
type: { type: String, enum: ['订单纠纷', '区域纠纷', '费用纠纷', '其他'], required: true },
|
|
title: { type: String, required: true },
|
|
content: { type: String },
|
|
status: { type: String, enum: ['待处理', '处理中', '已解决'], default: '待处理' },
|
|
result: { type: String },
|
|
handler: { type: String },
|
|
createdAt: { type: Date, default: Date.now },
|
|
updatedAt: { type: Date, default: Date.now }
|
|
});
|
|
|
|
disputeSchema.pre('save', function(next) {
|
|
if (!this.disputeId) {
|
|
this.disputeId = `DISP${Date.now()}`;
|
|
}
|
|
this.updatedAt = new Date();
|
|
next();
|
|
});
|
|
|
|
module.exports = mongoose.model('Dispute', disputeSchema);
|