为了账号安全,请及时绑定邮箱和手机立即绑定

递归统计团队奖, 计算每个人下线的业绩(pid)

标签:
PHP
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人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消