|
@@ -0,0 +1,32 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
+
|
|
|
+// 订单表
|
|
|
+const order = {
|
|
|
+ time: { type: String, required: false, zh: '下单时间' }, //
|
|
|
+ table: { type: String, required: false, zh: '下单桌号id' }, //
|
|
|
+ money: { type: Number, required: false, zh: '支付金额' }, //
|
|
|
+ money_num: { type: Number, required: false, zh: '餐位费' }, //
|
|
|
+ num: { type: Number, required: false, zh: '用餐人数' }, //
|
|
|
+ list: { type: Array, required: false, zh: '商品' }, //
|
|
|
+ type: { type: String, required: false, zh: '订单类型' }, //
|
|
|
+ remark: { type: String, required: false, zh: '备注' }, //
|
|
|
+};
|
|
|
+const schema = new Schema(order, {
|
|
|
+ toJSON: { getters: true, virtuals: true },
|
|
|
+});
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
+schema.index({ time: 1 });
|
|
|
+schema.index({ table: 1 });
|
|
|
+schema.index({ money: 1 });
|
|
|
+schema.index({ money_num: 1 });
|
|
|
+schema.index({ num: 1 });
|
|
|
+schema.index({ type: 1 });
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Order', schema, 'order');
|
|
|
+};
|