26 lines
881 B
JavaScript
26 lines
881 B
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const conflictSchema = new mongoose.Schema({
|
|
conflictId: { type: String, required: true, unique: true },
|
|
type: { type: String, enum: ['骑手门店', '门店公司'], required: true },
|
|
title: { type: String, required: true },
|
|
content: { type: String },
|
|
partyA: { type: String }, // 骑手/门店
|
|
partyB: { type: String }, // 门店/公司
|
|
status: { type: String, enum: ['待处理', '处理中', '已解决', '已关闭'], default: '待处理' },
|
|
handler: { type: String },
|
|
result: { type: String },
|
|
createdAt: { type: Date, default: Date.now },
|
|
updatedAt: { type: Date, default: Date.now }
|
|
});
|
|
|
|
conflictSchema.pre('save', function(next) {
|
|
if (!this.conflictId) {
|
|
this.conflictId = `CONF${Date.now()}`;
|
|
}
|
|
this.updatedAt = new Date();
|
|
next();
|
|
});
|
|
|
|
module.exports = mongoose.model('Conflict', conflictSchema);
|