123456789101112131415161718192021222324252627282930313233 |
- '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 costDetail = {
- school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
- payer_role: { type: String, required: false, zh: '消费用户角色i' }, //
- payer_id: { type: String, required: false, zh: '消费用户角色id', refPath: 'payer_role' }, //
- pay_for: { type: String, required: false, zh: '消费原因' }, //
- from_id: { type: String, required: false, zh: '消费原因id', refPath: 'pay_for' }, //
- type: { type: String, required: false, default: '0', zh: '扣款来源' }, // 0:直接支付;1余额
- pay_id: { type: String, required: false, zh: '支付id', ref: 'PayOrder' }, //
- };
- const schema = new Schema(costDetail, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ school_id: 1 });
- schema.index({ payer_role: 1 });
- schema.index({ payer_id: 1 });
- schema.index({ pay_for: 1 });
- schema.index({ from_id: 1 });
- schema.index({ type: 1 });
- schema.index({ pay_id: 1 });
- schema.plugin(metaPlugin);
- schema.plugin(MoneyPlugin({ zh: '消费金额', required: false }));
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('CostDetail', schema, 'costDetail');
- };
|