411 lines
16 KiB
PHP
411 lines
16 KiB
PHP
<?php
|
|
namespace app\console\controller;
|
|
use think\Controller;
|
|
use think\Session;
|
|
use think\Request;
|
|
use think\Db;
|
|
use waybill\WayBill;
|
|
use think\Lang;
|
|
class Index Extends Common{
|
|
public function index(){
|
|
$user_info = Session::get('user_info');
|
|
$table_id = $user_info['table_id'];
|
|
$tableInfo = Db::name('table')->where(array('id' => $table_id))->find();
|
|
if($tableInfo['game_id'] == 2){
|
|
$this->redirect('/index/tab_dt',301);
|
|
}else if($tableInfo['game_id'] == 1 && $tableInfo['mode'] == 2){
|
|
$this->redirect('/index/tab_b_win6',301);
|
|
}else if($tableInfo['game_id'] == 1 && $tableInfo['mode'] != 2){
|
|
$this->redirect('/index/tab_b',301);
|
|
}else{
|
|
Session::clear();
|
|
$this->redirect('login/index',301);
|
|
}
|
|
$this->redirect('/index/tab_'.$table_id,301);
|
|
}
|
|
public function create_online_token($user){
|
|
$ip = getIP();
|
|
$time = time();
|
|
return md5($ip.$time.$user['encrypt'].$user['password']);
|
|
}
|
|
public function tab_b(){
|
|
$user_info = Session::get('user_info');
|
|
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
|
|
if(!$user) exit(Lang::get('userNotExit'));
|
|
$online_token = $this->create_online_token($user);
|
|
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
|
|
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
|
|
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
|
|
if($table['scene_limit_money']){
|
|
$scene_limit_money = explode('-', $table['scene_limit_money']);
|
|
}else{
|
|
$scene_limit_money = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_tie']){
|
|
$scene_limit_money_tie = explode('-', $table['scene_limit_money_tie']);
|
|
}else{
|
|
$scene_limit_money_tie = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_pair']){
|
|
$scene_limit_money_pair = explode('-', $table['scene_limit_money_pair']);
|
|
}else{
|
|
$scene_limit_money_pair = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_usd']){
|
|
$scene_limit_money_usd = explode('-', $table['scene_limit_money_usd']);
|
|
}else{
|
|
$scene_limit_money_usd = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_tie_usd']){
|
|
$scene_limit_money_tie_usd = explode('-', $table['scene_limit_money_tie_usd']);
|
|
}else{
|
|
$scene_limit_money_tie_usd = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_pair_usd']){
|
|
$scene_limit_money_pair_usd = explode('-', $table['scene_limit_money_pair_usd']);
|
|
}else{
|
|
$scene_limit_money_pair_usd = array(0,0);
|
|
}
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('scene_limit_money',$scene_limit_money);
|
|
$this->assign('scene_limit_money_tie',$scene_limit_money_tie);
|
|
$this->assign('scene_limit_money_pair',$scene_limit_money_pair);
|
|
$this->assign('scene_limit_money_usd',$scene_limit_money_usd);
|
|
$this->assign('scene_limit_money_tie_usd',$scene_limit_money_tie_usd);
|
|
$this->assign('scene_limit_money_pair_usd',$scene_limit_money_pair_usd);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('connections_url','connections_'.$table['port']);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
//$this->assign('websocketUrl',$table['ws_local_url']);
|
|
$this->assign('langType',$langType);
|
|
$this->assign('lang',$lang);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_b_auto');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
public function tab_b_win6(){
|
|
$user_info = Session::get('user_info');
|
|
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
|
|
if(!$user) exit(Lang::get('userNotExit'));
|
|
$online_token = $this->create_online_token($user);
|
|
Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
|
|
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
|
|
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
|
|
if($table['scene_limit_money']){
|
|
$scene_limit_money = explode('-', $table['scene_limit_money']);
|
|
}else{
|
|
$scene_limit_money = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_tie']){
|
|
$scene_limit_money_tie = explode('-', $table['scene_limit_money_tie']);
|
|
}else{
|
|
$scene_limit_money_tie = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_pair']){
|
|
$scene_limit_money_pair = explode('-', $table['scene_limit_money_pair']);
|
|
}else{
|
|
$scene_limit_money_pair = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_usd']){
|
|
$scene_limit_money_usd = explode('-', $table['scene_limit_money_usd']);
|
|
}else{
|
|
$scene_limit_money_usd = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_tie_usd']){
|
|
$scene_limit_money_tie_usd = explode('-', $table['scene_limit_money_tie_usd']);
|
|
}else{
|
|
$scene_limit_money_tie_usd = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_pair_usd']){
|
|
$scene_limit_money_pair_usd = explode('-', $table['scene_limit_money_pair_usd']);
|
|
}else{
|
|
$scene_limit_money_pair_usd = array(0,0);
|
|
}
|
|
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('langType',$langType);
|
|
$this->assign('lang',$lang);
|
|
$this->assign('scene_limit_money',$scene_limit_money);
|
|
$this->assign('scene_limit_money_tie',$scene_limit_money_tie);
|
|
$this->assign('scene_limit_money_pair',$scene_limit_money_pair);
|
|
$this->assign('scene_limit_money_usd',$scene_limit_money_usd);
|
|
$this->assign('scene_limit_money_tie_usd',$scene_limit_money_tie_usd);
|
|
$this->assign('scene_limit_money_pair_usd',$scene_limit_money_pair_usd);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('connections_url','connections_'.$table['port']);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
//$this->assign('websocketUrl',$table['ws_local_url']);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_b_win6_auto');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
public function tab_dt(){
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
$user_info = Session::get('user_info');
|
|
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
|
|
if(!$user) exit(Lang::get('userNotExit'));
|
|
$online_token = $this->create_online_token($user);
|
|
Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
|
|
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
|
|
$memo = Db::name('memo')->where('table_id',$table['id'])->where('position',['=',2],['=',3],'or')->where('status',1)->order('id desc')->limit(1)->find();
|
|
if($table['scene_limit_money']){
|
|
$scene_limit_money = explode('-', $table['scene_limit_money']);
|
|
}else{
|
|
$scene_limit_money = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_tie']){
|
|
$scene_limit_money_tie = explode('-', $table['scene_limit_money_tie']);
|
|
}else{
|
|
$scene_limit_money_tie = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_usd']){
|
|
$scene_limit_money_usd = explode('-', $table['scene_limit_money_usd']);
|
|
}else{
|
|
$scene_limit_money_usd = array(0,0);
|
|
}
|
|
if($table['scene_limit_money_tie_usd']){
|
|
$scene_limit_money_tie_usd = explode('-', $table['scene_limit_money_tie_usd']);
|
|
}else{
|
|
$scene_limit_money_tie_usd = array(0,0);
|
|
}
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('lang',$lang);
|
|
$this->assign('langType',$langType);
|
|
$this->assign('scene_limit_money',$scene_limit_money);
|
|
$this->assign('scene_limit_money_tie',$scene_limit_money_tie);
|
|
|
|
$this->assign('scene_limit_money_usd',$scene_limit_money_usd);
|
|
$this->assign('scene_limit_money_tie_usd',$scene_limit_money_tie_usd);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('connections_url','connections_'.$table['port']);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
//$this->assign('websocketUrl',$table['ws_local_url']);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_dt_auto');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
//获取当前靴的结果汇总
|
|
public function get_result_total(){
|
|
if(Request::instance()->isPost()){
|
|
//获取路单对象
|
|
$table_id = Request::instance()->post('table_id');
|
|
$boot_id = Request::instance()->post('boot_id');
|
|
$game_id = Db::name('table')->where(array('id' => $table_id))->value('game_id');
|
|
$result = array();
|
|
if($game_id == 1){
|
|
//百家乐
|
|
$result['banker'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'result' => 1))->count();
|
|
$result['player'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'result' => 2))->count();
|
|
$result['tie'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'result' => 3))->count();
|
|
$result['bankerPair'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'pair' => 1))->count();
|
|
$result['playerPair'] = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'pair' => 2))->count();
|
|
$both = Db::name('number_tab')->where(array('boot_id' => $boot_id, 'pair' => 3))->count();
|
|
$result['bankerPair'] = $result['bankerPair'] + $both;
|
|
$result['playerPair'] = $result['playerPair'] + $both;
|
|
}else if($game_id == 2){
|
|
//龙虎
|
|
$result['banker'] = Db::name('number_tab_dt')->where(array('boot_id' => $boot_id, 'result' => 1))->count();
|
|
$result['player'] = Db::name('number_tab_dt')->where(array('boot_id' => $boot_id, 'result' => 2))->count();
|
|
$result['tie'] = Db::name('number_tab_dt')->where(array('boot_id' => $boot_id, 'result' => 3))->count();
|
|
}else if($game_id == 3){
|
|
//龙虎
|
|
$result['banker'] = Db::name('number_tab_dn')->where(array('boot_id' => $boot_id, 'result' => 1))->count();
|
|
$result['player'] = Db::name('number_tab_dn')->where(array('boot_id' => $boot_id, 'result' => 2))->count();
|
|
}
|
|
return json(['code'=>1,'data'=>$result]);
|
|
}
|
|
}
|
|
//获取当前在线人数
|
|
public function get_online_number(){
|
|
if(Request::instance()->isPost()){
|
|
//获取路单对象
|
|
$connections = Request::instance()->post('connections');
|
|
$redis = new \Redis();
|
|
$redis->connect('127.0.0.1',6379);
|
|
$connections = json_decode($redis->get($connections),true);
|
|
$count = is_array($connections) ? count($connections) : 0;
|
|
return json(['code'=>1,'data'=>$count]);
|
|
}
|
|
}
|
|
//打印
|
|
public function stamp(){
|
|
$game_id = intval(Request::instance()->get('game_id'));
|
|
$nid = intval(Request::instance()->get('nid'));
|
|
if($game_id == 1){
|
|
$number_tab = Db::name('number_tab')->where(array('id' => $nid))->find();
|
|
if($number_tab){
|
|
$boot = Db::name('boot')->where(array('id' => $number_tab['boot_id']))->find();
|
|
$table = Db::name('table')->where(array('id' => $number_tab['table_id']))->find();
|
|
}
|
|
}elseif($game_id == 2){
|
|
$number_tab = Db::name('number_tab_dt')->where(array('id' => $nid))->find();
|
|
if($number_tab){
|
|
$boot = Db::name('boot_dt')->where(array('id' => $number_tab['boot_id']))->find();
|
|
$table = Db::name('table')->where(array('id' => $number_tab['table_id']))->find();
|
|
}
|
|
}
|
|
if($number_tab && $boot && $table){
|
|
$this->assign('nowTime',date('Y-m-d H:i:s',time()));
|
|
$this->assign('tableName',$table['table_name']);
|
|
$this->assign('bootTime',date('Y-m-d H:i:s',$boot['create_time']));
|
|
$this->assign('nTime',date('Y-m-d H:i:s',$number_tab['start_time']));
|
|
}else{
|
|
$this->assign('nowTime',date('Y-m-d H:i:s',time()));
|
|
$this->assign('tableName','');
|
|
$this->assign('bootTime','');
|
|
$this->assign('nTime','');
|
|
}
|
|
return $this->fetch(); // 渲染模板
|
|
}
|
|
|
|
// 路单接口调用
|
|
public function waybill(){
|
|
if(Request::instance()->post()){
|
|
// 接收游戏ID和靴ID
|
|
$game_id = Request::instance()->post('game_id');
|
|
$boot_id = Request::instance()->post('boot_id');
|
|
$forecast = Request::instance()->post('forecast');
|
|
|
|
//验证游戏ID
|
|
if($game_id == 1){
|
|
$numberTabTable = 'number_tab';
|
|
}elseif($game_id == 2){
|
|
$numberTabTable = 'number_tab_dt';
|
|
}elseif($game_id == 3){
|
|
$numberTabTable = 'number_tab_dn';
|
|
}else{
|
|
die(json_encode(['status'=>false,'msg'=>'游戏ID错误']));
|
|
}
|
|
|
|
// 验证靴ID
|
|
if($boot_id > 0){
|
|
$ns = Db::name($numberTabTable)->where(array('boot_id' => $boot_id, 'bet_status' => 3))->field('result,pair')->order('start_time ASC,id ASC')->select();
|
|
if($forecast == 1){
|
|
// 庄问路
|
|
$ns[] = array('result'=>1,'pair'=>0);
|
|
}elseif($forecast == 2){
|
|
// 闲问路
|
|
$ns[] = array('result'=>2,'pair'=>0);
|
|
}
|
|
// 数据存在,输出路单
|
|
if($ns){
|
|
$result = waybill($ns);
|
|
die(json_encode($result));
|
|
}else{
|
|
$waybill = array();
|
|
$waybill['bigEyeRoad'] = [];
|
|
$waybill['bigRoad'] = [];
|
|
$waybill['pathway'] = [];
|
|
$waybill['roach'] = [];
|
|
$waybill['showRoad'] = [];
|
|
die(json_encode(['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]));
|
|
}
|
|
}else{
|
|
die(json_encode(['status'=>false,'msg'=>'靴ID错误']));
|
|
}
|
|
|
|
}else{
|
|
die(json_encode(['status'=>false,'msg'=>'操作错误']));
|
|
}
|
|
|
|
}
|
|
|
|
public function lang() {
|
|
switch ($_GET['lang']) {
|
|
case 'cn':
|
|
cookie('think_var', 'zh-cn');
|
|
break;
|
|
case 'tw':
|
|
cookie('think_var', 'zh-tw');
|
|
break;
|
|
case 'en':
|
|
cookie('think_var', 'en-us');
|
|
break;
|
|
//其它语言
|
|
}
|
|
}
|
|
public function get_number(){
|
|
if(Request::instance()->post() && intval(Request::instance()->post('number_tab_id')) > 0){
|
|
$number_tab_id = intval(Request::instance()->post('number_tab_id'));
|
|
$number = Db::name('number_tab')->where(array('id' => $number_tab_id))->value('number');
|
|
return json(array('data' => $number,'status' => 1));
|
|
}else{
|
|
return json(array('msg' => '数据出错','status' => 0));
|
|
}
|
|
}
|
|
public function get_number_dt(){
|
|
if(Request::instance()->post() && intval(Request::instance()->post('number_tab_id')) > 0){
|
|
$number_tab_id = intval(Request::instance()->post('number_tab_id'));
|
|
$number = Db::name('number_tab_dt')->where(array('id' => $number_tab_id))->value('number');
|
|
return json(array('data' => $number,'status' => 1));
|
|
}else{
|
|
return json(array('msg' => '数据出错','status' => 0));
|
|
}
|
|
}
|
|
//获取上一局number_tab_id
|
|
public function get_last_number_tab_id(){
|
|
if(Request::instance()->post() && intval(Request::instance()->post('game_id')) > 0){
|
|
$game_id = intval(Request::instance()->post('game_id'));
|
|
if($game_id == 1){
|
|
$numberTabTableName = 'number_tab';
|
|
$bootTableName = 'boot';
|
|
}elseif($game_id == 2){
|
|
$numberTabTableName = 'number_tab_dt';
|
|
$bootTableName = 'boot_dt';
|
|
}else{
|
|
return json(array('msg' => '数据出错','status' => 0));
|
|
}
|
|
$table_id = intval(Request::instance()->post('table_id'));
|
|
$boot_id = intval(Request::instance()->post('boot_id'));
|
|
if($table_id > 0 && $boot_id > 0){
|
|
$table_info = Db::name('table')->where('id',$table_id)->find();
|
|
if($table_info['table_type'] == 0){
|
|
if($table_info['bet_type'] != 2){
|
|
return json(array('msg' => '该桌不允许删除露珠','status' => 0));
|
|
}
|
|
}
|
|
$lastNumberTabTableId = Db::name($numberTabTableName)->where(array('game_id' => $game_id, 'table_id' => $table_id, 'boot_id' => $boot_id, 'bet_status' => 3))->order('id DESC')->limit(1)->value('id');
|
|
if($lastNumberTabTableId > 0){
|
|
return json(array('data' => $lastNumberTabTableId,'status' => 1));
|
|
}else{
|
|
return json(array('msg' => '没有可删除的上一铺','status' => 0));
|
|
}
|
|
}
|
|
return json(array('data' => $number,'status' => 1));
|
|
}else{
|
|
return json(array('msg' => '数据出错','status' => 0));
|
|
}
|
|
}
|
|
|
|
}
|