1. 程式人生 > >php獲取使用者的上5級使用者

php獲取使用者的上5級使用者

/*
     * 獲取發放獎勵的使用者  獲取上5級使用者
     * */
    public function getAwardUser($user,$exclude = []){
        $user_info = $this->getUserInfo($user);
        $parent_info = $this->getUserInfo($user_info['extend_id']);
        if($parent_info['extend_id']==0)
            return [];
            array_push
($exclude,[ 'uid'=>$parent_info['id'],//使用者uid 'level'=>$parent_info['level'],//使用者等級 'boss' => 0+1//使用者所屬幾級 ]); for ($i = 0; $i < 4 ; $i++) { $parent_info = $this->getUserInfo($parent_info['extend_id']); if (empty($parent_info
)) { $parent_info = [ 'id' => 0, 'extend_id' => 0, 'level' => 0, ]; } $arr=[ 'uid'=>$parent_info['id'],//使用者uid 'level'=>$parent_info['level'],//
使用者等級 'boss' => $i+1+1,//使用者所屬幾級 ]; array_push($exclude,$arr); } return $exclude; }
   /*
   * 獲取使用者資訊
   * */
    public function getUserInfo($id)
    {
        $user=zfun::f_row('user',"id='{$id}'",'id,token,extend_id,wxchat,level');
       // $userModel = $this->getDatabase('User');
       // $user = $userModel->selectRow("id='{$id}'",'id,token,extend_id,wxchat,level');
        return $user;
    }

//效果圖: