Example of recursive Commission scheme implemented by php and example of php recursive Commission _ PHP Tutorial

Source: Internet
Author: User
Example of php implementation of recursive Commission scheme, php recursive commission example. Example of php implementation of recursive Commission scheme, php recursive commission example this article describes the php implementation of recursive Commission scheme. For your reference, please refer to the following examples: examples of recursive commissions implemented by php in the recent CRM project and examples of php recursive commissions.

The example in this article describes the recursive Commission scheme implemented by php. We will share this with you for your reference. The details are as follows:

Recursive commissions have been used in recent CRM projects. the analysis is as follows:

The SQL statement is as follows:

Create table 'CRM _ proxy_bonux_rule' ('id' int (11) not null AUTO_INCREMENT COMMENT 'Greater than part of the Commission rule ID', 'bouns _ rule_name' varchar (20) not null comment 'rule name, such as Plan D 0-20 range ', 'rid 'bigint (20) default null comment' is 0, which is the DEFAULT global setting ', 'start _ rang 'smallint (6) default null comment' start Range', 'end _ rang 'smallint (6) default null comment' end range ', 'bonus _ rate' smallint (6) default null comment 'Commission rate', 'bonus _ reward 'decimal (8, 2) default null comment 'reward cash ', 'chain _ pre' int (11) default null Comment' The DEFAULT value on the chain table is 0, indicating the root node ', 'chain _ next' int (11) default null comment 'next value of the linked list ', 'Is _ standard' enum ('0', '1') whether the DEFAULT '0' Comment' is a 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 value $ min = $ standard ['start _ rang ']; // minimum value $ bonus_rate = $ standard ['bonus _ rate']; // dividend rate if ($ range <$ min) {return false;} $ standard_amount = 0; $ plus = 0; // whether the first if ($ standard ['is _ standard'] = 1) {$ standard_amount = $ price * $ min * $ bonus_rate/100; // request 600 300} else {$ plus = 1; // Second secondary accumulation} if ($ range> $ max) {$ number = ($ max-$ min) + $ plus; // calculate the difference value 5 4-3 = 1 $ amount = ($ price * $ number * $ bonus_rate/100 ); // request 200} else {$ number = ($ range-$ min) + $ plus; // calculate the difference value 4 1 $ amount = ($ price * $ number * $ bonus_rate/100); // seek 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, $ amount);} return $ amount ;}

I hope this article will help you with PHP programming.

Examples in this article describes the recursive commissions implemented by php. For your reference, please refer to the following details: recent CRM project...

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.