|
@@ -513,18 +513,21 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async checkStageRelaPhasePay(tid, sid) {
|
|
|
+ async checkStageRelaPhasePay(stage) {
|
|
|
if (this.ctx.stageRelaPhasePay !== undefined) return;
|
|
|
|
|
|
- const allPhase = await this.getAllPhasePay(tid);
|
|
|
+ const allPhase = await this.getAllPhasePay(stage.tid);
|
|
|
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);
|
|
|
this.ctx.stageRelaPhasePay = phase;
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
|