Explorar el Código

短信切换到阿里云平台

laiguoran hace 5 años
padre
commit
01da3a2bba

+ 42 - 0
app/const/sms_alitemplate.js

@@ -0,0 +1,42 @@
+'use strict';
+
+/**
+ * 阿里云短信通知静态
+ *
+ * @author Ellisran
+ * @date 2019/8/20
+ * @version
+ */
+const accessKey = 'LTAIALMjBHOs9PLA';
+const accessKeySecret = 'HSnULQs87wAJhcziAdyRv3GZ4EYctc';
+const signName = '纵横云计量';
+const regionId = 'cn-hangzhou';
+const endpoint = 'https://dysmsapi.aliyuncs.com';
+const smsTemplate = {
+    yzm: 'SMS_192820305', // 验证码:${code},15分钟内有效。
+    mmcz: 'SMS_192825318', // 账号:${account},密码重置为:${password}
+    ledger_check: 'SMS_192825164', // 项目:${project},标段:${number},台帐需要您审批,请登录系统处理。
+    ledger_result: 'SMS_192830156', // 项目:${project},标段:${number},台帐审批${status},请登录系统处理。
+    stage_check: 'SMS_192820179', // 项目:${project},标段:${number},第${qi}期,需要您审批。
+    stage_result: 'SMS_192835176', // 项目:${project},标段:${number},第${qi}期,审批${status}。
+    change_check: 'SMS_192820171', // 项目:${project},标段:${number},变更:${biangeng},需要您审批。
+    change_result: 'SMS_192830143', // 项目:${project},标段:${number},变更:${biangeng},审批${status}。
+    revise_check: 'SMS_193145529', // 项目:${project},标段:${number},台帐修订需要您审批,请登录系统处理。
+    revise_result: 'SMS_193140537', // 项目:${project},标段:${number},台帐修订审批${status},请登录系统处理。
+    revise_result2: 'SMS_192985611', // 项目:${project},标段:${number},台帐修订审批${status}。
+    revise_report: 'SMS_192985614', // 项目:${project},标段:${number},台帐修订已上报。
+};
+const smsStatus = {
+    back: '退回',
+    success: '通过',
+};
+
+module.exports = {
+    accessKey,
+    accessKeySecret,
+    signName,
+    endpoint,
+    regionId,
+    template: smsTemplate,
+    status: smsStatus,
+};

+ 32 - 5
app/extend/helper.js

@@ -15,7 +15,7 @@ const streamToArray = require('stream-to-array');
 const _ = require('lodash');
 const bc = require('../lib/base_calc.js');
 const Decimal = require('decimal.js');
