|
@@ -10,7 +10,6 @@
|
|
|
|
|
|
const auditConst = require('../const/audit').revise;
|
|
|
const smsTypeConst = require('../const/sms_type');
|
|
|
-const SMS = require('../lib/sms');
|
|
|
|
|
|
module.exports = app => {
|
|
|
class ReviseAudit extends app.BaseService {
|
|
@@ -197,16 +196,14 @@ module.exports = app => {
|
|
|
await transaction.update(this.ctx.service.ledgerRevise.tableName, reviseData);
|
|
|
|
|
|
// 添加短信通知-需要审批提醒功能
|
|
|
- const smsUser = await this.ctx.service.projectAccount.getDataById(audit.audit_id);
|
|
|
- if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
- const smsType = JSON.parse(smsUser.sms_type);
|
|
|
- if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
|
|
|
- const sms = new SMS(this.ctx);
|
|
|
- const tenderName = await sms.contentChange(this.ctx.tender.data.name);
|
|
|
- const content = '【纵横计量支付】' + tenderName + '台账修订需要您审批。';
|
|
|
- sms.send(smsUser.auth_mobile, content);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 下一人
|
|
|
+ await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.XD,
|
|
|
+ smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
|
|
|
+ // 其他参与人
|
|
|
+ const auditList = await this.getAuditors(revise.tid, 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 transaction.commit();
|
|
|
} catch (err) {
|
|
@@ -268,17 +265,16 @@ module.exports = app => {
|
|
|
if (nextAudit) {
|
|
|
await transaction.update(this.tableName, {id: nextAudit.id, status: auditConst.status.checking, begin_time: time});
|
|
|
|
|
|
- // 添加短信通知-需要审批提醒功能
|
|
|
- const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.audit_id);
|
|
|
- if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
- const smsType = JSON.parse(smsUser.sms_type);
|
|
|
- if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
|
|
|
- const sms = new SMS(this.ctx);
|
|
|
- const tenderName = await sms.contentChange(this.ctx.tender.data.name);
|
|
|
- const content = '【纵横计量支付】' + tenderName + '台帐修订需要您审批。';
|
|
|
- sms.send(smsUser.auth_mobile, content);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 短信通知-需要审批提醒功能
|
|
|
+ // 下一人
|
|
|
+ await this.ctx.helper.sendUserSms(nextAudit.user_id, smsTypeConst.const.XD,
|
|
|
+ smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
|
|
|
+ // 其他参与人
|
|
|
+ const auditList = await this.getAuditors(revise.tid, times);
|
|
|
+ const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
|
|
|
+ users.push(revise.uid);
|
|
|
+ await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
|
|
|
+ smsTypeConst.judge.result.toString(), '台账修订审批通过。');
|
|
|
} else {
|
|
|
// 同步修订信息
|
|
|
await transaction.update(this.ctx.service.ledgerRevise.tableName, {id: revise.id, status: checkType, end_time: time});
|
|
@@ -289,17 +285,16 @@ module.exports = app => {
|
|
|
id: revise.tid, total_price: sum.total_price, deal_tp: sum.deal_tp
|
|
|
});
|
|
|
|
|
|
- // 添加短信通知-审批通过提醒功能
|
|
|
- const smsUser = await this.ctx.service.projectAccount.getDataById(revise.uid);
|
|
|
- if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
- const smsType = JSON.parse(smsUser.sms_type);
|
|
|
- if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
|
|
|
- const sms = new SMS(this.ctx);
|
|
|
- const tenderName = await sms.contentChange(this.ctx.tender.data.name);
|
|
|
- const content = '【纵横计量支付】' + tenderName + '台账修订审批通过,请登录系统处理。';
|
|
|
- sms.send(smsUser.auth_mobile, content);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 短信通知-审批通过提醒功能
|
|
|
+ // 下一人
|
|
|
+ const msg = '台账修订审批通过,请登录系统处理。';
|
|
|
+ await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
|
|
|
+ smsTypeConst.judge.result.toString(), msg);
|
|
|
+ // 其他参与人
|
|
|
+ const auditList = await this.getAuditors(revise.tid, 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(), '台账修订审批通过。');
|
|
|
}
|
|
|
} else {
|
|
|
// 同步修订信息
|
|
@@ -316,17 +311,13 @@ module.exports = app => {
|
|
|
}
|
|
|
await transaction.insert(this.tableName, auditors);
|
|
|
|
|
|
- // 添加短信通知-审批退回提醒功能
|
|
|
- const smsUser = await this.ctx.service.projectAccount.getDataById(revise.uid);
|
|
|
- if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
- const smsType = JSON.parse(smsUser.sms_type);
|
|
|
- if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
|
|
|
- const sms = new SMS(this.ctx);
|
|
|
- const tenderName = await sms.contentChange(this.ctx.tender.data.name);
|
|
|
- const content = '【纵横计量支付】' + tenderName + '台账修订审批退回,请登录系统处理。';
|
|
|
- sms.send(smsUser.auth_mobile, content);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 短信通知-审批退回提醒功能
|
|
|
+ // 下一人
|
|
|
+ await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
|
|
|
+ smsTypeConst.judge.result.toString(), '台账修订审批退回,请登录系统处理。');
|
|
|
+ // 其他参与人
|
|
|
+ await this.ctx.helper.sendUserSms(this._.map(auditors, 'user_id'),
|
|
|
+ smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), '台账修订审批退回。');
|
|
|
}
|
|
|
|
|
|
await transaction.commit();
|