继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

根据团队业绩(三个区)上升等级

小陈vlog
关注TA
已关注
手记 24
粉丝 16
获赞 81
  public function order_pay(){
    	  $order_id=I('get.order_id');
    	  $user_id=session("user.user_id");
    	  $pay_count=M('user')->where(array('user_id'=>$user_id))->getField('pay_count');//我的钱包
    	  $order=M('order')->where(array('order_id'=>$order_id))->find();
    	  $pay_time=time();
    	  //dump($user_id);exit;
    	  if($pay_count < $order['money'] ){
    	  	  $this->error("你的钱包余额不足");
    	  }else{
    	  	  $aaa=M('order')->where(array('order_id'=>$order_id))->save(array('is_pay'=>1,'pay_time'=>$pay_time));
    	  	  $bbb=M('user')->where(array('user_id'=>$user_id))->setDec('pay_count',$order['money']);
    	  	  $ccc=M('user')->where(array('user_id'=>$user_id))->setInc('total_amount',$order['money']);//加个人累计业绩
    	  	  $this->level_tuandui();
    	  	  if($aaa&&$bbb&&$ccc){
    	  	  	  
    	  	  	  $this->fen_yong($order['money'],$user_id,$order_id);
    	  	  	  $this->success("支付成功",U('order/order_list'));
    	  	  }
    	  }
    	   
    	 
    }
    
    public  function level_tuandui(){
    	     //统计自己三个区下面的业绩
    	     
    	      
    	     $lv1=M('parameter3')->where(array('id'=>1))->getField('yeji_zhi');
    	     $lv2=M('parameter3')->where(array('id'=>2))->getField('yeji_zhi');
    	     $lv3=M('parameter3')->where(array('id'=>3))->getField('yeji_zhi');
    	     $lv4=M('parameter3')->where(array('id'=>4))->getField('yeji_zhi');
    	     $lv5=M('parameter3')->where(array('id'=>5))->getField('yeji_zhi');
    	      
    	     $data = M('user')->select();
         foreach ($data as $key => $va) {
              
              
               $user_id     = $va['user_id'];
               
              $where1['job'] = array('like',"%_$user_id_%");
    	        $qu1=M('user')->where(array('section'=>1))->where($where1)->where($where)->sum('total_amount');
    	        $qu2=M('user')->where(array('section'=>2))->where($where1)->where($where)->sum('total_amount');
    	        $qu3=M('user')->where(array('section'=>3))->where($where1)->where($where)->sum('total_amount');
    	      
    	        $qu_zong=$qu1 + $qu2  + $qu3;
               
               
               
               //等级1
               if($qu_zong >= $lv1  && $qu_zong <  $lv2){
                  
                     M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>1));
               }else 
                //等级2
               if($qu_zong >= $lv2  && $qu_zong <  $lv3 ){

                     M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>2));
               }
               else 
                //等级3
               if($qu_zong >= $lv3  && $qu_zong <  $lv4){

                    M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>3));
               }
               else 
                //等级4
               if($qu_zong >= $lv4  && $qu_zong < $lv5){

                    M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>4));
               }
               else 
                //等级5
               if($qu_zong >= $lv5){

                    M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>5));
               }


         }
    	
    	
    }
    
打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP