get(); $query = http_build_query($get); $this->assign('get',$get); $this->assign('query',$query); // 接收搜索的条件信息 $username = trim(Request::instance()->get('username')); $id = intval(Request::instance()->get('id')); $export = Request::instance()->get('export'); // 拼装搜索条件 $where = array(); if(!empty($username)) $where['username'] = $username; if($id > 0){ $where['agent_parent_id'] = $id; }else{ $where['agent_parent_id'] = 0; } $where['is_delete'] = 0; $where['agent'] = 1; if($export == 1){ $agent_list = Db::name('user')->where($where)->order('id desc')->select(); }else{ //获取所有代理信息 $agent_list = Db::name('user')->where($where)->order('id desc')->paginate(10,false,array('query'=>$get)); } foreach($agent_list as $k => $v){ $v['reg_time'] = date("Y-m-d H:i",$v['reg_time']); if(empty($v['nickname'])) $v['nickname'] = "-"; if($v['bet_type'] == 1){ $v['bet_type'] = '网络投注'; }elseif($v['bet_type'] == 2){ $v['bet_type'] = '电话投注'; }elseif($v['bet_type'] == 3){ $v['bet_type'] = '所有投注'; }else{ $v['bet_type'] = '-'; } if($v['type_xima'] == 1){ $v['ximalv'] = '双边 '.$v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'].' / '.$v['agent_ximalv_tc']; }elseif($v['type_xima'] == 2){ $v['ximalv'] = '单边 '.$v['agent_ximalv'].' / '.$v['agent_ximalv_dt'].' / '.$v['agent_ximalv_nn'].' / '.$v['agent_ximalv_tc']; }else{ $v['ximalv'] = '0 / 0'; } // 格式化数据 $v['last_recharge'] = round($v['last_recharge'],2); $v['money'] = round($v['money'],2); $v['win_limit'] = round($v['win_limit'],2); $agent_list[$k] = $v; } //导出excel列表 if($export == 1){ if($agent_list){ //重新组合 $excelData = array(); foreach($agent_list AS $k => $v){ $excelData[$k][0] = $v['username']; $excelData[$k][1] = $v['nickname']; if($v['agent_parent_nickname']){ $excelData[$k][2] = $v['agent_parent_username']."(".$v['agent_parent_nickname'].")"; }else{ $excelData[$k][2] = $v['agent_parent_username']; } $excelData[$k][3] = $v['bet_type']; $excelData[$k][4] = $v['last_recharge']; $excelData[$k][5] = $v['money']; $excelData[$k][6] = $v['agent_ximalv']; $excelData[$k][7] = $v['agent_cs']."%"; $excelData[$k][8] = $v['win_limit']; $excelData[$k][9] = $v['reg_time']; } $title = array('用户名','联系人','上级代理','投注方式','最近上分','商户余额','百/龙码率','占成','日赢上限','创建日期'); $this->exportExcelCore($excelData, '代理列表', $title); exit('已导出支持列表,请不要重复刷新该页面!'); }else{ exit('没有可以导出的列表!'); } } // 渲染变量和模板 $this->assign('agent_list',$agent_list); $this->assign('query',$query); return $this->fetch(); } /** * 添加代理页面 */ public function agent_add(){ $limit_list = Db::name('limit_money')->where('status',1)->select(); $pay_channel_list = Db::name('pay_channel')->where('status',1)->field('key,name')->select(); $this->assign('limit_list',$limit_list); $this->assign('pay_channel_list',$pay_channel_list); return $this->fetch('/agent/agent-add'); } /** * 处理添加代理 */ public function do_agent_add(){ if(Request::instance()->post()){ // 获取管理员信息 $user_info = Session::get('user_info'); // 接收提交过来的数据 $username = Request::instance()->post('username'); $nickname = Request::instance()->post('nickname'); $pass = Request::instance()->post('pass'); $repass = Request::instance()->post('repass'); $type_xima = round(Request::instance()->post('type_xima'),2); $agent_type = round(Request::instance()->post('agent_type'),2); $pay_channel = Request::instance()->post('pay_channel'); $share_xima = round(Request::instance()->post('share_xima'),2); $rebate_rate = round(Request::instance()->post('rebate_rate'),2); $ximalv = round(Request::instance()->post('ximalv'),2); $ximalv_dt = round(Request::instance()->post('ximalv_dt'),2); $ximalv_nn = round(Request::instance()->post('ximalv_nn'),2); $ximalv_tc = round(Request::instance()->post('ximalv_tc'),2); $cs = Request::instance()->post('cs'); $mobile = Request::instance()->post('mobile'); $email = Request::instance()->post('email'); $bet_type = Request::instance()->post('bet_type'); $limit_low = intval(Request::instance()->post('limit_low')); $limit_high = intval(Request::instance()->post('limit_high')); $limit_low_tie = intval(Request::instance()->post('limit_low_tie')); $limit_high_tie = intval(Request::instance()->post('limit_high_tie')); $limit_low_pair = intval(Request::instance()->post('limit_low_pair')); $limit_high_pair = intval(Request::instance()->post('limit_high_pair')); $price_banker = Request::instance()->post('price_banker'); $price_player = Request::instance()->post('price_player'); $price_tie_baccarat = Request::instance()->post('price_tie_baccarat'); $price_pair = Request::instance()->post('price_pair'); $price_luck_six_2 = Request::instance()->post('price_luck_six_2'); $price_luck_six_3 = Request::instance()->post('price_luck_six_3'); $price_big = Request::instance()->post('price_big'); $price_small = Request::instance()->post('price_small'); $price_dragon = Request::instance()->post('price_dragon'); $price_tiger = Request::instance()->post('price_tiger'); $price_tie_dt = Request::instance()->post('price_tie_dt'); $price_n0_n6 = Request::instance()->post('price_n0_n6'); $price_n7_n9 = Request::instance()->post('price_n7_n9'); $price_nn = Request::instance()->post('price_nn'); $price_5n = Request::instance()->post('price_5n'); $price_bomb = Request::instance()->post('price_bomb'); $win_limit = intval(Request::instance()->post('win_limit')); $price_tc_n1 = round(Request::instance()->post('price_tc_n1'),2); $price_tc_n2 = round(Request::instance()->post('price_tc_n2'),2); $price_tc_n3 = round(Request::instance()->post('price_tc_n3'),2); $price_tc_n4 = round(Request::instance()->post('price_tc_n4'),2); $price_tc_n5 = round(Request::instance()->post('price_tc_n5'),2); $price_tc_n6 = round(Request::instance()->post('price_tc_n6'),2); $price_tc_n7 = round(Request::instance()->post('price_tc_n7'),2); $price_tc_n8 = round(Request::instance()->post('price_tc_n8'),2); $price_tc_n9 = round(Request::instance()->post('price_tc_n9'),2); $price_tc_nn = round(Request::instance()->post('price_tc_nn'),2); $price_tc_bz = round(Request::instance()->post('price_tc_bz'),2); $price_tc_ths = round(Request::instance()->post('price_tc_ths'),2); $price_tc_hjths = round(Request::instance()->post('price_tc_hjths'),2); // $agent_commission_tc = Request::instance()->post('agent_commission_tc'); // $agent_commission_tc_banker = Request::instance()->post('agent_commission_tc_banker'); // 验证数据 if($limit_low > 0 && $limit_high > 0 && $limit_low >= $limit_high){ die(json_encode(['code'=>0,'msg'=>'请正确选择限红!'])); } // 数据验证 if( !isset($username) && empty($username) ){ die(json_encode(['code'=>0,'msg'=>'用户名不能为空!'])); } if( !isset($nickname) && empty($nickname) ){ die(json_encode(['code'=>0,'msg'=>'昵称不能为空!'])); } if( !isset($pass) && empty($pass) ){ die(json_encode(['code'=>0,'msg'=>'密码不能为空!'])); } if( !isset($repass) && empty($repass) ){ die(json_encode(['code'=>0,'msg'=>'确认密码不能为空!'])); } if( !in_array($agent_type,[1,2]) ){ die(json_encode(['code'=>0,'msg'=>'总代性质错误'])); } if( empty($pay_channel) ){ die(json_encode(['code'=>0,'msg'=>'请选择支付渠道'])); } if( !in_array($type_xima,[1,2]) ){ die(json_encode(['code'=>0,'msg'=>'洗码方式错误'])); } if( !in_array($share_xima,[1,2]) ){ die(json_encode(['code'=>0,'msg'=>'码量分担方式错误'])); } if( $rebate_rate > 100 || $rebate_rate < 0){ die(json_encode(['code'=>0,'msg'=>'返水率只能取0-100之间'])); } if( $ximalv > 100 || $ximalv < 0){ die(json_encode(['code'=>0,'msg'=>'百家乐码率只能取0-100之间'])); } if( $ximalv_dt > 100 || $ximalv_dt < 0){ die(json_encode(['code'=>0,'msg'=>'龙虎码率只能取0-100之间'])); } if( $ximalv_nn > 100 || $ximalv_nn < 0){ die(json_encode(['code'=>0,'msg'=>'牛牛码率只能取0-100之间'])); } if( $ximalv_tc > 100 || $ximalv_tc < 0){ die(json_encode(['code'=>0,'msg'=>'三卡牛牛码率只能取0-100之间'])); } if( !isset($cs) && empty($cs) ){ die(json_encode(['code'=>0,'msg'=>'占股不能为空!'])); } if( $cs > 100 ){ die(json_encode(['code'=>0,'msg'=>'占股不能大于100%!'])); } if( $repass != $pass ){ die(json_encode(['code'=>0,'msg'=>'两次密码不一致!'])); } if( $bet_type <= 0 ){ die(json_encode(['code'=>0,'msg'=>'请选择投注方式!'])); } if($limit_low <= 0){ die(json_encode(['code'=>0,'msg'=>'最低限红必须大于0!'])); } if($limit_high <= 0){ die(json_encode(['code'=>0,'msg'=>'最高限红必须大于0!'])); } if($limit_low > $limit_high){ die(json_encode(['code'=>0,'msg'=>'最高限红必须大于最低限红!'])); } if($limit_low_tie <= 0){ die(json_encode(['code'=>0,'msg'=>'最低和限红必须大于0!'])); } if($limit_high_tie <= 0){ die(json_encode(['code'=>0,'msg'=>'最高和限红必须大于0!'])); } if($limit_low_tie > $limit_high_tie){ die(json_encode(['code'=>0,'msg'=>'最高和限红必须大于最低和限红!'])); } if($limit_low_pair <= 0){ die(json_encode(['code'=>0,'msg'=>'最低对子限红必须大于0!'])); } if($limit_high_pair <= 0){ die(json_encode(['code'=>0,'msg'=>'最高对子限红必须大于0!'])); } if($limit_low_pair > $limit_low_pair){ die(json_encode(['code'=>0,'msg'=>'最高对子限红必须大于最低对子限红!'])); } if($price_banker <= 0){ die(json_encode(['code'=>0,'msg'=>'押庄赔率必须大于0!'])); } if($price_player <= 0){ die(json_encode(['code'=>0,'msg'=>'押闲赔率必须大于0!'])); } if($price_tie_baccarat <= 0){ die(json_encode(['code'=>0,'msg'=>'押和(百家乐)赔率必须大于0!'])); } if($price_pair <= 0){ die(json_encode(['code'=>0,'msg'=>'押对子赔率必须大于0!'])); } if($price_luck_six_2 <= 0){ die(json_encode(['code'=>0,'msg'=>'两张牌幸运6赔率必须大于0!'])); } if($price_luck_six_3 <= 0){ die(json_encode(['code'=>0,'msg'=>'三张牌幸运6赔率必须大于0!'])); } if($price_big <= 0){ die(json_encode(['code'=>0,'msg'=>'押大赔率必须大于0!'])); } if($price_small <= 0){ die(json_encode(['code'=>0,'msg'=>'押小赔率必须大于0!'])); } if($price_dragon <= 0){ die(json_encode(['code'=>0,'msg'=>'押龙赔率必须大于0!'])); } if($price_tiger <= 0){ die(json_encode(['code'=>0,'msg'=>'押虎赔率必须大于0!'])); } if($price_tie_dt <= 0){ die(json_encode(['code'=>0,'msg'=>'押和(龙虎斗)赔率必须大于0!'])); } if($price_n0_n6 <= 0){ die(json_encode(['code'=>0,'msg'=>'押无牛-牛6赔率必须大于0!'])); } if($price_n7_n9 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛7-牛9赔率必须大于0!'])); } if($price_nn <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛牛赔率必须大于0!'])); } if($price_5n <= 0){ die(json_encode(['code'=>0,'msg'=>'押五公赔率必须大于0!'])); } if($price_bomb <= 0){ die(json_encode(['code'=>0,'msg'=>'押四条赔率必须大于0!'])); } if($price_tc_n1 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛一(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n2 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛二(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n3 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛三(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n4 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛四(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n5 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛五(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n6 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛六(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n7 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛七(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n8 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛八(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n9 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛九(三卡牛牛)赔率必须大于0!'])); } if($price_tc_nn <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛牛(三卡牛牛)赔率必须大于0!'])); } if($price_tc_bz <= 0){ die(json_encode(['code'=>0,'msg'=>'押豹子(三卡牛牛)赔率必须大于0!'])); } if($price_tc_ths <= 0){ die(json_encode(['code'=>0,'msg'=>'押同花顺(三卡牛牛)赔率必须大于0!'])); } if($price_tc_hjths <= 0){ die(json_encode(['code'=>0,'msg'=>'押皇家同花顺(三卡牛牛)赔率必须大于0!'])); } if($win_limit <= 0){ $win_limit = 0; } // 检测用户名是否已经被注册 $user = Db::name('user')->where('username',$username)->find(); if($user){ die(json_encode(['code'=>0,'msg'=>'用户已存在!'])); } // 获取IP地址 if(getIp()){ $ip = getIp(); }else{ $ip = '0.0.0.0'; } // 拼装数据 $data = array(); $data['username'] = $username; $data['nickname'] = $nickname; $data['password'] = think_ucenter_md5($pass, UC_AUTH_KEY); $data['encrypt'] = getRandChar(); $data['mobile'] = $mobile; $data['email'] = $email; $data['agent_type'] = $agent_type; $data['pay_channel'] = $pay_channel; $data['type_xima'] = $type_xima; $data['share_xima'] = $share_xima; $data['rebate_rate'] = $rebate_rate; $data['agent_ximalv'] = $ximalv; $data['agent_ximalv_dt'] = $ximalv_dt; $data['agent_ximalv_nn'] = $ximalv_nn; $data['agent_ximalv_tc'] = $ximalv_tc; $data['agent_cs'] = $cs; $data['status'] = 1; $data['agent'] = 1; $data['agent_level'] = 1; $data['reg_time'] = time(); $data['reg_ip'] = $ip; $data['create_mode'] = 1; $data['agent_mode'] = 1; $data['is_under'] = 1; $data['bet_type'] = $bet_type; $data['create_user_id'] = $user_info['id']; $data['limit_low'] = $limit_low; $data['limit_high'] = $limit_high; $data['limit_low_tie'] = $limit_low_tie; $data['limit_high_tie'] = $limit_high_tie; $data['limit_low_pair'] = $limit_low_pair; $data['limit_high_pair'] = $limit_high_pair; $data['avatar'] = '/static/admin/images/admin.jpg'; $data['price_banker'] = $price_banker; $data['price_player'] = $price_player; $data['price_tie_baccarat'] = $price_tie_baccarat; $data['price_pair'] = $price_pair; $data['price_luck_six_2'] = $price_luck_six_2; $data['price_luck_six_3'] = $price_luck_six_3; $data['price_big'] = $price_big; $data['price_small'] = $price_small; $data['price_dragon'] = $price_dragon; $data['price_tiger'] = $price_tiger; $data['price_tie_dt'] = $price_tie_dt; $data['price_n0_n6'] = $price_n0_n6; $data['price_n7_n9'] = $price_n7_n9; $data['price_nn'] = $price_nn; $data['price_5n'] = $price_5n; $data['price_bomb'] = $price_bomb; $data['win_limit'] = $win_limit; $data['price_tc_n1'] = $price_tc_n1; $data['price_tc_n2'] = $price_tc_n2; $data['price_tc_n3'] = $price_tc_n3; $data['price_tc_n4'] = $price_tc_n4; $data['price_tc_n5'] = $price_tc_n5; $data['price_tc_n6'] = $price_tc_n6; $data['price_tc_n7'] = $price_tc_n7; $data['price_tc_n8'] = $price_tc_n8; $data['price_tc_n9'] = $price_tc_n9; $data['price_tc_nn'] = $price_tc_nn; $data['price_tc_bz'] = $price_tc_bz; $data['price_tc_ths'] = $price_tc_ths; $data['price_tc_hjths'] = $price_tc_hjths; $data['referral_code'] = getRandCode(); // $data['agent_commission_tc'] = $agent_commission_tc; // $data['agent_commission_tc_banker'] = $agent_commission_tc_banker; $insert_id = Db::name('user')->insertGetId($data); if($insert_id){ Db::name('user')->where(array('id' => $insert_id))->update(array('agent_parent_id_path' => $insert_id)); // 写入管理员日志 insertAdminLog('添加代理','添加代理:| ID: '.$insert_id.' | 账号: '.$username); die(json_encode(['code'=>1,'msg'=>'添加成功!'])); }else{ die(json_encode(['code'=>0,'msg'=>'添加失败!'])); } }else{ die(json_encode(['code'=>0,'msg'=>'操作错误!'])); } } /** * 编辑代理页面 */ public function agent_edit(){ // 接收代理ID,查询代理信息 $agent_id = Request::instance()->get('agent_id'); $agent = Db::name('user')->find($agent_id); $pay_channel_list = Db::name('pay_channel')->where('status',1)->field('key,name')->select(); // 渲染参数和模板 $this->assign('agent',$agent); $this->assign('pay_channel_list',$pay_channel_list); return $this->fetch('/agent/agent-edit'); } /** * 处理修改代理信息 */ public function do_agent_edit(){ if(Request::instance()->post()){ // 接收传过来的数据 $agent_id = Request::instance()->post('agent_id'); $username = Request::instance()->post('username'); $nickname = Request::instance()->post('nickname'); $pass = Request::instance()->post('pass'); $repass = Request::instance()->post('repass'); $agent_type = round(Request::instance()->post('agent_type'),2); $pay_channel = Request::instance()->post('pay_channel'); $type_xima = round(Request::instance()->post('type_xima'),2); $share_xima = round(Request::instance()->post('share_xima'),2); $rebate_rate = round(Request::instance()->post('rebate_rate'),2); $ximalv = round(Request::instance()->post('ximalv'),2); $ximalv_dt = round(Request::instance()->post('ximalv_dt'),2); $ximalv_nn = round(Request::instance()->post('ximalv_nn'),2); $ximalv_tc = round(Request::instance()->post('ximalv_tc'),2); $cs = Request::instance()->post('cs'); $mobile = Request::instance()->post('mobile'); $email = Request::instance()->post('email'); //$limit_list = Request::instance()->post('limit_list'); $bet_type = Request::instance()->post('bet_type'); $limit_low = intval(Request::instance()->post('limit_low')); $limit_high = intval(Request::instance()->post('limit_high')); $limit_low_tie = intval(Request::instance()->post('limit_low_tie')); $limit_high_tie = intval(Request::instance()->post('limit_high_tie')); $limit_low_pair = intval(Request::instance()->post('limit_low_pair')); $limit_high_pair = intval(Request::instance()->post('limit_high_pair')); $price_banker = Request::instance()->post('price_banker'); $price_player = Request::instance()->post('price_player'); $price_tie_baccarat = Request::instance()->post('price_tie_baccarat'); $price_pair = Request::instance()->post('price_pair'); $price_luck_six_2 = Request::instance()->post('price_luck_six_2'); $price_luck_six_3 = Request::instance()->post('price_luck_six_3'); $price_big = Request::instance()->post('price_big'); $price_small = Request::instance()->post('price_small'); $price_dragon = Request::instance()->post('price_dragon'); $price_tiger = Request::instance()->post('price_tiger'); $price_tie_dt = Request::instance()->post('price_tie_dt'); $price_n0_n6 = Request::instance()->post('price_n0_n6'); $price_n7_n9 = Request::instance()->post('price_n7_n9'); $price_nn = Request::instance()->post('price_nn'); $price_5n = Request::instance()->post('price_5n'); $price_bomb = Request::instance()->post('price_bomb'); $win_limit = Request::instance()->post('win_limit'); $price_tc_n1 = round(Request::instance()->post('price_tc_n1'),2); $price_tc_n2 = round(Request::instance()->post('price_tc_n2'),2); $price_tc_n3 = round(Request::instance()->post('price_tc_n3'),2); $price_tc_n4 = round(Request::instance()->post('price_tc_n4'),2); $price_tc_n5 = round(Request::instance()->post('price_tc_n5'),2); $price_tc_n6 = round(Request::instance()->post('price_tc_n6'),2); $price_tc_n7 = round(Request::instance()->post('price_tc_n7'),2); $price_tc_n8 = round(Request::instance()->post('price_tc_n8'),2); $price_tc_n9 = round(Request::instance()->post('price_tc_n9'),2); $price_tc_nn = round(Request::instance()->post('price_tc_nn'),2); $price_tc_bz = round(Request::instance()->post('price_tc_bz'),2); $price_tc_ths = round(Request::instance()->post('price_tc_ths'),2); $price_tc_hjths = round(Request::instance()->post('price_tc_hjths'),2); // $agent_commission_tc = Request::instance()->post('agent_commission_tc'); // $agent_commission_tc_banker = Request::instance()->post('agent_commission_tc_banker'); // 父代理的洗码率 $agent = Db::name('user')->find($agent_id); // 检查是否为下级代理(非总代理),如果是则提示去代理后台修改 if($agent['agent_parent_id'] > 0){ $parent_agent = Db::name('user')->where('id', $agent['agent_parent_id'])->find(); $parent_name = $parent_agent ? $parent_agent['username'] : '上级代理'; die(json_encode(['code'=>0,'msg'=>'该代理为下级代理,请联系其上级代理【'.$parent_name.'】在代理后台进行修改'])); } //数据验证 if(empty($username)){ die(json_encode(['code'=>0,'msg'=>'会员账号不能为空!'])); } if(empty($nickname)){ die(json_encode(['code'=>0,'msg'=>'会员昵称不能为空!'])); } if(!empty($pass) && strlen($pass) < 6){ die(json_encode(['code'=>0,'msg'=>'密码长度不能少于6位!'])); } if(!empty($pass) && $pass != $repass){ die(json_encode(['code'=>0,'msg'=>'两次密码输入不一致!'])); } if( !in_array($agent_type,[1,2]) ){ die(json_encode(['code'=>0,'msg'=>'总代性质错误'])); } if( empty($pay_channel) ){ die(json_encode(['code'=>0,'msg'=>'请选择支付渠道'])); } if( !in_array($type_xima,[1,2]) ){ die(json_encode(['code'=>0,'msg'=>'洗码方式错误'])); } if( !in_array($share_xima,[1,2]) ){ die(json_encode(['code'=>0,'msg'=>'码量分担方式错误'])); } if($rebate_rate > 100 || $rebate_rate < 0){ die(json_encode(['code'=>0,'msg'=>'返水率只能取0-100之间'])); } if($ximalv > 100 || $ximalv < 0){ die(json_encode(['code'=>0,'msg'=>'百家乐码率只能取0-100之间'])); } if($ximalv_dt > 100 || $ximalv_dt < 0){ die(json_encode(['code'=>0,'msg'=>'龙虎码率只能取0-100之间'])); } if($ximalv_nn > 100 || $ximalv_nn < 0){ die(json_encode(['code'=>0,'msg'=>'牛牛码率只能取0-100之间'])); } if($ximalv_tc > 100 || $ximalv_tc < 0){ die(json_encode(['code'=>0,'msg'=>'牛牛码率只能取0-100之间'])); } if($cs > 100){ die(json_encode(['code'=>0,'msg'=>'占股不能超过100%!'])); } if($bet_type <= 0){ die(json_encode(['code'=>0,'msg'=>'请选择投注方式'])); } if($limit_low <= 0){ die(json_encode(['code'=>0,'msg'=>'最低限红必须大于0!'])); } if($limit_high <= 0){ die(json_encode(['code'=>0,'msg'=>'最高限红必须大于0!'])); } if($limit_low > $limit_high){ die(json_encode(['code'=>0,'msg'=>'最高限红必须大于最低限红!'])); } if($limit_low_tie <= 0){ die(json_encode(['code'=>0,'msg'=>'最低和限红必须大于0!'])); } if($limit_high_tie <= 0){ die(json_encode(['code'=>0,'msg'=>'最高和限红必须大于0!'])); } if($limit_low_tie > $limit_high_tie){ die(json_encode(['code'=>0,'msg'=>'最高和限红必须大于最低和限红!'])); } if($limit_low_pair <= 0){ die(json_encode(['code'=>0,'msg'=>'最低对子限红必须大于0!'])); } if($limit_high_pair <= 0){ die(json_encode(['code'=>0,'msg'=>'最高对子限红必须大于0!'])); } if($limit_low_pair > $limit_low_pair){ die(json_encode(['code'=>0,'msg'=>'最高对子限红必须大于最低对子限红!'])); } if($price_banker <= 0){ die(json_encode(['code'=>0,'msg'=>'押庄赔率必须大于0!'])); } if($price_player <= 0){ die(json_encode(['code'=>0,'msg'=>'押闲赔率必须大于0!'])); } if($price_tie_baccarat <= 0){ die(json_encode(['code'=>0,'msg'=>'押和(百家乐)赔率必须大于0!'])); } if($price_pair <= 0){ die(json_encode(['code'=>0,'msg'=>'押对子赔率必须大于0!'])); } if($price_luck_six_2 <= 0){ die(json_encode(['code'=>0,'msg'=>'两张牌幸运6赔率必须大于0!'])); } if($price_luck_six_3 <= 0){ die(json_encode(['code'=>0,'msg'=>'三张牌幸运6赔率必须大于0!'])); } if($price_big <= 0){ die(json_encode(['code'=>0,'msg'=>'押大赔率必须大于0!'])); } if($price_small <= 0){ die(json_encode(['code'=>0,'msg'=>'押小赔率必须大于0!'])); } if($price_dragon <= 0){ die(json_encode(['code'=>0,'msg'=>'押龙赔率必须大于0!'])); } if($price_tiger <= 0){ die(json_encode(['code'=>0,'msg'=>'押虎赔率必须大于0!'])); } if($price_tie_dt <= 0){ die(json_encode(['code'=>0,'msg'=>'押和(龙虎斗)赔率必须大于0!'])); } if($price_n0_n6 <= 0){ die(json_encode(['code'=>0,'msg'=>'押无牛-牛6赔率必须大于0!'])); } if($price_n7_n9 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛7-牛9赔率必须大于0!'])); } if($price_nn <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛牛赔率必须大于0!'])); } if($price_5n <= 0){ die(json_encode(['code'=>0,'msg'=>'押五公赔率必须大于0!'])); } if($price_bomb <= 0){ die(json_encode(['code'=>0,'msg'=>'押四条赔率必须大于0!'])); } if($price_tc_n1 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛一(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n2 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛二(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n3 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛三(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n4 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛四(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n5 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛五(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n6 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛六(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n7 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛七(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n8 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛八(三卡牛牛)赔率必须大于0!'])); } if($price_tc_n9 <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛九(三卡牛牛)赔率必须大于0!'])); } if($price_tc_nn <= 0){ die(json_encode(['code'=>0,'msg'=>'押牛牛(三卡牛牛)赔率必须大于0!'])); } if($price_tc_bz <= 0){ die(json_encode(['code'=>0,'msg'=>'押豹子(三卡牛牛)赔率必须大于0!'])); } if($price_tc_ths <= 0){ die(json_encode(['code'=>0,'msg'=>'押同花顺(三卡牛牛)赔率必须大于0!'])); } if($price_tc_hjths <= 0){ die(json_encode(['code'=>0,'msg'=>'押皇家同花顺(三卡牛牛)赔率必须大于0!'])); } // if($agent_commission_tc <= 0){ // die(json_encode(['code'=>0,'msg'=>'三卡牛牛系统抽水不能为空!'])); // } // if($agent_commission_tc_banker <= 0){ // die(json_encode(['code'=>0,'msg'=>'三卡牛牛系统抽佣不能为空!'])); // } if(empty($win_limit)){ die(json_encode(['code'=>0,'msg'=>'日赢上限不能为空!'])); } // 获取下级最高的洗码率和占股 $childWhere = array(); $childWhere['agent'] = 1; $childWhere['agent_parent_id'] = array('>',0); $childWhere['agent_parent_id_path'] = array('like',$agent_id.',%'); $childMaxCs = Db::name('user')->where($childWhere)->max('agent_cs'); $childMaxXimalv = Db::name('user')->where($childWhere)->max('agent_ximalv'); $childMaxXimalvDt = Db::name('user')->where($childWhere)->max('agent_ximalv_dt'); $childMaxXimalvNn = Db::name('user')->where($childWhere)->max('agent_ximalv_nn'); $childMaxXimalvTc = Db::name('user')->where($childWhere)->max('agent_ximalv_tc'); $childMaxRebateRate = Db::name('user')->where($childWhere)->max('rebate_rate'); if($cs < $childMaxCs){ die(json_encode(['code'=>0,'msg'=>'占股不能低于下级代理的占股 '.$childMaxCs.'%'])); } if($ximalv < $childMaxXimalv){ die(json_encode(['code'=>0,'msg'=>'百家乐码率不能低于下级代理的百家乐码率 '.$childMaxXimalv.'%'])); } if($ximalv_dt < $childMaxXimalvDt){ die(json_encode(['code'=>0,'msg'=>'龙虎码率不能低于下级代理的龙虎码率 '.$childMaxXimalvDt.'%'])); } if($ximalv_nn < $childMaxXimalvNn){ die(json_encode(['code'=>0,'msg'=>'牛牛码率不能低于下级代理的牛牛码率 '.$childMaxXimalvNn.'%'])); } if($ximalv_tc < $childMaxXimalvTc){ die(json_encode(['code'=>0,'msg'=>'三卡牛牛码率不能低于下级代理的三卡牛牛码率 '.$childMaxXimalvNn.'%'])); } if($rebate_rate < $childMaxRebateRate){ die(json_encode(['code'=>0,'msg'=>'返水率率不能低于下级代理的返水率 '.$childMaxRebateRate.'%'])); } // 拼装数据 $data = array(); $data['username'] = $username; $data['nickname'] = $nickname; if(!empty($pass)) $data['password'] = think_ucenter_md5($pass, UC_AUTH_KEY); $data['agent_type'] = $agent_type; $data['pay_channel'] = $pay_channel; $data['type_xima'] = $type_xima; $data['share_xima'] = $share_xima; $data['rebate_rate'] = $rebate_rate; $data['agent_ximalv'] = $ximalv; $data['agent_ximalv_dt'] = $ximalv_dt; $data['agent_ximalv_nn'] = $ximalv_nn; $data['agent_ximalv_tc'] = $ximalv_tc; $data['agent_cs'] = $cs; $data['mobile'] = $mobile; $data['email'] = $email; $data['bet_type'] = $bet_type; //$data['limit_money_ids'] = $limit_list; $data['limit_low'] = $limit_low; $data['limit_high'] = $limit_high; $data['limit_low_tie'] = $limit_low_tie; $data['limit_high_tie'] = $limit_high_tie; $data['limit_low_pair'] = $limit_low_pair; $data['limit_high_pair'] = $limit_high_pair; $data['update_time'] = time(); $data['price_banker'] = $price_banker; $data['price_player'] = $price_player; $data['price_tie_baccarat'] = $price_tie_baccarat; $data['price_pair'] = $price_pair; $data['price_luck_six_2'] = $price_luck_six_2; $data['price_luck_six_3'] = $price_luck_six_3; $data['price_big'] = $price_big; $data['price_small'] = $price_small; $data['price_dragon'] = $price_dragon; $data['price_tiger'] = $price_tiger; $data['price_tie_dt'] = $price_tie_dt; $data['price_n0_n6'] = $price_n0_n6; $data['price_n7_n9'] = $price_n7_n9; $data['price_nn'] = $price_nn; $data['price_5n'] = $price_5n; $data['price_bomb'] = $price_bomb; $data['win_limit'] = $win_limit; $data['price_tc_n1'] = $price_tc_n1; $data['price_tc_n2'] = $price_tc_n2; $data['price_tc_n3'] = $price_tc_n3; $data['price_tc_n4'] = $price_tc_n4; $data['price_tc_n5'] = $price_tc_n5; $data['price_tc_n6'] = $price_tc_n6; $data['price_tc_n7'] = $price_tc_n7; $data['price_tc_n8'] = $price_tc_n8; $data['price_tc_n9'] = $price_tc_n9; $data['price_tc_nn'] = $price_tc_nn; $data['price_tc_bz'] = $price_tc_bz; $data['price_tc_ths'] = $price_tc_ths; $data['price_tc_hjths'] = $price_tc_hjths; // $data['agent_commission_tc'] = $agent_commission_tc; // $data['agent_commission_tc_banker'] = $agent_commission_tc_banker; // 修改总代理信息 $result = Db::name('user')->where('id',$agent_id)->update($data); if($result){ insertAdminLog('修改代理','修改代理:| ID: '.$agent_id.' | 账号:'.$username); die(json_encode(['code'=>1,'msg'=>'修改成功!'])); }else{ die(json_encode(['code'=>0,'msg'=>'修改失败!'])); } }else{ die(json_encode(['code'=>0,'msg'=>'操作错误!'])); } } /** * 修改用户状态(锁定和解锁用户) */ public function change_status(){ if(Request::instance()->post()){ // 接收传过来的数据 $user_id = Request::instance()->post('user_id'); $status = Request::instance()->post('status'); // 数据验证 if( !isset($user_id) && empty($user_id) ){ die(json_encode(['code'=>0,'msg'=>'用户不能为空!'])); } if( !isset($status) && empty($status) ){ die(json_encode(['code'=>0,'msg'=>'状态不能为空!'])); } // 修改用户状态 $result = Db::name('user')->where('id',$user_id)->update(['status'=>$status]); if($status == 1) $msg = "解锁"; if($status == 0) $msg = "锁定"; if($result){ insertAdminLog($msg."代理",$msg."代理: | ID: ".$user_id); die(json_encode(['code'=>1,'msg'=>$msg.'成功!'])); }else{ die(json_encode(['code'=>0,'msg'=>$msg.'失败!'])); } }else{ die(json_encode(['code'=>0,'msg'=>'操作错误!'])); } } /** * 删除代理 */ public function agent_del(){ if(Request::instance()->post()){ // 接收数据 $user_id = Request::instance()->post('user_id'); // 数据验证 if(!$user_id){ die(json_encode(['code'=>0,'msg'=>'用户不存在'])); } // 删除用户 $result = Db::name('user')->where('id',$user_id)->update(array('is_delete' => 1)); $agent_info = Db::name('user')->where('id',$user_id)->find(); $result2 = Db::name('user')->where(array('agent_parent_id_path' => array('like',"%".$user_id.",%")))->update(array('is_delete' => 1)); if($result){ insertAdminLog('删除代理',"删除代理: | ID: ".$user_id.' | 账号:'.$agent_info['username']); die(json_encode(['code'=>1,'msg'=>'删除成功!'])); }else{ die(json_encode(['code'=>1,'msg'=>'删除失败!'])); } }else{ die(json_encode(['code'=>0,'msg'=>'操作错误!'])); } } /** * 代理上下分列表 */ public function scores(){ // 接收分页的条件 $get = Request::instance()->get(); $query = http_build_query($get); $this->assign('get',$get); $this->assign('query',$query); // 接收搜索的条件信息 $username = trim(Request::instance()->get('username')); $mode = Request::instance()->get('mode'); $startDate = Request::instance()->get('startDate'); $endDate = Request::instance()->get('endDate'); $export = Request::instance()->get('export'); // 时间条件 $startTime = 0; $endTime = time(); if($startDate) $startTime = strtotime($startDate); if($endDate) $endTime = strtotime($endDate); // 拼装搜索条件 $where = array(); if(intval(Request::instance()->get('agent_or_admin')) == 1) $where['agent_or_admin'] = intval(Request::instance()->get('agent_or_admin')); if(!empty($username)) $where['username_for'] = $username; if($mode > 0) $where['mode'] = $mode; $where['create_time'] = array('between',[$startTime,$endTime]); // $where['user_type'] = 1; // 导出excel if($export == 1){ $scoresList = Db::name('recharge')->where($where)->order('create_time desc')->select(); }else{ // 获取所有的代理上下分记录 $scoresList = Db::name('recharge')->where($where)->order('create_time desc')->paginate(15,false,array('query'=>$get)); } foreach($scoresList as $k => $v){ $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); if($v['type'] == 1){ $v['type_msg'] = ' (上分/下分)'; }elseif($v['type'] == 2){ $v['type_msg'] = ' (洗码)'; }elseif($v['type'] == 3){ $v['type_msg'] = ' (占股结算)'; }elseif($v['type'] == 4){ $v['type_msg'] = ' (代理抽水)'; }else{ $v['type_msg'] = ' (未知)'; } if($v['mode'] == 1){ $v['mode_msg'] = '上分'.$v['type_msg']; }elseif($v['mode'] == 2){ $v['mode_msg'] = '下分'.$v['type_msg']; } // 操作人 if($v['agent_or_admin'] == 1 && strlen($v['admin_user_name']) > 0){ $v['controller_username'] = $v['admin_user_name']; } if($v['agent_or_admin'] == 1){ $v['agent_or_admin_msg'] = '总台操作'; }else{ $v['agent_or_admin_msg'] = '代理操作'; } $scoresList[$k] = $v; } //导出excel列表 if($export == 1){ if($scoresList){ //重新组合 $excelData = array(); foreach($scoresList AS $k => $v){ $excelData[$k][0] = $v['username_for']; $excelData[$k][1] = $v['nickname_for']; $excelData[$k][2] = $v['mode_msg']; $excelData[$k][3] = $v['amount']; $excelData[$k][4] = $v['admin_user_name']; $excelData[$k][5] = $v['new_money']; $excelData[$k][6] = $v['create_time']; $excelData[$k][7] = $v['remake']; } $title = array('账号','联系人','操作类型','操作金额','操作人','余额','创建日期','备注'); if($startDate && $endDate){ $this->exportExcelCore($excelData, '代理上下分-'.$startDate."--".$endDate, $title); }else{ $this->exportExcelCore($excelData, '代理上下分', $title); } exit('已导出支持列表,请不要重复刷新该页面!'); }else{ exit('没有可以导出的列表!'); } } // 渲染参数和模板 $this->assign('scoresList',$scoresList); return $this->fetch('/agent/scores'); } /** * 代理上下分添加页面 */ public function scores_add(){ Session::set('allowSubmit','YES'); // 登录用户信息 $user_info = Session('user_info'); $user_info = Db::name('admin')->find($user_info['id']); // 渲染参数和模板 $this->assign('user_info',$user_info); return $this->fetch('/agent/scores_add'); } /** * 处理代理上下分 */ public function do_scores_add(){ if(Request::instance()->post()){ $user_info = Session::get('user_info'); $user_info = Db::name('admin')->find($user_info['id']); // 接收参数 $username = Request::instance()->post('username'); $amount = Request::instance()->post('amount'); $mode = Request::instance()->post('mode'); $controller = Request::instance()->post('controller'); $remarks = Request::instance()->post('remarks'); // 验证 if(!$username){ die(json_encode(['code'=>0,'msg'=>'请选择账号!'])); } if(!$amount){ die(json_encode(['code'=>0,'msg'=>'请填写操作金额!'])); } if($amount <= 0){ die(json_encode(['code'=>0,'msg'=>'操作金额必须大于0!'])); } if(!$mode){ die(json_encode(['code'=>0,'msg'=>'请选择操作类型!'])); } if(!$controller){ die(json_encode(['code'=>0,'msg'=>'操作用户不能为空!'])); } // 被操作的用户 $user = Db::name('user')->where('username',$username)->find(); if($user['agent_parent_id'] != 0){ die(json_encode(['code'=>0, 'msg'=>'只能为总代理上下分'])); } //防止重复提交 $allowSubmit = Session::get('allowSubmit'); if($allowSubmit == 'YES'){ Session::delete('allowSubmit'); }else{ Session::delete('allowSubmit'); die(json_encode(['errorCode' => 1, 'errorMessage' => "请勿重复提交"])); } // 上下分 if($amount > 0){ $charge_data = array(); $charge_data['amount'] = $amount; $charge_data['mode'] = $mode; $charge_data['agent_or_admin'] = 1; $charge_data['controller_type'] = '总后台系统操作'; $charge_data['user_id'] = $user['id']; $charge_data['user_type'] = $user['agent']; $charge_data['user_agent_level'] = $user['agent_level']; $charge_data['username_for'] = $user['username']; $charge_data['nickname_for'] = $user['nickname']; $charge_data['user_parent_id'] = $user['agent_parent_id']; $charge_data['create_time'] = time(); $charge_data['old_money'] = $user['money']; if($mode == 1) $charge_data['new_money'] = $user['money'] + $amount; if($mode == 2) $charge_data['new_money'] = $user['money'] - $amount; $charge_data['admin_id'] = $user_info['id']; $charge_data['admin_user_name'] = $user_info['admin']; $charge_data['remake'] = $remarks; $insertResult = Db::name('recharge')->insert($charge_data); if($insertResult){ //更新账户 $updateData = array(); if($mode == 1){ $updateData['money'] = $user['money'] + $amount; $updateData['recharge_total_amount'] = $user['recharge_total_amount'] + $amount; }elseif($mode == 2){ $updateData['money'] = $user['money'] - $amount; $updateData['recharge_total_amount'] = $user['recharge_total_amount'] - $amount; } $updateData['last_recharge'] = $amount; $updateData['last_recharge_time'] = time(); $updateData['recharge_count'] = $user['recharge_count'] + 1; Db::name('user')->where(array('id' => $user['id']))->update($updateData); } } die(json_encode(['code'=>1,'msg'=>'保存成功!'])); }else{ die(json_encode(['code'=>0,'msg'=>'操作错误!'])); } } /** * 代理上下分详情展示 */ public function scores_add_show(){ $user_info = Session::get('user_info'); $user_info = Db::name('admin')->find($user_info['id']); // 接收参数 $id = Request::instance()->get('id'); // 查询上下分记录 $recharge = Db::name('recharge')->find($id); if($recharge['mode'] == 1) $recharge['mode_msg'] = "上分"; if($recharge['mode'] == 2) $recharge['mode_msg'] = "下分"; // 渲染参数和模板 $this->assign('recharge',$recharge); $this->assign('user_info',$user_info); return $this->fetch('/agent/scores_add_show'); } /** * 获取所有代理信息 */ public function getAgent(){ // 接收关键字 $username = Request::instance()->post('username'); if($username){ $agent_list = Db::name('user')->where(array('agent' => 1, 'is_delete' => 0, 'agent_parent_id' => 0))->where(array('username' => $username))->select(); }else{ $agent_list = Db::name('user')->where(array('agent' => 1, 'is_delete' => 0, 'agent_parent_id' => 0))->select(); } // 渲染参数和模板 $this->assign('agent_list',$agent_list); die(json_encode($this->fetch('/agent/scores_agent_list'))); } /** * 获取代理余额 */ public function getAgentMoney(){ if(Request::instance()->post()){ // 接收账号 $username = Request::instance()->post('username'); $agent_money = Db::name('user')->where('username',$username)->value('money'); // 返回数据 die(json_encode($agent_money)); }else{ die(json_encode(['code'=>0,'msg'=>'操作错误!'])); } } public function agent_print(){ $get = Request::instance()->get(); $query = http_build_query($get); $username = Request::instance()->get('username'); $nickname = Request::instance()->get('nickname'); $agent_level = Request::instance()->get('agent_level'); $status = Request::instance()->get('status'); $startDate = Request::instance()->get('startDate'); $endDate = Request::instance()->get('endDate'); $startTime = 0; $endTime = time(); $where = array(); if(!empty($username)) $where['username'] = array('like',"%".$username."%"); if(!empty($nickname)) $where['nickname'] = array('like',"%".$nickname."%"); if($agent_level > 0) $where['agent_level'] = $agent_level; if($status > 0){ // 锁定不能用0作为判断,用2代替 if($status == 2){ $where['status'] = 0; }else{ $where['status'] = $status; } } if($startDate) $startTime = strtotime($startDate); if($endDate) $endTime = strtotime($endDate); $where['is_delete'] = 0; // 未删除 $where['agent'] = 1; // 代理 $where['reg_time'] = array('between',[$startTime,$endTime]); $agent_list = Db::name('user')->where($where)->order('reg_time desc')->select(); $agent_sum = Db::name('user')->where($where)->count(); foreach($agent_list as $k => $v){ $v['reg_time'] = date("Y-m-d H:i:s",$v['reg_time']); if($v['agent_level'] == 1) $v['agent_level_msg'] = "总代"; if($v['agent_level'] == 2) $v['agent_level_msg'] = "一级"; if($v['agent_level'] == 3) $v['agent_level_msg'] = "二级"; if($v['is_under'] == 0) $v['is_under'] = "否"; if($v['is_under'] == 1) $v['is_under'] = "是"; if(empty($v['nickname'])) $v['nickname'] = "无"; $agent_list[$k] = $v; } // 渲染变量和模板 $this->assign('agent_list',$agent_list); $this->assign('agent_sum',$agent_sum); return $this->fetch(); } public function scores_print(){ // 接收分页的条件 $get = Request::instance()->get(); $query = http_build_query($get); $this->assign('get',$get); $this->assign('query',$query); // 接收搜索的条件信息 $username = Request::instance()->get('username'); $agent_level = Request::instance()->get('agent_level'); $mode = Request::instance()->get('mode'); $startDate = Request::instance()->get('startDate'); $endDate = Request::instance()->get('endDate'); $where = array(); if(!empty($username)) $where['username_for'] = array('like',"%".$username."%"); if(!empty($agent_level) && $agent_level >= 0) $where['user_agent_level'] = $agent_level; if($mode > 0) $where['mode'] = $mode; $startTime = 0; $endTime = time(); if($startDate) $startTime = strtotime($startDate); if($endDate) $endTime = strtotime($endDate); $where['create_time'] = array('between',[$startTime,$endTime]); $where['user_type'] = 1; // 代理 $scoresList = Db::name('recharge')->where($where)->order('create_time desc')->select(); foreach($scoresList as $k => $v){ $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); if($v['mode'] == 1) $v['mode_msg'] = "上分"; if($v['mode'] == 2) $v['mode_msg'] = "下分"; if($v['user_agent_level'] == 1) $v['user_agent_level_msg'] = "总代"; if($v['user_agent_level'] == 2) $v['user_agent_level_msg'] = "一级"; if($v['user_agent_level'] == 3) $v['user_agent_level_msg'] = "二级"; $scoresList[$k] = $v; } // 渲染参数和模板 $this->assign('scoresList',$scoresList); return $this->fetch(); } public function profit(){ $where = array(); $where['is_delete'] = 0; $where['agent'] = 1; $where['id'] = ['>',1]; $zd_agent_list = Db::name('user')->where($where)->where('agent_parent_id',0)->field('id,username,nickname,agent_cs')->select(); $agent_list = array(); $agent_info = array(); foreach($zd_agent_list as $key => $value){ $agent_info['id'] = $value['id']; $agent_info['username'] = $value['username'].' | '.$value['nickname'].' | '.$value['agent_cs'].'%'; array_push($agent_list,$agent_info); $yj_agent_list = Db::name('user')->where('agent_parent_id',$value['id'])->where($where)->field('id,username,nickname,agent_cs')->select(); foreach ($yj_agent_list as $k => $v) { $agent_info['id'] = $v['id']; $agent_info['username'] = ' |__'.$v['username'].' | '.$v['nickname'].' | '.$v['agent_cs'].'%'; array_push($agent_list,$agent_info); $ej_agent_list = Db::name('user')->where('agent_parent_id',$v['id'])->where($where)->field('id,username,nickname,agent_cs')->select(); foreach ($ej_agent_list as $a => $b) { $agent_info['id'] = $b['id']; $agent_info['username'] = '     |__'.$b['username'].' | '.$b['nickname'].' | '.$b['agent_cs'].'%'; array_push($agent_list,$agent_info); $sj_agent_list = Db::name('user')->where('agent_parent_id',$b['id'])->where($where)->field('id,username,nickname,agent_cs')->select(); foreach ($sj_agent_list as $c => $d) { $agent_info['id'] = $d['id']; $agent_info['username'] = '         |__'.$d['username'].' | '.$d['nickname'].' | '.$d['agent_cs'].'%'; array_push($agent_list,$agent_info); } } } } $this->assign('agent_list',$agent_list); return $this->fetch(); } public function get_profit(){ $zd_agent = Request::instance()->post('zd_agent'); $start_time = Request::instance()->post('start_time'); $end_time = Request::instance()->post('end_time'); $start_time = strtotime($start_time); $end_time = strtotime($end_time); if($end_time-$start_time > 2678400){ die(json_encode(['code'=>0,'msg'=>'时间选择区间最多为一个月!'])); } if(!$zd_agent){ die(json_encode(['code'=>0,'msg'=>'请选择代理!'])); } $user_info = Db::name('user')->where('id',$zd_agent)->find(); $betwhere = array(); $betwhere['create_time'] = array('between',[$start_time,$end_time]); if($user_info['agent_parent_id'] == 0){ $betwhere['agent_parent_id_path'] = array('like',$zd_agent.',%'); }else{ $betwhere['agent_parent_id_path'] = array('like','%,'.$zd_agent.',%'); } $return_data = array(); //总上下水 $return_data['bet_win_total'] = Db::name('bet')->where($betwhere)->sum('win_total'); $return_data['bet_win_total'] = to_number($return_data['bet_win_total']); //归属总代上下水 $zs_player_list = Db::name('user')->where('agent_parent_id',$zd_agent)->where('agent',0)->field('id')->select(); $zs_player_list = array_column($zs_player_list, 'id'); $zs_player_win_total = Db::name('bet')->where($betwhere)->whereIn('user_id',$zs_player_list)->sum('win_total'); $zs_player_win_total = $zs_player_win_total*$user_info['agent_cs']/100; $zs_agent_list = Db::name('user')->where('agent_parent_id',$zd_agent)->where('agent',1)->field('id,username,agent_cs')->select(); if($zs_agent_list){ foreach ($zs_agent_list as $key => $value) { if($value['agent_cs'] < 100){ $zs_agent_win_total = Db::name('bet')->where('create_time','between',[$start_time,$end_time])->where('agent_parent_id_path','like','%,'.$value['id'].',%')->sum('win_total'); $zs_player_win_total = $zs_player_win_total + $zs_agent_win_total*(100-$value['agent_cs'])/100; } } } $return_data['zs_bet_win_total'] = to_number($zs_player_win_total); //码量 $return_data['maliang'] = Db::name('xima')->where('create_time','between',[$start_time,$end_time])->where('user_id',$zd_agent)->sum('maliang_cl'); $return_data['maliang'] = to_number($return_data['maliang']); //总收益 $return_data['total_profit'] = sprintf("%.2f",$return_data['zs_bet_win_total'] - $return_data['maliang']); //总押 $return_data['bet_amount'] = Db::name('bet')->where($betwhere)->sum('amount'); //玩家数量 $bet_play_num = Db::name('bet')->where($betwhere)->distinct(true)->field('user_id,username')->select(); $return_data['bet_play_num'] = count($bet_play_num); //百家乐总赢 $return_data['baccarat_win_towal'] = Db::name('bet')->where($betwhere)->where('game_id',1)->sum('win_total'); $return_data['baccarat_win_towal'] = to_number($return_data['baccarat_win_towal']); //龙虎总赢 $return_data['dt_win_towal'] = Db::name('bet')->where($betwhere)->where('game_id',2)->sum('win_total'); $return_data['dt_win_towal'] = to_number($return_data['dt_win_towal']); //牛牛总赢 $return_data['nn_win_towal'] = Db::name('bet')->where($betwhere)->where('game_id',4)->sum('win_total'); $return_data['nn_win_towal'] = to_number($return_data['nn_win_towal']); //三卡总赢 $return_data['tk_win_towal'] = Db::name('bet')->where($betwhere)->where('game_id',5)->sum('win_total'); $return_data['tk_win_towal'] = to_number($return_data['tk_win_towal']); if($return_data['bet_play_num'] > 0){ $play_win_list = array(); foreach ($bet_play_num as $k => $v) { $s_play_win_list = array(); $s_play_win_list['user_id'] = $v['user_id']; $s_play_win_list['username'] = $v['username']; $s_play_win_list['win_total'] = Db::name('bet')->where($betwhere)->where('user_id',$v['user_id'])->sum('win_total'); array_push($play_win_list, $s_play_win_list); } $win_total = array_column($play_win_list,'win_total'); array_multisort($win_total,SORT_DESC,$play_win_list); if($play_win_list[0]['win_total'] > 0){ $lucky_bet_amount = Db::name('bet')->where($betwhere)->where('user_id',$play_win_list[0]['user_id'])->sum('amount'); $lucky_bet_num = Db::name('bet')->where($betwhere)->where('user_id',$play_win_list[0]['user_id'])->count(); $lucky_arr = array(); $licky_win_total = array(); $lucky_win_baccarat = Db::name('bet')->where($betwhere)->where('game_id',1)->where('user_id',$play_win_list[0]['user_id'])->sum('win_total'); $licky_win_total['name'] = '百家乐'; $licky_win_total['person_win_total'] = $lucky_win_baccarat; array_push($lucky_arr, $licky_win_total); $lucky_win_dt = Db::name('bet')->where($betwhere)->where('game_id',2)->where('user_id',$play_win_list[0]['user_id'])->sum('win_total'); $licky_win_total['name'] = '龙虎'; $licky_win_total['person_win_total'] = $lucky_win_dt; array_push($lucky_arr, $licky_win_total); $lucky_win_nn = Db::name('bet')->where($betwhere)->where('game_id',4)->where('user_id',$play_win_list[0]['user_id'])->sum('win_total'); $licky_win_total['name'] = '牛牛'; $licky_win_total['person_win_total'] = $lucky_win_nn; array_push($lucky_arr, $licky_win_total); $lucky_win_tk = Db::name('bet')->where($betwhere)->where('game_id',5)->where('user_id',$play_win_list[0]['user_id'])->sum('win_total'); $licky_win_total = array(); $licky_win_total['name'] = '三卡牛牛'; $licky_win_total['person_win_total'] = $lucky_win_tk; array_push($lucky_arr, $licky_win_total); $person_win_total = array_column($lucky_arr,'person_win_total'); array_multisort($person_win_total,SORT_DESC,$lucky_arr); $return_data['lucky_palyer'] = ' 用户名:'.$play_win_list[0]['username'].' | 总赢:'.$play_win_list[0]['win_total'].' | 总押:'.$lucky_bet_amount.' | 注数:'.$lucky_bet_num.' | 赢最多的游戏:'.$lucky_arr[0]['name']; }else{ $return_data['lucky_palyer'] = '-'; } if($play_win_list[$return_data['bet_play_num']-1]['win_total'] < 0){ $fucking_bet_amount = Db::name('bet')->where($betwhere)->where('user_id',$play_win_list[$return_data['bet_play_num']-1]['user_id'])->sum('amount'); $fucking_bet_num = Db::name('bet')->where($betwhere)->where('user_id',$play_win_list[$return_data['bet_play_num']-1]['user_id'])->count(); $fucking_arr = array(); $licky_win_total = array(); $fucking_win_baccarat = Db::name('bet')->where($betwhere)->where('game_id',1)->where('user_id',$play_win_list[$return_data['bet_play_num']-1]['user_id'])->sum('win_total'); $licky_win_total['name'] = '百家乐'; $licky_win_total['person_win_total'] = $fucking_win_baccarat; array_push($fucking_arr, $licky_win_total); $fucking_win_dt = Db::name('bet')->where($betwhere)->where('game_id',2)->where('user_id',$play_win_list[$return_data['bet_play_num']-1]['user_id'])->sum('win_total'); $licky_win_total['name'] = '龙虎'; $licky_win_total['person_win_total'] = $fucking_win_dt; array_push($fucking_arr, $licky_win_total); $fucking_win_nn = Db::name('bet')->where($betwhere)->where('game_id',4)->where('user_id',$play_win_list[$return_data['bet_play_num']-1]['user_id'])->sum('win_total'); $licky_win_total['name'] = '牛牛'; $licky_win_total['person_win_total'] = $fucking_win_nn; array_push($fucking_arr, $licky_win_total); $fucking_win_tk = Db::name('bet')->where($betwhere)->where('game_id',5)->where('user_id',$play_win_list[$return_data['bet_play_num']-1]['user_id'])->sum('win_total'); $licky_win_total = array(); $licky_win_total['name'] = '三卡牛牛'; $licky_win_total['person_win_total'] = $fucking_win_tk; array_push($fucking_arr, $licky_win_total); $person_win_total = array_column($fucking_arr,'person_win_total'); array_multisort($person_win_total,SORT_DESC,$fucking_arr); $return_data['fucking_player'] = ' 用户名:'.$play_win_list[$return_data['bet_play_num']-1]['username'].' | 总输:'.$play_win_list[$return_data['bet_play_num']-1]['win_total'].' | 总押:'.$fucking_bet_amount.' | 注数:'.$fucking_bet_num.' | 输最多的游戏:'.$fucking_arr[3]['name']; }else{ $return_data['fucking_player'] = '-'; } }else{ $return_data['lucky_palyer'] = '-'; $return_data['fucking_player'] = '-'; } return json(['code'=>1,'data'=>$return_data]); } }