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