|
@@ -335,13 +335,15 @@ module.exports = app => {
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
await transaction.update(this.ctx.service.ledger.tableName, data);
|
|
|
- if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
|
|
|
- await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
|
|
|
- } else {
|
|
|
- updateData.id = stageBills.id;
|
|
|
- await transaction.update(this.tableName, updateData);
|
|
|
+ if (stageBills) {
|
|
|
+ if (stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
|
|
|
+ const ledgerBills = await this.ctx.service.ledger.getDataById(data.id);
|
|
|
+ await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
|
|
|
+ } else {
|
|
|
+ updateData.id = stageBills.id;
|
|
|
+ await transaction.update(this.tableName, updateData);
|
|
|
+ }
|
|
|
}
|
|
|
- await transaction.update(this.tableName, updateData);
|
|
|
await transaction.commit();
|
|
|
} catch (err) {
|
|
|
await transaction.rollback();
|