afterSale.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. const transport = {
  6. customer_transport_no: { type: String, zh: '客户的快递单号' },
  7. customer_transport_type: { type: String, zh: '客户的快递公司' },
  8. customer_receive: { type: Boolean, zh: '客户是否签收' },
  9. shop_transport_no: { type: String, zh: '店家的快递单号' },
  10. shop_transport_type: { type: String, zh: '店家的快递公司' },
  11. shop_receive: { type: Boolean, zh: '店铺是否签收' },
  12. };
  13. // 售后进度
  14. const afterSale = {
  15. order_detail: { type: String, required: false, zh: '订单详情', ref: 'Trade.OrderDetail' }, //
  16. customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
  17. shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
  18. set_id: { type: String, required: false, zh: '套装id' }, //
  19. goods: { type: Object, required: false, zh: '需要售后的商品快照清单' }, // 一条记录值售后1个商品, goods._id:规格id
  20. type: { type: String, required: false, zh: '售后类型' }, // 字典:afterSale_type
  21. reason: { type: String, required: false, zh: '申请理由' }, // 字典:afterSale_reason
  22. desc: { type: String, required: false, zh: '申请售后描述' }, //
  23. file: { type: Array, required: false, zh: '凭证图片' }, //
  24. transport: { type: Object, required: false, zh: '快递信息' }, // 双方都可能快递单号,也都有可能有收货字段
  25. apply_time: { type: String, required: false, zh: '售后申请时间' }, //
  26. end_time: { type: String, required: false, zh: '售后结束时间' }, //
  27. status: { type: String, required: false, zh: '售后状态' }, // 字典:afterSale_status
  28. deal_person: { type: String, required: false, zh: '处理人', ref: 'User.Admin' }, //
  29. out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf
  30. };
  31. const schema = new Schema(afterSale, { toJSON: { getters: true, virtuals: true } });
  32. schema.index({ id: 1 });
  33. schema.index({ 'meta.createdAt': 1 });
  34. schema.index({ shop: 1 });
  35. schema.index({ type: 1 });
  36. schema.index({ apply_time: 1 });
  37. schema.index({ end_time: 1 });
  38. schema.index({ deal_person: 1 });
  39. schema.index({ out_bill: 1 });
  40. schema.plugin(metaPlugin);
  41. schema.plugin(MoneyPlugin({ zh: '退款金额', required: false, key: 'money' }));
  42. module.exports = app => {
  43. const { mongoose } = app;
  44. return mongoose.model('AfterSale', schema, 'afterSale');
  45. };