| 
					
				 | 
			
			
				@@ -69,8 +69,8 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (stage.order > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const cur = await this.ctx.service.stagePos.getLastestStageData2(tender.id, stage.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //if (!cur || cur.length === 0) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const pre = await this.getFinalData(tender, stage.order - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if ((!cur || cur.length === 0) && (!pre || pre.length === 0)) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (const c of cur) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     delete c.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     delete c.said; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -90,13 +90,12 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //await transaction.insert(this.tableName, cur); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (const p of pre) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     p.sid = stage.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     p.sorder = stage.order; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     p.used = p.used || !this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.qc_qty); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await transaction.insert(this.tableName, cur.concat(pre)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await transaction.insert(this.tableName, cur ? cur.concat(pre) : pre); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const sql = 'Insert Into ??(tid, sid, lid, pid, sorder, contract_qty, qc_qty, used)' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             '  SELECT p.tid, p.sid, p.lid, p.pid, ? As `sorder`, p.contract_qty, p.qc_qty,' + 
			 |