1234567891011121314151617181920212223242526272829 |
- '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 charge = {
- school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
- payer_id: { type: String, required: false, zh: '充值用户角色id', refPath: 'payer_role', getProp: [ 'name' ] }, //
- payer_role: { type: String, required: false, zh: '充值用户角色' }, //
- pay_id: { type: String, required: false, zh: '支付id', ref: 'Payorder' }, //
- is_pay: { type: String, required: false, zh: '支付状态' }, // 0:未支付;1:支付成功;-1:支付失败;-3:已退款
- type: { type: String, default: '0', zh: '类型' }, // 0:充值;1:退款至余额
- time: { type: String, required: false, zh: '时间' }, //
- };
- const schema = new Schema(charge, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ school_id: 1 });
- schema.index({ payer_id: 1 });
- schema.index({ payer_role: 1 });
- schema.index({ is_pay: 1 });
- schema.plugin(metaPlugin);
- schema.plugin(moneyPlugin({ zh: '充值金额' }));
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Charge', schema, 'charge');
- };
|