'use strict'; /** * * @author Mai * @date * @version */ module.exports = options => { /** * 结算期 校验 中间件 * 1. 读取 结算期 数据 * 2. 检验用户是否参与(不校验具体权限) * * @param {function} next - 中间件继续执行的方法 * @return {void} */ return function* stageCheck(next) { try { // 读取标段数据 const settleOrder = parseInt(this.params.sorder); if (settleOrder <= 0) throw '您访问的期不存在'; const settle = yield this.service.settle.getDataByCondition({ tid: this.tender.id, settle_order: settleOrder }); if (!settle) throw '您访问的期不存在'; yield this.service.settle.doCheckSettle(settle); // 获取最新的期数 settle.highOrder = yield this.service.settle.count({ tid: this.tender.id }); this.settle = settle; yield next; } catch (err) { this.log(err); this.redirect(`/tender/${this.params.id}/settle`); } }; };