| 
					
				 | 
			
			
				@@ -88,6 +88,10 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 判断t_type是否为费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const transaction = await this.db.beginTransaction(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (data.t_type === materialConst.t_type[0].value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data.quantity = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data.expr = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.update(this.tableName, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 let m_tp = this.ctx.material.m_tp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (data.t_type === materialConst.t_type[1].value) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -126,7 +130,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * @returns {Promise<*>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async calcQuantityByMB(transaction, mid, mb) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (mb.t_type === 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (mb.t_type === materialConst.t_type[0].value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const sql = 'SELECT SUM(`gather_qty`*`quantity`) as quantity FROM ' + this.ctx.service.materialList.tableName + ' WHERE `mid`=? AND `mb_id`=? AND `is_join`=1'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const sqlParam = [mid, mb.id]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const mb_quantity = await transaction.queryOne(sql, sqlParam); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -139,13 +143,14 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return await this.ctx.helper.round(this.ctx.helper.mul(mb_quantity.quantity, mb.m_spread), 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (mb.t_type === materialConst.t_type[1].value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const updateData = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    id: mb.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    pre_tp: mb.quantity && mb.m_spread !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.pre_tp, this.ctx.helper.mul(mb.quantity, mb.m_spread)), 2) : mb.pre_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return await this.ctx.helper.round(this.ctx.helper.mul(mb.quantity, mb.m_spread), 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const updateData = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                id: mb.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                pre_tp: mb.quantity && mb.m_spread !== null ? this.ctx.helper.round(this.ctx.helper.add(mb.pre_tp, this.ctx.helper.mul(mb.quantity, mb.m_spread)), 2) : mb.pre_tp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            await transaction.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return await this.ctx.helper.round(this.ctx.helper.mul(mb.quantity, mb.m_spread), 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /** 
			 |