settle_check.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. /**
  3. *
  4. * @author Mai
  5. * @date
  6. * @version
  7. */
  8. module.exports = options => {
  9. /**
  10. * 结算期 校验 中间件
  11. * 1. 读取 结算期 数据
  12. * 2. 检验用户是否参与(不校验具体权限)
  13. *
  14. * @param {function} next - 中间件继续执行的方法
  15. * @return {void}
  16. */
  17. return function* settleCheck(next) {
  18. try {
  19. // 读取标段数据
  20. const settleOrder = parseInt(this.params.sorder);
  21. if (settleOrder <= 0) throw '您访问的期不存在';
  22. const settle = yield this.service.settle.getDataByCondition({ tid: this.tender.id, settle_order: settleOrder });
  23. if (!settle) throw '您访问的期不存在';
  24. yield this.service.settle.doCheckSettle(settle);
  25. // 获取最新的期数
  26. settle.highOrder = yield this.service.settle.count({ tid: this.tender.id });
  27. this.settle = settle;
  28. yield next;
  29. } catch (err) {
  30. this.log(err);
  31. this.redirect(`/tender/${this.params.id}/settle`);
  32. }
  33. };
  34. };