|  | @@ -86,12 +86,6 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  pays = await transaction.select(this.ctx.service.pay.tableName, {where: { tid: this.ctx.tender.id } });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              const stagePays = [];
 | 
	
		
			
				|  |  | -            for (const p of pays) {
 | 
	
		
			
				|  |  | -                stagePays.push({
 | 
	
		
			
				|  |  | -                    tid: p.tid, sid: stage.id, pid: p.id,
 | 
	
		
			
				|  |  | -                    stimes: stage.times, sorder: 0, expr: p.expr, name: p.name,
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |              // 获取截止上期数据
 | 
	
		
			
				|  |  |              if (stage.order > 1) {
 | 
	
		
			
				|  |  |                  const preStage = await this.ctx.service.stage.getDataByCondition({tid: stage.tid, order: stage.order - 1});
 | 
	
	
		
			
				|  | @@ -99,14 +93,25 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                      throw '标段数据有误';
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  const prePays = await this.getStageLastestPays(preStage.id);
 | 
	
		
			
				|  |  | +                console.log(prePays.length);
 | 
	
		
			
				|  |  |                  for (const pp of prePays) {
 | 
	
		
			
				|  |  | -                    const sp = this._.find(stagePays, {pid: pp.pid});
 | 
	
		
			
				|  |  | -                    sp.name = pp.name;
 | 
	
		
			
				|  |  | -                    sp.expr = pp.expr;
 | 
	
		
			
				|  |  | -                    sp.pre_tp = pp.end_tp;
 | 
	
		
			
				|  |  | -                    sp.pause = pp.pause;
 | 
	
		
			
				|  |  | -                    sp.pre_used = pp.pre_used || !this.ctx.helper.checkZero(pp.tp);
 | 
	
		
			
				|  |  | -                    sp.pre_finish = pp.rprice ? pp.end_tp === pp.rprice : false;
 | 
	
		
			
				|  |  | +                    const p = this._.find(pays, {id: pp.pid});
 | 
	
		
			
				|  |  | +                    stagePays.push({
 | 
	
		
			
				|  |  | +                        tid: p.tid, sid: stage.id, pid: p.id,
 | 
	
		
			
				|  |  | +                        stimes: stage.times, sorder: 0,
 | 
	
		
			
				|  |  | +                        name: pp.name, expr: pp.expr, pause: pp.pause,
 | 
	
		
			
				|  |  | +                        pre_tp: pp.end_tp,
 | 
	
		
			
				|  |  | +                        pre_used: pp.pre_used || !this.ctx.helper.checkZero(pp.tp),
 | 
	
		
			
				|  |  | +                        pre_finish: pp.pre_finish || (pp.rprice ? pp.end_tp === pp.rprice : false),
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                console.log(stagePays.length);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                for (const p of pays) {
 | 
	
		
			
				|  |  | +                    stagePays.push({
 | 
	
		
			
				|  |  | +                        tid: p.tid, sid: stage.id, pid: p.id,
 | 
	
		
			
				|  |  | +                        stimes: stage.times, sorder: 0, expr: p.expr, name: p.name,
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              let result;
 | 
	
	
		
			
				|  | @@ -115,7 +120,7 @@ module.exports = app => {
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  result = await this.db.insert(this.tableName, stagePays);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            return result.affectedRows === pays.length;
 | 
	
		
			
				|  |  | +            return result.affectedRows === stagePays.length;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          async getStagePay(stage, pid) {
 |