MaiXinRong 3 years ago
parent
commit
bd4be407ad
1 changed files with 17 additions and 8 deletions
  1. 17 8
      app/controller/tender_controller.js

+ 17 - 8
app/controller/tender_controller.js

@@ -400,6 +400,16 @@ module.exports = app => {
                 const lastStage = stages.length > 0 ? stages[0] : null; // await ctx.service.stage.getLastestStage(ctx.tender.id);
                 if (lastStage) {
                     await this.ctx.service.stage.checkStageGatherData(lastStage);
+
+                    if ((!bCalcTp) && tender.measure_type === measureType.gcl.value) {
+                        bCalcTp = lastStage.status !== auditConst.stage.status.checked && !lastStage.readOnly;
+                    }
+                    if (bCalcTp) {
+                        const sum = await this.ctx.service.ledger.addUp({ tender_id: tender.id/* , is_leaf: true*/ });
+                        tender.total_price = sum.total_price;
+                        tender.deal_tp = sum.deal_tp;
+                    }
+
                     tender.gather_tp = ctx.helper.add(lastStage.contract_tp, lastStage.qc_tp);
                     tender.end_contract_tp = ctx.helper.add(lastStage.contract_tp, lastStage.pre_contract_tp);
                     tender.end_qc_tp = ctx.helper.add(lastStage.qc_tp, lastStage.pre_qc_tp);
@@ -435,10 +445,13 @@ module.exports = app => {
                         const times = lastStage.status === auditConst.stage.status.checkNo ? lastStage.times - 1 : lastStage.times;
                         lastStage.auditors = await ctx.service.stageAudit.getFinalAuditGroup(lastStage.id, times);
                     }
-                    if ((!bCalcTp) && tender.measure_type === measureType.gcl.value) {
-                        bCalcTp = lastStage.status !== auditConst.stage.status.checked && !lastStage.readOnly;
-                    }
                 } else {
+                    if (bCalcTp) {
+                        const sum = await this.ctx.service.ledger.addUp({ tender_id: tender.id/* , is_leaf: true*/ });
+                        tender.total_price = sum.total_price;
+                        tender.deal_tp = sum.deal_tp;
+                    }
+
                     if (tender.ledger_status !== auditConst.ledger.status.uncheck) {
                         const status_name = await this.ctx.service.ledgerAudit.getStatusName(tender.id, tender.ledger_times);
                         tender.status_users = status_name ? status_name.name : '';
@@ -449,11 +462,7 @@ module.exports = app => {
                         tender.status_users = status_name ? status_name.name : '';
                     }
                 }
-                if (bCalcTp) {
-                    const sum = await this.ctx.service.ledger.addUp({ tender_id: tender.id/* , is_leaf: true*/ });
-                    tender.total_price = sum.total_price;
-                    tender.deal_tp = sum.deal_tp;
-                }
+
                 const tiModel = new tenderInfoModel(ctx);
                 const gclChapter = await tiModel.gatherChapter();