1234567891011121314151617181920212223242526272829 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 订单表
- const order = {
- date: { type: String }, // 下单日期
- arrange_id: { type: ObjectId }, // 安排内容的数据id,arrange中arrange的id
- openid: { type: String }, // 微信openid
- order_no: { type: String }, // 订单号
- phone: { type: String }, // 预留电话
- name: { type: String }, // 预留姓名
- status: { type: String, default: '0' }, // 状态0-未支付;1-支付完成
- pay_way: { type: String }, // 0-微信直接支付;1-vip账户划走;
- remark: { type: String },
- };
- const schema = new Schema(order, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ date: 1 });
- schema.index({ openid: 1 });
- schema.index({ order_no: 1 });
- schema.index({ status: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Order', schema, 'order');
- };
|