| 
					
				 | 
			
			
				@@ -283,6 +283,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 判断t_type是否为费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let usedList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 let order = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (order_by) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if (data) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -294,6 +295,9 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         order = order ? order + 1 : 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const sql1 = 'SELECT a.* FROM ?? as b LEFT JOIN ?? as a ON b.cbid = a.id WHERE b.cid = ? GROUP BY b.cbid'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const sqlParam1 = [this.ctx.service.stageChange.tableName, this.tableName, this.ctx.change.cid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    usedList = await transaction.query(sql1, sqlParam1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 先删除原本的台账清单数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     const sql = 'DELETE FROM ?? WHERE cid = ? and lid != "0"'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     const sqlParam = [this.tableName, this.ctx.change.cid]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -312,9 +316,6 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (insertDatas.length > 0) await transaction.insert(this.tableName, insertDatas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.calcCamountSum(transaction); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (!order_by) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    const sql1 = 'SELECT a.* FROM ?? as b LEFT JOIN ?? as a ON b.cbid = a.id WHERE b.cid = ? GROUP BY b.cbid'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    const sqlParam1 = [this.ctx.service.stageChange.tableName, this.tableName, this.ctx.change.cid]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    const usedList = await transaction.query(sql1, sqlParam1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 更新stage_change和stage_change_final的cbid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if (usedList.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         const updateList = []; 
			 |