afterSale.js 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 售后进度
  5. const afterSale = {
  6. order_detail: { type: String, required: false, zh: '订单详情', ref: 'Trade.OrderDetail' }, //
  7. customer: { type: String, required: false, zh: '顾客', ref: 'User.Customer' }, //
  8. shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
  9. goods: { type: Object, required: false, zh: '需要售后的商品快照清单' }, // 一条记录值售后1个商品
  10. type: { type: String, required: false, zh: '售后类型' }, // 字典:afterSale_type
  11. reason: { type: String, required: false, zh: '申请理由' }, // 字典:afterSale_reason
  12. desc: { type: String, required: false, zh: '申请售后描述' }, //
  13. file: { type: Array, required: false, zh: '凭证图片' }, //
  14. transport: { type: Object, required: false, zh: '快递信息' }, //
  15. apply_time: { type: String, required: false, zh: '售后申请时间' }, //
  16. end_time: { type: String, required: false, zh: '售后结束时间' }, //
  17. status: { type: String, required: false, zh: '售后状态' }, // 字典:afterSale_status
  18. };
  19. const schema = new Schema(afterSale, { toJSON: { getters: true, virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.index({ type: 1 });
  23. schema.index({ apply_time: 1 });
  24. schema.index({ end_time: 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('AfterSale', schema, 'afterSale');
  29. };