|
@@ -21,37 +21,53 @@ module.exports = app => {
|
|
this.tableName = 's2b_spec_msg';
|
|
this.tableName = 's2b_spec_msg';
|
|
}
|
|
}
|
|
|
|
|
|
- async tenderNeedMsg(pid, tid) {
|
|
|
|
|
|
+ async tenderNeedMsg(pid, tid, timing) {
|
|
const specProj = await this.db.get('zh_s2b_spec_proj', { id: pid });
|
|
const specProj = await this.db.get('zh_s2b_spec_proj', { id: pid });
|
|
if (!specProj || !specProj.is_push) return false;
|
|
if (!specProj || !specProj.is_push) return false;
|
|
|
|
+
|
|
switch (specProj.push_tender_type) {
|
|
switch (specProj.push_tender_type) {
|
|
- case 0: return true;
|
|
|
|
case 1:
|
|
case 1:
|
|
const filter = specProj.filter_tender ? specProj.filter_tender.split(',') : [];
|
|
const filter = specProj.filter_tender ? specProj.filter_tender.split(',') : [];
|
|
- return filter.indexOf(tid + '') < 0;
|
|
|
|
|
|
+ if (filter.indexOf(tid + '') >= 0) return false;
|
|
|
|
+ break;
|
|
case 2:
|
|
case 2:
|
|
const access = specProj.access_tender ? specProj.access_tender.split(',') : [];
|
|
const access = specProj.access_tender ? specProj.access_tender.split(',') : [];
|
|
- return access.indexOf(tid + '') >= 0;
|
|
|
|
|
|
+ if (access.indexOf(tid + '') < 0) return false;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ const soleTender = await this.db.get('zh_s2b_spec_tender', { id: tid, is_valid: 1 });
|
|
|
|
+ const specPush = await this.db.get('zh_s2b_spec_push', { pid, tid: soleTender ? tid : 0, valid: 1, push_timing: timing });
|
|
|
|
+ return !!specPush;
|
|
}
|
|
}
|
|
|
|
|
|
async addLedgerMsg(transaction, pid, tender, timing) {
|
|
async addLedgerMsg(transaction, pid, tender, timing) {
|
|
- const needMsg = await this.tenderNeedMsg(pid, tender.id);
|
|
|
|
|
|
+ const needMsg = await this.tenderNeedMsg(pid, tender.id, timing);
|
|
if (!needMsg) return;
|
|
if (!needMsg) return;
|
|
await transaction.insert(this.tableName, { pid, tid: tender.id, timing });
|
|
await transaction.insert(this.tableName, { pid, tid: tender.id, timing });
|
|
}
|
|
}
|
|
|
|
|
|
async addReviseMsg(transaction, pid, revise, timing) {
|
|
async addReviseMsg(transaction, pid, revise, timing) {
|
|
- const needMsg = await this.tenderNeedMsg(pid, revise.tid);
|
|
|
|
|
|
+ const needMsg = await this.tenderNeedMsg(pid, revise.tid, timing);
|
|
if (!needMsg) return;
|
|
if (!needMsg) return;
|
|
await transaction.insert(this.tableName, { pid, tid: revise.tid, rid: revise.id, timing });
|
|
await transaction.insert(this.tableName, { pid, tid: revise.tid, rid: revise.id, timing });
|
|
}
|
|
}
|
|
|
|
|
|
async addStageMsg(transaction, pid, stage, timing) {
|
|
async addStageMsg(transaction, pid, stage, timing) {
|
|
- const needMsg = await this.tenderNeedMsg(pid, stage.tid);
|
|
|
|
|
|
+ const needMsg = await this.tenderNeedMsg(pid, stage.tid, timing);
|
|
if (!needMsg) return;
|
|
if (!needMsg) return;
|
|
await transaction.insert(this.tableName, { pid, tid: stage.tid, sid: stage.id, timing });
|
|
await transaction.insert(this.tableName, { pid, tid: stage.tid, sid: stage.id, timing });
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ async addReportMsg(transaction, pid, tender, stage, timing) {
|
|
|
|
+ const needMsg = await this.tenderNeedMsg(pid, stage.tid, timing);
|
|
|
|
+ if (!needMsg) return;
|
|
|
|
+ if (transaction) {
|
|
|
|
+ await transaction.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing });
|
|
|
|
+ } else {
|
|
|
|
+ await this.db.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return SpecPull;
|
|
return SpecPull;
|