无限极分销,查询分销用户的星级

无限极分销根据销售,根据用户的销售总额、下级数量,下级销售额达到指定数量自动升级会员等级
 function get_lvss(){
                $ttda['id']=$_SESSION['id'];

            $aa=M('user')->join("level on user.dls_lv=level.level_id")
                    ->where($ttda)
                    ->find();
            $perf=$aa['perf'];
            $ttaa['pid']=$_SESSION['id'];
            //查询用户的下级用户和自己的销售总额
		//查询自己下级数量
            $number=M('fx_user')->where($ttaa)->count();
		//查询下级的用户ID遍历放入uid中
            $uids=M('fx_user')->where($ttaa)->field('uid')->select();
            $uid=''; 
               foreach ($uids as $key => $v) {        
                       foreach ($v as $key => $value) {
                           $uid[]=$value;
                       }
                   }
            $ssa['id']=array('in',$uid);
            //查询等级需要的条件
            $level=M('level')->select();         
            foreach ($level as $k => $v) {        
                if ($perf>=$v['demand']&&$number>=$v['lower_number']) {
                     $wher['id']=array('in',$uid);
                        $condition['_logic'] = "AND";
                        $asa['_complex']=$wher;
                        $asa['perf'] = array("egt",$v['lower_achievement']);                
                   $achii= M('user')->where($asa)->count();                 
                  if ($achii>=$v['lower_group']) {
                 $lvs=$v['level_id'];
                  }                   
                }
            }    
            return $lvs;
    }

你可能感兴趣的:(PHP,thinkphp,mysql,分销,无限极分销查询)