afterSale.js 1.8 KB

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