shopInBill.js 1.2 KB

123456789101112131415161718192021222324252627282930
  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. // 店铺流水
  6. // 如果是入账,则有抽成比例,总金额.出账则不需要抽成比例和总金额
  7. const shopInBill = {
  8. shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
  9. cut: { type: Number, required: false, zh: '抽成比例' }, //
  10. time: { type: String, required: false, zh: '流水时间' }, //
  11. source: { type: String, required: false, zh: '来源' }, // 字典:cashBack_source
  12. source_id: { type: String, required: false, zh: '来源id' }, //
  13. };
  14. const schema = new Schema(shopInBill, { toJSON: { getters: true, virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.index({ shop: 1 });
  18. schema.index({ source: 1 });
  19. schema.index({ source_id: 1 });
  20. schema.plugin(metaPlugin);
  21. schema.plugin(MoneyPlugin({ zh: '总金额', required: false, key: 'total' }));
  22. schema.plugin(MoneyPlugin({ zh: '净金额', required: false, key: 'receipts' }));
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('ShopInBill', schema, 'shopInBill');
  26. };