<repo_name>xj0707/tigergame<file_sep>/.svn/pristine/07/077b9c6eab368804a18c9523f493fade2980d3e1.svn-base
<?php
namespace application\admin\controller;

use think\Db;

class GameReportsController extends CommonController{
//玩家报表
    public function index(){
        if(!$this->come_where['parent'][1]){
            $this->error('无商户无玩家信息！！');
        }
        $where['g.parent']=$this->come_where['parent'];
//        $players=Db::name('gameReports')->alias('g')->join('na_users u','g.parent=u.uid')
//            ->field('g.gameName gg,g.wct gwct,g.totalBetCount gtbc,g.avgRTP ga,g.totalPays gtp,g.totalBets gtb,g.totalPlayers gt,g.updatedAt gu,u.suffix us,u.username uu')
//            ->where($where)->paginate(20);
        $merchantIds=session('tiger_parentId');
        $gameReports=array();
        foreach ($merchantIds as $key=>$parent){
            $totalBetCount=Db::name('playerReports')->where('parent',$parent)->sum('totalBetCount');//投注次数
            if(!$totalBetCount){
                unset($gameReports[$key]);
                continue;
            }
            $totalPays=Db::name('playerReports')->where('parent',$parent)->sum('totalPays');//中奖金额
            $totalBets=Db::name('playerReports')->where('parent',$parent)->sum('totalBets');//投注金额
            $totalusers=Db::name('playerReports')->where('parent',$parent)->count();//玩家总数
            $avgRTP='0.00';
            if($totalBets){
                $avgRTP=round($totalPays/$totalBets,2);//RTP;
            }
            $merch=Db::name('users')->field('username,nickname')->where('uid',$parent)->find();
            $gameReports[$key]['gameName']='塔罗之谜';
            $gameReports[$key]['totalBets']=sprintf("%.2f", $totalBets);
            $gameReports[$key]['totalPays']=sprintf("%.2f", $totalPays);
            $gameReports[$key]['totalusers']=$totalusers;
            $gameReports[$key]['totalBetCount']=$totalBetCount;
            $gameReports[$key]['avgRTP']=$avgRTP;
            $gameReports[$key]['merch']=$merch['nickname'];
        }

        $role=session('tiger_role');
        switch ($role){
            case 1://平台管理
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 2://顶级代理
                $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                $this->assign('data1',$data1);
                break;
            case 3://线路商
                $id=session('tiger_uid');
                $users=Db::name('users')->field('uid')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 4://次级代理
                $id=session('tiger_uid');
                $users=Db::name('users')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                break;
            case 5://商户
                break;
            case 6://超管
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                $this->assign('data3',$data3);
                break;
        }
        $this->assign('role',$role);
        $this->assign('players',$gameReports);
        return $this->fetch();
    }

    /**
     * 线路商查询
     */
    public function xl(){
        $id=input('get.id');
        if($id==-1){
            $this->error('请选择线路商！！！');
        }
        $info=Db::name('users')->field('uid')->where('id',$id)->find();
        $role=session('tiger_role');
        if($info){
            $uid=$info['uid'];
            $user_ids=Db::name('users')->field('uid')->where('levelindex','like',"%$uid%")->select();
            $gameReports=array();
            foreach ($user_ids as $key=>$user_id){
                $parent=$user_id['uid'];
                $totalBetCount=Db::name('playerReports')->where('parent',$parent)->sum('totalBetCount');//投注次数
                $totalPays=Db::name('playerReports')->where('parent',$parent)->sum('totalPays');//中奖金额
                $totalBets=Db::name('playerReports')->where('parent',$parent)->sum('totalBets');//投注金额
                $totalusers=Db::name('playerReports')->where('parent',$parent)->count();//玩家总数
                $avgRTP=0;
                if($totalBets){
                    $avgRTP=round($totalPays/$totalBets,2);//RTP;
                }
                $merch=Db::name('users')->field('username,nickname')->where('uid',$parent)->find();
                $gameReports[$key]['gameName']='塔罗之谜';
                $gameReports[$key]['totalBets']=sprintf("%.2f", $totalBets);
                $gameReports[$key]['totalPays']=sprintf("%.2f", $totalPays);
                $gameReports[$key]['totalusers']=$totalusers;
                $gameReports[$key]['totalBetCount']=$totalBetCount;
                $gameReports[$key]['avgRTP']=$avgRTP;
                $gameReports[$key]['merch']=$merch['nickname'];
            }
//
//            $players=Db::name('gameReports')->alias('g')->join('na_users u','g.parent=u.uid')
//                ->field('g.gameName gg,g.wct gwct,g.totalBetCount gtbc,g.avgRTP ga,g.totalPays gtp,g.totalBets gtb,g.totalPlayers gt,g.updatedAt gu,u.suffix us,u.username uu')
//                ->where('g.parent','in',$guanli)->paginate(20);
            switch ($role){
                case 1://平台管理
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 2://顶级代理
                    $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                    $this->assign('data1',$data1);
                    break;
                case 3://线路商
                    $id=session('tiger_uid');
                    $users=Db::name('users')->field('uid')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                    $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 4://次级代理
                    $id=session('tiger_uid');
                    $users=Db::name('users')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    break;
                case 5://商户
                    break;
                case 6://超管
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    $this->assign('data3',$data3);
                    break;
            }
            $this->assign('role',$role);
            $this->assign('players',$gameReports);
            return $this->fetch('index');
        }

    }
    /**
     * 商户查询
     */
    public function sh(){
        $id=input('get.id');
        if($id==-1){
            $this->error('请选择商户！！！');
        }
        $info=Db::name('users')->field('uid')->where('id',$id)->find();
        $role=session('tiger_role');
        if($info){
            $parent=$info['uid'];
            $totalBetCount=Db::name('playerReports')->where('parent',$parent)->sum('totalBetCount');//投注次数
            $totalPays=Db::name('playerReports')->where('parent',$parent)->sum('totalPays');//中奖金额
            $totalBets=Db::name('playerReports')->where('parent',$parent)->sum('totalBets');//投注金额
            $totalusers=Db::name('playerReports')->where('parent',$parent)->count();//玩家总数
            $avgRTP=0;
            if($totalBets){
                $avgRTP=round($totalPays/$totalBets,2);//RTP;
            }
            $merch=Db::name('users')->field('username,nickname')->where('uid',$parent)->find();
            $gameReports[0]['gameName']='塔罗之谜';
            $gameReports[0]['totalBets']=sprintf("%.2f", $totalBets);
            $gameReports[0]['totalPays']=sprintf("%.2f", $totalPays);
            $gameReports[0]['totalusers']=$totalusers;
            $gameReports[0]['totalBetCount']=$totalBetCount;
            $gameReports[0]['avgRTP']=$avgRTP;
            $gameReports[0]['merch']=$merch['nickname'];
//            $players=Db::name('gameReports')->alias('g')->join('na_users u','g.parent=u.uid')
//                ->field('g.gameName gg,g.wct gwct,g.totalBetCount gtbc,g.avgRTP ga,g.totalPays gtp,g.totalBets gtb,g.totalPlayers gt,g.updatedAt gu,u.suffix us,u.username uu')
//                ->where('g.parent',$uid)->paginate(20);
            switch ($role){
                case 1://平台管理
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 2://顶级代理
                    $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                    $this->assign('data1',$data1);
                    break;
                case 3://线路商
                    $id=session('tiger_uid');
                    $users=Db::name('users')->field('uid')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                    $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 4://次级代理
                    $id=session('tiger_uid');
                    $users=Db::name('users')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    break;
                case 5://商户
                    break;
                case 6://超管
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    $this->assign('data3',$data3);
                    break;
            }
            $this->assign('role',$role);
            $this->assign('players',$gameReports);
            return $this->fetch('index');
        }

    }