-Decimal.set({precision: 50, defaults: true});
+Decimal.set({ precision: 50, defaults: true });
 const SMS = require('../lib/sms');
 
 module.exports = {
@@ -864,7 +864,7 @@ module.exports = {
     async sendUserSms(userId, type, judge, msg) {
         const mobiles = [];
         if (!userId || (userId instanceof Array && userId.length === 0)) return;
-        const smsUser = await this.ctx.service.projectAccount.getAllDataByCondition({where: {id: userId}});
+        const smsUser = await this.ctx.service.projectAccount.getAllDataByCondition({ where: { id: userId } });
         for (const su of smsUser) {
             if (!su.auth_mobile || su.auth_mobile === '') continue;
             if (!su.sms_type || su.sms_type === '') continue;
@@ -885,19 +885,46 @@ module.exports = {
         }
     },
 
+    async sendAliSms(userId, type, judge, code, data = {}) {
+        const mobiles = [];
+        if (!userId || (userId instanceof Array && userId.length === 0)) return;
+        const smsUser = await this.ctx.service.projectAccount.getAllDataByCondition({ where: { id: userId } });
+        for (const su of smsUser) {
+            if (!su.auth_mobile || su.auth_mobile === '') continue;
+            if (!su.sms_type || su.sms_type === '') continue;
+
+            const smsType = JSON.parse(su.sms_type);
+            if (smsType[type] && smsType[type].indexOf(judge) !== -1) {
+                mobiles.push(su.auth_mobile);
+            }
+        }
+
+        if (mobiles.length > 0) {
+            const sms = new SMS(this.ctx);
+            const tenderName = await sms.contentChange(this.ctx.tender.data.name);
+            const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+            const param = {
+                project: projectName,
+                number: tenderName,
+            };
+            const postParam = Object.assign(param, data);
+            sms.aliSend(mobiles, postParam, code);
+        }
+    },
+
     /**
      *
      * @param setting
      * @param data
      * @returns {{} & any & {"!ref": string} & {"!cols"}}
      */
-    simpleXlsxSheetData (setting, data) {
+    simpleXlsxSheetData(setting, data) {
         const headerStyle = {
             font: { sz: 10, bold: true },
-            alignment: {horizontal: 'center'},
+            alignment: { horizontal: 'center' },
         };
         const sHeader = setting.header
-            .map((v, i) => Object.assign({}, {v: v, s: headerStyle, position: String.fromCharCode(65+i) + 1 }))
+            .map((v, i) => Object.assign({}, { v: v, s: headerStyle, position: String.fromCharCode(65+i) + 1 }))
             .reduce((prev, next) => Object.assign({}, prev, {[next.position]: {v: next.v, s: next.s}}), {});
         const sData = data
             .map((v, i) => v.map((k, j) => Object.assign({}, {

+ 44 - 0
app/lib/sms.js

@@ -9,6 +9,8 @@
  */
 
 // const xmlReader = require('xmlreader');
+const Core = require('@alicloud/pop-core');
+const smsAli = require('../const/sms_alitemplate.js');
 class SMS {
 
     /**
@@ -23,6 +25,48 @@ class SMS {
         // this.url = 'http://sms.haotingyun.com/v2/sms/single_send.json';
         this.url2 = 'http://sms.haotingyun.com/v2/sms/tpl_single_send.json';
         // this.url = 'http://101.132.42.40:7862/sms';
+        this.client = new Core({
+            accessKeyId: smsAli.accessKey,
+            accessKeySecret: smsAli.accessKeySecret,
+            endpoint: smsAli.endpoint,
+            apiVersion: '2017-05-25',
+        });
+
+    }
+
+    async aliSend(mobile, data, code) {
+        if (mobile instanceof Array) {
+            mobile = mobile.join(',');
+        }
+        let flag = false;
+        // const flag = false;
+        const params = {
+            RegionId: smsAli.regionId,
+            PhoneNumbers: mobile,
+            SignName: smsAli.signName,
+            TemplateCode: code,
+            TemplateParam: JSON.stringify(data),
+        };
+        const requestOption = {
+            method: 'POST',
+        };
+        // console.log(params);
+        try {
+            await this.client.request('SendSms', params, requestOption).then(result => {
+                if (result.Code === 'OK') {
+                    flag = true;
+                } else {
+                    throw '短信发送失败!';
+                }
+            }, ex => {
+                console.log(ex);
+                throw '短信发送失败!';
+            });
+        } catch (e) {
+            console.log(e);
+            flag = false;
+        }
+        return flag;
     }
 
     /**

+ 6 - 5
app/router.js

@@ -226,7 +226,8 @@ module.exports = app => {
     app.post('/tender/:id/measure/stage/:order/extra/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.uploadFile');
     app.get('/tender/:id/measure/stage/:order/extra/download/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.downloadFile');
     app.post('/tender/:id/measure/stage/:order/extra/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.deleteFile');
-
+    // 期审批管理
+    app.get('/tender/:id/measure/stage/:order/manager', sessionAuth, tenderCheck, stageCheck, 'stageController.manager');
     // 报表
     app.get('/tender/:id/report', sessionAuth, tenderCheck, 'reportController.index');
     app.get('/tender/:id/measure/stage/:order/report', sessionAuth, tenderCheck, stageCheck, 'reportController.index');
@@ -257,10 +258,10 @@ module.exports = app => {
     app.post('/tender/:id/change/delete', sessionAuth, tenderCheck, 'changeController.delete');
     app.post('/tender/:id/change/bills', sessionAuth, tenderCheck, 'changeController.bills');
 
-    app.post('/change/save', sessionAuth, 'changeController.save');
+    app.post('/tender/:id/change/save', sessionAuth, tenderCheck, 'changeController.save');
 
-    app.post('/change/approval', sessionAuth, 'changeController.approval');
-    app.post('/change/check/again', sessionAuth, 'changeController.checkAgain');
+    app.post('/tender/:id/change/approval', sessionAuth, tenderCheck, 'changeController.approval');
+    app.post('/tender/:id/change/check/again', sessionAuth, tenderCheck, 'changeController.checkAgain');
 
     app.post('/tender/:id/change/:cid/check/codeRepeat', sessionAuth, tenderCheck, 'changeController.checkCodeRepeat');
 
@@ -327,5 +328,5 @@ module.exports = app => {
     app.get('/wap/tender/:id', sessionAuth, tenderCheck, 'wapController.tender');
     app.get('/wap/tender/:id/stage/:order', sessionAuth, tenderCheck, 'wapController.stage');
     app.get('/wap/tender/:id/change/:cid/info', sessionAuth, tenderCheck, 'wapController.change');
-    app.post('/wap/change/approval', sessionAuth, 'wapController.changeApproval');
+    app.post('/wap/tender/:id/change/approval', sessionAuth, tenderCheck, 'wapController.changeApproval');
 };

+ 90 - 65
app/service/change.js

@@ -13,6 +13,7 @@ const fs = require('fs');
 const path = require('path');
 const smsTypeConst = require('../const/sms_type');
 const SMS = require('../lib/sms');
+const SmsAliConst = require('../const/sms_alitemplate');
 
 module.exports = app => {
     class Change extends app.BaseService {
@@ -218,6 +219,7 @@ module.exports = app => {
          * 获取变更令列表
          * @param {int} tenderId - 标段id
          * @param {int} status - 状态
+         * @param {int} hadlimit - 分页
          * @return {object} list - 列表
          */
         async getListByStatus(tenderId, status = 0, hadlimit = 1) {
@@ -366,19 +368,24 @@ module.exports = app => {
                         uSite++;
                         uSort++;
                         insertCA.push(caArray);
+                        console.log(change_status, index);
 
                         // 添加短信通知-需要审批提醒功能
                         if (change_status && index === 0) {
-                            const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo[0]);
-                            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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
-                                    const sms = new SMS(this.ctx);
-                                    const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeInfo.tid + '/change/' + changeInfo.cid + '/info#shenpi');
-                                    const content = '【纵横计量支付】' + changeInfo.code + '变更需要您审批。' + result;
-                                    sms.send(smsUser.auth_mobile, content);
-                                }
-                            }
+                            // const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo[0]);
+                            // 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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                            //         const sms = new SMS(this.ctx);
+                            //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeInfo.tid + '/change/' + changeInfo.cid + '/info#shenpi');
+                            //         const content = '【纵横计量支付】' + changeInfo.code + '变更需要您审批。' + result;
+                            //         sms.send(smsUser.auth_mobile, content);
+                            //     }
+                            // }
+                            const sms = new SMS(this.ctx);
+                            const code = await sms.contentChange(changeInfo.code);
+                            await this.ctx.helper.sendAliSms(auditInfo[0], smsTypeConst.const.BG,
+                                smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code });
                         }
                     }
                     await this.transaction.insert(this.ctx.service.changeAudit.tableName, insertCA);
@@ -519,22 +526,27 @@ module.exports = app => {
                     change_update.sin_time = Date.parse(new Date()) / 1000;
 
                     // 添加短信通知-审批通过提醒功能
-                    const mobile_array = [];
+                    // const mobile_array = [];
                     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 !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                            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);
-                            }
-                        }
-                    }
-                    if (mobile_array.length > 0) {
-                        const sms = new SMS(this.ctx);
-                        const content = '【纵横计量支付】' + changeData.code + '变更,审批通过。';
-                        sms.send(mobile_array, content);
-                    }
+                    // for (const user of auditList) {
+                    //     const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
+                    //     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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
+                    //             mobile_array.push(smsUser.auth_mobile);
+                    //         }
+                    //     }
+                    // }
+                    // if (mobile_array.length > 0) {
+                    //     const sms = new SMS(this.ctx);
+                    //     const content = '【纵横计量支付】' + changeData.code + '变更,审批通过。';
+                    //     sms.send(mobile_array, content);
+                    // }
+                    const users = this._.map(auditList, 'uid');
+                    const sms = new SMS(this.ctx);
+                    const code = await sms.contentChange(changeData.code);
+                    await this.ctx.helper.sendAliSms(users, smsTypeConst.const.BG,
+                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_result, { biangeng: code, status: SmsAliConst.status.success });
                 } else {
                     // 设置下一个审批人为审批状态
                     const nextAudit_update = {
@@ -545,17 +557,21 @@ 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 !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                        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 code = await sms.contentChange(changeData.code);
-                            const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeData.tid + '/change/' + changeData.cid + '/info#shenpi');
-                            const content = '【纵横计量支付】' + code + '变更需要您审批。' + result;
-                            sms.send(smsUser.auth_mobile, content);
-                        }
-                    }
+                    const sms = new SMS(this.ctx);
+                    const code = await sms.contentChange(changeData.code);
+                    // const smsUser = await this.ctx.service.projectAccount.getDataById(nextAuditData.uid);
+                    // 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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                    //         const sms = new SMS(this.ctx);
+                    //         const code = await sms.contentChange(changeData.code);
+                    //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeData.tid + '/change/' + changeData.cid + '/info#shenpi');
+                    //         const content = '【纵横计量支付】' + code + '变更需要您审批。' + result;
+                    //         sms.send(smsUser.auth_mobile, content);
+                    //     }
+                    // }
+                    await this.ctx.helper.sendAliSms(nextAuditData.uid, smsTypeConst.const.BG,
+                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code });
                 }
                 change_update.total_price = total_price;
                 const options = {
@@ -625,7 +641,7 @@ module.exports = app => {
             let result = false;
             try {
                 const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
-                const tenderInfo  = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
+                const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
                 // 设置审批人退回
                 const audit_update = {
                     id: postData.audit_id,
@@ -683,22 +699,27 @@ module.exports = app => {
                 result = true;
 
                 // 添加短信通知-审批退回提醒功能
-                const mobile_array = [];
-                for (const user of insert_audit_array) {
-                    const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
-                    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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
-                            mobile_array.push(smsUser.auth_mobile);
-                        }
-                    }
-                }
-                if (mobile_array.length > 0) {
-                    const sms = new SMS(this.ctx);
-                    const code = await sms.contentChange(changeData.code);
-                    const content = '【纵横计量支付】' + code + '变更,审批退回。';
-                    sms.send(mobile_array, content);
-                }
+                // const mobile_array = [];
+                // for (const user of insert_audit_array) {
+                //     const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
+                //     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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
+                //             mobile_array.push(smsUser.auth_mobile);
+                //         }
+                //     }
+                // }
+                // if (mobile_array.length > 0) {
+                //     const sms = new SMS(this.ctx);
+                //     const code = await sms.contentChange(changeData.code);
+                //     const content = '【纵横计量支付】' + code + '变更,审批退回。';
+                //     sms.send(mobile_array, content);
+                // }
+                const users = this._.map(insert_audit_array, 'uid');
+                const sms = new SMS(this.ctx);
+                const code = await sms.contentChange(changeData.code);
+                await this.ctx.helper.sendAliSms(users, smsTypeConst.const.BG,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_result, { biangeng: code, status: SmsAliConst.status.back });
             } catch (error) {
                 await this.transaction.rollback();
                 result = false;
@@ -718,7 +739,7 @@ module.exports = app => {
             let result = false;
             try {
                 const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
-                const tenderInfo  = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
+                const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
                 // 设置审批人退回
                 const audit_update = {
                     id: postData.audit_id,
@@ -811,17 +832,21 @@ module.exports = app => {
                 result = true;
 
                 // 添加短信通知-需要审批提醒功能
-                const smsUser = await this.ctx.service.projectAccount.getDataById(lastauditInfo.uid);
-                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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
-                        const sms = new SMS(this.ctx);
-                        const code = await sms.contentChange(changeData.code);
-                        const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeData.tid + '/change/' + changeData.cid + '/info#shenpi');
-                        const content = '【纵横计量支付】' + code + '变更需要您审批。' + result;
-                        sms.send(smsUser.auth_mobile, content);
-                    }
-                }
+                // const smsUser = await this.ctx.service.projectAccount.getDataById(lastauditInfo.uid);
+                // 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.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                //         const sms = new SMS(this.ctx);
+                //         const code = await sms.contentChange(changeData.code);
+                //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + changeData.tid + '/change/' + changeData.cid + '/info#shenpi');
+                //         const content = '【纵横计量支付】' + code + '变更需要您审批。' + result;
+                //         sms.send(smsUser.auth_mobile, content);
+                //     }
+                // }
+                const sms = new SMS(this.ctx);
+                const code = await sms.contentChange(changeData.code);
+                await this.ctx.helper.sendAliSms(lastauditInfo.uid, smsTypeConst.const.BG,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.change_check, { biangeng: code });
             } catch (error) {
                 await this.transaction.rollback();
                 result = false;

+ 82 - 92
app/service/ledger_audit.js

@@ -11,6 +11,7 @@
 const auditConst = require('../const/audit').ledger;
 const smsTypeConst = require('../const/sms_type');
 const SMS = require('../lib/sms');
+const SmsAliConst = require('../const/sms_alitemplate');
 
 module.exports = app => {
     class LedgerAudit extends app.BaseService {
@@ -184,7 +185,7 @@ module.exports = app => {
                 await this._syncOrderByDelete(transaction, tenderId, auditor.audit_order, times);
                 await transaction.delete(this.tableName, condition);
                 await transaction.commit();
-            } catch(err) {
+            } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
@@ -214,20 +215,10 @@ module.exports = app => {
                 });
 
                 // 添加短信通知-需要审批提醒功能
-                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 this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.TZ,
+                //     smsTypeConst.judge.approval.toString(), '台帐需要您审批。');
+                await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.TZ,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
 
                 await transaction.commit();
             } catch (err) {
@@ -253,76 +244,67 @@ module.exports = app => {
             try {
                 // 整理当前流程审核人状态更新
                 const time = new Date();
-                const audit = await this.getDataByCondition({tender_id: tenderId, times: times, status: auditConst.status.checking});
+                const audit = await this.getDataByCondition({ tender_id: tenderId, times, status: auditConst.status.checking });
                 if (!audit) {
                     throw '审核数据错误';
                 }
                 // 更新当前审核流程
-                await transaction.update(this.tableName, {id: audit.id, status: checkType, opinion: opinion, end_time: time});
+                await transaction.update(this.tableName, { id: audit.id, status: checkType, opinion, end_time: time });
                 if (checkType === auditConst.status.checked) {
-                    const nextAudit = await this.getDataByCondition({tender_id: tenderId, times: times, audit_order: audit.audit_order + 1});
+                    const nextAudit = await this.getDataByCondition({ tender_id: tenderId, times, audit_order: audit.audit_order + 1 });
                     // 无下一审核人表示,审核结束
                     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 !== '' && 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(), '台帐需要您审批。');
+                        await transaction.update(this.tableName, { id: nextAudit.id, status: auditConst.status.checking, begin_time: time });
+                        // await this.ctx.helper.sendUserSms(nextAudit.audit_id, smsTypeConst.const.TZ,
+                        //     smsTypeConst.judge.approval.toString(), '台帐需要您审批。');
+                        await this.ctx.helper.sendAliSms(nextAudit.audit_id, smsTypeConst.const.TZ,
+                            smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
                     } else {
                         // 同步标段信息
-                        await transaction.update(this.ctx.service.tender.tableName, {id: tenderId, ledger_status: checkType});
+                        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 smsUser1 = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
-                        if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
-                            const smsType = JSON.parse(smsUser1.sms_type);
-                            if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
-                                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 !== '' && smsUser.sms_type !== null) {
-                                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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                            const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                            const content = '【纵横计量支付】' + ptmsg + '台账审批通过,请登录系统处理。';
-                            sms.send(mobile_array, content);
-                        }
+                        // const mobile_array = [];
+                        // const tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
+                        // const smsUser1 = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
+                        // if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
+                        //     const smsType = JSON.parse(smsUser1.sms_type);
+                        //     if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
+                        //         mobile_array.push(smsUser1.auth_mobile);
+                        //     }
+                        // }
                         // const auditList = await this.getAuditors(tenderId, times);
-                        // const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
+                        // 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 !== '' && smsUser.sms_type !== null) {
+                        //         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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                        //     const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                        //     const content = '【纵横计量支付】' + ptmsg + '台账审批通过,请登录系统处理。';
+                        //     sms.send(mobile_array, content);
+                        // }
+                        const auditList = await this.getAuditors(tenderId, times);
+                        const users = this._.pull(this._.map(auditList, 'audit_id'), audit.id);
                         // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.TZ,
                         //     smsTypeConst.judge.result.toString(), '台账审批通过,请登录系统处理。');
+                        await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ,
+                            smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, { status: SmsAliConst.status.success });
                     }
                 } else {
                     // 同步标段信息
-                    await transaction.update(this.ctx.service.tender.tableName, {id: tenderId, ledger_times: times+1, ledger_status: checkType});
+                    await transaction.update(this.ctx.service.tender.tableName, { id: tenderId, ledger_times: times + 1, ledger_status: checkType});
                     // 拷贝新一次审核流程列表
                     const auditors = await this.getAllDataByCondition({
-                        where: {tender_id: tenderId, times: times},
-                        columns: ['tender_id', 'audit_order', 'audit_id']
+                        where: { tender_id: tenderId, times },
+                        columns: ['tender_id', 'audit_order', 'audit_id'],
                     });
                     for (const a of auditors) {
                         a.times = times + 1;
@@ -331,32 +313,40 @@ module.exports = app => {
                     await transaction.insert(this.tableName, auditors);
 
                     // 添加短信通知-审批退回提醒功能
-                    const mobile_array = [];
-                    const tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
-                    const smsUser1 = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
-                    if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
-                        const smsType = JSON.parse(smsUser1.sms_type);
-                        if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
-                            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 !== '' && smsUser.sms_type !== null) {
-                            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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                        const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                        const content = '【纵横计量支付】' + ptmsg + '台账审批退回,请登录系统处理。';
-                        sms.send(mobile_array, content);
-                    }
+                    // const mobile_array = [];
+                    // const tenderInfo = await this.ctx.service.tender.getDataById(tenderId);
+                    // const smsUser1 = await this.ctx.service.projectAccount.getDataById(tenderInfo.user_id);
+                    // if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
+                    //     const smsType = JSON.parse(smsUser1.sms_type);
+                    //     if (smsType[smsTypeConst.const.TZ] !== undefined && smsType[smsTypeConst.const.TZ].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
+                    //         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 !== '' && smsUser.sms_type !== null) {
+                    //         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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                    //     const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                    //     const content = '【纵横计量支付】' + ptmsg + '台账审批退回,请登录系统处理。';
+                    //     sms.send(mobile_array, content);
+                    // }
+                    const auditList = await this.getAuditors(tenderId, times);
+                    console.log(auditList);
+                    const users = this._.pull(this._.map(auditList, 'audit_id'), audit.id);
+                    console.log(users);
+                    // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.TZ,
+                    //     smsTypeConst.judge.result.toString(), '台账审批退回,请登录系统处理。');
+                    await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ,
+                        smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, { status: SmsAliConst.status.back });
                 }
 
                 await transaction.commit();

+ 20 - 7
app/service/project_account.js

@@ -12,6 +12,7 @@
 const crypto = require('crypto');
 const SSO = require('../lib/sso');
 const SMS = require('../lib/sms');
+const SmsAliConst = require('../const/sms_alitemplate');
 module.exports = app => {
 
     class ProjectAccount extends app.BaseService {
@@ -250,7 +251,7 @@ module.exports = app => {
         async getAllAccountByProjectId(projectId) {
             const condition = {
                 columns: ['id', 'account', 'name', 'company', 'account_group', 'role', 'mobile', 'telephone', 'enable', 'permission', 'sign_path'],
-                where: { project_id: projectId},
+                where: { project_id: projectId },
             };
             const accountList = await this.getAllDataByCondition(condition);
 
@@ -391,6 +392,7 @@ module.exports = app => {
          * 修改账号资料
          *
          * @param {Object} data - post过来的数据
+         * @param {int} id - userid
          * @return {Boolean} - 返回修改结果
          */
         async saveInfo(data, id) {
@@ -442,8 +444,12 @@ module.exports = app => {
             // 发送短信
             if (accountData.auth_mobile) {
                 const sms = new SMS(this.ctx);
-                const content = '【纵横计量支付】账号:' + accountData.account + ',密码重置为:' + newPassword;
-                sms.send(accountData.auth_mobile, content);
+                // const content = '【纵横计量支付】账号:' + accountData.account + ',密码重置为:' + newPassword;
+                // sms.send(accountData.auth_mobile, content);
+                sms.aliSend(accountData.auth_mobile, {
+                    account: accountData.account,
+                    password: newPassword,
+                }, SmsAliConst.template.mmcz);
             }
 
             const result = operate.affectedRows > 0;
@@ -467,8 +473,9 @@ module.exports = app => {
             // 发送短信
             try {
                 const sms = new SMS(this.ctx);
-                const content = '【纵横计量支付】验证码:' + randString + ',15分钟内有效。';
-                result = await sms.send(mobile, content);
+                // const content = '【纵横计量支付】验证码:' + randString + ',15分钟内有效。';
+                // result = await sms.send(mobile, content);
+                result = await sms.aliSend(mobile, { code: randString }, SmsAliConst.template.yzm);
             } catch (error) {
                 result = false;
             }
@@ -511,6 +518,7 @@ module.exports = app => {
          *
          * @param {Number} accountId - 账号id
          * @param {String} password - 重置的密码
+         * @param {String} account - 重置的账号名
          * @return {Boolean} - 重置结果
          */
         async resetPassword(accountId, password, account = '') {
@@ -547,8 +555,12 @@ module.exports = app => {
                 // 发送短信
                 if (accountData.auth_mobile !== '') {
                     const sms = new SMS(this.ctx);
-                    const content = '【纵横计量支付】账号:' + (account ? account : accountData.account) + ',密码重置为:' + password;
-                    sms.send(accountData.auth_mobile, content);
+                    // const content = '【纵横计量支付】账号:' + (account ? account : accountData.account) + ',密码重置为:' + password;
+                    // sms.send(accountData.auth_mobile, content);
+                    sms.aliSend(accountData.auth_mobile, {
+                        account: account ? account : accountData.account,
+                        password,
+                    }, SmsAliConst.template.mmcz);
                 }
 
                 this.transaction.commit();
@@ -574,6 +586,7 @@ module.exports = app => {
         /**
          * 保存用户权限数据
          *
+         * @param {int} id - userid
          * @param {Object} data - post过来的数据
          * @return {Boolean} - 返回权限修改结果
          */

+ 41 - 24
app/service/revise_audit.js

@@ -10,6 +10,7 @@
 
 const auditConst = require('../const/audit').revise;
 const smsTypeConst = require('../const/sms_type');
+const SmsAliConst = require('../const/sms_alitemplate');
 
 module.exports = app => {
     class ReviseAudit extends app.BaseService {
@@ -226,13 +227,17 @@ module.exports = app => {
 
                 // 添加短信通知-需要审批提醒功能
                 // 下一人
-                await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.XD,
-                    smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
+                // await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.XD,
+                //     smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
+                await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.XD,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.revise_check);
                 // 其他参与人
                 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 this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
+                //     smsTypeConst.judge.result.toString(), '台账修订已上报。');
+                await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD,
+                    smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_report);
 
                 await transaction.commit();
             } catch (err) {
@@ -289,27 +294,31 @@ module.exports = app => {
                 const time = new Date();
                 // 更新当前审核流程
                 await transaction.update(this.tableName, {
-                    id: audit.id, status: checkType, opinion: opinion, end_time: time,
+                    id: audit.id, status: checkType, opinion, end_time: time,
                 });
                 if (checkType === auditConst.status.checked) {
-                    const nextAudit = await this.getDataByCondition({rid: revise.id, times: times, audit_order: audit.audit_order + 1});
+                    const nextAudit = await this.getDataByCondition({ rid: revise.id, times, audit_order: audit.audit_order + 1 });
                     // 无下一审核人表示,审核结束
                     if (nextAudit) {
-                        await transaction.update(this.tableName, {id: nextAudit.id, status: auditConst.status.checking, begin_time: time});
+                        await transaction.update(this.tableName, { id: nextAudit.id, status: auditConst.status.checking, begin_time: time });
 
                         // 短信通知-需要审批提醒功能
                         // 下一人
-                        await this.ctx.helper.sendUserSms(nextAudit.user_id, smsTypeConst.const.XD,
-                            smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
+                        // await this.ctx.helper.sendUserSms(nextAudit.user_id, smsTypeConst.const.XD,
+                        //     smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
+                        await this.ctx.helper.sendAliSms(nextAudit.user_id, smsTypeConst.const.XD,
+                            smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, { status: SmsAliConst.status.success });
                         // 其他参与人
                         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(), '台账修订审批通过。');
+                        // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
+                        //     smsTypeConst.judge.result.toString(), '台账修订审批通过。');
+                        await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD,
+                            smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, { status: SmsAliConst.status.success });
                     } else {
                         // 同步修订信息
-                        await transaction.update(this.ctx.service.ledgerRevise.tableName, {id: revise.id, status: checkType, end_time: time});
+                        await transaction.update(this.ctx.service.ledgerRevise.tableName, { id: revise.id, status: checkType, end_time: time });
                         // 最新一期跟台账相关的缓存数据应过期
                         const lastStage = await this.ctx.service.stage.getLastestStage(revise.tid, true);
                         const cacheTime = new Date();
@@ -324,22 +333,26 @@ module.exports = app => {
 
                         // 短信通知-审批通过提醒功能
                         // 下一人
-                        const msg = '台账修订审批通过,请登录系统处理。';
-                        await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
-                            smsTypeConst.judge.result.toString(), msg);
+                        // const msg = '台账修订审批通过,请登录系统处理。';
+                        // await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
+                        //     smsTypeConst.judge.result.toString(), msg);
+                        await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD,
+                            smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, { status: SmsAliConst.status.success });
                         // 其他参与人
                         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 this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
+                        //     smsTypeConst.judge.result.toString(), '台账修订审批通过。');
+                        await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD,
+                            smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, { status: SmsAliConst.status.success });
                     }
                 } else {
                     // 同步修订信息
-                    await transaction.update(this.ctx.service.ledgerRevise.tableName, {id: revise.id, times: times+1, status: checkType});
+                    await transaction.update(this.ctx.service.ledgerRevise.tableName, { id: revise.id, times: times + 1, status: checkType });
                     // 拷贝新一次审核流程列表
                     const auditors = await this.getAllDataByCondition({
-                        where: {rid: revise.id, times: times},
-                        columns: ['tender_id', 'rid', 'audit_order', 'audit_id']
+                        where: { rid: revise.id, times },
+                        columns: ['tender_id', 'rid', 'audit_order', 'audit_id'],
                     });
                     for (const a of auditors) {
                         a.times = times + 1;
@@ -350,11 +363,15 @@ module.exports = app => {
 
                     // 短信通知-审批退回提醒功能
                     // 下一人
-                    await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
-                        smsTypeConst.judge.result.toString(), '台账修订审批退回,请登录系统处理。');
+                    // await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
+                    //     smsTypeConst.judge.result.toString(), '台账修订审批退回,请登录系统处理。');
+                    await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD,
+                        smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, { status: SmsAliConst.status.back });
                     // 其他参与人
-                    await this.ctx.helper.sendUserSms(this._.map(auditors, 'user_id'),
-                        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 this.ctx.helper.sendAliSms(this._.map(auditors, 'user_id'), smsTypeConst.const.XD,
+                        smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, { status: SmsAliConst.status.back });
                 }
 
                 await transaction.commit();

+ 137 - 118
app/service/stage_audit.js

@@ -11,6 +11,7 @@
 const auditConst = require('../const/audit').stage;
 const smsTypeConst = require('../const/sms_type');
 const SMS = require('../lib/sms');
+const SmsAliConst = require('../const/sms_alitemplate');
 
 module.exports = app => {
     class StageAudit extends app.BaseService {
@@ -209,7 +210,7 @@ module.exports = app => {
          * @returns {Promise<boolean>}
          */
         async start(stageId, times = 1) {
-            const audit = await this.getDataByCondition({sid: stageId, times: times, order: 1});
+            const audit = await this.getDataByCondition({ sid: stageId, times, order: 1 });
             if (!audit) {
                 throw '请先选择审批人,再上报数据';
             }
@@ -244,25 +245,28 @@ module.exports = app => {
                 });
 
                 // 添加短信通知-需要审批提醒功能
-                const smsUser = await this.ctx.service.projectAccount.getDataById(audit.aid);
-                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.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
-                        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 tenderName = await sms.contentChange(tenderInfo.name);
-                        const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                        const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                        const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
-                        const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
-                        sms.send(smsUser.auth_mobile, content);
-                    }
-                }
+                // const smsUser = await this.ctx.service.projectAccount.getDataById(audit.aid);
+                // 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.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                //         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 tenderName = await sms.contentChange(tenderInfo.name);
+                //         const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                //         const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
+                //         const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
+                //         sms.send(smsUser.auth_mobile, content);
+                //     }
+                // }
+                const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                await this.ctx.helper.sendAliSms(audit.aid, smsTypeConst.const.JL,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
 
                 // todo 更新标段tender状态 ?
                 await transaction.commit();
-            } catch(err) {
+            } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
@@ -312,22 +316,25 @@ module.exports = app => {
                     });
 
                     // 添加短信通知-需要审批提醒功能
-                    const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);
-                    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.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
-                            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 tenderName = await sms.contentChange(tenderInfo.name);
-                            const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                            const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
-                            // const result = '';
-                            const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                            const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
-                            sms.send(smsUser.auth_mobile, content);
-                        }
-                    }
+                    // const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);
+                    // 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.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                    //         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 tenderName = await sms.contentChange(tenderInfo.name);
+                    //         const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                    //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
+                    //         // const result = '';
+                    //         const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                    //         const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
+                    //         sms.send(smsUser.auth_mobile, content);
+                    //     }
+                    // }
+                    const stageInfo = await this.ctx.service.stage.getDataById(nextAudit.sid);
+                    await this.ctx.helper.sendAliSms(nextAudit.aid, smsTypeConst.const.JL,
+                        smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
                 } else {
                     // 本期结束
                     // 生成截止本期数据 final数据
@@ -347,34 +354,37 @@ module.exports = app => {
                     });
 
                     // 添加短信通知-审批通过提醒功能
-                    const mobile_array = [];
+                    // const mobile_array = [];
                     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 !== '' && smsUser1.sms_type !== null) {
-                        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);
-                        }
-                    }
-                    for (const user of auditList) {
-                        const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
-                        if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                            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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                        const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                        const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,审批通过。';
-                        sms.send(mobile_array, content);
-                    }
+                    // const smsUser1 = await this.ctx.service.projectAccount.getDataById(stageInfo.user_id);
+                    // if (smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
+                    //     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);
+                    //     }
+                    // }
+                    // for (const user of auditList) {
+                    //     const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
+                    //     if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
+                    //         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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                    //     const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                    //     const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,审批通过。';
+                    //     sms.send(mobile_array, content);
+                    // }
+                    const users = this._.pull(this._.map(auditList, 'aid'), stageInfo.user_id);
+                    await this.ctx.helper.sendAliSms(users, smsTypeConst.const.JL,
+                        smsTypeConst.judge.result.toString(), SmsAliConst.template.stage_result, { qi: stageInfo.order, status: SmsAliConst.status.success });
                 }
                 await transaction.commit();
             } catch (err) {
@@ -435,34 +445,37 @@ module.exports = app => {
                 await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
 
                 // 添加短信通知-审批退回提醒功能
-                const mobile_array = [];
+                // const mobile_array = [];
                 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 !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
-                    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);
-                    }
-                }
-                for (const user of auditList) {
-                    const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
-                    if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                        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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                    const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                    const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,审批退回。';
-                    sms.send(mobile_array, content);
-                }
+                // const smsUser1 = await this.ctx.service.projectAccount.getDataById(stageInfo.user_id);
+                // if (smsUser1.auth_mobile !== '' && smsUser1.auth_mobile !== undefined && smsUser1.sms_type !== '' && smsUser1.sms_type !== null) {
+                //     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);
+                //     }
+                // }
+                // for (const user of auditList) {
+                //     const smsUser = await this.ctx.service.projectAccount.getDataById(user.aid);
+                //     if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
+                //         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 projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                //     const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                //     const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,审批退回。';
+                //     sms.send(mobile_array, content);
+                // }
+                const users = this._.pull(this._.map(auditList, 'aid'), stageInfo.user_id);
+                await this.ctx.helper.sendAliSms(users, smsTypeConst.const.JL,
+                    smsTypeConst.judge.result.toString(), SmsAliConst.template.stage_result, { qi: stageInfo.order, status: SmsAliConst.status.back });
 
                 await transaction.commit();
             } catch (err) {
@@ -474,7 +487,7 @@ module.exports = app => {
         async _checkNoPre(stageId, checkData, times) {
             const time = new Date();
             // 整理当前流程审核人状态更新
-            const audit = await this.getDataByCondition({sid: stageId, times: times, status: auditConst.status.checking});
+            const audit = await this.getDataByCondition({ sid: stageId, times, status: auditConst.status.checking });
             if (!audit || audit.order <= 1) {
                 throw '审核数据错误';
             }
@@ -544,25 +557,28 @@ module.exports = app => {
                 });
 
                 // 添加短信通知-需要审批提醒功能
-                const smsUser = await this.ctx.service.projectAccount.getDataById(preAuditor.aid);
-                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.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
-                        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 tenderName = await sms.contentChange(tenderInfo.name);
-                        const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                        const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                        const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
-                        // const result = '';
-                        const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
-                        sms.send(smsUser.auth_mobile, content);
-                    }
-                }
+                // const smsUser = await this.ctx.service.projectAccount.getDataById(preAuditor.aid);
+                // 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.JL] !== undefined && smsType[smsTypeConst.const.JL].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
+                //         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 tenderName = await sms.contentChange(tenderInfo.name);
+                //         const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                //         const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
+                //         // const result = '';
+                //         const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
+                //         sms.send(smsUser.auth_mobile, content);
+                //     }
+                // }
+                const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                await this.ctx.helper.sendAliSms(preAuditor.aid, smsTypeConst.const.JL,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
 
                 await transaction.commit();
-            } catch(err) {
+            } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
@@ -762,21 +778,24 @@ module.exports = app => {
                 });
 
                 // 添加短信通知-需要审批提醒功能
-                const smsUser = await this.ctx.service.projectAccount.getDataById(audit.aid);
-                if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
-                    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);
-                        const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
-                        const sms = new SMS(this.ctx);
-                        const tenderName = await sms.contentChange(tenderInfo.name);
-                        const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
-                        const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
-                        const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
-                        const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
-                        sms.send(smsUser.auth_mobile, content);
-                    }
-                }
+                // const smsUser = await this.ctx.service.projectAccount.getDataById(audit.aid);
+                // if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '' && smsUser.sms_type !== null) {
+                //     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);
+                //         const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                //         const sms = new SMS(this.ctx);
+                //         const tenderName = await sms.contentChange(tenderInfo.name);
+                //         const projectName = await sms.contentChange(this.ctx.tender.info.deal_info.buildName);
+                //         const ptmsg = projectName !== '' ? '项目「' + projectName + '」标段「' + tenderName + '」' : tenderName;
+                //         const result = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order);
+                //         const content = '【纵横计量支付】' + ptmsg + '第' + stageInfo.order + '期,需要您审批。' + result;
+                //         sms.send(smsUser.auth_mobile, content);
+                //     }
+                // }
+                const stageInfo = await this.ctx.service.stage.getDataById(audit.sid);
+                await this.ctx.helper.sendAliSms(audit.aid, smsTypeConst.const.JL,
+                    smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order });
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();

+ 1 - 1
app/view/change/info.ejs

@@ -174,7 +174,7 @@
             <div class="sjs-height-0 container-fluid">
             <!--变更信息-->
             <% if (auditStatus === 1 || auditStatus === 2) { %>
-            <form action="/change/save?_csrf=<%= ctx.csrf %>" method="post" id="change_form">
+            <form action="/tender/<%- change.tid %>/change/save?_csrf=<%= ctx.csrf %>" method="post" id="change_form">
                 <div class="row">
                     <div class="col-md-4">
                         <div class="form-group">

+ 3 - 3
app/view/change/info_modal.ejs

@@ -442,7 +442,7 @@
     <!--审批通过-->
     <div class="modal fade" id="sp-done" data-backdrop="static">
         <div class="modal-dialog modal-lg" role="document">
-            <form class="modal-content" action="/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="success-approval">
+            <form class="modal-content" action="/tender/<%- tender.id %>/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="success-approval">
                 <div class="modal-header">
                     <h5 class="modal-title">审批通过</h5>
                 </div>
@@ -589,7 +589,7 @@
     <!--审批退回-->
     <div class="modal fade" id="sp-back" data-backdrop="static">
         <div class="modal-dialog modal-lg" role="document">
-            <form class="modal-content" action="/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="fail-approval">
+            <form class="modal-content" action="/tender/<%- tender.id %>/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="fail-approval">
                 <div class="modal-header">
                     <h5 class="modal-title">审批退回</h5>
                 </div>
@@ -770,7 +770,7 @@
 <!--重新审批-->
 <div class="modal fade" id="sp-down-back" data-backdrop="static">
     <div class="modal-dialog" role="document">
-        <form class="modal-content" method="post" action="/change/check/again">
+        <form class="modal-content" method="post" action="/tender/<%- tender.id %>/change/check/again">
             <div class="modal-header">
                 <h5 class="modal-title">重新审批</h5>
             </div>

+ 1 - 1
app/view/wap/shenpi_change.ejs

@@ -254,7 +254,7 @@
 <!--审批退回弹窗-->
 <div class="modal" tabindex="-1" role="dialog" id="sp-back">
     <div class="modal-dialog" role="document">
-        <form class="modal-content" action="/wap/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="fail-approval">
+        <form class="modal-content" action="/wap/tender/<%- tender.id %>/change/approval?_csrf=<%= ctx.csrf %>" method="post" id="fail-approval">
             <div class="modal-header">
                 <h5 class="modal-title">审批退回</h5>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 2839 - 2754
package-lock.json


+ 1 - 0
package.json

@@ -4,6 +4,7 @@
   "description": "calculation paying frontend",
   "private": true,
   "dependencies": {
+    "@alicloud/pop-core": "^1.7.9",
     "ali-rds": "^3.3.0",
     "atob": "^2.1.2",
     "bignumber.js": "^8.1.1",