PHP implementation of Recursive commission scheme example, PHP Recursive Commission example _php Tutorial

Source: Internet
Author: User
Tags php programming

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.