orderDetail.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 'use strict';
  2. const transport = {
  3. shop_transport_no: '运单号',
  4. shop_transport_type: '快递公司类型',
  5. };
  6. const discount_detail = {
  7. // key:value形式
  8. key: '领取的优惠券id',
  9. value: 'key:value形式:key:规格id ; value:分配的价格',
  10. };
  11. const act = {
  12. // [object]形式
  13. act_id: { type: String, zh: '活动id' },
  14. money: { type: Number, zh: '返现金额' },
  15. time: { type: String, zh: '返现时间' },
  16. data: { type: Object, zh: '退款数据' },
  17. };
  18. const total_detail = {
  19. goods_total: { type: Number, zh: '商品总价' },
  20. freight_total: { type: Number, zh: '运费总价' },
  21. discount_detail: { type: Object, zh: '优惠券明细' },
  22. act: { type: Array, zh: '活动相关' },
  23. };
  24. const Schema = require('mongoose').Schema;
  25. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  26. /**
  27. * goods中会标记已对账的规格(out_bill:true),已对账的商品将不会再出现在对账单
  28. * 所有的规格对账后,该订单也将变为已对账状态
  29. */
  30. // 订单详情
  31. const orderDetail = {
  32. order: { type: String, required: false, zh: '总订单', ref: 'Trade.order' }, //
  33. shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
  34. customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
  35. address: { type: Object, required: false, zh: '邮寄地址' }, //
  36. no: { type: String, required: false, zh: '订单号' }, //
  37. transport: { type: Array, required: false, zh: '快递' }, // {no:运单号,type:快递公司编码}
  38. goods: { type: Array, required: false, zh: '商品快照清单' }, // 下单时,商品的属性设置:[{商品规格,商品信息}]
  39. total_detail: { type: Object, required: false, zh: '金额明细' }, // 本单的:{货物总价,运费总价,优惠详情:{优惠券id:{规格id:优惠金额}}}
  40. buy_time: { type: String, required: false, zh: '下单时间' }, //
  41. pay_time: { type: String, required: false, zh: '支付时间' }, //
  42. discount: { type: Array, required: false, zh: '优惠' }, //
  43. status: { type: String, required: false, zh: '订单状态' }, // 字典:order_process
  44. remarks: { type: String, required: false, zh: '订单备注' }, //
  45. type: { type: String, required: false, default: '0', zh: '订单类型' }, // 字典:order_type
  46. out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf
  47. inviter: { type: String, required: false, zh: '推荐商品人', ref: 'User.User' }, // 返现部分
  48. transport_type: { type: String, required: false, zh: '快递类型' }, // 字典:transport_type
  49. };
  50. const schema = new Schema(orderDetail, { toJSON: { getters: true, virtuals: true } });
  51. schema.index({ id: 1 });
  52. schema.index({ 'meta.createdAt': 1 });
  53. schema.index({ order: 1 });
  54. schema.index({ shop: 1 });
  55. schema.index({ customer: 1 });
  56. schema.index({ address: 1 });
  57. schema.index({ no: 1 });
  58. schema.index({ buy_time: 1 });
  59. schema.index({ pay_time: 1 });
  60. schema.index({ status: 1 });
  61. schema.index({ type: 1 });
  62. schema.index({ out_bill: 1 });
  63. schema.index({ inviter: 1 });
  64. schema.index({ transport_type: 1 });
  65. schema.plugin(metaPlugin);
  66. module.exports = app => {
  67. const { mongoose } = app;
  68. return mongoose.model('OrderDetail', schema, 'orderDetail');
  69. };