public function ceshi(){
$this->getTotalteamperformance(4);
}
function getTotalteamperformance($userid){//团队总业绩
$totalteamperformance=0;
// $userid=I('get.id');
$userlist=M('user')->where(array('pid1'=>$userid))->select();
if(count($userlist)>0){
$totalteamperformance=$totalteamperformance+M('user')->where(array('pid1'=>$userid))->sum('total_amount')+M('user')->where(array('pid2'=>$userid))->sum('total_amount');
foreach ($userlist as $k=> $v) {
$totalteamperformance=$totalteamperformance+M('user')->where(array('pid1'=>$user_id))->sum('total_amount');
$userlist1=M('user')->where(array('pid1'=>$v['user_id']))->select();
//dump($userlist1);
if(count($userlist1)>0){
$totalteamperformance=$totalteamperformance+$this->getChildernTotalteamperformance($userlist1);
}
}
}
echo $totalteamperformance;
}
function getChildernTotalteamperformance($user){
$totalteamperformance=0;
foreach ($user as $k=> $v) {
$totalteamperformance=$totalteamperformance+M('user')->where(array('pid1'=>$v['user_id']))->sum('total_amount');
$userlist1=M('user')->where(array('pid1'=>$v['user_id']))->select();
if(count($userlist1)>0){
$totalteamperformance=$totalteamperformance+$this->getChildernTotalteamperformance($userlist1);
}
}
return $totalteamperformance;
}
点击查看更多内容
2人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