Quellcode durchsuchen

短信项目名获取方式修改

laiguoran vor 5 Jahren
Ursprung
Commit
f36356a636
4 geänderte Dateien mit 58 neuen und 32 gelöschten Zeilen
  1. 3 1
      app/extend/helper.js
  2. 0 1
      app/lib/sms.js
  3. 37 24
      app/service/ledger_audit.js
  4. 18 6
      app/service/stage_audit.js

+ 3 - 1
app/extend/helper.js

@@ -878,7 +878,9 @@ module.exports = {
         if (mobiles.length > 0) {
             const sms = new SMS(this.ctx);
             const tenderName = await sms.contentChange(this.ctx.tender.data.name);
-            const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + msg;
+            let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+            projectName = projectName !== '' ? projectName + '-' : '';
+            const content = '【纵横计量支付】' + projectName + tenderName + msg;
             sms.send(mobiles, content);
         }
     },

+ 0 - 1
app/lib/sms.js

@@ -95,7 +95,6 @@ class SMS {
      * @return {Object} - 解析结果
      */
     async contentChange(content) {
-        console.log(content);
         let str = content.replace(/【/g, '(');
         str = str.replace(/】/g, ')');
         str = str.replace(/工程款/g, '***');

+ 37 - 24
app/service/ledger_audit.js

@@ -214,17 +214,20 @@ module.exports = app => {
                 });
 
                 // 添加短信通知-需要审批提醒功能
-                const smsUser = await this.ctx.service.projectAccount.getDataById(audit.audit_id);
-                if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                    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);
-                        const sms = new SMS(this.ctx);
-                        const tenderName = await sms.contentChange(tenderInfo.name);
-                        const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '台帐需要您审批。';
-                        sms.send(smsUser.auth_mobile, content);
-                    }
-                }
+                await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.TZ,
+                    smsTypeConst.judge.approval.toString(), '台帐需要您审批。');
+                // const smsUser = await this.ctx.service.projectAccount.getDataById(audit.audit_id);
+                // if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
+                //     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);
+                //         const projectName = await this.ctx.service.tenderInfo.getDealInfoBuildName(tenderId);
+                //         const sms = new SMS(this.ctx);
+                //         const tenderName = await sms.contentChange(tenderInfo.name);
+                //         const content = '【纵横计量支付】' + (projectName !== '' ? projectName + '-' : '') + tenderName + '台帐需要您审批。';
+                //         sms.send(smsUser.auth_mobile, content);
+                //     }
+                // }
 
                 await transaction.commit();
             } catch (err) {
@@ -263,17 +266,19 @@ module.exports = app => {
                         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 !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                            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);
-                                const sms = new SMS(this.ctx);
-                                const tenderName = await sms.contentChange(tenderInfo.name);
-                                const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '台帐需要您审批。';
-                                sms.send(smsUser.auth_mobile, content);
-                            }
-                        }
+                        // const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.audit_id);
+                        // if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
+                        //     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);
+                        //         const sms = new SMS(this.ctx);
+                        //         const tenderName = await sms.contentChange(tenderInfo.name);
+                        //         const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '台帐需要您审批。';
+                        //         sms.send(smsUser.auth_mobile, content);
+                        //     }
+                        // }
+                        await this.ctx.helper.sendUserSms(nextAudit.audit_id, smsTypeConst.const.TZ,
+                            smsTypeConst.judge.approval.toString(), '台帐需要您审批。');
                     } else {
                         // 同步标段信息
                         await transaction.update(this.ctx.service.tender.tableName, {id: tenderId, ledger_status: checkType});
@@ -301,9 +306,15 @@ module.exports = app => {
                         if (mobile_array.length > 0) {
                             const sms = new SMS(this.ctx);
                             const tenderName = await sms.contentChange(tenderInfo.name);
-                            const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '台账审批通过,请登录系统处理。';
+                            let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                            projectName = projectName !== '' ? projectName + '-' : '';
+                            const content = '【纵横计量支付】' + projectName + tenderName + '台账审批通过,请登录系统处理。';
                             sms.send(mobile_array, content);
                         }
+                        // const auditList = await this.getAuditors(tenderId, times);
+                        // const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
+                        // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.TZ,
+                        //     smsTypeConst.judge.result.toString(), '台账审批通过,请登录系统处理。');
                     }
                 } else {
                     // 同步标段信息
@@ -341,7 +352,9 @@ module.exports = app => {
                     if (mobile_array.length > 0) {
                         const sms = new SMS(this.ctx);
                         const tenderName = await sms.contentChange(tenderInfo.name);
-                        const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '台账审批退回,请登录系统处理。';
+                        let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                        projectName = projectName !== '' ? projectName + '-' : '';
+                        const content = '【纵横计量支付】' + projectName + tenderName + '台账审批退回,请登录系统处理。';
                         sms.send(mobile_array, content);
                     }
                 }

+ 18 - 6
app/service/stage_audit.js

@@ -243,7 +243,9 @@ module.exports = app => {
                         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
                         const sms = new SMS(this.ctx);
                         const tenderName = await sms.contentChange(tenderInfo.name);
-                        const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
+                        let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                        projectName = projectName !== '' ? projectName + '-' : '';
+                        const content = '【纵横计量支付】' + projectName + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -299,7 +301,9 @@ module.exports = app => {
                             const stageInfo = await this.ctx.service.stage.getDataById(nextAudit.sid);
                             const sms = new SMS(this.ctx);
                             const tenderName = await sms.contentChange(tenderInfo.name);
-                            const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
+                            let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                            projectName = projectName !== '' ? projectName + '-' : '';
+                            const content = '【纵横计量支付】' + projectName + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                             sms.send(smsUser.auth_mobile, content);
                         }
                     }
@@ -343,7 +347,9 @@ module.exports = app => {
                         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 = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '第' + stageInfo.order + '期,审批通过。';
+                        let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                        projectName = projectName !== '' ? projectName + '-' : '';
+                        const content = '【纵横计量支付】' + projectName + tenderName + '第' + stageInfo.order + '期,审批通过。';
                         sms.send(mobile_array, content);
                     }
                 }
@@ -420,7 +426,9 @@ module.exports = app => {
                     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 = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '第' + stageInfo.order + '期,审批退回。';
+                    let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                    projectName = projectName !== '' ? projectName + '-' : '';
+                    const content = '【纵横计量支付】' + projectName + tenderName + '第' + stageInfo.order + '期,审批退回。';
                     sms.send(mobile_array, content);
                 }
 
@@ -503,7 +511,9 @@ module.exports = app => {
                         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
                         const sms = new SMS(this.ctx);
                         const tenderName = await sms.contentChange(tenderInfo.name);
-                        const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
+                        let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                        projectName = projectName !== '' ? projectName + '-' : '';
+                        const content = '【纵横计量支付】' + projectName + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -717,7 +727,9 @@ module.exports = app => {
                         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
                         const sms = new SMS(this.ctx);
                         const tenderName = await sms.contentChange(tenderInfo.name);
-                        const content = '【纵横计量支付】' + this.ctx.session.sessionProject.name + '-' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
+                        let projectName = await sms.contentChange(JSON.parse(this.ctx.tender.info.deal_info).buildName);
+                        projectName = projectName !== '' ? projectName + '-' : '';
+                        const content = '【纵横计量支付】' + projectName + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }