|
@@ -420,6 +420,7 @@ module.exports = app => {
|
|
* @return {void}
|
|
* @return {void}
|
|
*/
|
|
*/
|
|
async approvalSuccess(postData, changeData) {
|
|
async approvalSuccess(postData, changeData) {
|
|
|
|
+ let tenderInfo;
|
|
// 初始化事务
|
|
// 初始化事务
|
|
this.transaction = await this.db.beginTransaction();
|
|
this.transaction = await this.db.beginTransaction();
|
|
let result = false;
|
|
let result = false;
|
|
@@ -445,8 +446,12 @@ module.exports = app => {
|
|
const lid = listInfo[0];
|
|
const lid = listInfo[0];
|
|
const amount = listInfo[1];
|
|
const amount = listInfo[1];
|
|
const changeListInfo = await this.ctx.service.changeAuditList.getDataById(lid);
|
|
const changeListInfo = await this.ctx.service.changeAuditList.getDataById(lid);
|
|
|
|
+ if (!tenderInfo) {
|
|
|
|
+ tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeListInfo.tid);
|
|
|
|
+ }
|
|
if (changeListInfo !== undefined) {
|
|
if (changeListInfo !== undefined) {
|
|
- total_price += this.ctx.helper.accMul(changeListInfo.unit_price, parseFloat(amount));
|
|
|
|
|
|
+ total_price = this.ctx.helper.add(total_price,
|
|
|
|
+ this.ctx.helper.mul(changeListInfo.unit_price, amount, tenderInfo.decimal.tp));
|
|
const audit_amount = changeListInfo.audit_amount !== null && changeListInfo.audit_amount !== '' ? changeListInfo.audit_amount.split(',') : [];
|
|
const audit_amount = changeListInfo.audit_amount !== null && changeListInfo.audit_amount !== '' ? changeListInfo.audit_amount.split(',') : [];
|
|
audit_amount.push(amount);
|
|
audit_amount.push(amount);
|
|
const list_update = {
|
|
const list_update = {
|
|
@@ -514,6 +519,7 @@ module.exports = app => {
|
|
await this.transaction.commit();
|
|
await this.transaction.commit();
|
|
result = true;
|
|
result = true;
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
+ console.log(error);
|
|
await this.transaction.rollback();
|
|
await this.transaction.rollback();
|
|
result = false;
|
|
result = false;
|
|
}
|
|
}
|
|
@@ -571,6 +577,7 @@ module.exports = app => {
|
|
let result = false;
|
|
let result = false;
|
|
try {
|
|
try {
|
|
const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
|
|
const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
|
|
|
|
+ const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
|
|
// 设置审批人退回
|
|
// 设置审批人退回
|
|
const audit_update = {
|
|
const audit_update = {
|
|
id: postData.audit_id,
|
|
id: postData.audit_id,
|
|
@@ -607,7 +614,8 @@ module.exports = app => {
|
|
const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
|
|
const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
|
|
let total_price = 0;
|
|
let total_price = 0;
|
|
for (const cl of changeList) {
|
|
for (const cl of changeList) {
|
|
- total_price += this.ctx.helper.accMul(cl.unit_price, cl.camount);
|
|
|
|
|
|
+ total_price = this.ctx.helper.add(total_price,
|
|
|
|
+ this.ctx.helper.mul(cl.unit_price, cl.camount, tenderInfo.decimal.tp));
|
|
}
|
|
}
|
|
// 设置变更令退回
|
|
// 设置变更令退回
|
|
const change_update = {
|
|
const change_update = {
|
|
@@ -662,6 +670,7 @@ module.exports = app => {
|
|
let result = false;
|
|
let result = false;
|
|
try {
|
|
try {
|
|
const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
|
|
const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
|
|
|
|
+ const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
|
|
// 设置审批人退回
|
|
// 设置审批人退回
|
|
const audit_update = {
|
|
const audit_update = {
|
|
id: postData.audit_id,
|
|
id: postData.audit_id,
|
|
@@ -732,7 +741,8 @@ module.exports = app => {
|
|
audit_amount: audit_amount.join(','),
|
|
audit_amount: audit_amount.join(','),
|
|
spamount: parseFloat(last_amount),
|
|
spamount: parseFloat(last_amount),
|
|
};
|
|
};
|
|
- total_price += this.ctx.helper.accMul(cl.unit_price, parseFloat(last_amount));
|
|
|
|
|
|
+ total_price = this.ctx.helper.add(total_price,
|
|
|
|
+ this.ctx.helper.mul(cl.unit_price, parseFloat(last_amount), tenderInfo.decimal.tp));
|
|
await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
|
|
await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -902,6 +912,7 @@ module.exports = app => {
|
|
let result = false;
|
|
let result = false;
|
|
try {
|
|
try {
|
|
const changeInfo = await this.getDataByCondition({ cid });
|
|
const changeInfo = await this.getDataByCondition({ cid });
|
|
|
|
+ const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
|
|
|
|
|
|
// 获取终审
|
|
// 获取终审
|
|
const auditInfo = (await this.ctx.service.changeAudit.getAllDataByCondition({ where: { cid }, orders: [['usort', 'desc']], limit: 1, offset: 0 }))[0];
|
|
const auditInfo = (await this.ctx.service.changeAudit.getAllDataByCondition({ where: { cid }, orders: [['usort', 'desc']], limit: 1, offset: 0 }))[0];
|
|
@@ -949,7 +960,8 @@ module.exports = app => {
|
|
audit_amount: audit_amount.join(','),
|
|
audit_amount: audit_amount.join(','),
|
|
samount: '',
|
|
samount: '',
|
|
};
|
|
};
|
|
- total_price += this.ctx.helper.accMul(cl.unit_price, cl.camount);
|
|
|
|
|
|
+ total_price = this.ctx.helper.add(total_price,
|
|
|
|
+ this.ctx.helper.mul(cl.unit_price, cl.camount, tenderInfo.decima.tp));
|
|
await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
|
|
await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
|
|
}
|
|
}
|
|
|
|
|