浏览代码

短信通知修复

laiguoran 5 年之前
父节点
当前提交
52d37e03c2

+ 0 - 3
app/extend/helper.js

@@ -232,14 +232,11 @@ module.exports = {
     async sendRequest(url, data, type = 'POST', dataType = 'json') {
         // 发起请求
         try {
-            console.log(url);
-            console.log(data);
             const response = await this.ctx.curl(url, {
                 method: type,
                 data,
                 dataType,
             });
-            console.log(response);
             if (response.status !== 200) {
                 throw '请求失败';
             }

+ 14 - 0
app/lib/sms.js

@@ -87,6 +87,20 @@ class SMS {
     //         });
     //     });
     // }
+
+    /**
+     * 关键字转换
+     *
+     * @param {String} content - 内容
+     * @return {Object} - 解析结果
+     */
+    async contentChange(content) {
+        console.log(content);
+        let str = content.replace(/【/g, '(');
+        str = str.replace(/】/g, ')');
+        str = str.replace(/工程款/g, '***');
+        return str;
+    }
 }
 
 module.exports = SMS;

+ 2 - 1
app/middleware/tender_check.js

@@ -38,6 +38,7 @@ module.exports = options => {
             if (!tender.data.ledger_status) {
                 tender.data.ledger_status = auditConst.status.uncheck;
             }
+            tender.auditLedgerConst = auditConst;
             if (!tender.data.ledger_times) {
                 tender.data.ledger_times = 1;
             }
@@ -70,4 +71,4 @@ module.exports = options => {
             this.redirect('/list');
         }
     };
-};
+};

+ 8 - 4
app/service/change.js

@@ -488,7 +488,8 @@ module.exports = app => {
                         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);
-                            const content = '【纵横计量支付】' + changeData.code + '变更需要您审批。';
+                            const code = await sms.contentChange(changeData.code);
+                            const content = '【纵横计量支付】' + code + '变更需要您审批。';
                             sms.send(smsUser.auth_mobile, content);
                         }
                     }
@@ -613,7 +614,8 @@ module.exports = app => {
                     const smsType = JSON.parse(smsUser.sms_type);
                     if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
                         const sms = new SMS(this.ctx);
-                        const content = '【纵横计量支付】' + changeData.code + '变更,审批退回。';
+                        const code = await sms.contentChange(changeData.code);
+                        const content = '【纵横计量支付】' + code + '变更,审批退回。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -727,7 +729,8 @@ module.exports = app => {
                     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);
-                        const content = '【纵横计量支付】' + changeData.code + '变更需要您审批。';
+                        const code = await sms.contentChange(changeData.code);
+                        const content = '【纵横计量支付】' + code + '变更需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -944,7 +947,8 @@ module.exports = app => {
                     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);
-                        const content = '【纵横计量支付】' + changeInfo.code + '变更需要您审批。';
+                        const code = await sms.contentChange(changeInfo.code);
+                        const content = '【纵横计量支付】' + code + '变更需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }

+ 8 - 4
app/service/ledger_audit.js

@@ -193,7 +193,8 @@ module.exports = app => {
                     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 content = '【纵横计量支付】' + tenderInfo.name + '台帐需要您审批。';
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '台帐需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -257,7 +258,8 @@ module.exports = app => {
                             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 content = '【纵横计量支付】' + tenderInfo.name + '台帐需要您审批。';
+                                const tenderName = await sms.contentChange(tenderInfo.name);
+                                const content = '【纵横计量支付】' + tenderName + '台帐需要您审批。';
                                 sms.send(smsUser.auth_mobile, content);
                             }
                         }
@@ -274,7 +276,8 @@ module.exports = app => {
                             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 content = '【纵横计量支付】' + tenderInfo.name + '台账审批通过。';
+                                const tenderName = await sms.contentChange(tenderInfo.name);
+                                const content = '【纵横计量支付】' + tenderName + '台账审批通过,请登录系统处理。';
                                 sms.send(smsUser.auth_mobile, content);
                             }
                         }
