|
@@ -8,10 +8,11 @@
|
|
|
* @version
|
|
|
*/
|
|
|
|
|
|
-const auditConst = require('../const/audit').revise
|
|
|
-const smsTypeConst = require('../const/sms_type')
|
|
|
-const SmsAliConst = require('../const/sms_alitemplate')
|
|
|
-const pushType = require('../const/audit').pushType
|
|
|
+const auditConst = require('../const/audit').revise;
|
|
|
+const smsTypeConst = require('../const/sms_type');
|
|
|
+const SmsAliConst = require('../const/sms_alitemplate');
|
|
|
+const wxConst = require('../const/wechat_template');
|
|
|
+const pushType = require('../const/audit').pushType;
|
|
|
|
|
|
module.exports = app => {
|
|
|
class ReviseAudit extends app.BaseService {
|
|
@@ -22,8 +23,8 @@ module.exports = app => {
|
|
|
* @return {void}
|
|
|
*/
|
|
|
constructor(ctx) {
|
|
|
- super(ctx)
|
|
|
- this.tableName = 'revise_audit'
|
|
|
+ super(ctx);
|
|
|
+ this.tableName = 'revise_audit';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -39,9 +40,9 @@ module.exports = app => {
|
|
|
'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
|
'FROM ?? AS la, ?? AS pa ' +
|
|
|
'WHERE la.`rid` = ? and la.`audit_id` = ? and la.`times` = ?' +
|
|
|
- ' and la.`audit_id` = pa.`id`'
|
|
|
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, reviseId, auditorId, times]
|
|
|
- return await this.db.queryOne(sql, sqlParam)
|
|
|
+ ' and la.`audit_id` = pa.`id`';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, reviseId, auditorId, times];
|
|
|
+ return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -61,9 +62,9 @@ module.exports = app => {
|
|
|
' INNER JOIN ' +
|
|
|
this.ctx.service.projectAccount.tableName +
|
|
|
' AS pa ON la.`rid` = ? and la.`times` = ? and la.`audit_id` = pa.`id`' +
|
|
|
- ' ORDER BY la.`audit_order`'
|
|
|
- const sqlParam = [reviseId, times]
|
|
|
- return await this.db.query(sql, sqlParam)
|
|
|
+ ' ORDER BY la.`audit_order`';
|
|
|
+ const sqlParam = [reviseId, times];
|
|
|
+ return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -77,16 +78,16 @@ module.exports = app => {
|
|
|
const sql =
|
|
|
'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
|
|
|
'FROM ?? AS la, ?? AS pa, (SELECT `audit_id`,(@i:=@i+1) as `sort` FROM ??, (select @i:=0) as it WHERE `rid` = ? AND `times` = ? GROUP BY `audit_id`) as g ' +
|
|
|
- 'WHERE la.`rid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`audit_order`'
|
|
|
+ 'WHERE la.`rid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`audit_order`';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, rid, times, rid, times]
|
|
|
- const result = await this.db.query(sql, sqlParam)
|
|
|
- const sql2 = 'SELECT COUNT(a.`audit_id`) as num FROM (SELECT `audit_id` FROM ?? WHERE `rid` = ? AND `times` = ? GROUP BY `audit_id`) as a'
|
|
|
- const sqlParam2 = [this.tableName, rid, times]
|
|
|
- const count = await this.db.queryOne(sql2, sqlParam2)
|
|
|
+ const result = await this.db.query(sql, sqlParam);
|
|
|
+ const sql2 = 'SELECT COUNT(a.`audit_id`) as num FROM (SELECT `audit_id` FROM ?? WHERE `rid` = ? AND `times` = ? GROUP BY `audit_id`) as a';
|
|
|
+ const sqlParam2 = [this.tableName, rid, times];
|
|
|
+ const count = await this.db.queryOne(sql2, sqlParam2);
|
|
|
for (const i in result) {
|
|
|
- result[i].max_sort = count.num
|
|
|
+ result[i].max_sort = count.num;
|
|
|
}
|
|
|
- return result
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -101,9 +102,9 @@ module.exports = app => {
|
|
|
'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
|
'FROM ?? AS la, ?? AS pa ' +
|
|
|
'WHERE la.`rid` = ? and la.`status` = ? and la.`times` = ?' +
|
|
|
- ' and la.`audit_id` = pa.`id`'
|
|
|
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, reviseId, auditConst.status.checking, times]
|
|
|
- return await this.db.queryOne(sql, sqlParam)
|
|
|
+ ' and la.`audit_id` = pa.`id`';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, reviseId, auditConst.status.checking, times];
|
|
|
+ return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -114,10 +115,10 @@ module.exports = app => {
|
|
|
* @returns {Promise<number>}
|
|
|
*/
|
|
|
async getNewOrder(reviseId, times = 1) {
|
|
|
- const sql = 'SELECT Max(??) As max_order FROM ?? Where `rid` = ? and `times` = ?'
|
|
|
- const sqlParam = ['audit_order', this.tableName, reviseId, times]
|
|
|
- const result = await this.db.queryOne(sql, sqlParam)
|
|
|
- return result && result.max_order ? result.max_order + 1 : 1
|
|
|
+ const sql = 'SELECT Max(??) As max_order FROM ?? Where `rid` = ? and `times` = ?';
|
|
|
+ const sqlParam = ['audit_order', this.tableName, reviseId, times];
|
|
|
+ const result = await this.db.queryOne(sql, sqlParam);
|
|
|
+ return result && result.max_order ? result.max_order + 1 : 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -129,8 +130,8 @@ module.exports = app => {
|
|
|
* @returns {Promise<number>}
|
|
|
*/
|
|
|
async addAuditor(revise, auditorId) {
|
|
|
- const times = revise.times ? revise.times : 1
|
|
|
- const newOrder = await this.getNewOrder(revise.id, times)
|
|
|
+ const times = revise.times ? revise.times : 1;
|
|
|
+ const newOrder = await this.getNewOrder(revise.id, times);
|
|
|
const data = {
|
|
|
tender_id: revise.tid,
|
|
|
audit_id: auditorId,
|
|
@@ -139,9 +140,9 @@ module.exports = app => {
|
|
|
status: auditConst.status.uncheck,
|
|
|
rid: revise.id,
|
|
|
in_time: new Date()
|
|
|
- }
|
|
|
- const result = await this.db.insert(this.tableName, data)
|
|
|
- return (result.effectRows = 1)
|
|
|
+ };
|
|
|
+ const result = await this.db.insert(this.tableName, data);
|
|
|
+ return (result.effectRows = 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -154,27 +155,27 @@ module.exports = app => {
|
|
|
* @private
|
|
|
*/
|
|
|
async _syncOrderByDelete(transaction, reviseId, order, times) {
|
|
|
- this.initSqlBuilder()
|
|
|
+ this.initSqlBuilder();
|
|
|
this.sqlBuilder.setAndWhere('rid', {
|
|
|
value: this.db.escape(reviseId),
|
|
|
operate: '='
|
|
|
- })
|
|
|
+ });
|
|
|
this.sqlBuilder.setAndWhere('audit_order', {
|
|
|
value: order,
|
|
|
operate: '>='
|
|
|
- })
|
|
|
+ });
|
|
|
this.sqlBuilder.setAndWhere('times', {
|
|
|
value: times,
|
|
|
operate: '='
|
|
|
- })
|
|
|
+ });
|
|
|
this.sqlBuilder.setUpdateData('audit_order', {
|
|
|
value: 1,
|
|
|
selfOperate: '-'
|
|
|
- })
|
|
|
- const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update')
|
|
|
- const data = await transaction.query(sql, sqlParam)
|
|
|
+ });
|
|
|
+ const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
|
|
|
+ const data = await transaction.query(sql, sqlParam);
|
|
|
|
|
|
- return data
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -186,22 +187,22 @@ module.exports = app => {
|
|
|
* @returns {Promise<boolean>}
|
|
|
*/
|
|
|
async deleteAuditor(revise, auditorId) {
|
|
|
- const times = revise.times ? revise.times : 1
|
|
|
- const transaction = await this.db.beginTransaction()
|
|
|
+ const times = revise.times ? revise.times : 1;
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
- const condition = { rid: revise.id, audit_id: auditorId, times }
|
|
|
- const auditor = await this.getDataByCondition(condition)
|
|
|
+ const condition = { rid: revise.id, audit_id: auditorId, times };
|
|
|
+ const auditor = await this.getDataByCondition(condition);
|
|
|
if (!auditor) {
|
|
|
throw '该审核人不存在'
|
|
|
}
|
|
|
- await this._syncOrderByDelete(transaction, revise.id, auditor.audit_order, times)
|
|
|
- await transaction.delete(this.tableName, condition)
|
|
|
- await transaction.commit()
|
|
|
+ await this._syncOrderByDelete(transaction, revise.id, auditor.audit_order, times);
|
|
|
+ await transaction.delete(this.tableName, condition);
|
|
|
+ await transaction.commit();
|
|
|
} catch (err) {
|
|
|
- await transaction.rollback()
|
|
|
- throw err
|
|
|
+ await transaction.rollback();
|
|
|
+ throw err;
|
|
|
}
|
|
|
- return true
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -235,7 +236,7 @@ module.exports = app => {
|
|
|
pos_file: posHis
|
|
|
};
|
|
|
if (revise.times === 1) {
|
|
|
- reviseData.begin_time = time
|
|
|
+ reviseData.begin_time = time;
|
|
|
}
|
|
|
await transaction.update(this.ctx.service.ledgerRevise.tableName, reviseData);
|
|
|
|
|
@@ -244,19 +245,32 @@ module.exports = app => {
|
|
|
// await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.XD,
|
|
|
// smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
|
|
|
await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), SmsAliConst.template.revise_check);
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData = {
|
|
|
+ status: wxConst.status.check,
|
|
|
+ tips: wxConst.tips.check,
|
|
|
+ begin_time: Date.parse(time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(audit.audit_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), wxConst.template.revise, wechatData);
|
|
|
// 其他参与人
|
|
|
const auditList = await this.getAuditors(revise.id, times)
|
|
|
const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
|
|
|
// await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
|
|
|
// smsTypeConst.judge.result.toString(), '台账修订已上报。');
|
|
|
await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_report);
|
|
|
-
|
|
|
- await transaction.commit()
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData2 = {
|
|
|
+ status: wxConst.status.report,
|
|
|
+ tips: wxConst.tips.report,
|
|
|
+ begin_time: Date.parse(time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(audit.audit_id, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData2);
|
|
|
+ await transaction.commit();
|
|
|
} catch (err) {
|
|
|
- await transaction.rollback()
|
|
|
- throw err
|
|
|
+ await transaction.rollback();
|
|
|
+ throw err;
|
|
|
}
|
|
|
- return true
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
async _replaceLedgerByRevise(transaction, revise) {
|
|
@@ -307,14 +321,14 @@ module.exports = app => {
|
|
|
rid: revise.id,
|
|
|
times,
|
|
|
status: auditConst.status.checking
|
|
|
- })
|
|
|
- if (!audit) throw '审核数据错误'
|
|
|
- const pid = this.ctx.session.sessionProject.id
|
|
|
- const transaction = await this.db.beginTransaction()
|
|
|
+ });
|
|
|
+ if (!audit) throw '审核数据错误';
|
|
|
+ const pid = this.ctx.session.sessionProject.id;
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
- const auditList = await this.getAuditors(revise.id, times)
|
|
|
+ const auditList = await this.getAuditors(revise.id, times);
|
|
|
// 审核通过添加到推送表
|
|
|
- const noticeContent = await this.getNoticeContent(pid, audit.tender_id, audit.rid, audit.audit_id)
|
|
|
+ const noticeContent = await this.getNoticeContent(pid, audit.tender_id, audit.rid, audit.audit_id);
|
|
|
const records = [
|
|
|
{
|
|
|
pid,
|
|
@@ -323,7 +337,7 @@ module.exports = app => {
|
|
|
status: checkType,
|
|
|
content: noticeContent
|
|
|
}
|
|
|
- ]
|
|
|
+ ];
|
|
|
auditList.forEach(audit => {
|
|
|
records.push({
|
|
|
pid,
|
|
@@ -333,7 +347,7 @@ module.exports = app => {
|
|
|
content: noticeContent
|
|
|
})
|
|
|
});
|
|
|
- await transaction.insert('zh_notice', records)
|
|
|
+ await transaction.insert('zh_notice', records);
|
|
|
|
|
|
// 整理当前流程审核人状态更新
|
|
|
const time = new Date();
|
|
@@ -362,9 +376,14 @@ module.exports = app => {
|
|
|
// 下一人
|
|
|
// await this.ctx.helper.sendUserSms(nextAudit.user_id, smsTypeConst.const.XD,
|
|
|
// smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
|
|
|
- await this.ctx.helper.sendAliSms(nextAudit.user_id, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
|
|
|
- status: SmsAliConst.status.success
|
|
|
- });
|
|
|
+ await this.ctx.helper.sendAliSms(nextAudit.user_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), SmsAliConst.template.revise_check);
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData = {
|
|
|
+ status: wxConst.status.check,
|
|
|
+ tips: wxConst.tips.check,
|
|
|
+ begin_time: Date.parse(revise.begin_time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(nextAudit.user_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), wxConst.template.revise, wechatData);
|
|
|
// 其他参与人
|
|
|
const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
|
|
|
users.push(revise.uid);
|
|
@@ -373,6 +392,13 @@ module.exports = app => {
|
|
|
await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, {
|
|
|
status: SmsAliConst.status.success
|
|
|
})
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData2 = {
|
|
|
+ status: wxConst.status.success,
|
|
|
+ tips: wxConst.tips.success,
|
|
|
+ begin_time: Date.parse(revise.begin_time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData2);
|
|
|
} else {
|
|
|
// 同步修订信息
|
|
|
await transaction.update(this.ctx.service.ledgerRevise.tableName, {
|
|
@@ -407,6 +433,13 @@ module.exports = app => {
|
|
|
await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
|
|
|
status: SmsAliConst.status.success
|
|
|
});
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData = {
|
|
|
+ status: wxConst.status.success,
|
|
|
+ tips: wxConst.tips.success,
|
|
|
+ begin_time: Date.parse(revise.begin_time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData);
|
|
|
// 其他参与人
|
|
|
const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
|
|
|
// await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
|
|
@@ -414,6 +447,13 @@ module.exports = app => {
|
|
|
await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, {
|
|
|
status: SmsAliConst.status.success
|
|
|
})
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData2 = {
|
|
|
+ status: wxConst.status.success,
|
|
|
+ tips: wxConst.tips.success,
|
|
|
+ begin_time: Date.parse(revise.begin_time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData2);
|
|
|
}
|
|
|
} else {
|
|
|
// 同步修订信息
|
|
@@ -440,7 +480,14 @@ module.exports = app => {
|
|
|
// smsTypeConst.judge.result.toString(), '台账修订审批退回,请登录系统处理。');
|
|
|
await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
|
|
|
status: SmsAliConst.status.back
|
|
|
- })
|
|
|
+ });
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData = {
|
|
|
+ status: wxConst.status.back,
|
|
|
+ tips: wxConst.tips.back,
|
|
|
+ begin_time: Date.parse(revise.begin_time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData);
|
|
|
// 其他参与人
|
|
|
// await this.ctx.helper.sendUserSms(this._.map(auditors, 'user_id'),
|
|
|
// smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), '台账修订审批退回。');
|
|
@@ -452,13 +499,20 @@ module.exports = app => {
|
|
|
{
|
|
|
status: SmsAliConst.status.back
|
|
|
}
|
|
|
- )
|
|
|
+ );
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData2 = {
|
|
|
+ status: wxConst.status.back,
|
|
|
+ tips: wxConst.tips.back,
|
|
|
+ begin_time: Date.parse(revise.begin_time),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(this._.map(auditors, 'user_id'), smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData2);
|
|
|
}
|
|
|
|
|
|
- await transaction.commit()
|
|
|
+ await transaction.commit();
|
|
|
} catch (err) {
|
|
|
- await transaction.rollback()
|
|
|
- throw err
|
|
|
+ await transaction.rollback();
|
|
|
+ throw err;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -487,9 +541,9 @@ module.exports = app => {
|
|
|
this.ctx.service.projectAccount.tableName +
|
|
|
' As p On ra.audit_id = p.id' +
|
|
|
' WHERE r.`valid` != 0 and ((ra.`audit_id` = ? and ra.`status` = ?) OR' +
|
|
|
- ' (r.`uid` = ? and r.`status` = ? and ra.`status` = ? and ra.`times` = (r.`times`-1)))'
|
|
|
- const sqlParam = [auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo]
|
|
|
- return await this.db.query(sql, sqlParam)
|
|
|
+ ' (r.`uid` = ? and r.`status` = ? and ra.`status` = ? and ra.`times` = (r.`times`-1)))';
|
|
|
+ const sqlParam = [auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo];
|
|
|
+ return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -518,13 +572,13 @@ module.exports = app => {
|
|
|
orders: [['create_time', 'desc']],
|
|
|
limit: 10,
|
|
|
offset: 0
|
|
|
- })
|
|
|
+ });
|
|
|
notice = notice.map(v => {
|
|
|
- const extra = JSON.parse(v.content)
|
|
|
- delete v.content
|
|
|
- return { ...v, ...extra }
|
|
|
- })
|
|
|
- return notice
|
|
|
+ const extra = JSON.parse(v.content);
|
|
|
+ delete v.content;
|
|
|
+ return { ...v, ...extra };
|
|
|
+ });
|
|
|
+ return notice;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -541,10 +595,10 @@ module.exports = app => {
|
|
|
' FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
|
|
|
' LEFT JOIN ?? As r On r.`id` = ? ' +
|
|
|
' LEFT JOIN ?? As pa ON pa.`id` = ? ' +
|
|
|
- ' WHERE t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`'
|
|
|
- const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.ledgerRevise.tableName, rid, this.ctx.service.projectAccount.tableName, uid, pid]
|
|
|
- const content = await this.db.query(noticeSql, noticeSqlParam)
|
|
|
- return content.length ? JSON.stringify(content[0]) : ''
|
|
|
+ ' WHERE t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
|
|
|
+ const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.ledgerRevise.tableName, rid, this.ctx.service.projectAccount.tableName, uid, pid];
|
|
|
+ const content = await this.db.query(noticeSql, noticeSqlParam);
|
|
|
+ return content.length ? JSON.stringify(content[0]) : '';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -556,9 +610,9 @@ module.exports = app => {
|
|
|
* @return {Promise<boolean>}
|
|
|
*/
|
|
|
async getAuditorByStatus(rid, status, times = 1) {
|
|
|
- let auditor = null
|
|
|
- let sql = ''
|
|
|
- let sqlParam = ''
|
|
|
+ let auditor = null;
|
|
|
+ let sql = '';
|
|
|
+ let sqlParam = '';
|
|
|
switch (status) {
|
|
|
case auditConst.status.checking:
|
|
|
case auditConst.status.checked:
|
|
@@ -566,23 +620,23 @@ module.exports = app => {
|
|
|
sql =
|
|
|
'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`rid`, la.`audit_order` ' +
|
|
|
'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`rid` = ? and la.`status` = ? and la.`audit_id` = pa.`id` order by la.`times` desc, la.`audit_order` desc'
|
|
|
- sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, status]
|
|
|
- auditor = await this.db.queryOne(sql, sqlParam)
|
|
|
- break
|
|
|
+ 'WHERE la.`rid` = ? and la.`status` = ? and la.`audit_id` = pa.`id` order by la.`times` desc, la.`audit_order` desc';
|
|
|
+ sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, status];
|
|
|
+ auditor = await this.db.queryOne(sql, sqlParam);
|
|
|
+ break;
|
|
|
case auditConst.status.checkNo:
|
|
|
sql =
|
|
|
'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`rid`, la.`audit_order` ' +
|
|
|
'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`rid` = ? and la.`status` = ? and la.`times` = ? and la.`audit_id` = pa.`id` order by la.`times` desc, la.`audit_order` desc'
|
|
|
- sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, auditConst.status.checkNo, parseInt(times) - 1]
|
|
|
- auditor = await this.db.queryOne(sql, sqlParam)
|
|
|
- break
|
|
|
+ 'WHERE la.`rid` = ? and la.`status` = ? and la.`times` = ? and la.`audit_id` = pa.`id` order by la.`times` desc, la.`audit_order` desc';
|
|
|
+ sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, auditConst.status.checkNo, parseInt(times) - 1];
|
|
|
+ auditor = await this.db.queryOne(sql, sqlParam);
|
|
|
+ break;
|
|
|
case auditConst.status.uncheck:
|
|
|
default:
|
|
|
- break
|
|
|
+ break;
|
|
|
}
|
|
|
- return auditor
|
|
|
+ return auditor;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -595,9 +649,9 @@ module.exports = app => {
|
|
|
const sql =
|
|
|
'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`rid`, la.`audit_order` ' +
|
|
|
'FROM ?? AS la, ?? AS pa ' +
|
|
|
- 'WHERE la.`rid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` GROUP BY la.`audit_id` ORDER BY la.`audit_order`'
|
|
|
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, times]
|
|
|
- return await this.db.query(sql, sqlParam)
|
|
|
+ 'WHERE la.`rid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, rid, times];
|
|
|
+ return await this.db.query(sql, sqlParam);
|
|
|
// const sql = 'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid`';
|
|
|
// const sqlParam = [this.tableName, stageId, times];
|
|
|
// return await this.db.query(sql, sqlParam);
|
|
@@ -612,11 +666,11 @@ module.exports = app => {
|
|
|
this.ctx.service.tender.tableName +
|
|
|
' t On ra.tender_id = t.id' +
|
|
|
' WHERE t.id = ?' +
|
|
|
- ' GROUP BY ra.audit_id'
|
|
|
- const sqlParam = [tenderId]
|
|
|
- return this.db.query(sql, sqlParam)
|
|
|
+ ' GROUP BY ra.audit_id';
|
|
|
+ const sqlParam = [tenderId];
|
|
|
+ return this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return ReviseAudit
|
|
|
-}
|
|
|
+};
|