465 lines
18 KiB
PHP
465 lines
18 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
use think\Request;
|
|
use think\Session;
|
|
|
|
class Game extends Common{
|
|
public function delete_table(){
|
|
if(Request::instance()->isPost()){
|
|
$table_id = intval(Request::instance()->post('table_id'));
|
|
if($table_id > 0){
|
|
$status = Db::name('table')->where(array('id' => $table_id))->value('status');
|
|
if($status == 1){
|
|
Db::name('table')->where(array('id' => $table_id))->limit(1)->update(array('status' => 0));
|
|
}else{
|
|
Db::name('table')->where(array('id' => $table_id))->limit(1)->update(array('status' => 1));
|
|
}
|
|
return json(array('Success' => 1, 'Msg' => '操作成功'));
|
|
}else{
|
|
return json(array('Success' => 0, 'Msg' => '操作失败'));
|
|
}
|
|
}
|
|
}
|
|
public function index(){
|
|
$get = Request::instance()->get();
|
|
$query = http_build_query($get);
|
|
$this->assign('get',$get);
|
|
$this->assign('query',$query);
|
|
$table_name = trim(Request::instance()->get('table_name'));
|
|
$where = array();
|
|
if($table_name != ''){
|
|
$where['table_name'] = $table_name;
|
|
}
|
|
$table_info = Db::name('user_controller')->alias('a')->join('table b','a.table_id = b.id')->where($where)->order('table_id desc')->select();
|
|
foreach($table_info as $k => $v){
|
|
$v['number_total'] = Db::name('number_tab')->where('table_id',$v['id'])->count();
|
|
$v['boot_total'] = Db::name('boot')->where('table_id',$v['id'])->count();
|
|
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'] = '无';
|
|
}
|
|
|
|
$table_info[$k] = $v;
|
|
}
|
|
$this->assign('table_info',$table_info);
|
|
return $this->fetch();
|
|
}
|
|
public function edit_table_info(){
|
|
$table_id = Request::instance()->get('table_id');
|
|
$table_info = Db::name('user_controller')->alias('a')->join('table b','a.table_id = b.id')->where('is_delete',0)->where("table_id",$table_id)->find();
|
|
$table_info['min_bankerplayer'] = substr($table_info['limit_money'],0,strpos($table_info['limit_money'], '-'));
|
|
$table_info['max_bankerplayer'] = substr(strstr($table_info['limit_money'], '-'),1);
|
|
$table_info['min_tie'] = substr($table_info['limit_money_tie'],0,strpos($table_info['limit_money_tie'], '-'));
|
|
$table_info['max_tie'] = substr(strstr($table_info['limit_money_tie'], '-'),1);
|
|
$table_info['min_pair'] = substr($table_info['limit_money_pair'],0,strpos($table_info['limit_money_pair'], '-'));
|
|
$table_info['max_pair'] = substr(strstr($table_info['limit_money_pair'], '-'),1);
|
|
// 渲染参数和模板
|
|
$this->assign('table_info',$table_info);
|
|
return $this->fetch();
|
|
}
|
|
public function do_edit_table_info(){
|
|
$table_id = $this->request->param('table_id');
|
|
$table_info = Db::name('table')->where('id',$table_id)->find();
|
|
$table_num = $this->request->param('table_num');
|
|
$table_name = $this->request->param('table_name');
|
|
$bet_type = $this->request->param('bet_type');
|
|
$seat_num = $this->request->param('seat_num');
|
|
|
|
|
|
$min_bankerplayer = $this->request->param('min_bankerplayer');
|
|
$max_bankerplayer = $this->request->param('max_bankerplayer');
|
|
$min_tie = $this->request->param('min_tie');
|
|
$max_tie = $this->request->param('max_tie');
|
|
$min_pair = $this->request->param('min_pair');
|
|
$max_pair = $this->request->param('max_pair');
|
|
$wait_time = $this->request->param('wait_time');
|
|
$is_scavenging = $this->request->param('is_scavenging');
|
|
|
|
$newPassword = $this->request->param('newPassword');
|
|
$confirmNewPassword = $this->request->param('confirmNewPassword');
|
|
if($table_num <= 0){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写桌台号为数字!';
|
|
return $msg;
|
|
}
|
|
if(!$table_name){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写桌台名称!';
|
|
return $msg;
|
|
}
|
|
if($bet_type <= 0){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请选择投注方式!';
|
|
return $msg;
|
|
}
|
|
if(!$min_bankerplayer || !$max_bankerplayer){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写完整网络-庄闲限红!';
|
|
return $msg;
|
|
}
|
|
if($table_info['game_id'] == 1 || $table_info['game_id'] == 2){
|
|
if(!$min_tie || !$max_tie){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写完整网络-和限红!';
|
|
return $msg;
|
|
}
|
|
}
|
|
if($table_info['game_id'] == 1){
|
|
if(!$min_pair || !$max_pair){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写完整网络-对限红!';
|
|
return $msg;
|
|
}
|
|
}
|
|
if(!$wait_time){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写等待开牌时间!';
|
|
return $msg;
|
|
}
|
|
if($newPassword){
|
|
if(strlen($newPassword) < 6 || strlen($newPassword) > 20){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '密码长度必须是6到20个字符!';
|
|
return $msg;
|
|
}
|
|
if(!$confirmNewPassword){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请再次输入密码!';
|
|
return $msg;
|
|
}
|
|
if($newPassword != $confirmNewPassword){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '两次输入的密码不一致!';
|
|
return $msg;
|
|
}
|
|
}
|
|
if($confirmNewPassword){
|
|
if(!$newPassword){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写新密码!';
|
|
return $msg;
|
|
}
|
|
}
|
|
$update = array();
|
|
$update['b.table_num'] = $table_num;
|
|
$update['b.table_name'] = $table_name;
|
|
$update['b.bet_type'] = $bet_type;
|
|
$update['b.seat_num'] = $seat_num;
|
|
$update['b.limit_money'] = $min_bankerplayer.'-'.$max_bankerplayer;
|
|
if($table_info['game_id'] == 1 || $table_info['game_id'] == 2){
|
|
$update['b.limit_money_tie'] = $min_tie.'-'.$max_tie;
|
|
}
|
|
if($table_info['game_id'] == 1){
|
|
$update['b.limit_money_pair'] = $min_pair.'-'.$max_pair;
|
|
}
|
|
$update['b.wait_time'] = $wait_time;
|
|
$update['b.is_scavenging'] = $is_scavenging;
|
|
|
|
$update['b.media_far_rtmp'] = trim($this->request->param('media_far_rtmp'));
|
|
$update['b.media_far_flv'] = trim($this->request->param('media_far_flv'));
|
|
$update['b.media_far_ws'] = trim($this->request->param('media_far_ws'));
|
|
$update['b.media_near_rtmp'] = trim($this->request->param('media_near_rtmp'));
|
|
$update['b.media_near_flv'] = trim($this->request->param('media_near_flv'));
|
|
$update['b.media_near_ws'] = trim($this->request->param('media_near_ws'));
|
|
|
|
$update['b.limit_money_total'] = intval($this->request->param('limit_money_total'));
|
|
$update['b.limit_money_tie_total'] = intval($this->request->param('limit_money_tie_total'));
|
|
$update['b.limit_money_pair_total'] = intval($this->request->param('limit_money_pair_total'));
|
|
|
|
$update['b.sort'] = intval($this->request->param('sort'));
|
|
|
|
$update['b.interval_time'] = intval($this->request->param('interval_time'));
|
|
$update['b.card_first_type'] = intval($this->request->param('card_first_type'));
|
|
|
|
if($newPassword){
|
|
$update['a.password'] = think_ucenter_md5($newPassword,UC_AUTH_KEY);
|
|
}
|
|
$update['b.phone'] = trim($this->request->param('phone'));
|
|
if($update['b.phone']){
|
|
$findPhone = Db::name('table')->where(['phone'=>$update['b.phone']])->where('id','<>',$table_id)->find();
|
|
if($findPhone){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '手机号已被使用!';
|
|
return $msg;
|
|
}
|
|
}
|
|
Db::name('user_controller')->alias('a')->join('table b','a.table_id = b.id')->where('a.is_delete',0)->where("a.table_id",$table_id)->update($update);
|
|
$msg['status'] = 2;
|
|
$msg['code'] = '修改成功';
|
|
return $msg;
|
|
}
|
|
|
|
public function add_table(){
|
|
return $this->fetch();
|
|
}
|
|
public function do_add_table(){
|
|
$table['table_num'] = $this->request->param('table_num');
|
|
$table['table_name'] = $this->request->param('table_name');
|
|
$table['game_id'] = $this->request->param('game_id');
|
|
/*
|
|
if($table['game_id'] == 1){
|
|
$table['mode'] = $this->request->param('mode');
|
|
}
|
|
*/
|
|
$min_bankerplayer = $this->request->param('min_bankerplayer');
|
|
$max_bankerplayer = $this->request->param('max_bankerplayer');
|
|
if($table['game_id'] == 1 || $table['game_id'] == 2){
|
|
$min_tie = $this->request->param('min_tie');
|
|
$max_tie = $this->request->param('max_tie');
|
|
}
|
|
if($table['game_id'] == 1){
|
|
$min_pair = $this->request->param('min_pair');
|
|
$max_pair = $this->request->param('max_pair');
|
|
}
|
|
$wait_time = $this->request->param('wait_time');
|
|
$rob_time = $this->request->param('rob_time');
|
|
$is_scavenging = $this->request->param('is_scavenging');
|
|
$is_rob = $this->request->param('is_rob');
|
|
|
|
if (is_null($is_rob)) $is_rob = 0;
|
|
|
|
$remarks = $this->request->param('remarks');
|
|
$bet_type = $this->request->param('bet_type');
|
|
$controller['username'] = $this->request->param('username');
|
|
$newPassword = $this->request->param('newPassword');
|
|
$confirmNewPassword = $this->request->param('confirmNewPassword');
|
|
$controller['nickname'] = $this->request->param('nickname');
|
|
$table['phone'] = trim($this->request->param('phone'));
|
|
|
|
$is_localhost_control = intval($this->request->param('is_localhost_control'));
|
|
$limit_banker_amount = intval($this->request->param('limit_banker_amount'));
|
|
if($is_localhost_control == 1 && $is_scavenging == 1){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '桌子选择扫牌,则只能选择网络控制';
|
|
return $msg;
|
|
}
|
|
|
|
if($table['table_num'] <= 0){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写桌台号为数字!';
|
|
return $msg;
|
|
}
|
|
if(!$table['table_name']){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写桌台名称!';
|
|
return $msg;
|
|
}
|
|
$is_table_name = Db::name('table')->where(array('table_name' => $table['table_name'], 'status' => 1))->find();
|
|
if($is_table_name){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '该桌台已经存在,请输入新的桌台名称!';
|
|
return $msg;
|
|
}
|
|
if(!$table['game_id']){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请选择游戏名称!';
|
|
return $msg;
|
|
}
|
|
/*
|
|
if($table['game_id'] == 1){
|
|
if(!$table['mode']){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请选择游戏模式!';
|
|
return $msg;
|
|
}
|
|
}
|
|
*/
|
|
if($bet_type <= 0){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请选择游戏模式!';
|
|
return $msg;
|
|
}
|
|
if(!$min_bankerplayer || !$max_bankerplayer){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写完整网络-庄闲限红!';
|
|
return $msg;
|
|
}
|
|
if($table['game_id'] == 1 || $table['game_id'] == 2){
|
|
if(!$min_tie || !$max_tie){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写完整网络-和限红!';
|
|
return $msg;
|
|
}
|
|
}
|
|
if($table['game_id'] == 1){
|
|
if(!$min_pair || !$max_pair){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写完整网络-对限红!';
|
|
return $msg;
|
|
}
|
|
}
|
|
if(!$controller['username']){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写账户名!';
|
|
return $msg;
|
|
}
|
|
if(!$newPassword){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写密码!';
|
|
return $msg;
|
|
}
|
|
if(strlen($newPassword) < 6 || strlen($newPassword) > 20){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '密码长度必须是6到20个字符!';
|
|
return $msg;
|
|
}
|
|
if(!$confirmNewPassword){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请再次填写密码!';
|
|
return $msg;
|
|
}
|
|
if($newPassword != $confirmNewPassword){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '两次输入的密码不一致!';
|
|
return $msg;
|
|
}
|
|
if(!$controller['nickname']){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写昵称!';
|
|
return $msg;
|
|
}
|
|
if($table['game_id'] == 1){
|
|
$table['game_name'] = '百家乐';
|
|
$table['is_rob'] = 0;
|
|
}else if($table['game_id'] == 2){
|
|
$table['game_name'] = '龙虎斗';
|
|
/*
|
|
$table['mode'] = 0;
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
*/
|
|
$table['is_rob'] = 0;
|
|
}else if($table['game_id'] == 4){
|
|
$table['game_name'] = '牛牛';
|
|
/*
|
|
$table['mode'] = 0;
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
*/
|
|
$table['is_rob'] = $is_rob;
|
|
}else if($table['game_id'] == 5){
|
|
$table['game_name'] = '三卡牛牛';
|
|
/*
|
|
$table['mode'] = 0;
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
*/
|
|
$table['is_rob'] = $is_rob;
|
|
}else if($table['game_id'] == 6){
|
|
$table['game_name'] = '色碟';
|
|
/*
|
|
$table['mode'] = 0;
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
*/
|
|
$table['is_rob'] = $is_rob;
|
|
}else if($table['game_id'] == 7){
|
|
$table['game_name'] = '骰宝';
|
|
/*
|
|
$table['mode'] = 0;
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
*/
|
|
$table['is_rob'] = $is_rob;
|
|
}else if($table['game_id'] == 8){
|
|
$table['game_name'] = '轮盘';
|
|
/*
|
|
$table['mode'] = 0;
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
*/
|
|
$table['is_rob'] = $is_rob;
|
|
}
|
|
/*
|
|
if($table['mode'] == 1){
|
|
$table['special_num'] = 0;
|
|
$table['percent_num'] = 0.00;
|
|
}else if($table['mode'] == 2){
|
|
$table['special_num'] = 6;
|
|
$table['percent_num'] = 0.50;
|
|
}
|
|
*/
|
|
$table['table_limit'] = 0.00;
|
|
$table['limit_money'] = $min_bankerplayer.'-'.$max_bankerplayer;
|
|
if($table['game_id'] == 1 || $table['game_id'] == 2){
|
|
$table['limit_money_tie'] = $min_tie.'-'.$max_tie;
|
|
}
|
|
if($table['game_id'] == 1){
|
|
$table['limit_money_pair'] = $min_pair.'-'.$max_pair;
|
|
}
|
|
$table['is_scavenging'] = $is_scavenging;
|
|
// $table['is_rob'] = $is_rob;
|
|
if($table['game_id'] == 5){
|
|
if($table['is_rob'] == 1){
|
|
if(!$limit_banker_amount){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '请填写上庄金额!';
|
|
return $msg;
|
|
}
|
|
$table['limit_banker_amount'] = $limit_banker_amount;
|
|
}
|
|
}
|
|
$table['media_far_rtmp'] = trim($this->request->param('media_far_rtmp'));
|
|
$table['media_far_flv'] = trim($this->request->param('media_far_flv'));
|
|
$table['media_far_ws'] = trim($this->request->param('media_far_ws'));
|
|
$table['media_near_rtmp'] = trim($this->request->param('media_near_rtmp'));
|
|
$table['media_near_flv'] = trim($this->request->param('media_near_flv'));
|
|
$table['media_near_ws'] = trim($this->request->param('media_near_ws'));
|
|
$table['limit_money_total'] = intval($this->request->param('limit_money_total'));
|
|
$table['limit_money_tie_total'] = intval($this->request->param('limit_money_tie_total'));
|
|
$table['limit_money_pair_total'] = intval($this->request->param('limit_money_pair_total'));
|
|
|
|
$table['bet_type'] = $bet_type;
|
|
$table['is_localhost_control'] = $is_localhost_control;
|
|
|
|
$table['interval_time'] = intval($this->request->param('interval_time'));
|
|
$table['card_first_type'] = intval($this->request->param('card_first_type'));
|
|
|
|
$table['seat_num'] = intval($this->request->param('seat_num'));
|
|
|
|
if($remarks){
|
|
$table['remake'] = $remarks;
|
|
}
|
|
if($wait_time){
|
|
$table['wait_time'] = $wait_time;
|
|
}
|
|
if($table['phone']){
|
|
$findPhone = Db::name('table')->where(['phone'=>$table['phone']])->find();
|
|
if($findPhone){
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '手机号已被使用!';
|
|
return $msg;
|
|
}
|
|
}
|
|
|
|
$is_table = Db::name('table')->insert($table);
|
|
if($is_table == 1){
|
|
$controller['table_id'] = Db::name('table')->getLastInsID();
|
|
$controller['password'] = think_ucenter_md5($newPassword,UC_AUTH_KEY);
|
|
$controller['encrypt'] = getRandChar();
|
|
$is_controller = Db::name('user_controller')->insert($controller);
|
|
if($is_controller){
|
|
$msg['status'] = 2;
|
|
$msg['code'] = '添加成功!';
|
|
return $msg;
|
|
}else{
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '添加失败,请稍后再试!';
|
|
return $msg;
|
|
}
|
|
}else{
|
|
$msg['status'] = 1;
|
|
$msg['code'] = '添加失败,请稍后再试!';
|
|
return $msg;
|
|
}
|
|
}
|
|
}
|