laiguoran 2 лет назад
Родитель
Сommit
ddab837ada
1 измененных файлов с 28 добавлено и 7 удалено
  1. 28 7
      app/service/payment_detail.js

+ 28 - 7
app/service/payment_detail.js

@@ -198,20 +198,31 @@ module.exports = app => {
         }
 
         async haveNotice2Tender(tid, uid) {
-            const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pda' +
-                ' ON pd.`id` = pda.`td_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tender_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
+            const sql = 'SELECT pd.`id`, pd.`tr_id`, pd.`order` FROM ?? as pd LEFT JOIN ?? as pda' +
+                ' ON pd.`id` = pda.`td_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tender_id` = ? AND' +
+                ' ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
                 ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)' +
                 ' OR (pra.`uid` = ? AND pra.`signature_msg` is null AND pd.`status` != ? AND pd.`status` != ?))';
             const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentRptAudit.tableName, tid,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo,
                 auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo];
-            const result = await this.db.queryOne(sql, params);
-            return result ? result.count : 0;
+            const result = await this.db.query(sql, params);
+            if (result && result.length > 0) {
+                for (const one of result) {
+                    const maxOrder = await this.count({
+                        tr_id: one.id,
+                    });
+                    if (one.order === maxOrder) {
+                        return 1;
+                    }
+                }
+            }
+            return 0;
         }
 
         async haveNotice2TenderRpt(tr_id, uid) {
-            const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pda' +
+            const sql = 'SELECT pd.`id`, pd.`tr_id`, pd.`order` FROM ?? as pd LEFT JOIN ?? as pda' +
                 ' ON pd.`id` = pda.`td_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tr_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
                 ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)' +
                 ' OR (pra.`uid` = ? AND pra.`signature_msg` is null AND pd.`status` != ? AND pd.`status` != ?))';
@@ -219,8 +230,18 @@ module.exports = app => {
                 uid, auditConst.status.uncheck, auditConst.status.checkNo,
                 auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo];
-            const result = await this.db.queryOne(sql, params);
-            return result ? result.count : 0;
+            const result = await this.db.query(sql, params);
+            if (result && result.length > 0) {
+                for (const one of result) {
+                    const maxOrder = await this.count({
+                        tr_id: one.id,
+                    });
+                    if (one.order === maxOrder) {
+                        return 1;
+                    }
+                }
+            }
+            return 0;
         }
 
         async haveDetail2Tender(tid) {