|
@@ -197,6 +197,17 @@ module.exports = app => {
|
|
|
return updateData;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async doDeleteStage(stage, transaction) {
|
|
|
+ await transaction.delete(this.tableName, { csid: 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.query('SELECT MAX(stimes) as stimes, MAX(sorder) as sorder FROM ? WHERE sid = ?', [this.ctx.service.stagePay.tableName, preStage.id]);
|
|
|
+ const resortSql = `UPDATE ${this.tableName} p LEFT JOIN ${this.ctx.service.stagePay.tableName} sp ON p.id === sp.pid`+
|
|
|
+ ' SET p.`order` = sp.porder WHERE p.tid = ? and sp.sid = ? and sp.stimes = ? and sp.sorder = ?';
|
|
|
+ await transaction.query(resortSql, [stage.tid, preStage.id, max.stimes, max.sorder]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return Pay;
|