瀏覽代碼

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

MaiXinRong 5 年之前
父節點
當前提交
7b6fa83c95
共有 3 個文件被更改,包括 55 次插入28 次删除
  1. 6 6
      app/service/change.js
  2. 43 16
      app/service/ledger_audit.js
  3. 6 6
      app/service/stage_audit.js

+ 6 - 6
app/service/change.js

@@ -327,7 +327,7 @@ module.exports = app => {
                         // 添加短信通知-需要审批提醒功能
                         if (change_status && index === 0) {
                             const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo[0]);
-                            if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                            if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                                 const smsType = JSON.parse(smsUser.sms_type);
                                 if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                                     const sms = new SMS(this.ctx);
@@ -469,7 +469,7 @@ module.exports = app => {
                     const auditList = await this.ctx.service.changeAudit.getListGroupByTimes(changeData.cid, changeData.times);
                     for (const user of auditList) {
                         const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
-                        if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                        if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                             const smsType = JSON.parse(smsUser.sms_type);
                             if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
                                 mobile_array.push(smsUser.auth_mobile);
@@ -492,7 +492,7 @@ module.exports = app => {
                     // 添加短信通知-需要审批提醒功能
                     const nextAuditData = await this.ctx.service.changeAudit.getDataById(postData.audit_next_id);
                     const smsUser = await this.ctx.service.projectAccount.getDataById(nextAuditData.uid);
-                    if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                    if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                         const smsType = JSON.parse(smsUser.sms_type);
                         if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                             const sms = new SMS(this.ctx);
@@ -628,7 +628,7 @@ module.exports = app => {
                 const mobile_array = [];
                 for (const user of insert_audit_array) {
                     const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
-                    if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                    if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                         const smsType = JSON.parse(smsUser.sms_type);
                         if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
                             mobile_array.push(smsUser.auth_mobile);
@@ -752,7 +752,7 @@ module.exports = app => {
 
                 // 添加短信通知-需要审批提醒功能
                 const smsUser = await this.ctx.service.projectAccount.getDataById(lastauditInfo.uid);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                     const smsType = JSON.parse(smsUser.sms_type);
                     if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                         const sms = new SMS(this.ctx);
@@ -970,7 +970,7 @@ module.exports = app => {
 
                 // 添加短信通知-需要审批提醒功能
                 const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo.uid);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                     const smsType = JSON.parse(smsUser.sms_type);
                     if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                         const sms = new SMS(this.ctx);

+ 43 - 16
app/service/ledger_audit.js

@@ -188,7 +188,7 @@ module.exports = app => {
 
                 // 添加短信通知-需要审批提醒功能
                 const smsUser = await this.ctx.service.projectAccount.getDataById(audit.audit_id);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                if (smsUser.auth_mobile !== '' && 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 tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
@@ -237,7 +237,7 @@ module.exports = app => {
 
                         // 添加短信通知-需要审批提醒功能
                         const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.audit_id);
-                        if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                        if (smsUser.auth_mobile !== '' && 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 tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
@@ -252,17 +252,31 @@ module.exports = app => {
                         await transaction.update(this.ctx.service.tender.tableName, {id: tenderId, ledger_status: checkType});
 
                         // 添加短信通知-审批通过提醒功能
+                        const mobile_array = [];
                         const tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
-                        const smsUser = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
-                        if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
-                            const smsType = JSON.parse(smsUser.sms_type);
+                        const smsUser1 = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
+                        if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '') {
+                            const smsType = JSON.parse(smsUser1.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(tenderInfo.name);
-                                const content = '【纵横计量支付】' + tenderName + '台账审批通过,请登录系统处理。';
-                                sms.send(smsUser.auth_mobile, content);
+                                mobile_array.push(smsUser1.auth_mobile);
                             }
                         }
+                        const auditList = await this.getAuditors(tenderId, times);
+                        for (const user of auditList) {
+                            const smsUser = await this.ctx.service.projectAccount.getDataById(user.audit_id);
+                            if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                                const smsType = JSON.parse(smsUser.sms_type);
+                                if (mobile_array.indexOf(smsUser.auth_mobile) === -1 && smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
+                                    mobile_array.push(smsUser.auth_mobile);
+                                }
+                            }
+                        }
+                        if (mobile_array.length > 0) {
+                            const sms = new SMS(this.ctx);
+                            const tenderName = await sms.contentChange(tenderInfo.name);
+                            const content = '【纵横计量支付】' + tenderName + '台账审批通过,请登录系统处理。';
+                            sms.send(mobile_array, content);
+                        }
                     }
                 } else {
                     // 同步标段信息
@@ -279,17 +293,30 @@ module.exports = app => {
                     await transaction.insert(this.tableName, auditors);
 
                     // 添加短信通知-审批退回提醒功能
+                    const mobile_array = [];
                     const tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
-                    const smsUser = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
-                    if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
-                        const smsType = JSON.parse(smsUser.sms_type);
+                    const smsUser1 = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
+                    if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '') {
+                        const smsType = JSON.parse(smsUser1.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(tenderInfo.name);
-                            const content = '【纵横计量支付】' + tenderName + '台账审批退回,请登录系统处理。';
-                            sms.send(smsUser.auth_mobile, content);
+                            mobile_array.push(smsUser1.auth_mobile);
                         }
                     }
+                    for (const user of auditors) {
+                        const smsUser = await this.ctx.service.projectAccount.getDataById(user.audit_id);
+                        if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                            const smsType = JSON.parse(smsUser.sms_type);
+                            if (mobile_array.indexOf(smsUser.auth_mobile) === -1 && smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
+                                mobile_array.push(smsUser.auth_mobile);
+                            }
+                        }
+                    }
+                    if (mobile_array.length > 0) {
+                        const sms = new SMS(this.ctx);
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '台账审批退回,请登录系统处理。';
+                        sms.send(mobile_array, content);
+                    }
                 }
 
                 await transaction.commit();

+ 6 - 6
app/service/stage_audit.js

@@ -198,7 +198,7 @@ module.exports = app => {
 
                 // 添加短信通知-需要审批提醒功能
                 const smsUser = await this.ctx.service.projectAccount.getDataById(audit.aid);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                     const smsType = JSON.parse(smsUser.sms_type);
                     if (smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                         const tenderInfo = await this.ctx.service.tender.getDataById(audit.tid);
@@ -249,7 +249,7 @@ module.exports = app => {
 
                     // 添加短信通知-需要审批提醒功能
                     const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);
-                    if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                    if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                         const smsType = JSON.parse(smsUser.sms_type);
                         if (smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                             const tenderInfo = await this.ctx.service.tender.getDataById(nextAudit.tid);
@@ -287,7 +287,7 @@ module.exports = app => {
                     }
                     for (const user of auditList) {
                         const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
-                        if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                        if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                             const smsType = JSON.parse(smsUser.sms_type);
                             if (mobile_array.indexOf(smsUser.auth_mobile) === -1 && smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
                                 mobile_array.push(smsUser.auth_mobile);
@@ -350,7 +350,7 @@ module.exports = app => {
                 const stageInfo = await this.ctx.service.stage.getDataById(stageId);
                 const auditList = await this.getAuditors(stageId, stageInfo.times);
                 const smsUser1 = await this.ctx.service.projectAccount.getDataById(stageInfo.user_id);
-                if (smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '') {
+                if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '') {
                     const smsType = JSON.parse(smsUser1.sms_type);
                     if (smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
                         mobile_array.push(smsUser1.auth_mobile);
@@ -358,7 +358,7 @@ module.exports = app => {
                 }
                 for (const user of auditList) {
                     const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
-                    if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                    if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                         const smsType = JSON.parse(smsUser.sms_type);
                         if (mobile_array.indexOf(smsUser.auth_mobile) === -1 && smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
                             mobile_array.push(smsUser.auth_mobile);
@@ -424,7 +424,7 @@ module.exports = app => {
 
                 // 添加短信通知-需要审批提醒功能
                 const smsUser = await this.ctx.service.projectAccount.getDataById(preAuditor.aid);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
+                if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
                     const smsType = JSON.parse(smsUser.sms_type);
                     if (smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
                         const tenderInfo = await this.ctx.service.tender.getDataById(audit.tid);