    /**
     * 代理商查询
     */
    public function dl(){
        $id=input('get.id');
        if($id==-1){
            $this->error('请选择代理！！！');
        }
        $info=Db::name('users')->field('uid')->where('id',$id)->find();
        $role=session('tiger_role');
        if($info){
            $uid=$info['uid'];
            $user_ids=Db::name('users')->field('uid')->where('levelindex','like',"%$uid%")->select();
            $gameReports=array();
            foreach ($user_ids as $key=>$user_id){
                $parent=$user_id['uid'];
                $totalBetCount=Db::name('playerReports')->where('parent',$parent)->sum('totalBetCount');//投注次数
                $totalPays=Db::name('playerReports')->where('parent',$parent)->sum('totalPays');//中奖金额
                $totalBets=Db::name('playerReports')->where('parent',$parent)->sum('totalBets');//投注金额
                $totalusers=Db::name('playerReports')->where('parent',$parent)->count();//玩家总数
                $avgRTP=0;
                if($totalBets){
                    $avgRTP=round($totalPays/$totalBets,2);//RTP;
                }
                $merch=Db::name('users')->field('username,nickname')->where('uid',$parent)->find();
                $gameReports[$key]['gameName']='塔罗之谜';
                $gameReports[$key]['totalBets']=sprintf("%.2f", $totalBets);
                $gameReports[$key]['totalPays']=sprintf("%.2f", $totalPays);
                $gameReports[$key]['totalusers']=$totalusers;
                $gameReports[$key]['totalBetCount']=$totalBetCount;
                $gameReports[$key]['avgRTP']=$avgRTP;
                $gameReports[$key]['merch']=$merch['nickname'];
            }
//            $players=Db::name('gameReports')->alias('g')->join('na_users u','g.parent=u.uid')
//                ->field('g.gameName gg,g.wct gwct,g.totalBetCount gtbc,g.avgRTP ga,g.totalPays gtp,g.totalBets gtb,g.totalPlayers gt,g.updatedAt gu,u.suffix us,u.username uu')
//                ->where('g.parent','in',$guanli)->paginate(20);
            switch ($role){
                case 1://平台管理
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 2://顶级代理
                    $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                    $this->assign('data1',$data1);
                    break;
                case 3://线路商
                    $id=session('tiger_uid');
                    $users=Db::name('users')->field('uid')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                    $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 4://次级代理
                    $id=session('tiger_uid');
                    $users=Db::name('users')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    break;
                case 5://商户
                    break;
                case 6://超管
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    $this->assign('data3',$data3);
                    break;
            }
            $this->assign('role',$role);
            $this->assign('players',$gameReports);
            return $this->fetch('index');
        }
    }

    /**
     *游戏名称查询
     */
    public function likeGamename(){
        $gamename=input('post.gamename');
        $role=session('tiger_role');
        $where['g.parent']=$this->come_where['parent'];
        $players=Db::name('gameReports')->alias('g')->join('na_users u','g.parent=u.uid')
            ->field('g.gameName gg,g.wct gwct,g.totalBetCount gtbc,g.avgRTP ga,g.totalPays gtp,g.totalBets gtb,g.totalPlayers gt,g.updatedAt gu,u.suffix us,u.username uu')
            ->where('g.gameName','like',"%$gamename%")->where($where)->paginate(20);
        switch ($role){
            case 1://平台管理
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 2://顶级代理
                $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                $this->assign('data1',$data1);
                break;
            case 3://线路商
                $id=session('tiger_uid');
                $users=Db::name('users')->field('uid')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 4://次级代理
                $id=session('tiger_uid');
                $users=Db::name('users')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                break;
            case 5://商户
                break;
            case 6://超管
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                $this->assign('data3',$data3);
                break;
        }
        $this->assign('role',$role);
        $this->assign('players',$players);
        return $this->fetch('index');

    }





}<file_sep>/.svn/pristine/64/646ae46212594d32ea35028012e7e7077f6e990e.svn-base
<?php
namespace application\admin\controller;

use think\Db;
use think\Session;

class GameSetController extends CommonController{
    //
    public function index(){
        $userIds=session('tiger_parentId');
        if(count($userIds)){
            $userinfos=Db::name('users')->where('uid','in',$userIds)->where('msn','<>',-1)->paginate(20);
            $this->assign('userinfos',$userinfos);
            return $this->fetch();
        }else{
            $this->error('无任何商户信息！');
        }
    }

