|
@@ -139,7 +139,7 @@ module.exports = app => {
|
|
|
return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
- async _insertStageBillsData(transaction, insertData, ledgerData) {
|
|
|
+ async _insertStageBillsData(transaction, insertData, orgData, ledgerData) {
|
|
|
const info = this.ctx.tender.info;
|
|
|
const d = {
|
|
|
tid: this.ctx.tender.id,
|
|
@@ -149,6 +149,13 @@ module.exports = app => {
|
|
|
order: this.ctx.stage.curOrder,
|
|
|
said: this.ctx.session.sessionUser.accountId,
|
|
|
};
|
|
|
+ if (orgData) {
|
|
|
+ d.contract_qty = orgData.contract_qty;
|
|
|
+ d.contract_tp = orgData.contract_tp;
|
|
|
+ d.qc_qty = orgData.qc_qty;
|
|
|
+ d.qc_tp = orgData.qc_tp;
|
|
|
+ d.postil = orgData.postil;
|
|
|
+ }
|
|
|
|
|
|
const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
|
|
|
if (insertData.contract_qty) {
|
|
@@ -187,13 +194,14 @@ module.exports = app => {
|
|
|
d.qc_qty = this.round(d.qc_qty, precision.value);
|
|
|
d.qc_tp = this.ctx.helper.mul(d.qc_qty, ledgerBills.unit_price, info.decimal.tp);
|
|
|
}
|
|
|
- if (!stageBills) {
|
|
|
- d.tid = this.ctx.tender.id;
|
|
|
- d.sid = this.ctx.stage.id;
|
|
|
- d.said = this.ctx.session.sessionUser.accountId;
|
|
|
- d.times = this.ctx.stage.curTimes;
|
|
|
- d.order = this.ctx.stage.curOrder;
|
|
|
- await transaction.insert(this.tableName, d);
|
|
|
+ if (!stageBills || stageBills.times !== this.ctx.stage.curTimes || stageBills.order !== this.ctx.stage.curOrder) {
|
|
|
+ await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
|
|
|
+ // d.tid = this.ctx.tender.id;
|
|
|
+ // d.sid = this.ctx.stage.id;
|
|
|
+ // d.said = this.ctx.session.sessionUser.accountId;
|
|
|
+ // d.times = this.ctx.stage.curTimes;
|
|
|
+ // d.order = this.ctx.stage.curOrder;
|
|
|
+ // await transaction.insert(this.tableName, d);
|
|
|
} else {
|
|
|
d.id = stageBills.id;
|
|
|
await transaction.update(this.tableName, d);
|
|
@@ -235,11 +243,11 @@ module.exports = app => {
|
|
|
updateData.id = stageBills.id;
|
|
|
await transaction.update(this.tableName, updateData);
|
|
|
} else {
|
|
|
- await this._insertStageBillsData(transaction, updateData, ledgerBills);
|
|
|
+ await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- await this._insertStageBillsData(transaction, updateData, ledgerBills);
|
|
|
+ await this._insertStageBillsData(transaction, updateData, stageBills, ledgerBills);
|
|
|
}
|
|
|
};
|
|
|
/**
|