# distribution **Repository Path**: limyang94/distribution ## Basic Information - **Project Name**: distribution - **Description**: distribution - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-05-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

distribution

distribution.

## Before Installing ```composer log ... "repositories": { "distribution": { "type": "vcs", "url": "https://gitee.com/limyang94/distribution.git" }, ... } ... ``` ## Installing ```shell $ composer require limyang/distribution -vvv ``` ## Usage ```php // 构建节点 $node = new NodeEntity(); // 设置分润扣点(佣金基础上扣除)(手续费/其他费用) $node->setCommissionBuckle(30); // 设置可获得佣金上限 $node->setCommissionMaximum(9999); // 设置分润比例 $node->setRatio(50); // 设置佣金 $node->setCommission(1000); // 设置其他额外奖励 $node->setExtraCommission(100); ``` ```php // 构建分销链 $node1 = new NodeEntity(); $node2 = new NodeEntity(); $chain = new ChainEntity(); $node1->setNodeId(1)->setCommissionBuckle(10)->setRatio(50); $node2->setNodeId(2)->setCommissionBuckle(20)->setRatio(99); // 添加节点到分销链 $chain->addNode($node1)->addNode($node2); ``` ```php // 调用分销算法 $algorithm = new UnlimitedAlgorithm(); // 设置待分润金额 链条以及当前操作的链条 $chains = $algorithm->setPendingCommission(10000)->setChain($chain,$chainIndex)->setChainIndex($chainIndex)->handle(); ``` #### 调用算法返回数据结构(双向链表) ```php array:1 [ 1 => Limyang\TestVcs\Component\ChainEntity {#298 -linkList: SplDoublyLinkedList {#299 mode: IT_MODE_FIFO | IT_MODE_KEEP dllist: array:2 [ 0 => Limyang\TestVcs\Component\NodeEntity {#295 #nodeId: 1 #level: 0 #commission: "50000" #commissionBuckle: 10 #commissionMaximum: 9223372036854775807 #ratio: 50 #extraCommission: 0 #effectRatioClass: array:1 [ 0 => array:5 [ "class" => "app\Api\Controllers\UserController" "function" => "show" "before" => 0 "after" => 50 "reason" => "" ] ] #effectCommissionClass: array:1 [ 0 => array:5 [ "class" => "Limyang\TestVcs\Algorithm\UnlimitedAlgorithm" "function" => "apportion" "before" => 0 "after" => "50000" "reason" => "" ] ] -positionLevel: 3 } 1 => Limyang\TestVcs\Component\NodeEntity {#296 #nodeId: 2 #level: 0 #commission: "99000" #commissionBuckle: 20 #commissionMaximum: 9223372036854775807 #ratio: 99 #extraCommission: 0 #effectRatioClass: array:1 [ 0 => array:5 [ "class" => "app\Api\Controllers\UserController" "function" => "show" "before" => 0 "after" => 99 "reason" => "" ] ] #effectCommissionClass: array:1 [ 0 => array:5 [ "class" => "Limyang\TestVcs\Algorithm\UnlimitedAlgorithm" "function" => "apportion" "before" => 0 "after" => "99000" "reason" => "" ] ] -positionLevel: 3 } ] } } ] ``` ## Contributing You can contribute in one of three ways: 1. File bug reports using the [issue tracker](https://gitee.com/limyang/test-vcs/issues). 2. Answer questions or fix bugs on the [issue tracker](https://gitee.com/limyang/test-vcs/issues). 3. Contribute new features or update the wiki. _The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._ ## License MIT