首页 > 其他分享 >无限极

无限极

时间:2023-09-11 16:57:20浏览次数:29  
标签:tree list 无限极 user partner where id

 1     //获取合伙人下级树
 2     public function getPartnerTree()
 3     {
 4 
 5         //合伙人
 6         $partner = new PartnerUserModel;
 7         
 8         $user_id = input('post.user_id');
 9  
10         $partner_id = $partner->where('user_id',$user_id)->value('user_id');
11         if(!$partner_id){
12             return json(['code'=>-1,'msg'=>'合伙人不存在']);
13         }
14         $list = UserModel::where("user_id",$partner_id)->find();
15 
16         $list["children"] = $this->getTree($partner_id);
17 
18         return $this->renderSuccess(compact('list'));
19     }
20 
21     public  function getTree($partner_id)
22     {
23         //推荐人
24         $referee = new RefereeModel;
25         $list = $referee->where(["dealer_id"=>["=",$partner_id],"level"=>1])->select()->toArray();
26         $tree = [];
27         if(!empty($list)){
28             foreach ($list as $key => $val) {
29                 $tree[$key]= UserModel::where("user_id",$val['user_id'])->find();
30                 $tree[$key]['children'] =$this->getTree($val['user_id']);
31             }
32         }
33         return $tree; 
34     }

 

标签:tree,list,无限极,user,partner,where,id
From: https://www.cnblogs.com/silen0119/p/17693916.html

相关文章