php - Calculate commision based on level completeness of a binary tree -
i have 2 tables.
- business plans
- users binary
right now, if see users_binary, following hierarchy being developed.
1 / \ 3 4 / \ / \ 19 33 18 32
i want calculate commission based of completeness of level. has 2 childs. first level complete. user 1 on plan 1. plan 1's right , left points 20 , commission percentage 4.5. it's first level complete. ((20+20)*4.5%) commission. when 3 , 4 completes 1st levels, user 1 ((20+20+20+20)*4.5%) commission. 1 thing note. in query, note commission being calculated monday saturday , point_status should equal n.
this getbasictree function.
function getbasictree($user_id) { $query="select user_id,first_name,last_name,leg users introducer_id = '".$user_id."' , leg != ''"; if(($data=$this->customquery($query))!=null) { return $data; } return 0; }
anyone willing me out understanding logic how done. unable understand recursion , make logic it.
Comments
Post a Comment