瀏覽代碼

合同支付取值调整

MaiXinRong 1 月之前
父節點
當前提交
17c319c2fa
共有 3 個文件被更改,包括 12 次插入7 次删除
  1. 3 1
      app/controller/pay_controller.js
  2. 7 4
      app/service/phase_pay.js
  3. 2 2
      app/service/report_memory.js

+ 3 - 1
app/controller/pay_controller.js

@@ -34,10 +34,12 @@ module.exports = app => {
                     if (p.audit_status !== audit.common.status.checked) await this.ctx.service.phasePay.loadUser(p);
                     if (p.audit_status !== audit.common.status.checked) await this.ctx.service.phasePay.loadUser(p);
                     relaStage.push(...p.rela_stage);
                     relaStage.push(...p.rela_stage);
                 }
                 }
+                const relaStageOrder = this.ctx.helper._.orderBy(relaStage, ['stage_order'], ['desc']);
+                const maxOrder = relaStageOrder.length > 0 ? relaStageOrder[0].stage_order : 0;
                 const stages = await this.ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id }, orders: [['order', 'AEC']] });
                 const stages = await this.ctx.service.stage.getAllDataByCondition({ where: { tid: ctx.tender.id }, orders: [['order', 'AEC']] });
                 const validStages = stages.filter(s => {
                 const validStages = stages.filter(s => {
                     if (s.status !== audit.stage.status.checked) return false;
                     if (s.status !== audit.stage.status.checked) return false;
-                    return !relaStage.find(r => { return s.id === r.stage_id; });
+                    return !relaStage.find(r => { return s.id === r.stage_id; }) && s.order > maxOrder;
                 });
                 });
                 this.ctx.service.phasePay.calculatePhasePay(phasePays);
                 this.ctx.service.phasePay.calculatePhasePay(phasePays);
                 const renderData = {
                 const renderData = {

+ 7 - 4
app/service/phase_pay.js

@@ -513,18 +513,21 @@ module.exports = app => {
             }
             }
         }
         }
 
 
-        async checkStageRelaPhasePay(tid, sid) {
+        async checkStageRelaPhasePay(stage) {
             if (this.ctx.stageRelaPhasePay !== undefined) return;
             if (this.ctx.stageRelaPhasePay !== undefined) return;
 
 
-            const allPhase = await this.getAllPhasePay(tid);
+            const allPhase = await this.getAllPhasePay(stage.tid);
             for (const phase of allPhase) {
             for (const phase of allPhase) {
-                if (phase.rela_stage.find(x => { return x.stage_id === sid; })) {
+                if (phase.rela_stage.find(x => { return x.stage_id === stage.id; })) {
                     await this.doCheckPhase(phase);
                     await this.doCheckPhase(phase);
                     this.ctx.stageRelaPhasePay = phase;
                     this.ctx.stageRelaPhasePay = phase;
                     return;
                     return;
                 }
                 }
+                const fs = this.ctx.helper._.orderBy(phase.rela_stage.filter(x => { return x.stage_order < stage.order; }), ['stage_order'], ['desc']);
+                phase.maxRelaStageOrder = fs.length > 0 ? fs[0].stage_order : 0;
             }
             }
-            this.ctx.stageRelaPhasePay = null;
+            const fp = this.ctx.helper._.orderBy(allPhase.filter(x => { return x.maxRelaStageOrder > 0; }), ['maxRelaStageOrder'], ['desc']);
+            this.ctx.stageRelaPhasePay = fp.length > 0 ? fp[0] : null;
         }
         }
     }
     }
 
 

+ 2 - 2
app/service/report_memory.js

@@ -1740,7 +1740,7 @@ module.exports = app => {
         async getPhasePay(tid, sid) {
         async getPhasePay(tid, sid) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
             await this.ctx.service.stage.checkStage(sid);
-            await this.ctx.service.phasePay.checkStageRelaPhasePay(tid, sid);
+            await this.ctx.service.phasePay.checkStageRelaPhasePay(this.ctx.stage);
 
 
             return this.ctx.stageRelaPhasePay || {};
             return this.ctx.stageRelaPhasePay || {};
         }
         }
@@ -1748,7 +1748,7 @@ module.exports = app => {
         async getPhasePayDetail(tid, sid) {
         async getPhasePayDetail(tid, sid) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
             await this.ctx.service.stage.checkStage(sid);
-            await this.ctx.service.phasePay.checkStageRelaPhasePay(tid, sid);
+            await this.ctx.service.phasePay.checkStageRelaPhasePay(this.ctx.stage);
 
 
             if (!this.ctx.stageRelaPhasePay) return [];
             if (!this.ctx.stageRelaPhasePay) return [];
             const data = await this.ctx.service.phasePayDetail.getDetailData(this.ctx.stageRelaPhasePay);
             const data = await this.ctx.service.phasePayDetail.getDetailData(this.ctx.stageRelaPhasePay);