| 
						
						
						
					 | 
				
				 | 
				
					@ -0,0 +1,45 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					package productrpc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"strings" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"git.tetele.net/tgo/helper" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * commission_rule 规则,1按系统设置,2单独设置 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * commission_value 单独佣金值 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * commission_rate 系统佣金比例 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					func ProductCommission(commission_rule, commission_value, commission_rate string, product_price, cost_price string, quantity interface{}) float64 { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						var commission_rule_rate float64 //佣金按比例换算成的小数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						var commission_type string | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						switch commission_rule { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						case "1": //按系统设置
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							commission_rule_rate = helper.FloatQuo(commission_rate, 100) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							commission_type = "rate" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						case "2": //单独设置
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if strings.Contains(commission_value, "%") { //百分比
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								commission_rule_rate = helper.FloatQuo(strings.ReplaceAll(commission_value, "%", ""), 100) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								commission_type = "rate" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								commission_type = "fixed" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						var commission float64 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						switch commission_type { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						case "rate": | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							commission = helper.FloatMul(helper.FloatMul(helper.FloatSub(product_price, cost_price), commission_rule_rate), quantity) //利润
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						case "fixed": | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							commission = helper.FloatMul(commission_value, quantity) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return commission | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |