Bladeren bron

合同支付,序号cache相关

MaiXinRong 1 jaar geleden
bovenliggende
commit
38f73710a0
1 gewijzigde bestanden met toevoegingen van 4 en 3 verwijderingen
  1. 4 3
      app/service/pay.js

+ 4 - 3
app/service/pay.js

@@ -202,10 +202,11 @@ module.exports = app => {
             await transaction.delete(this.tableName, { csid: stage.id });
             if (stage.order > 1) {
                 const preStage = await this.ctx.service.stage.getDataByCondition({ tid: stage.tid, order: stage.order - 1});
-                const max = await this.db.queryOne('SELECT MAX(stimes) as stimes, MAX(sorder) as sorder FROM ?? WHERE sid = ?', [this.ctx.service.stagePay.tableName, preStage.id]);
+                const maxTimes = await this.db.queryOne('SELECT Max(stimes) as stimes FROM ?? WHERE sid = ?', [this.ctx.service.stagePay.tableName, preStage.id]);
+                const maxOrder = await this.db.queryOne('SELECT Max(sorder) as sorder FROM ?? WHERE sid = ? And stimes = ?', [this.ctx.service.stagePay.tableName, preStage.id, maxTimes.stimes]);
                 const resortSql = `UPDATE ${this.tableName} p LEFT JOIN ${this.ctx.service.stagePay.tableName} sp ON p.id = sp.pid`+
-                    '  SET p.`order` = sp.porder, p.`expr` = sp.`expr`, p.valid = 1 WHERE p.tid = ? and sp.sid = ? and sp.stimes = ? and sp.sorder = ?';
-                await transaction.query(resortSql, [stage.tid, preStage.id, max.stimes, max.sorder]);
+                    '  SET p.`order` = sp.porder, p.`expr` = sp.`expr`, p.valid = 1 WHERE p.tid = ? and sp.sid = ? and sp.stimes = ? and sp.sorder = ? and sp.porder > 0';
+                await transaction.query(resortSql, [stage.tid, preStage.id, maxTimes.stimes, maxOrder.sorder]);
             }
         }
     }