    //线数线注设置
    public function xsxz(){
        //$this->error('暂未开通');
        $uid=input('uid');
        $info=Db::name('users')->where('uid',$uid)->find();
        //初始线注
        $xzinit=[
            ['v1'=>0.01,'istrue'=>0],['v1'=>0.25,'istrue'=>0],['v1'=>0.50,'istrue'=>0],['v1'=>1.0,'istrue'=>0],
            ['v1'=>1.25,'istrue'=>0],['v1'=>2.50,'istrue'=>0],['v1'=>3.75,'istrue'=>0],['v1'=>5.0,'istrue'=>0],
            ['v1'=>10.0,'istrue'=>0],['v1'=>20.0,'istrue'=>0],['v1'=>25.0,'istrue'=>0],['v1'=>50.0,'istrue'=>0],
            ['v1'=>100.0,'istrue'=>0],['v1'=>125.0,'istrue'=>0],['v1'=>200.0,'istrue'=>0]
        ];
        $xzinfo=explode(',',$info['betcfg']);
        foreach ($xzinit as $key=>$xz){
            if(in_array($xz['v1'],$xzinfo)){
                $xzinit[$key]['istrue']=1;
            }
        }
        $this->assign('nickname',$info['nickname']);
        $this->assign('xzinit',$xzinit);
        $this->assign('xs',$info['linecfg']);
        $this->assign('uid',$uid);
        return $this->fetch();
    }
    //线数请求
    public function doxs(){
        $uid=input('uid');
        $xs=input('xs');
        $typeId=input('typeId');
        if($typeId==40001){
            $url=config('xsxz40001');
        }elseif($typeId==40002){
            $url=config('xsxz40002');
        }

        $data=[
            'uid'=>$uid,
            'linecfg'=>$xs
        ];
        if($xs>25 || $xs<0){
            $this->error('线数应该在0-25之间');
        }
        $jsonstr=json_encode($data);
        $ch=curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_HEADER,0);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_POST,true);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$jsonstr);
        // 设置HTTPS支持
        date_default_timezone_set('PRC');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        $output=curl_exec($ch);
        curl_close($ch);
        if($output){
            $obj=json_decode($output);
            if($obj->code==0) {
                return json(['code'=>1,'message'=>'操作成功！']);
            }else{
                return json(['code'=>-1,'message'=>'操作失败！'.$obj->err]);
            }
        }else{
            return json(['code'=>-1,'message'=>'请求失败！']);
        }
    }
    //线注请求修改
    public function doxz(){
        $uid=input('uid');
        $xzstr=input('xz');
        $typeId=input('typeId');
        if($typeId==40001){
            $url=config('xsxz40001');
        }elseif($typeId==40002){
            $url=config('xsxz40002');
        }

        $data=[
            'uid'=>$uid,
            'betcfg'=>$xzstr
        ];
        $jsonstr=json_encode($data);
        $ch=curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_HEADER,0);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_POST,true);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$jsonstr);
        // 设置HTTPS支持
        date_default_timezone_set('PRC');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        $output=curl_exec($ch);
        curl_close($ch);
        //var_dump($output);
        if($output){
            $obj=json_decode($output);
            if($obj->code==0) {
                return json(['code'=>1,'message'=>'操作成功！']);
            }else{
                return json(['code'=>-1,'message'=>'操作失败！'.$obj->err]);
            }
        }else{
            return json(['code'=>-1,'message'=>'请求失败！']);
        }
    }



}<file_sep>/.svn/pristine/51/5171a67e0d4ea250482f8235a87fb618ff2074cc.svn-base
/*
Navicat MySQL Data Transfer

Source Server         : localhost_3306
Source Server Version : 50617
Source Host           : localhost:3306
Source Database       : na_tigergame

Target Server Type    : MYSQL
Target Server Version : 50617
File Encoding         : 65001

Date: 2017-09-30 03:18:23
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for na_total_reports
-- ----------------------------
DROP TABLE IF EXISTS `na_total_reports`;
CREATE TABLE `na_total_reports` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `gameUserId` varchar(36) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `nickname` varchar(10) DEFAULT NULL,
  `balance` decimal(20,2) DEFAULT NULL,
  `parentId` varchar(36) DEFAULT NULL,
  `betCount` varchar(255) DEFAULT NULL,
  `winlose` decimal(20,2) DEFAULT NULL,
  `totalBet` varchar(20) DEFAULT NULL,
  `wcr` decimal(20,2) DEFAULT NULL,
  `ret` decimal(20,2) DEFAULT NULL,
  `agentBalance` decimal(20,2) DEFAULT NULL,
  `agentRate` varchar(5) DEFAULT NULL,
  `giveback` decimal(20,2) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_total_reports
-- ----------------------------
<file_sep>/.svn/pristine/a3/a38bdbf4b3eaecb665f8d09061ef6681bb19ef18.svn-base
<?php
namespace application\admin\controller;


use think\Db;

class PlayerReportsBController extends CommonController{
    //选择游戏
    public function typeSelect(){

        return $this->fetch();
    }

//玩家报表
    public function index(){
        //$typeid=input('typeid');
        if(!$this->come_where['parent'][1]){
            $this->error('无商户无玩家信息！！');
        }
        $where['p.parent']=$this->come_where['parent'];
        $players=Db::name('playerReportsB')->alias('p')->join('na_users u','p.parent=u.uid')
            ->field('p.username pu,p.wct pwct,p.msn pm,p.balance pb,p.waterflow pw,p.totalBetCount ptbc,p.avgRTP pa,p.totalPays ptp,p.totalBets ptb,u.suffix us,u.username uu,p.pid,u.nickname uni')
            ->where($where)->paginate(20);
        $role=session('tiger_role');
        switch ($role){
            case 1://平台管理
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 2://顶级代理
                $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                $this->assign('data1',$data1);
                break;
            case 3://线路商
                $id=session('tiger_uid');
                $users=Db::name('users')->field('uid')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 4://次级代理
                $id=session('tiger_uid');
                $users=Db::name('users')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                break;
            case 5://商户
                break;
            case 6://超管
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                $this->assign('data3',$data3);
                break;
        }
//        if($typeid){
//            if($typeid==40001){
//                $typename='塔罗之谜';
//                $this->assign('typename',$typename);
//            }
//        }

        $this->assign('typeId',40002);
        $this->assign('role',$role);
        $this->assign('players',$players);
        return $this->fetch();
    }

    /**
     * 线路商查询
     */
    public function xl(){
        $id=input('get.id');
        if($id==-1){
            $this->error('请选择线路商！！！');
        }
        $info=Db::name('users')->field('uid')->where('id',$id)->find();
        $role=session('tiger_role');
        if($info){
            $uid=$info['uid'];
            $user_ids=Db::name('users')->field('uid')->where('levelindex','like',"%$uid%")->select();
            $guanli=[$uid];
            foreach ($user_ids as $user_id){
                $guanli[]=$user_id['uid'];
            }
            $players=Db::name('playerReportsB')->alias('p')->join('na_users u','p.parent=u.uid')
                ->field('p.username pu,p.wct pwct,p.msn pm,p.balance pb,p.waterflow pw,p.totalBetCount ptbc,p.avgRTP pa,p.totalPays ptp,p.totalBets ptb,u.suffix us,u.username uu,p.pid,u.nickname uni')
                ->where('p.parent','in',$guanli)->paginate(20,false,['query' => request()->param()]);
            switch ($role){
                case 1://平台管理
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 2://顶级代理
                    $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                    $this->assign('data1',$data1);
                    break;
                case 3://线路商
                    $id=session('tiger_uid');
                    $users=Db::name('users')->field('uid')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                    $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 4://次级代理
                    $id=session('tiger_uid');
                    $users=Db::name('users')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    break;
                case 5://商户
                    break;
                case 6://超管
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    $this->assign('data3',$data3);
                    break;
            }
            $this->assign('typeId',40002);
            $this->assign('role',$role);
            $this->assign('players',$players);
            return $this->fetch('index');
        }

    }
    /**
     * 商户查询
     */
    public function sh(){
        $id=input('get.id');
        if($id==-1){
            $this->error('请选择商户！！！');
        }
        $info=Db::name('users')->field('uid')->where('id',$id)->find();
        $role=session('tiger_role');
        if($info){
            $uid=$info['uid'];
            $players=Db::name('playerReportsB')->alias('p')->join('na_users u','p.parent=u.uid')
                ->field('p.username pu,p.wct pwct,p.msn pm,p.balance pb,p.waterflow pw,p.totalBetCount ptbc,p.avgRTP pa,p.totalPays ptp,p.totalBets ptb,u.suffix us,u.username uu,p.pid,u.nickname uni')
                ->where('p.parent',$uid)->paginate(20,false,['query' => request()->param()]);
            switch ($role){
                case 1://平台管理
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 2://顶级代理
                    $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                    $this->assign('data1',$data1);
                    break;
                case 3://线路商
                    $id=session('tiger_uid');
                    $users=Db::name('users')->field('uid')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                    $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 4://次级代理
                    $id=session('tiger_uid');
                    $users=Db::name('users')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    break;
                case 5://商户
                    break;
                case 6://超管
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    $this->assign('data3',$data3);
                    break;
            }
            $this->assign('typeId',40002);
            $this->assign('role',$role);
            $this->assign('players',$players);
            return $this->fetch('index');
        }

    }

    /**
     * 代理商查询
     */
    public function dl(){
        $id=input('get.id');
        if($id==-1){
            $this->error('请选择代理！！！');
        }
        $info=Db::name('users')->field('uid')->where('id',$id)->find();
        $role=session('tiger_role');
        if($info){
            $uid=$info['uid'];
            $user_ids=Db::name('users')->field('uid')->where('levelindex','like',"%$uid%")->select();
            $guanli=[$uid];
            foreach ($user_ids as $user_id){
                $guanli[]=$user_id['uid'];
            }
            $players=Db::name('playerReportsB')->alias('p')->join('na_users u','p.parent=u.uid')
                ->field('p.username pu,p.wct pwct,p.msn pm,p.balance pb,p.waterflow pw,p.totalBetCount ptbc,p.avgRTP pa,p.totalPays ptp,p.totalBets ptb,u.suffix us,u.username uu,p.pid,u.nickname uni')
                ->where('p.parent','in',$guanli)->paginate(20,false,['query' => request()->param()]);
            switch ($role){
                case 1://平台管理
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 2://顶级代理
                    $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                    $this->assign('data1',$data1);
                    break;
                case 3://线路商
                    $id=session('tiger_uid');
                    $users=Db::name('users')->field('uid')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                    $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    break;
                case 4://次级代理
                    $id=session('tiger_uid');
                    $users=Db::name('users')->where('id',$id)->find();
                    $uid=$users['uid'];
                    $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                    $this->assign('data1',$data1);
                    break;
                case 5://商户
                    break;
                case 6://超管
                    $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                    $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                    $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                    $this->assign('data1',$data1);
                    $this->assign('data2',$data2);
                    $this->assign('data3',$data3);
                    break;
            }
            $this->assign('typeId',40002);
            $this->assign('role',$role);
            $this->assign('players',$players);
            return $this->fetch('index');
        }
    }

    /**
     *玩家用户名查询
     */
    public function likeUsername(){
        $username=input('post.username');
        $role=session('tiger_role');
        $where['p.parent']=$this->come_where['parent'];
        $players=Db::name('playerReportsB')->alias('p')->join('na_users u','p.parent=u.uid')
            ->field('p.username pu,p.wct pwct,p.msn pm,p.balance pb,p.waterflow pw,p.totalBetCount ptbc,p.avgRTP pa,p.totalPays ptp,p.totalBets ptb,u.suffix us,u.username uu,p.pid,u.nickname uni')
            ->where('p.username','like',"%$username%")->where($where)->paginate(20);
        switch ($role){
            case 1://平台管理
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 2://顶级代理
                $data1=Db::name('users')->where('msn','0')->where('levelIndex','<>','0')->select();
                $this->assign('data1',$data1);
                break;
            case 3://线路商
                $id=session('tiger_uid');
                $users=Db::name('users')->field('uid')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','-1')->where('levelindex','like',"%$uid%")->select();
                $data2=Db::name('users')->where('msn','<>','-1')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                break;
            case 4://次级代理
                $id=session('tiger_uid');
                $users=Db::name('users')->where('id',$id)->find();
                $uid=$users['uid'];
                $data1=Db::name('users')->where('msn','0')->where('levelindex','like',"%$uid%")->select();
                $this->assign('data1',$data1);
                break;
            case 5://商户
                break;
            case 6://超管
                $data1=Db::name('users')->where('msn','-1')->where('suffix','<>','Platform')->select();
                $data2=Db::name('users')->where("msn !='-1' and msn != '0'")->select();
                $data3=Db::name('users')->where('msn','0')->where('levelindex','<>','0')->select();
                $this->assign('data1',$data1);
                $this->assign('data2',$data2);
                $this->assign('data3',$data3);
                break;
        }
        $this->assign('typeId',40002);
        $this->assign('role',$role);
        $this->assign('players',$players);
        return $this->fetch('index');

    }




}<file_sep>/application/admin/controller/IndexController.php
<?php

