php - Calculate commision based on level completeness of a binary tree -


i have 2 tables.

  1. business plans

enter image description here

  1. users binary

enter image description here

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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -