|
@@ -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]);
|
|
|
}
|
|
|
}
|
|
|
}
|