/**
 *  
 * @file   Index.php  
 * @date   2016-8-23 16:03:10 
 * @author <NAME><<EMAIL>>  
 * @version    SVN:$Id:$ 
 */  

namespace application\admin\controller;

class IndexController extends CommonController{
    /**
     * 后台首页
     */
    public function index(){
        $role=session('tiger_role');
        $msg='';
        switch ($role){
            case 1:
                $msg='当前身份：管理员';
                break;
            case 2:
                $msg='当前身份：代理管理员';
                break;
            case 3:
                $msg='当前身份：线路商';
                break;
            case 4:
                $msg='当前身份：代理';
                break;
            case 5:
                $msg='当前身份：商户';
                break;
            case 6:
                $msg='当前身份：超管';
                break;
        }
        $this->assign('msg',$msg);
        return $this->fetch();
    }
    
    
}<file_sep>/sql/na_tigergame.sql
/*
Navicat MySQL Data Transfer

Source Server         : localhost_3306
Source Server Version : 50617
Source Host           : localhost:3306
Source Database       : na_tigergame

Target Server Type    : MYSQL
Target Server Version : 50617
File Encoding         : 65001

Date: 2017-09-01 11:45:57
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for na_admin
-- ----------------------------
DROP TABLE IF EXISTS `na_admin`;
CREATE TABLE `na_admin` (
  `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(20) NOT NULL DEFAULT '',
  `password` varchar(32) NOT NULL DEFAULT '',
  `encrypt` varchar(6) NOT NULL DEFAULT '',
  `lastloginip` int(10) NOT NULL DEFAULT '0',
  `lastlogintime` int(10) unsigned NOT NULL DEFAULT '0',
  `email` varchar(40) NOT NULL DEFAULT '',
  `mobile` varchar(11) NOT NULL DEFAULT '',
  `realname` varchar(50) NOT NULL DEFAULT '',
  `openid` varchar(255) NOT NULL DEFAULT '',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否有效(2:无效,1:有效)',
  `updatetime` int(10) NOT NULL DEFAULT '0',
  `uid` varchar(50) DEFAULT NULL COMMENT '平台管理员的uid ',
  PRIMARY KEY (`id`),
  KEY `username` (`username`),
  KEY `status` (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_admin
-- ----------------------------
INSERT INTO `na_admin` VALUES ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '', '2130706433', '1504233919', '<EMAIL>', '13076050636', '小肖', '', '1', '1502875535', null);

-- ----------------------------
-- Table structure for na_admin_group
-- ----------------------------
DROP TABLE IF EXISTS `na_admin_group`;
CREATE TABLE `na_admin_group` (
  `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `description` text,
  `rules` varchar(500) NOT NULL DEFAULT '' COMMENT '用户组拥有的规则id，多个规则 , 隔开',
  `listorder` smallint(5) unsigned NOT NULL DEFAULT '0',
  `updatetime` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `listorder` (`listorder`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_admin_group
-- ----------------------------
INSERT INTO `na_admin_group` VALUES ('1', '系统首页', '拥有系统首页模块', '31', '0', '1503288249');
INSERT INTO `na_admin_group` VALUES ('4', '商户管理', '拥有商户管理权限', '48,50,51,55,56,57,58,52', '0', '1503539486');
INSERT INTO `na_admin_group` VALUES ('5', '报表统计', '拥有报表统计模块查看', '49,53,59,60,61,62,54,63,64,65,66', '0', '1503539502');

-- ----------------------------
-- Table structure for na_admin_group_access
-- ----------------------------
DROP TABLE IF EXISTS `na_admin_group_access`;
CREATE TABLE `na_admin_group_access` (
  `uid` int(10) unsigned NOT NULL COMMENT '用户id',
  `group_id` mediumint(8) unsigned NOT NULL COMMENT '用户组id',
  UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
  KEY `uid` (`uid`),
  KEY `group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_admin_group_access
-- ----------------------------
INSERT INTO `na_admin_group_access` VALUES ('20', '1');
INSERT INTO `na_admin_group_access` VALUES ('21', '1');
INSERT INTO `na_admin_group_access` VALUES ('22', '1');
INSERT INTO `na_admin_group_access` VALUES ('23', '1');
INSERT INTO `na_admin_group_access` VALUES ('24', '1');
INSERT INTO `na_admin_group_access` VALUES ('25', '1');
INSERT INTO `na_admin_group_access` VALUES ('26', '1');
INSERT INTO `na_admin_group_access` VALUES ('20', '4');
INSERT INTO `na_admin_group_access` VALUES ('21', '4');
INSERT INTO `na_admin_group_access` VALUES ('22', '4');
INSERT INTO `na_admin_group_access` VALUES ('23', '4');
INSERT INTO `na_admin_group_access` VALUES ('24', '4');
INSERT INTO `na_admin_group_access` VALUES ('25', '4');
INSERT INTO `na_admin_group_access` VALUES ('26', '4');
INSERT INTO `na_admin_group_access` VALUES ('20', '5');
INSERT INTO `na_admin_group_access` VALUES ('21', '5');
INSERT INTO `na_admin_group_access` VALUES ('22', '5');
INSERT INTO `na_admin_group_access` VALUES ('23', '5');
INSERT INTO `na_admin_group_access` VALUES ('24', '5');
INSERT INTO `na_admin_group_access` VALUES ('25', '5');
INSERT INTO `na_admin_group_access` VALUES ('26', '5');

-- ----------------------------
-- Table structure for na_admin_log
-- ----------------------------
DROP TABLE IF EXISTS `na_admin_log`;
CREATE TABLE `na_admin_log` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `m` varchar(15) NOT NULL,
  `c` varchar(20) NOT NULL,
  `a` varchar(20) NOT NULL,
  `querystring` varchar(255) NOT NULL,
  `userid` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `username` varchar(20) NOT NULL,
  `ip` int(10) NOT NULL,
  `time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_admin_log
-- ----------------------------
INSERT INTO `na_admin_log` VALUES ('1', 'admin', 'Menu', 'del', '?id=45', '1', 'admin', '2130706433', '2017-08-15 16:25:18');
INSERT INTO `na_admin_log` VALUES ('2', 'admin', 'Group', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:27:00');
INSERT INTO `na_admin_log` VALUES ('3', 'admin', 'Admin', 'public_edit_info', '', '1', 'admin', '2130706433', '2017-08-15 16:27:01');
INSERT INTO `na_admin_log` VALUES ('4', 'admin', 'Group', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:30:54');
INSERT INTO `na_admin_log` VALUES ('5', 'admin', 'Admin', 'public_edit_info', '', '1', 'admin', '2130706433', '2017-08-15 16:30:56');
INSERT INTO `na_admin_log` VALUES ('6', 'admin', 'Admin', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:30:57');
INSERT INTO `na_admin_log` VALUES ('7', 'admin', 'Menu', 'info', '', '1', 'admin', '2130706433', '2017-08-15 16:31:36');
INSERT INTO `na_admin_log` VALUES ('8', 'admin', 'Menu', 'add', '', '1', 'admin', '2130706433', '2017-08-15 16:32:53');
INSERT INTO `na_admin_log` VALUES ('9', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:34:22');
INSERT INTO `na_admin_log` VALUES ('10', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:34:37');
INSERT INTO `na_admin_log` VALUES ('11', 'admin', 'Player', 'favicon.ico', '', '1', 'admin', '2130706433', '2017-08-15 16:34:37');
INSERT INTO `na_admin_log` VALUES ('12', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:35:09');
INSERT INTO `na_admin_log` VALUES ('13', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-15 16:35:24');
INSERT INTO `na_admin_log` VALUES ('14', 'admin', 'Index', 'favicon.ico', '', '1', 'admin', '2130706433', '2017-08-16 10:32:17');
INSERT INTO `na_admin_log` VALUES ('15', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:33:24');
INSERT INTO `na_admin_log` VALUES ('16', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:33:32');
INSERT INTO `na_admin_log` VALUES ('17', 'admin', 'Player', 'favicon.ico', '', '1', 'admin', '2130706433', '2017-08-16 11:33:32');
INSERT INTO `na_admin_log` VALUES ('18', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:33:51');
INSERT INTO `na_admin_log` VALUES ('19', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:35:31');
INSERT INTO `na_admin_log` VALUES ('20', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:35:46');
INSERT INTO `na_admin_log` VALUES ('21', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:36:11');
INSERT INTO `na_admin_log` VALUES ('22', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:37:30');
INSERT INTO `na_admin_log` VALUES ('23', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:38:54');
INSERT INTO `na_admin_log` VALUES ('24', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 11:46:38');
INSERT INTO `na_admin_log` VALUES ('25', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 12:15:30');
INSERT INTO `na_admin_log` VALUES ('26', 'admin', 'Player', 'index', '', '1', 'admin', '2130706433', '2017-08-16 12:19:14');
INSERT INTO `na_admin_log` VALUES ('27', 'admin', 'Menu', 'favicon.ico', '', '1', 'admin', '2130706433', '2017-08-16 12:20:02');
INSERT INTO `na_admin_log` VALUES ('28', 'admin', 'Menu', 'info', '', '1', 'admin', '2130706433', '2017-08-16 12:20:13');
INSERT INTO `na_admin_log` VALUES ('29', 'admin', 'Menu', 'add', '', '1', 'admin', '2130706433', '2017-08-16 12:21:20');
INSERT INTO `na_admin_log` VALUES ('30', 'admin', 'GameReports', 'index', '', '1', 'admin', '2130706433', '2017-08-16 14:41:41');
INSERT INTO `na_admin_log` VALUES ('31', 'admin', 'Log', 'favicon.ico', '', '1', 'admin', '2130706433', '2017-08-16 14:43:51');

-- ----------------------------
-- Table structure for na_game_reports
-- ----------------------------
DROP TABLE IF EXISTS `na_game_reports`;
CREATE TABLE `na_game_reports` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `gameName` varchar(50) DEFAULT NULL COMMENT '游戏名称',
  `updatedAt` int(11) DEFAULT NULL COMMENT '更新时间',
  `totalPays` float DEFAULT NULL COMMENT '中奖金额',
  `totalBets` float DEFAULT NULL COMMENT '投注金额',
  `totalBetCount` int(11) DEFAULT NULL COMMENT '投注次数',
  `totalPlayers` int(11) DEFAULT NULL COMMENT '投注用户数',
  `avgRTP` float DEFAULT NULL,
  `parent` varchar(36) DEFAULT NULL COMMENT '对应商户的uid',
  `wct` float(10,2) DEFAULT NULL COMMENT '洗马量',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_game_reports
-- ----------------------------

-- ----------------------------
-- Table structure for na_menu
-- ----------------------------
DROP TABLE IF EXISTS `na_menu`;
CREATE TABLE `na_menu` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` char(40) NOT NULL DEFAULT '',
  `parentid` smallint(6) DEFAULT '0',
  `icon` varchar(20) NOT NULL DEFAULT '',
  `c` varchar(20) DEFAULT NULL,
  `a` varchar(20) DEFAULT NULL,
  `data` varchar(50) NOT NULL DEFAULT '',
  `tip` varchar(255) NOT NULL DEFAULT '' COMMENT '提示',
  `group` varchar(50) DEFAULT '' COMMENT '分组',
  `listorder` smallint(6) unsigned NOT NULL DEFAULT '999',
  `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否显示(1:显示,2:不显示)',
  `updatetime` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `listorder` (`listorder`),
  KEY `parentid` (`parentid`)
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_menu
-- ----------------------------
INSERT INTO `na_menu` VALUES ('1', '管理设置', '0', 'fa-users', 'Admin', 'admin', '', '', '', '1', '1', '1476175413');
INSERT INTO `na_menu` VALUES ('2', '管理员管理', '1', '', 'Admin', 'index', '', '', '', '0', '1', '1476175413');
INSERT INTO `na_menu` VALUES ('3', '详情', '2', '', 'Admin', 'info', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('4', '添加', '2', '', 'Admin', 'add', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('5', '修改', '2', '', 'Admin', 'edit', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('6', '删除', '2', '', 'Admin', 'del', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('7', '权限管理', '1', '', 'Group', 'index', '', '', '', '0', '1', '1488781190');
INSERT INTO `na_menu` VALUES ('8', '详情', '7', '', 'Group', 'info', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('9', '添加', '7', '', 'Group', 'add', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('10', '修改', '7', '', 'Group', 'edit', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('11', '删除', '7', '', 'Group', 'del', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('12', '菜单管理', '18', '', 'Menu', 'index', '', '', '', '0', '1', '1476175413');
INSERT INTO `na_menu` VALUES ('13', '查看', '12', '', 'Menu', 'info', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('14', '添加', '12', '', 'Menu', 'add', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('15', '修改', '12', '', 'Menu', 'edit', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('16', '删除', '12', '', 'Menu', 'del', '', '', '', '0', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('18', '系统设置', '0', 'fa-cogs', 'Menu', 'index', '', '', '', '2', '1', '1476175413');
INSERT INTO `na_menu` VALUES ('22', '权限设置', '2', '', 'Group', 'rule', '', '', '', '999', '2', '1476175413');
INSERT INTO `na_menu` VALUES ('23', '个人设置', '1', '', 'Admin', 'public_edit_info', '', '', '', '999', '2', '1502865964');
INSERT INTO `na_menu` VALUES ('27', '日志管理', '18', '', 'Log', 'index', '', '', '', '999', '2', '1502865919');
INSERT INTO `na_menu` VALUES ('31', '系统首页', '0', 'fa-bank', 'Index', 'index', '', '', '', '0', '1', '1476175413');
INSERT INTO `na_menu` VALUES ('48', '商户管理', '0', 'fa-user-plus', 'Merchant', 'index', '', '', '', '999', '1', '1502867010');
INSERT INTO `na_menu` VALUES ('49', '报表统计', '0', 'fa-area-chart', 'GameReports', 'index', '', '', '', '999', '1', '1502866845');
INSERT INTO `na_menu` VALUES ('50', '商户信息', '48', '', 'Merchant', 'index', '', '', '', '999', '2', '1502874043');
INSERT INTO `na_menu` VALUES ('51', '玩家信息', '48', '', 'Player', 'index', '', '', '', '999', '1', '1502867129');
INSERT INTO `na_menu` VALUES ('52', '额度记录', '48', '', 'Limit', 'index', '', '', '', '999', '2', '1502874053');
INSERT INTO `na_menu` VALUES ('53', '玩家报表', '49', '', 'PlayerReports', 'index', '', '', '', '999', '1', '1502866923');
INSERT INTO `na_menu` VALUES ('54', '游戏报表', '49', '', 'GameReports', 'index', '', '', '', '999', '1', null);
INSERT INTO `na_menu` VALUES ('55', '线路商查询', '51', '', 'Player', 'xl', '', '', '', '999', '2', '1503374844');
INSERT INTO `na_menu` VALUES ('56', '商户查询', '51', '', 'Player', 'sh', '', '', '', '999', '2', '1503374863');
INSERT INTO `na_menu` VALUES ('57', '玩家用户名查询', '51', '', 'Player', 'likeUsername', '', '', '', '999', '2', '1503374878');
INSERT INTO `na_menu` VALUES ('58', '代理商查询', '51', '', 'Player', 'dl', '', '', '', '999', '2', '1503374893');
INSERT INTO `na_menu` VALUES ('59', '线路商查询', '53', '', 'PlayerReports', 'xl', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('60', '商户查询', '53', '', 'PlayerReports', 'sh', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('61', '玩家用户名查询', '53', '', 'PlayerReports', 'likeUsername', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('62', '代理商查询', '53', '', 'PlayerReports', 'dl', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('63', '线路商查询', '54', '', 'GameReports', 'xl', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('64', '商户查询', '54', '', 'GameReports', 'sh', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('65', '代理商查询', '54', '', 'GameReports', 'dl', '', '', '', '999', '2', null);
INSERT INTO `na_menu` VALUES ('66', '游戏名称查询', '54', '', 'GameReports', 'likeGamename', '', '', '', '999', '2', null);

-- ----------------------------
-- Table structure for na_merchants
-- ----------------------------
DROP TABLE IF EXISTS `na_merchants`;
CREATE TABLE `na_merchants` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(255) DEFAULT NULL,
  `msn` varchar(255) DEFAULT NULL,
  `displayName` varchar(255) DEFAULT NULL,
  `userId` int(11) DEFAULT NULL,
  `userStatus` varchar(255) DEFAULT NULL,
  `createdAt` datetime DEFAULT NULL,
  `updatedAt` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_merchants
-- ----------------------------

-- ----------------------------
-- Table structure for na_players
-- ----------------------------
DROP TABLE IF EXISTS `na_players`;
CREATE TABLE `na_players` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键自增长的ID',
  `uid` varchar(36) DEFAULT NULL COMMENT '玩家的uid',
  `parent` varchar(36) DEFAULT NULL COMMENT '所属商户的uid',
  `username` varchar(50) DEFAULT NULL COMMENT '玩家账户',
  `nickname` varchar(10) DEFAULT NULL COMMENT '玩家昵称',
  `suffix` varchar(20) DEFAULT NULL COMMENT '玩家前缀',
  `msn` varchar(5) DEFAULT NULL COMMENT '线路号',
  `createdAt` datetime DEFAULT NULL COMMENT '创建时间',
  `balance` float DEFAULT NULL COMMENT '玩家余额',
  `waterflow` float DEFAULT NULL COMMENT '玩家流水总额',
  `content` text COMMENT 'josn格式的数据',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_players
-- ----------------------------

-- ----------------------------
-- Table structure for na_player_reports
-- ----------------------------
DROP TABLE IF EXISTS `na_player_reports`;
CREATE TABLE `na_player_reports` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(50) DEFAULT NULL COMMENT '玩家账户',
  `totalBetCount` int(11) DEFAULT NULL COMMENT '投注次数',
  `avgRTP` float DEFAULT NULL,
  `totalPays` float DEFAULT NULL COMMENT '中奖金额',
  `totalBets` float DEFAULT NULL COMMENT '投注金额',
  `balance` float DEFAULT NULL COMMENT '玩家余额',
  `waterflow` float DEFAULT NULL COMMENT '流水总额',
  `msn` varchar(5) DEFAULT NULL,
  `parent` varchar(36) DEFAULT NULL COMMENT '对应商户的uid',
  `wct` float(10,2) DEFAULT NULL COMMENT '洗马量',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_player_reports
-- ----------------------------

-- ----------------------------
-- Table structure for na_users
-- ----------------------------
DROP TABLE IF EXISTS `na_users`;
CREATE TABLE `na_users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uid` varchar(36) DEFAULT NULL COMMENT '管理员，线路商，商户，代理，的ID',
  `parent` varchar(36) DEFAULT NULL COMMENT '上级用户uid',
  `ancestor` varchar(36) DEFAULT NULL COMMENT '根用户uid',
  `username` varchar(50) DEFAULT NULL COMMENT '用户账号',
  `suffix` varchar(10) DEFAULT NULL COMMENT '当前用户前缀',
  `msn` varchar(5) DEFAULT NULL COMMENT '当前用户线路号',
  `content` text COMMENT 'json格式数据',
  `createdAt` int(11) DEFAULT NULL COMMENT '创建时间',
  `updatedAt` int(11) DEFAULT NULL COMMENT '更新时间',
  `levelindex` varchar(1800) DEFAULT NULL COMMENT '层级关系所属',
  `wcr` float(10,2) DEFAULT NULL COMMENT '洗马比',
  `ptr` float(10,2) DEFAULT NULL COMMENT '成数',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of na_users
-- ----------------------------
<file_sep>/.svn/pristine/c9/c93b5b5423500e90eb869aec2c7390599da81320.svn-base
<?php
namespace application\admin\controller;

use think\Controller;
use think\Db;
class ApiController extends Controller{

    //写入管理员数据
    public function addAdminInfo(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $datainfo['uid']=$data->uid;
        $datainfo['parent']=$data->parent;
        $datainfo['ancestor']=$data->ancestor;
        $datainfo['username']=$data->username;
        $datainfo['nickname']=$data->nickname;
        $datainfo['suffix']=$data->suffix;
        $datainfo['msn']=$data->msn;
        $datainfo['content']=$data->content;
        $datainfo['createdAt']=date("Y-m-d H:i:s");
        $datainfo['updatedAt']=date("Y-m-d H:i:s");
        $datainfo['levelindex']=$data->levelindex;
        $datainfo['wcr']=$data->wcr;
        $datainfo['ptr']=$data->ptr;
        $datainfo['linecfg']=$data->linecfg;
        $datainfo['betcfg']=$data->betcfg;
        if(!$datainfo['uid'] || !$datainfo['suffix'] ){
            return json(['code'=>0,'message'=>'数据不完整']);
        }

        $uinfo=Db::name('users')->where('uid',$data->uid)->find();
        if($uinfo){
            unset($datainfo['createdAt']);
            $res=Db::name('users')->where('id',$uinfo['id'])->update($datainfo);
            if($res){
                return json(['code'=>1,'message'=>'更新成功']);
            }else{
                return json(['code'=>0,'message'=>'更新失败']);
            }
        }else{
            $res=Db::name('users')->insert($datainfo);
            if($res){
                $adminId = Db::name('users')->getLastInsID();
                $groups=Db::name('adminGroup')->field('id')->select();
                foreach($groups as $v) {
                    Db::name('adminGroupAccess')->insert(['uid' => $adminId, 'group_id' => $v['id']]);//生成权限
                }
                return json(['code'=>1,'message'=>'插入成功']);
            }else{
                return json(['code'=>0,'message'=>'插入失败']);
            }
        }

    }
    //写入玩家数据
    public function addPlayers(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $playerinfo['uid']=$data->uid;
        $playerinfo['parent']=$data->parent;
        $playerinfo['username']=$data->username;
        $playerinfo['nickname']=$data->nickname;
        $playerinfo['suffix']=$data->suffix;
        $playerinfo['msn']=$data->msn;
        $playerinfo['createdAt']=date("Y-m-d H:i:s",time());
        $playerinfo['balance']=$data->balance;
        $playerinfo['waterflow']=$data->waterflow;
        $playerinfo['content']=$data->content;
        if(!$playerinfo['uid'] || !$playerinfo['parent'] || !$playerinfo['username']){
            return json(['code'=>0,'message'=>'数据不完整']);
        }
        $uinfo=Db::name('players')->where('uid',$data->uid)->find();
        if($uinfo){
            $res=Db::name('players')->where('id',$uinfo['id'])->update($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'操作成功']);
            }else{
                return json(['code'=>0,'message'=>'操作失败']);
            }
        }else{
            $res=Db::name('players')->insert($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'操作成功']);
            }else{
                return json(['code'=>0,'message'=>'操作失败']);
            }
        }

    }

    //写入游戏报表数据
    public  function addGameReports(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $playerinfo['gameName']=$data->gameName;
        $playerinfo['updatedAt']=$data->updatedAt;
        $playerinfo['totalPays']=$data->totalPays;
        $playerinfo['totalBets']=$data->totalBets;
        $playerinfo['totalBetCount']=$data->totalBetCount;
        $playerinfo['totalPlayers']=$data->totalPlayers;
        $playerinfo['avgRTP']=$data->avgRTP;
        $playerinfo['parent']=$data->parent;
        $playerinfo['wct']=$data->wct;

        if(!$playerinfo['gameName'] || !$playerinfo['parent']){
            return json(['code'=>0,'message'=>'数据不完整']);
        }
        $res=Db::name('gameReports')->insert($playerinfo);
        if($res){
            return json(['code'=>1,'message'=>'操作成功']);
        }else{
            return json(['code'=>0,'message'=>'操作失败']);
        }
    }

    //写入玩家报表数据之塔罗之谜
    public function addPlayerReports(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $playerinfo['pid']=$data->pid;
        $playerinfo['username']=$data->username;
        $playerinfo['totalBetCount']=$data->totalBetCount;
        $playerinfo['avgRTP']=$data->avgRTP;
        $playerinfo['totalPays']=$data->totalPays;
        $playerinfo['totalBets']=$data->totalBets;
        $playerinfo['balance']=$data->balance;
        $playerinfo['waterflow']=$data->waterflow;
        $playerinfo['msn']=$data->msn;
        $playerinfo['parent']=$data->parent;
        $playerinfo['wct']=$data->wct;
        if(!$playerinfo['username'] || !$playerinfo['parent'] || !$playerinfo['pid']){
            return json(['code'=>0,'message'=>'数据不完整']);
        }
        $prinfo=Db::name('playerReports')->where('pid',$playerinfo['pid'])->find();
        if($prinfo){//更新p
            $res=Db::name('playerReports')->where('id',$prinfo['id'])->update($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'更新成功']);
            }else{
                return json(['code'=>0,'message'=>'更新失败']);
            }
        }else{
            $res=Db::name('playerReports')->insert($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'操作成功']);
            }else{
                return json(['code'=>0,'message'=>'操作失败']);
            }
        }

    }

    //写入玩家报表数据之塔罗之谜
    public function addPlayerReportsB(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $playerinfo['pid']=$data->pid;
        $playerinfo['username']=$data->username;
        $playerinfo['totalBetCount']=$data->totalBetCount;
        $playerinfo['avgRTP']=$data->avgRTP;
        $playerinfo['totalPays']=$data->totalPays;
        $playerinfo['totalBets']=$data->totalBets;
        $playerinfo['balance']=$data->balance;
        $playerinfo['waterflow']=$data->waterflow;
        $playerinfo['msn']=$data->msn;
        $playerinfo['parent']=$data->parent;
        $playerinfo['wct']=$data->wct;
        if(!$playerinfo['username'] || !$playerinfo['parent'] || !$playerinfo['pid']){
            return json(['code'=>0,'message'=>'数据不完整']);
        }
        $prinfo=Db::name('playerReportsB')->where('pid',$playerinfo['pid'])->find();
        if($prinfo){//更新p
            $res=Db::name('playerReportsB')->where('id',$prinfo['id'])->update($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'更新成功']);
            }else{
                return json(['code'=>0,'message'=>'更新失败']);
            }
        }else{
            $res=Db::name('playerReportsB')->insert($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'操作成功']);
            }else{
                return json(['code'=>0,'message'=>'操作失败']);
            }
        }

    }

    //写入玩家总记录数
    public function totalReports(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $playerinfo['gameUserId']=$data->gameUserId;
        $playerinfo['username']=$data->username;
        $playerinfo['nickname']=$data->nickname;
        $playerinfo['balance']=$data->balance;
        $playerinfo['parentId']=$data->parentId;
        $playerinfo['betCount']=$data->betCount;
        $playerinfo['winlose']=$data->winlose;
        $playerinfo['totalBet']=$data->totalBet;
        $playerinfo['wcr']=$data->wcr;
        $playerinfo['ret']=$data->ret;
        $playerinfo['agentBalance']=$data->agentBalance;
        $playerinfo['agentRate']=$data->agentRate;
        $playerinfo['giveback']=$data->giveback;
        if(!$playerinfo['gameUserId'] || !$playerinfo['parentId'] ){
            return json(['code'=>0,'message'=>'数据不完整']);
        }
        $prinfo=Db::name('totalReports')->where('gameUserId',$playerinfo['gameUserId'])->find();
        if($prinfo){//更新p
            $res=Db::name('totalReports')->where('id',$prinfo['id'])->update($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'更新成功']);
            }else{
                return json(['code'=>0,'message'=>'更新失败']);
            }
        }else{
            $res=Db::name('totalReports')->insert($playerinfo);
            if($res){
                return json(['code'=>1,'message'=>'操作成功']);
            }else{
                return json(['code'=>0,'message'=>'操作失败']);
            }
        }

    }

    //写入商户数据

	//新接口验证身份信息 返回登录URL ---NA平台
	public function checkLoginAccess(){
        header("Access-Control-Allow-Origin:*");
        $info=file_get_contents('php://input');
        $data=json_decode($info);
        $uid=$data->id;
        $timestamp=$data->timestamp;
        $sign=$data->sign;
        if(!$uid ||  !$timestamp  || !$sign){
            return json(['code'=>1,'msg'=>'参数不完整!']);
        }
        $str='id'.$uid.'timestamp'.$timestamp;
        $str=urlencode($str);
        $gameKey=config('tigerkey');//定义老虎机的key
        $truesign=$gameKey.$str.$gameKey;
        $truesign=hash('sha256',$truesign);
        if($truesign!=$sign){
            $jsonarr=[
                'code'=>1,
                'msg'=>'签名验证失败!',
            ];
            return  json($jsonarr);
        }
        //用uid去查找这个商户信息存在不？
        $info=Db::name('users')->where('uid',$uid)->find();
        if(!$info){
            $jsonarr=[
                'code'=>1,
                'msg'=>'信息没有同步,后台没有检测到商户,请联系管理员!',
            ];
            return  json($jsonarr);
        }
        //取出msn /suffix;
        $msn=$info['msn'];
        $suffix=$info['suffix'];
        $levelIndex=$info['levelindex'];
        $guanli=[];
        $time=time();
        //定义身份
        if($levelIndex==0 && $suffix=='Platform'){//管理员
            //找出所有的线路商或者商户
            $guanliinfos=Db::name('users')->field('uid')->where('levelindex','like','%01%')->where('msn','<>',0)->where('suffix','<>','Platform')->select();
            foreach ($guanliinfos as $guanliinfo){
                $guanli[]=$guanliinfo['uid'];
            }
        }
        if($levelIndex==0 && $msn==0){//代理管理员 没有玩家的
            $dailiinfos=Db::name('users')->field('uid')->where('levelindex','like','%01%')->where('msn',0)->select();
            foreach ($dailiinfos as $dailiinfo){
                $guanli[]=$dailiinfo['uid'];
            }
        }
        if($msn==-1 && $levelIndex!=0){//值为ｎｕｌｌ就是线路商
            $xianlus=Db::name('users')->field('uid')->where('levelindex','like',"%$uid%")->select();
            foreach ($xianlus as $xianlu){
                $guanli[]=$xianlu['uid'];
            }
        }
        if($msn==0 && $levelIndex!=0 ){//代理
            $guanli[]=$uid;
            $dailiinfos=Db::name('users')->field('uid')->where('levelindex','like',"%$uid%")->select();
            foreach ($dailiinfos as $dailiinfo){
                $guanli[]=$dailiinfo['uid'];
            }
        }
        if($levelIndex!=0 && $msn!=0 && $msn !=-1){//商户
            $guanli[]=$uid;
        }

        if(!count($guanli)){
            $jsonarr=[
                'code'=>1,
                'msg'=>'无商户无玩家信息',
            ];
            return  json($jsonarr);
        }
        //生成URL
        $data=[
            'uid'=>$info['id'],
            'time'=>$time
        ];
        $token=serialize($data);
        $token = encry_code($token);//加密
        $jsonarr=[
            'code'=>0,
            'msg'=>'success',
            'url'=>'http://'.config('naurl').'/admin/login/apilogin/token/'.$token.'.html'
        ];
        return  json($jsonarr);
    }
//线路
    public function treeXianLu($uid){
        $xinlus=Db::name('users')->where('parent',$uid)->select();
        static $uids=array();
        foreach ($xinlus as $xinlu){
            if($xinlu['msn']){
                $uids[]=$xinlu['uid'];
            }else{
                $this->treeXianLu($xinlu['uid']);
            }
        }
        return $uids;
    }
	//代理
    public function treeDaiLi(){


    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}