Example of recursive commission scheme implemented by PHP, PHP recursive Commission instance
In this paper, the Recursive Commission scheme for PHP implementation is described. Share to everyone for your reference, as follows:
In the recent CRM project, a recursive commission scheme was used to analyze the following:
The SQL statements are as follows:
CREATE TABLE ' crm_proxy_bonux_rule ' (' id ' int (one) not NULL auto_increment COMMENT ' exceeded partial royalty rule id ', ' bouns_rule_name ' varchar (a) NOT null COMMENT ' rule name, such as D set 0-20 range ', ' rid ' bigint (a) default NULL COMMENT ' is 0, is the defaults global setting ', ' Start_rang ' smallint (6) default null COMMENT ' Start range ', ' End_rang ' smallint (6) default null COMMENT ' End Range ', ' bonus_rate ' smallint (6) Defau LT null COMMENT ' royalty rate ', ' Bonus_reward ' decimal (8,2) default null COMMENT ' Reward cash ', ' chain_pre ' int (one-by-one) default null COMMENT ' linked list The previous value defaults to 0, which represents the root node ', ' chain_next ' int (one) default NULL COMMENT ' list next value ', ' Is_standard ' enum (' 0 ', ' 1 ') default ' 0 ' COMMENT ' is the standard ', PRIMARY KEY (' id ')) engine=innodb auto_increment=12 DEFAULT Charset=utf8;
The PHP implementation code is as follows:
Private Function Bouns_recursion ($range, $standard,& $rule _list, $amount) {$price = 1000; $max = $standard [' End_rang '];//maximum $min = $standard [' Start_rang '];//minimum $bonus _rate = $standard [' bonus_rate '];//dividends Rate if ($range < $min) {return false; } $standard _amount = 0; $plus = 0; Is the standard first if ($standard [' Is_standard ']==1) {$standard _amount = $price * $min * $bonus _rate/100;//Commission 600 300 }else{$plus = 1;//The second time to accumulate} if ($range > $max) {$number = ($max-$min) + $plus;//Calculate travel value 5 4-3 = = 1 $amount = ($price * $number * $bonus _rate/100); }else{$number = ($range-$min) + $plus;//Calculate Travel value 4 1 $amount = ($price * $number * $bonus _RATE/10 0); COMMISSION} $amount = $amount + $standard _amount;//800 if (!empty ($rule _list[$standard [' Chain_next ']) && $range > $max) {return $amount + = $this->bouns_recursion ($range, $rule _list[$standard [' Chain_next '], $rule _list, $amou NT); } return $amount;}
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1071399.html www.bkjia.com true http://www.bkjia.com/PHPjc/1071399.html techarticle PHP Implementation of the Recursive Commission scheme example, PHP Recursive Commission example of this article describes the implementation of PHP recursive Commission scheme. Share to everyone for your reference, as follows: Recent CRM Project ...