Hello everyone, I am a novice. Ask you a question.
A is the pyramid vertex, below has the junior member ABCdef and so on several, each junior member below also has the junior member several, this has been arranged continuously.
If the E1 membership is upgraded to a tier one member, a can receive a commission of 10 dollars.
But if his on-line is B1 status as a member, then 10 yuan will be returned to B1.
What kind of thought should be used to count the percentage of a in a certain time period, that is, the commission of all branches of a must rule out the member data in the B1 branch.
Reply content:
Hello everyone, I am a novice. Ask you a question.
A is the pyramid vertex, below has the junior member ABCdef and so on several, each junior member below also has the junior member several, this has been arranged continuously.
If the E1 membership is upgraded to a tier one member, a can receive a commission of 10 dollars.
But if his on-line is B1 status as a member, then 10 yuan will be returned to B1.
What kind of thought should be used to count the percentage of a in a certain time period, that is, the commission of all branches of a must rule out the member data in the B1 branch.
Traverse the child node of a, if not a member, add a linear table (indicating that the node is upgraded, a can gain), and then continue to traverse this node
//伪代码 获取到A节点可以获得收益的后辈节点//topNode为节点对象function getAllChilds(object topNode){ static childArr=[]; foreach(topNode->getAllChilds as index=>tempChildNode){ //如果当前节点不为一级节点 if(!tempChildNode->rankIsOne){ array_push(childArr,tempChildNode); getAllChilds(tempChildNode); } } return childArr;}
But look at the topic is a time period A of the Commission, meaning as if the node tree each node rank is going to change, this is a bit difficult
Or, each time the node is upgraded, it calculates the gain, the revenue node, and the time, written to the database. This makes the query require only one SQL statement.
Traverse all the nodes and remove the parent node from the tree as the branch of the member you requested. ......