'use strict'; const transport = { shop_transport_no: '运单号', shop_transport_type: '快递公司类型', }; const discount_detail = { // key:value形式 key: '领取的优惠券id', value: 'key:value形式:key:规格id ; value:分配的价格', }; const act = { // [object]形式 act_id: { type: String, zh: '活动id' }, money: { type: Number, zh: '返现金额' }, time: { type: String, zh: '返现时间' }, data: { type: Object, zh: '退款数据' }, }; const total_detail = { goods_total: { type: Number, zh: '商品总价' }, freight_total: { type: Number, zh: '运费总价' }, discount_detail: { type: Object, zh: '优惠券明细' }, act: { type: Array, zh: '活动相关' }, }; 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: Array, 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 out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf inviter: { type: String, required: false, zh: '推荐商品人', ref: 'User.User' }, // 返现部分 transport_type: { type: String, required: false, zh: '快递类型' }, // 字典:transport_type }; 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({ out_bill: 1 }); schema.index({ inviter: 1 }); schema.index({ transport_type: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('OrderDetail', schema, 'orderDetail'); };