orderDetail.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. const transport = {
  3. shop_transport_no: '运单号',
  4. shop_transport_type: '快递公司类型',
  5. };
  6. const Schema = require('mongoose').Schema;
  7. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  8. /**
  9. * goods中会标记已对账的规格(out_bill:true),已对账的商品将不会再出现在对账单
  10. * 所有的规格对账后,该订单也将变为已对账状态
  11. */
  12. // 订单详情
  13. const orderDetail = {
  14. order: { type: String, required: false, zh: '总订单', ref: 'Trade.order' }, //
  15. shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
  16. customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
  17. address: { type: Object, required: false, zh: '邮寄地址' }, //
  18. no: { type: String, required: false, zh: '订单号' }, //
  19. transport: { type: Object, required: false, zh: '快递' }, // {no:运单号,type:快递公司编码}
  20. goods: { type: Array, required: false, zh: '商品快照清单' }, // 下单时,商品的属性设置:[{商品规格,商品信息}]
  21. total_detail: { type: Object, required: false, zh: '金额明细' }, // 本单的:{货物总价,运费总价,优惠详情:{优惠券id:{规格id:优惠金额}}}
  22. buy_time: { type: String, required: false, zh: '下单时间' }, //
  23. pay_time: { type: String, required: false, zh: '支付时间' }, //
  24. discount: { type: Array, required: false, zh: '优惠' }, //
  25. status: { type: String, required: false, zh: '订单状态' }, // 字典:order_process
  26. remarks: { type: String, required: false, zh: '订单备注' }, //
  27. type: { type: String, required: false, default: '0', zh: '订单类型' }, // 字典:order_type
  28. group: { type: String, required: false, zh: '所属团', ref: 'Group.Group' }, //
  29. out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf
  30. };
  31. const schema = new Schema(orderDetail, { toJSON: { getters: true, virtuals: true } });
  32. schema.index({ id: 1 });
  33. schema.index({ 'meta.createdAt': 1 });
  34. schema.index({ order: 1 });
  35. schema.index({ shop: 1 });
  36. schema.index({ customer: 1 });
  37. schema.index({ address: 1 });
  38. schema.index({ no: 1 });
  39. schema.index({ buy_time: 1 });
  40. schema.index({ pay_time: 1 });
  41. schema.index({ status: 1 });
  42. schema.index({ type: 1 });
  43. schema.index({ group: 1 });
  44. schema.index({ out_bill: 1 });
  45. schema.plugin(metaPlugin);
  46. module.exports = app => {
  47. const { mongoose } = app;
  48. return mongoose.model('OrderDetail', schema, 'orderDetail');
  49. };