| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- module.exports = app => {
- class SpecPull extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 's2b_spec_msg';
- }
- async tenderNeedMsg(pid, tid) {
- const specProj = await this.db.get('zh_s2b_spec_proj', { id: pid });
- if (!specProj || !specProj.is_push) return false;
- switch (specProj.push_tender_type) {
- case 0: return true;
- case 1:
- const filter = specProj.filter_tender ? specProj.filter_tender.split(',') : [];
- return filter.indexOf(tid + '') < 0;
- case 2:
- const access = specProj.access_tender ? specProj.access_tender.split(',') : [];
- return access.indexOf(tid + '') >= 0;
- }
- }
- async addLedgerMsg(transaction, pid, tender, timing) {
- const needMsg = await this.tenderNeedMsg(pid, tender.id);
- if (!needMsg) return;
- await transaction.insert(this.tableName, { pid, tid: tender.id, timing });
- }
- async addReviseMsg(transaction, pid, revise, timing) {
- const needMsg = await this.tenderNeedMsg(pid, revise.tid);
- if (!needMsg) return;
- await transaction.insert(this.tableName, { pid, tid: revise.tid, rid: revise.id, timing });
- }
- async addStageMsg(transaction, pid, stage, timing) {
- const needMsg = await this.tenderNeedMsg(pid, stage.tid);
- if (!needMsg) return;
- await transaction.insert(this.tableName, { pid, tid: stage.tid, sid: stage.id, timing });
- }
- }
- return SpecPull;
- };
|