Jelajahi Sumber

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

MaiXinRong 5 tahun lalu
induk
melakukan
56d4475fcd
1 mengubah file dengan 45 tambahan dan 17 penghapusan
  1. 45 17
      app/service/stage_audit.js

+ 45 - 17
app/service/stage_audit.js

@@ -275,18 +275,32 @@ module.exports = app => {
                     });
 
                     // 添加短信通知-审批通过提醒功能
+                    const mobile_array = [];
                     const stageInfo = await this.ctx.service.stage.getDataById(stageId);
-                    const smsUser = await this.ctx.service.projectAccount.getDataById(stageInfo.user_id);
-                    if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
-                        const smsType = JSON.parse(smsUser.sms_type);
+                    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 !== '') {
+                        const smsType = JSON.parse(smsUser1.sms_type);
                         if (smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
-                            const tenderInfo = await this.ctx.service.tender.getDataById(stageInfo.tid);
-                            const sms = new SMS(this.ctx);
-                            const tenderName = await sms.contentChange(tenderInfo.name);
-                            const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,审批通过。';
-                            sms.send(smsUser.auth_mobile, content);
+                            mobile_array.push(smsUser1.auth_mobile);
+                        }
+                    }
+                    for (const user of auditList) {
+                        const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
+                        if (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);
+                            }
                         }
                     }
+                    if (mobile_array.length > 0) {
+                        const tenderInfo = await this.ctx.service.tender.getDataById(stageInfo.tid);
+                        const sms = new SMS(this.ctx);
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,审批通过。';
+                        sms.send(mobile_array, content);
+                    }
                 }
                 await transaction.commit();
             } catch (err) {
@@ -298,7 +312,7 @@ module.exports = app => {
         async _checkNo(stageId, checkData, times) {
             const time = new Date();
             // 整理当前流程审核人状态更新
-            const audit = await this.getDataByCondition({sid: stageId, times: times, status: auditConst.status.checking, check_detail: false});
+            const audit = await this.getDataByCondition({sid: stageId, times: times, status: auditConst.status.checking});
             if (!audit) {
                 throw '审核数据错误';
             }
@@ -332,18 +346,32 @@ module.exports = app => {
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times + 1, 0, transaction);
 
                 // 添加短信通知-审批退回提醒功能
+                const mobile_array = [];
                 const stageInfo = await this.ctx.service.stage.getDataById(stageId);
-                const smsUser = await this.ctx.service.projectAccount.getDataById(stageInfo.user_id);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
-                    const smsType = JSON.parse(smsUser.sms_type);
+                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 !== '') {
+                    const smsType = JSON.parse(smsUser1.sms_type);
                     if (smsType[smsTypeConst.const.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
-                        const tenderInfo = await this.ctx.service.tender.getDataById(stageInfo.tid);
-                        const sms = new SMS(this.ctx);
-                        const tenderName = await sms.contentChange(tenderInfo.name);
-                        const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,审批退回。';
-                        sms.send(smsUser.auth_mobile, content);
+                        mobile_array.push(smsUser1.auth_mobile);
                     }
                 }
+                for (const user of auditList) {
+                    const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
+                    if (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);
+                        }
+                    }
+                }
+                if (mobile_array.length > 0) {
+                    const tenderInfo = await this.ctx.service.tender.getDataById(stageInfo.tid);
+                    const sms = new SMS(this.ctx);
+                    const tenderName = await sms.contentChange(tenderInfo.name);
+                    const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,审批退回。';
+                    sms.send(mobile_array, content);
+                }
 
                 await transaction.commit();
             } catch (err) {