achieve_verify_record.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. // 审核记录
  7. class Achieve_verify_recordService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'achieve_verify_record');
  10. this.model = this.ctx.model.AchieveVerifyRecord;
  11. this.apply = this.ctx.model.AchieveApply;
  12. this.expert = this.ctx.model.AchieveExpert;
  13. }
  14. /**
  15. * 添加审核记录
  16. * @param {Object} data 审核数据
  17. */
  18. async create(data) {
  19. const { status, apply_id } = data;
  20. const res = await this.apply.updateOne({ _id: apply_id }, { status });
  21. if (res.ok && _.isNumber(res.ok) && res.ok > 0) {
  22. const record = await this.model.create(data);
  23. // 21-03-22 先不需要了:status=2时(评分已过,需要缴费),需要将该apply_id下的临时专家全部修改成GG状态(status=1)
  24. // if (status === '2') {
  25. // await this.expert.updateMany({ apply_id }, { status: '1' });
  26. // }
  27. // if (status === '3') {
  28. // await this.expert.updateMany({ apply_id }, { status: '1' });
  29. // }
  30. return record;
  31. }
  32. throw new BusinessError(ErrorCode.SERVICE_FAULT, '审核失败');
  33. }
  34. }
  35. module.exports = Achieve_verify_recordService;