|
@@ -331,11 +331,15 @@ module.exports = app => {
|
|
|
const result = await this.db.query(sql, sqlParam);
|
|
|
return result[0].count;
|
|
|
case 1: // 待处理(你的)
|
|
|
- return await this.ctx.service.changeAudit.count({
|
|
|
- tid: tenderId,
|
|
|
- uid: this.ctx.session.sessionUser.accountId,
|
|
|
- status: 2,
|
|
|
- });
|
|
|
+ // return await this.ctx.service.changeAudit.count({
|
|
|
+ // tid: tenderId,
|
|
|
+ // uid: this.ctx.session.sessionUser.accountId,
|
|
|
+ // status: 2,
|
|
|
+ // });
|
|
|
+ const sql6 = 'SELECT count(*) AS count FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)';
|
|
|
+ const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
|
|
|
+ const result6 = await this.db.query(sql6, sqlParam6);
|
|
|
+ return result6[0].count;
|
|
|
case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
|
|
|
const sql2 =
|
|
|
'SELECT count(*) AS count FROM ?? AS a WHERE ' +
|
|
@@ -370,6 +374,68 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async getTp(tenderId, status) {
|
|
|
+ if (this.ctx.tender.isTourist && status === 0) {
|
|
|
+ const sql5 = 'SELECT SUM(total_price) AS total_price FROM ?? WHERE tid = ?';
|
|
|
+ const sqlParam5 = [this.tableName, tenderId];
|
|
|
+ const result5 = await this.db.query(sql5, sqlParam5);
|
|
|
+ return result5[0].total_price ? result5[0].total_price : 0;
|
|
|
+ }
|
|
|
+ switch (status) {
|
|
|
+ case 0: // 包含你的所有变更令
|
|
|
+ const sql =
|
|
|
+ 'SELECT SUM(a.total_price) AS total_price FROM ?? AS a WHERE a.tid = ? AND ' +
|
|
|
+ '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid)) OR a.status = ? )';
|
|
|
+ const sqlParam = [
|
|
|
+ this.tableName,
|
|
|
+ tenderId,
|
|
|
+ this.ctx.session.sessionUser.accountId,
|
|
|
+ audit.flow.status.uncheck,
|
|
|
+ this.ctx.service.changeAudit.tableName,
|
|
|
+ this.ctx.session.sessionUser.accountId,
|
|
|
+ audit.flow.status.checked,
|
|
|
+ ];
|
|
|
+ const result = await this.db.query(sql, sqlParam);
|
|
|
+ return result[0].total_price ? result[0].total_price : 0;
|
|
|
+ case 1: // 待处理(你的)
|
|
|
+ const sql6 = 'SELECT SUM(a.total_price) AS total_price FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?)';
|
|
|
+ const sqlParam6 = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, audit.flow.auditStatus.checking];
|
|
|
+ const result6 = await this.db.query(sql6, sqlParam6);
|
|
|
+ return result6[0].total_price ? result6[0].total_price : 0;
|
|
|
+ case 5: // 待上报(所有的)PS:取未上报,退回,修订的变更令
|
|
|
+ const sql2 =
|
|
|
+ 'SELECT SUM(a.total_price) AS total_price FROM ?? AS a WHERE ' +
|
|
|
+ 'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid) ' +
|
|
|
+ 'AND (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?';
|
|
|
+ const sqlParam2 = [
|
|
|
+ this.tableName,
|
|
|
+ this.ctx.service.changeAudit.tableName,
|
|
|
+ this.ctx.session.sessionUser.accountId,
|
|
|
+ audit.flow.status.uncheck,
|
|
|
+ audit.flow.status.back,
|
|
|
+ audit.flow.status.revise,
|
|
|
+ tenderId,
|
|
|
+ ];
|
|
|
+ const result2 = await this.db.query(sql2, sqlParam2);
|
|
|
+ return result2[0].total_price ? result2[0].total_price : 0;
|
|
|
+ case 2: // 进行中(所有的)
|
|
|
+ case 4: // 终止(所有的)
|
|
|
+ const sql3 =
|
|
|
+ 'SELECT SUM(a.total_price) AS total_price FROM ?? AS a WHERE ' +
|
|
|
+ 'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times = b.times GROUP BY b.cid) AND a.status = ? AND a.tid = ?';
|
|
|
+ const sqlParam3 = [this.tableName, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId, status, tenderId];
|
|
|
+ const result3 = await this.db.query(sql3, sqlParam3);
|
|
|
+ return result3[0].total_price ? result3[0].total_price : 0;
|
|
|
+ case 3: // 已完成(所有的)
|
|
|
+ const sql4 = 'SELECT SUM(total_price) AS total_price FROM ?? WHERE status = ? AND tid = ?';
|
|
|
+ const sqlParam4 = [this.tableName, status, tenderId];
|
|
|
+ const result4 = await this.db.query(sql4, sqlParam4);
|
|
|
+ return result4[0].total_price ? result4[0].total_price : 0;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取变更令个数
|
|
|
* @param {int} tenderId - 标段id
|