@@ -302,7 +305,8 @@ module.exports = app => {
                         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 content = '【纵横计量支付】' + tenderInfo.name + '台账审批退回。';
+                            const tenderName = await sms.contentChange(tenderInfo.name);
+                            const content = '【纵横计量支付】' + tenderName + '台账审批退回,请登录系统处理。';
                             sms.send(smsUser.auth_mobile, content);
                         }
                     }

+ 12 - 6
app/service/stage_audit.js

@@ -204,7 +204,8 @@ module.exports = app => {
                         const tenderInfo = await this.ctx.service.tender.getDataById(audit.tid);
                         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
                         const sms = new SMS(this.ctx);
-                        const content = '【纵横计量支付】' + tenderInfo.name + '第' + stageInfo.order + '期,需要您审批。';
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -254,7 +255,8 @@ module.exports = app => {
                             const tenderInfo = await this.ctx.service.tender.getDataById(nextAudit.tid);
                             const stageInfo = await this.ctx.service.stage.getDataById(nextAudit.sid);
                             const sms = new SMS(this.ctx);
-                            const content = '【纵横计量支付】' + tenderInfo.name + '第' + stageInfo.order + '期,需要您审批。';
+                            const tenderName = await sms.contentChange(tenderInfo.name);
+                            const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                             sms.send(smsUser.auth_mobile, content);
                         }
                     }
@@ -280,7 +282,8 @@ module.exports = app => {
                         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 content = '【纵横计量支付】' + tenderInfo.name + '第' + stageInfo.order + '期,审批通过。';
+                            const tenderName = await sms.contentChange(tenderInfo.name);
+                            const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,审批通过。';
                             sms.send(smsUser.auth_mobile, content);
                         }
                     }
@@ -336,7 +339,8 @@ module.exports = app => {
                     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 content = '【纵横计量支付】' + tenderInfo.name + '第' + stageInfo.order + '期,审批退回。';
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,审批退回。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -398,7 +402,8 @@ module.exports = app => {
                         const tenderInfo = await this.ctx.service.tender.getDataById(audit.tid);
                         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
                         const sms = new SMS(this.ctx);
-                        const content = '【纵横计量支付】' + tenderInfo.name + '第' + stageInfo.order + '期,需要您审批。';
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }
@@ -606,7 +611,8 @@ module.exports = app => {
                         const tenderInfo = await this.ctx.service.tender.getDataById(audit.tid);
                         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
                         const sms = new SMS(this.ctx);
-                        const content = '【纵横计量支付】' + tenderInfo.name + '第' + stageInfo.order + '期,需要您审批。';
+                        const tenderName = await sms.contentChange(tenderInfo.name);
+                        const content = '【纵横计量支付】' + tenderName + '第' + stageInfo.order + '期,需要您审批。';
                         sms.send(smsUser.auth_mobile, content);
                     }
                 }

+ 3 - 1
app/view/tender/tender_sub_menu.ejs

@@ -14,7 +14,9 @@
             <h3><i class="fa fa-list-alt"></i> 0号台帐</h3>
             <ul class="nav-list list-unstyled sub-list">
                 <li <% if (ctx.url === '/tender/' + ctx.tender.id + '/ledger') { %>class="active"<% } %>><a href="/tender/<%- ctx.tender.id %>/ledger"><span>台帐分解</span></a></li>
+                <% if (ctx.tender.data.ledger_status !== ctx.tender.auditLedgerConst.status.uncheck) { %>
                 <li <% if (ctx.url === '/tender/' + ctx.tender.id + '/ledger/audit') { %>class="active"<% } %>><a href="/tender/<%- ctx.tender.id %>/ledger/audit"><span>台帐审批</span></a></li>
+                <% } %>
                 <li <% if (ctx.url === '/tender/' + ctx.tender.id + '/revise') { %>class="active"<% } %>><a href="/tender/<%- ctx.tender.id %>/revise"><span>台帐修订</span></a></li>
             </ul>
         </div>
@@ -37,4 +39,4 @@
         </div>
         <div class="side-fold"><a href="javascript: void(0)" data-toggle="tooltip" data-placement="top" data-original-title="折叠侧栏" id="to-mini-menu"><i class="fa fa-sign-out fa-flip-horizontal"></i></a></div>
     </div>
-</div>
+</div>