bill.js 686 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. //
  7. class BillService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'bill');
  10. this.model = this.ctx.model.Race.Bill;
  11. this.baseUserModel = this.ctx.model.Base.User;
  12. }
  13. async afterQuery(filter, data) {
  14. for (const i of data) {
  15. const user_id = _.get(i, 'payer_id.user_id');
  16. const user = await this.baseUserModel.findById(user_id);
  17. if (user) i.payer_name = user.name;
  18. }
  19. return data;
  20. }
  21. }
  22. module.exports = BillService;