'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin'); const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin'); /** * 与订单不同,此处是1订单1规格模式,对完账就对完了 */ // 售后进度 const afterSale = { order_detail: { type: String, required: false, zh: '订单详情', ref: 'Trade.OrderDetail' }, // customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, // shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, // goods: { type: Object, required: false, zh: '需要售后的商品快照清单' }, // 一条记录值售后1个商品 type: { type: String, required: false, zh: '售后类型' }, // 字典:afterSale_type reason: { type: String, required: false, zh: '申请理由' }, // 字典:afterSale_reason desc: { type: String, required: false, zh: '申请售后描述' }, // file: { type: Array, required: false, zh: '凭证图片' }, // transport: { type: Object, required: false, zh: '快递信息' }, // apply_time: { type: String, required: false, zh: '售后申请时间' }, // end_time: { type: String, required: false, zh: '售后结束时间' }, // status: { type: String, required: false, zh: '售后状态' }, // 字典:afterSale_status result: { type: Object, required: false, zh: '售后结果' }, // 售后完成后需要补充的内容,例如:退款的金额 deal_person: { type: String, required: false, zh: '处理人', ref: 'User.Admin' }, // out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf }; const schema = new Schema(afterSale, { toJSON: { getters: true, virtuals: true } }); schema.index({ id: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.index({ type: 1 }); schema.index({ apply_time: 1 }); schema.index({ end_time: 1 }); schema.index({ deal_person: 1 }); schema.index({ out_bill: 1 }); schema.plugin(metaPlugin); schema.plugin(MoneyPlugin({ zh: '退款金额', required: false, key: 'money' })); module.exports = app => { const { mongoose } = app; return mongoose.model('AfterSale', schema, 'afterSale'); };