'use strict'; const transport = { shop_transport_no: '运单号', shop_transport_type: '快递公司类型', }; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); /** * goods中会标记已对账的规格(out_bill:true),已对账的商品将不会再出现在对账单 * 所有的规格对账后,该订单也将变为已对账状态 */ // 订单详情 const orderDetail = { order: { type: String, required: false, zh: '总订单', ref: 'Trade.order' }, // shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, // customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, // address: { type: Object, required: false, zh: '邮寄地址' }, // no: { type: String, required: false, zh: '订单号' }, // transport: { type: Object, required: false, zh: '快递' }, // {no:运单号,type:快递公司编码} goods: { type: Array, required: false, zh: '商品快照清单' }, // 下单时,商品的属性设置:[{商品规格,商品信息}] total_detail: { type: Object, required: false, zh: '金额明细' }, // 本单的:{货物总价,运费总价,优惠详情:{优惠券id:{规格id:优惠金额}}} buy_time: { type: String, required: false, zh: '下单时间' }, // pay_time: { type: String, required: false, zh: '支付时间' }, // discount: { type: Array, required: false, zh: '优惠' }, // status: { type: String, required: false, zh: '订单状态' }, // 字典:order_process remarks: { type: String, required: false, zh: '订单备注' }, // type: { type: String, required: false, default: '0', zh: '订单类型' }, // 字典:order_type group: { type: String, required: false, zh: '所属团', ref: 'Group.Group' }, // out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf }; const schema = new Schema(orderDetail, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ order: 1 }); schema.index({ shop: 1 }); schema.index({ customer: 1 }); schema.index({ address: 1 }); schema.index({ no: 1 }); schema.index({ buy_time: 1 }); schema.index({ pay_time: 1 }); schema.index({ status: 1 }); schema.index({ type: 1 }); schema.index({ group: 1 }); schema.index({ out_bill: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('OrderDetail', schema, 'orderDetail'); };