Browse Source

fix: 修复台账分解审核推送异常bug

lanjianrong 4 years ago
parent
commit
b577d4ac81
1 changed files with 23 additions and 6 deletions
  1. 23 6
      app/service/ledger_audit.js

+ 23 - 6
app/service/ledger_audit.js

@@ -54,7 +54,11 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getStatusName(tenderId, times) {
-            const sql = 'SELECT pa.`name` ' + 'FROM ?? AS la, ?? AS pa ' + 'WHERE la.`tender_id` = ?' + '    and la.`audit_id` = pa.`id` and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC'
+            const sql =
+                'SELECT pa.`name` ' +
+                'FROM ?? AS la, ?? AS pa ' +
+                'WHERE la.`tender_id` = ?' +
+                '    and la.`audit_id` = pa.`id` and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC'
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.uncheck]
             return await this.db.queryOne(sql, sqlParam)
         }
@@ -262,6 +266,7 @@ module.exports = app => {
 
                 // 获取审核人列表
                 const auditList = await this.getAuditors(tenderId, times)
+                console.log('auditList', auditList)
                 // 添加推送
                 const noticeContent = await this.getNoticeContent(audit.tender_id, pid, audit.audit_id)
                 const records = [
@@ -269,7 +274,7 @@ module.exports = app => {
                         pid,
                         type: pushType.ledger,
                         uid: this.ctx.tender.data.user_id,
-                        status: auditConst.status.checked,
+                        status: checkType,
                         content: noticeContent
                     }
                 ]
@@ -278,7 +283,7 @@ module.exports = app => {
                         pid,
                         type: pushType.ledger,
                         uid: audit.audit_id,
-                        status: auditConst.status.checked,
+                        status: checkType,
                         content: noticeContent
                     })
                 })
@@ -339,7 +344,9 @@ module.exports = app => {
                         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 })
+                        await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, {
+                            status: SmsAliConst.status.success
+                        })
                     }
                 } else {
                     // 同步标段信息
@@ -389,7 +396,9 @@ module.exports = app => {
                     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.back })
+                    await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, {
+                        status: SmsAliConst.status.back
+                    })
                 }
 
                 await transaction.commit()
@@ -411,7 +420,15 @@ module.exports = app => {
                 'FROM ?? AS la, ?? AS t ' +
                 'WHERE ((la.`audit_id` = ? and la.`status` = ?) OR (t.`user_id` = ? and t.`ledger_status` = ? and la.`status` = ? and la.`times` = (t.`ledger_times`-1)))' +
                 '    and la.`tender_id` = t.`id`'
-            const sqlParam = [this.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo]
+            const sqlParam = [
+                this.tableName,
+                this.ctx.service.tender.tableName,
+                auditorId,
+                auditConst.status.checking,
+                auditorId,
+                auditConst.status.checkNo,
+                auditConst.status.checkNo
+            ]
             return await this.db.query(sql, sqlParam)
         }