|
@@ -95,7 +95,7 @@ module.exports = app => {
|
|
|
switch (status) {
|
|
|
case auditConst.status.checking :
|
|
|
case auditConst.status.checked :
|
|
|
- sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order` ' +
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order`, la.`status` ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
' WHERE la.`cpid` = ? and la.`status` = ? ' +
|
|
|
' ORDER BY la.`times` desc, la.`order` desc';
|
|
@@ -103,7 +103,7 @@ module.exports = app => {
|
|
|
auditor = await this.db.queryOne(sql, sqlParam);
|
|
|
break;
|
|
|
case auditConst.status.checkNo :
|
|
|
- sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order` ' +
|
|
|
+ sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order`, la.`status` ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
|
|
|
' WHERE la.`cpid` = ? and la.`status` = ? and la.`times` = ?' +
|
|
|
' ORDER BY la.`times` desc, la.`order` desc';
|
|
@@ -271,8 +271,12 @@ module.exports = app => {
|
|
|
id: cpId, status: auditConst.status.checking,
|
|
|
});
|
|
|
// 微信模板通知
|
|
|
+ const shenpiUrl = await this.ctx.helper.urlToShort(
|
|
|
+ this.ctx.protocol + '://' + this.ctx.host + '/wap/tender/' + this.ctx.tender.id + '/change/plan/' + cpId + '/info#shenpi'
|
|
|
+ );
|
|
|
const wechatData = {
|
|
|
type: 'plan',
|
|
|
+ wap_url: shenpiUrl,
|
|
|
status: wxConst.status.check,
|
|
|
tips: wxConst.tips.check,
|
|
|
code: this.ctx.session.sessionProject.code,
|
|
@@ -313,7 +317,7 @@ module.exports = app => {
|
|
|
* @param {Number} cpId 方案id
|
|
|
* @param {Number} uid 审批人id
|
|
|
*/
|
|
|
- async getNoticeContent(pid, tid, cpId, uid) {
|
|
|
+ async getNoticeContent(pid, tid, cpId, uid, opinion = '') {
|
|
|
const noticeSql = 'SELECT * FROM (SELECT ' +
|
|
|
' t.`id` As `tid`, ma.`cpid`, m.`code` as `c_code`, t.`name`, pa.`name` As `su_name`, pa.role As `su_role`' +
|
|
|
' FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
|
|
@@ -323,6 +327,9 @@ module.exports = app => {
|
|
|
' WHERE t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
|
|
|
const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.changePlan.tableName, cpId, this.tableName, this.ctx.service.projectAccount.tableName, uid, pid];
|
|
|
const content = await this.db.query(noticeSql, noticeSqlParam);
|
|
|
+ if (content.length) {
|
|
|
+ content[0].opinion = opinion;
|
|
|
+ }
|
|
|
return content.length ? JSON.stringify(content[0]) : '';
|
|
|
}
|
|
|
|
|
@@ -372,7 +379,7 @@ module.exports = app => {
|
|
|
await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
|
|
|
// 获取推送必要信息
|
|
|
- const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
|
|
|
+ const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
|
|
|
// 添加推送
|
|
|
const records = [{ pid, type: pushType.changePlan, uid: this.ctx.change.uid, status: auditConst.status.checked, content: noticeContent }];
|
|
|
auditors.forEach(audit => {
|
|
@@ -394,8 +401,12 @@ module.exports = app => {
|
|
|
});
|
|
|
|
|
|
// 微信模板通知
|
|
|
+ const shenpiUrl = await this.ctx.helper.urlToShort(
|
|
|
+ this.ctx.protocol + '://' + this.ctx.host + '/wap/tender/' + this.ctx.tender.id + '/change/plan/' + cpId + '/info#shenpi'
|
|
|
+ );
|
|
|
const wechatData = {
|
|
|
type: 'plan',
|
|
|
+ wap_url: shenpiUrl,
|
|
|
status: wxConst.status.check,
|
|
|
tips: wxConst.tips.check,
|
|
|
code: this.ctx.session.sessionProject.code,
|
|
@@ -413,8 +424,12 @@ module.exports = app => {
|
|
|
|
|
|
// 微信模板通知
|
|
|
const users = this._.uniq(this._.concat(this._.map(auditors, 'aid'), this.ctx.change.uid));
|
|
|
+ const shenpiUrl = await this.ctx.helper.urlToShort(
|
|
|
+ this.ctx.protocol + '://' + this.ctx.host + '/wap/tender/' + this.ctx.tender.id + '/change/plan/' + cpId + '/info#shenpi'
|
|
|
+ );
|
|
|
const wechatData = {
|
|
|
type: 'plan',
|
|
|
+ wap_url: shenpiUrl,
|
|
|
status: wxConst.status.success,
|
|
|
tips: wxConst.tips.success,
|
|
|
code: this.ctx.session.sessionProject.code,
|
|
@@ -450,7 +465,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
// 添加到消息推送表
|
|
|
- const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
|
|
|
+ const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
|
|
|
const records = [{ pid, type: pushType.changePlan, uid: this.ctx.change.uid, status: auditConst.status.checkNo, content: noticeContent }];
|
|
|
auditors.forEach(audit => {
|
|
|
records.push({ pid, type: pushType.changePlan, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });
|
|
@@ -467,8 +482,12 @@ module.exports = app => {
|
|
|
await this.ctx.service.changePlanList.delAuditAmount(transaction, cpId);
|
|
|
// 微信模板通知
|
|
|
const users = this._.uniq(this._.concat(this._.map(auditors, 'aid'), this.ctx.change.uid));
|
|
|
+ const shenpiUrl = await this.ctx.helper.urlToShort(
|
|
|
+ this.ctx.protocol + '://' + this.ctx.host + '/wap/tender/' + this.ctx.tender.id + '/change/plan/' + cpId + '/info#shenpi'
|
|
|
+ );
|
|
|
const wechatData = {
|
|
|
type: 'plan',
|
|
|
+ wap_url: shenpiUrl,
|
|
|
status: wxConst.status.back,
|
|
|
tips: wxConst.tips.back,
|
|
|
code: this.ctx.session.sessionProject.code,
|
|
@@ -516,7 +535,34 @@ module.exports = app => {
|
|
|
const sqlParam = [tenderId];
|
|
|
return this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ /**
|
|
|
+ * 取待审批期列表(wap用)
|
|
|
+ *
|
|
|
+ * @param auditorId
|
|
|
+ * @return {Promise<*>}
|
|
|
+ */
|
|
|
+ async getAuditChangePlanByWap(auditorId) {
|
|
|
+ const sql =
|
|
|
+ 'SELECT sa.`aid`, sa.`times`, sa.`begin_time`, sa.`end_time`, sa.`tid`, sa.`cpid`,' +
|
|
|
+ ' s.*,' +
|
|
|
+ ' t.`name` as `t_name`, t.`project_id`, t.`type`, t.`user_id`,' +
|
|
|
+ ' ti.`deal_info`, ti.`decimal` ' +
|
|
|
+ ' FROM ?? AS sa' +
|
|
|
+ ' Left Join ?? AS s On sa.`cpid` = s.`id`' +
|
|
|
+ ' Left Join ?? As t On sa.`tid` = t.`id`' +
|
|
|
+ ' Left Join ?? AS ti ON ti.`tid` = t.`id`' +
|
|
|
+ ' WHERE sa.`aid` = ? and sa.`status` = ?';
|
|
|
+ const sqlParam = [
|
|
|
+ this.tableName,
|
|
|
+ this.ctx.service.changePlan.tableName,
|
|
|
+ this.ctx.service.tender.tableName,
|
|
|
+ this.ctx.service.tenderInfo.tableName,
|
|
|
+ auditorId,
|
|
|
+ auditConst.status.checking,
|
|
|
+ ];
|
|
|
+ return await this.db.query(sql, sqlParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
return ChangePlanAudit;
|
|
|
};
|