1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- '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');
- const transport = {
- customer_transport_no: { type: String, zh: '客户的快递单号' },
- customer_transport_type: { type: String, zh: '客户的快递公司' },
- customer_receive: { type: Boolean, zh: '客户是否签收' },
- shop_transport_no: { type: String, zh: '店家的快递单号' },
- shop_transport_type: { type: String, zh: '店家的快递公司' },
- shop_receive: { type: Boolean, zh: '店铺是否签收' },
- };
- // 售后进度
- 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' }, //
- set_id: { type: String, required: false, zh: '套装id' }, //
- goods: { type: Object, required: false, zh: '需要售后的商品快照清单' }, // 一条记录值售后1个商品, goods._id:规格id
- 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
- 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({ shop: 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');
- };
|