<?php
/*
* 代理首页
*/
public function index(){
//获取下级数量,总流水(暂时未做处理),今日新进的商户
$agent_wxapp_id=input('post.agent_wxapp_id');
$data=Cache::get($agent_wxapp_id);
//死数据,调试流程
$info=Db::name('agent_user')->where(['recommend_id'=>1])->select();
$res=$this->recursion($info->toArray());
return json(['msg'=>'获取成功','code'=>'success','data'=>$res]);
}
/*
* 根据当前登录的代理id获取其下级代理id
*/
private function recursion($res){
$output = array();
foreach($res as $k => $v){
$infos=Db::name('agent_user')->where(['recommend_id'=>$v['agent_user_id']])->select();
$output []= $v;
if (!empty($infos)){
$output = array_merge($output, $this->recursion($infos));
}
}
return $output;
}
?>
本文为郭涛原创文章,转载无需和我联系,但请注明来自郭涛博客www.51wgt.com