384 lines
14 KiB
PHP
384 lines
14 KiB
PHP
<?php
|
|
namespace app\deal\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 create_online_token($user){
|
|
$ip = getIP();
|
|
$time = time();
|
|
return md5($user['encrypt'].$user['password']);
|
|
}
|
|
public function tab_baccarat(){
|
|
$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();
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('doIsOpening',DO_IS_OPENING);
|
|
$this->assign('localPhoneWS',LOCAL_PHONE_WS);
|
|
$this->assign('lang',$lang);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
$this->assign('langType',$langType);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_b_auto');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
public function tab_baccarat_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();
|
|
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('langType',$langType);
|
|
$this->assign('lang',$lang);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_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();
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('doIsOpening',DO_IS_OPENING);
|
|
$this->assign('localPhoneWS',LOCAL_PHONE_WS);
|
|
$this->assign('lang',$lang);
|
|
$this->assign('langType',$langType);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_dt_auto');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
public function tab_nn(){
|
|
$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();
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('localPhoneWS',LOCAL_PHONE_WS);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
$this->assign('langType',$langType);
|
|
$this->assign('lang',$lang);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_nn');
|
|
}else{
|
|
exit('is_scavengingis error');
|
|
}
|
|
}
|
|
public function tab_knn(){
|
|
$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();
|
|
// 获取语言包信息
|
|
$langType = cookie('think_var');
|
|
$lang = Lang::get();
|
|
$lang = json_encode($lang);
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('localPhoneWS',LOCAL_PHONE_WS);
|
|
$this->assign('memo',$memo);
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
$this->assign('langType',$langType);
|
|
$this->assign('lang',$lang);
|
|
if($table['is_scavenging'] == 1){
|
|
return $this->fetch('/index/tab_knn');
|
|
}else{
|
|
exit('is_scavengingis error');
|
|
}
|
|
}
|
|
//获取当前靴的结果汇总
|
|
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('table_id' => $table_id, 'boot_id' => $boot_id, 'result' => 1))->count();
|
|
$result['player'] = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'result' => 2))->count();
|
|
$result['tie'] = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'result' => 3))->count();
|
|
$result['bankerPair'] = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'pair' => 1))->count();
|
|
$result['playerPair'] = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'pair' => 2))->count();
|
|
$both = Db::name('number_tab')->where(array('table_id' => $table_id, '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')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'result' => 1))->count();
|
|
$result['player'] = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'result' => 2))->count();
|
|
$result['tie'] = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'result' => 3))->count();
|
|
}
|
|
return json(['code'=>1,'data'=>$result]);
|
|
}
|
|
}
|
|
//获取当前靴的结果汇总
|
|
public function get_result_total_nn(){
|
|
if(Request::instance()->isPost()){
|
|
//获取路单对象
|
|
$table_id = Request::instance()->post('table_id');
|
|
$boot_id = Request::instance()->post('boot_id');
|
|
$banker_total = 0;
|
|
$player_total = 0;
|
|
$result = array();
|
|
$all_result = Db::name('number_tab_nn')->where(array('table_id' => $table_id, 'boot_id' => $boot_id,'bet_status'=>3))->select();
|
|
foreach($all_result as $k => $v){
|
|
if($v['win_player_1'] == 1){
|
|
$player_total++;
|
|
}elseif($v['win_player_1'] == 0){
|
|
$banker_total++;
|
|
}
|
|
if($v['win_player_2'] == 1){
|
|
$player_total++;
|
|
}elseif($v['win_player_2'] == 0){
|
|
$banker_total++;
|
|
}
|
|
if($v['win_player_3'] == 1){
|
|
$player_total++;
|
|
}elseif($v['win_player_3'] == 0){
|
|
$banker_total++;
|
|
}
|
|
|
|
}
|
|
$result['banker'] = $banker_total;
|
|
$result['player'] = $player_total;
|
|
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 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 > 0){
|
|
$numberTabTable = 'number_tab';
|
|
}else{
|
|
return json(['status'=>false,'msg'=>'游戏ID错误']);
|
|
}
|
|
|
|
// 验证靴ID
|
|
if($boot_id > 0){
|
|
$ns = Db::name($numberTabTable)->where(array('game_id' => $game_id, '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);
|
|
return json($result);
|
|
}else{
|
|
$waybill = array();
|
|
$waybill['bigEyeRoad'] = [];
|
|
$waybill['bigRoad'] = [];
|
|
$waybill['pathway'] = [];
|
|
$waybill['roach'] = [];
|
|
$waybill['showRoad'] = [];
|
|
return json(['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]);
|
|
}
|
|
}else{
|
|
return json(['status'=>false,'msg'=>'靴ID错误']);
|
|
}
|
|
|
|
}else{
|
|
return json(['status'=>false,'msg'=>'操作错误']);
|
|
}
|
|
|
|
}
|
|
// 路单接口调用
|
|
public function waybill_nn(){
|
|
if(Request::instance()->post()){
|
|
// 接收游戏ID和靴ID
|
|
$game_id = Request::instance()->post('game_id');
|
|
$boot_id = Request::instance()->post('boot_id');
|
|
|
|
//验证游戏ID
|
|
if($game_id == 4 || $game_id == 5){
|
|
$numberTabTable = 'number_tab';
|
|
}else{
|
|
return json(['status'=>false,'msg'=>'游戏ID错误']);
|
|
}
|
|
|
|
// 验证靴ID
|
|
if($boot_id > 0){
|
|
$ns = Db::name($numberTabTable)->where(array('game_id' => $game_id, 'boot_id' => $boot_id, 'bet_status' => 3))->field('result_banker,result_player_1,result_player_2,result_player_3,win_player_1,win_player_2,win_player_3')->order('start_time ASC,id ASC')->select();
|
|
// 数据存在,输出路单
|
|
if($ns){
|
|
$result = nn_waybill($ns);
|
|
return json($result);
|
|
}else{
|
|
$waybill = array();
|
|
return json(['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]);
|
|
}
|
|
}else{
|
|
return json(['status'=>false,'msg'=>'靴ID错误']);
|
|
}
|
|
|
|
}else{
|
|
return json(['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_nn_num(){
|
|
if(Request::instance()->post()){
|
|
$result_arr = Request::instance()->post('result_json');
|
|
$result = JudgeCowCow(json_decode($result_arr,true));
|
|
return json(['status'=>true,'msg'=>$result['word']]);
|
|
}else{
|
|
return json(['status'=>false,'msg'=>'操作错误']);
|
|
}
|
|
}
|
|
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 > 0){
|
|
$numberTabTableName = 'number_tab';
|
|
}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));
|
|
}
|
|
}
|
|
}
|