where('id',$sess_user_info['id'])->find(); $table_info = Db::name('table')->where('game_id','in',[1,2,4,5])->where('status = 1 or is_contracted = 1')->where('table_type',0)->order('game_id asc')->order('sort asc')->field(['id','table_name','game_id','table_num','game_name','in_checkout','is_contracted'])->select(); $bet_person = 0; $websocketUrl = LOCAL_TRACKER_SERVER; $websocketProtocol = LOCAL_TRACKER_PROTOCOL; foreach ($table_info as $k => $v) { $number_form = 'number_tab'; $bet_form = 'bet'; $number_tab = Db::name($number_form)->where('table_id',$v['id'])->order('id desc')->find(); if($number_tab['bet_status'] == 0){ $v['status'] = '等待'; }elseif($number_tab['bet_status'] == 1){ $v['status'] = '接受下注'; }elseif($number_tab['bet_status'] == 2){ $v['status'] = '下注结束'; }elseif($number_tab['bet_status'] == 3){ $v['status'] = '开出结果'; } if($number_tab['boot_num']){ $v['boot_num'] = $number_tab['boot_num']; }else{ $v['boot_num'] = 0; } if($number_tab['number']){ $v['number'] = $number_tab['number']; }else{ $v['number'] = 0; } if($number_tab['boot_id']){ $v['boot_id'] = $number_tab['boot_id']; }else{ $v['boot_id'] = 0; } $sw_amount = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$v['id']) ->where('b.game_id',$v['game_id']) ->where('b.boot_id',$v['boot_id']) ->where('b.number',$v['number']) ->where('b.status',1) ->where('u.is_sw',1) ->field('SUM(b.banker_amount) as banker_amount, SUM(b.player_amount) as player_amount, SUM(b.tie_amount) as tie_amount, SUM(b.luck_six_amount) as luck_six_amount, SUM(b.big_amount) as big_amount, SUM(b.small_amount) as small_amount, SUM(b.banker_pair_amount) as banker_pair_amount, SUM(b.player_pair_amount) as player_pair_amount, SUM(b.amount_player_1) as amount_player_1, SUM(b.amount_player_2) as amount_player_2, SUM(b.amount_player_3) as amount_player_3, SUM(b.amount_player_1_times) as amount_player_1_times, SUM(b.amount_player_2_times) as amount_player_2_times, SUM(b.amount_player_3_times) as amount_player_3_times' ) ->find(); if($v['game_id'] == 1 || $v['game_id'] == 2){ $v['banker_amount'] = floor($number_tab['banker_amount'] - (int)$sw_amount['banker_amount']); $v['player_amount'] = floor($number_tab['player_amount'] - (int)$sw_amount['player_amount']); $v['tie_amount'] = floor($number_tab['tie_amount'] - (int)$sw_amount['tie_amount']); if($v['game_id'] == 1){ $v['banker_pair_amount'] = floor($number_tab['banker_pair_amount'] - (int)$sw_amount['banker_pair_amount']); $v['player_pair_amount'] = floor($number_tab['player_pair_amount'] - (int)$sw_amount['player_pair_amount']); $v['luck_six_amount'] = floor($number_tab['luck_six_amount'] - (int)$sw_amount['luck_six_amount']); $v['big_amount'] = floor($number_tab['big_amount'] - (int)$sw_amount['big_amount']); $v['small_amount'] = floor($number_tab['small_amount'] - (int)$sw_amount['small_amount']); } $v['difference'] = $v['banker_amount'] - $v['player_amount']; if($v['difference'] > 0){ $v['difference_type'] = 1; }elseif($v['difference'] < 0){ $v['difference'] = to_number($v['difference']); $v['difference_type'] = 2; }else{ $v['difference_type'] = 3; } $ns = Db::name($number_form)->where(array('boot_id' => $number_tab['boot_id'], 'bet_status' => 3))->field('result,pair')->order('start_time ASC,id ASC')->select(); // 数据存在,输出路单 if($ns){ $result = waybill($ns); $v['waybill'] = $result; }else{ $waybill = array(); $waybill['bigEyeRoad'] = []; $waybill['bigRoad'] = []; $waybill['pathway'] = []; $waybill['roach'] = []; $waybill['showRoad'] = []; $v['waybill'] = ['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]; } } if($v['game_id'] == 4 || $v['game_id'] == 5){ $v['amount_player_1'] = floor($number_tab['amount_player_1'] - (int)$sw_amount['amount_player_1']); $v['amount_player_2'] = floor($number_tab['amount_player_2'] - (int)$sw_amount['amount_player_2']); $v['amount_player_3'] = floor($number_tab['amount_player_3'] - (int)$sw_amount['amount_player_3']); $v['amount_player_1_times'] = floor($number_tab['amount_player_1_times'] - (int)$sw_amount['amount_player_1_times']); $v['amount_player_2_times'] = floor($number_tab['amount_player_2_times'] - (int)$sw_amount['amount_player_2_times']); $v['amount_player_3_times'] = floor($number_tab['amount_player_3_times'] - (int)$sw_amount['amount_player_3_times']); $waybill = array(); $waybill['bigEyeRoad'] = []; $waybill['bigRoad'] = []; $waybill['pathway'] = []; $waybill['roach'] = []; $waybill['showRoad'] = []; $v['waybill'] = ['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]; } if($v['game_id'] == 1 || $v['game_id'] == 2){ $v['banker_forecast'] = 0; $v['player_forecast'] = 0; $v['tie_forecast'] = 0; $v['banker_pair_forecast'] = 0; $v['player_pair_forecast'] = 0; $v['luck_six_2_forecast'] = 0; $v['luck_six_3_forecast'] = 0; $v['big_forecast'] = 0; $v['small_forecast'] = 0; }elseif($v['game_id'] == 4){ $v['player_1_forecast'] = 0; $v['player_1_times_n1_n6_forecast'] = 0; $v['player_1_times_n7_n9_forecast'] = 0; $v['player_1_times_nn_forecast'] = 0; $v['player_1_times_5n_forecast'] = 0; $v['player_2_forecast'] = 0; $v['player_2_times_n1_n6_forecast'] = 0; $v['player_2_times_n7_n9_forecast'] = 0; $v['player_2_times_nn_forecast'] = 0; $v['player_2_times_5n_forecast'] = 0; $v['player_3_forecast'] = 0; $v['player_3_times_n1_n6_forecast'] = 0; $v['player_3_times_n7_n9_forecast'] = 0; $v['player_3_times_nn_forecast'] = 0; $v['player_3_times_5n_forecast'] = 0; }elseif($v['game_id'] == 5){ $v['player_1_forecast'] = 0; $v['player_2_forecast'] = 0; $v['player_3_forecast'] = 0; $v['player_1_times_n1_forecast'] = 0; $v['player_1_times_n2_forecast'] = 0; $v['player_1_times_n3_forecast'] = 0; $v['player_1_times_n4_forecast'] = 0; $v['player_1_times_n5_forecast'] = 0; $v['player_1_times_n6_forecast'] = 0; $v['player_1_times_n7_forecast'] = 0; $v['player_1_times_n8_forecast'] = 0; $v['player_1_times_n9_forecast'] = 0; $v['player_1_times_nn_forecast'] = 0; $v['player_1_times_bz_forecast'] = 0; $v['player_1_times_ths_forecast'] = 0; $v['player_1_times_hjths_forecast'] = 0; $v['player_2_times_n1_forecast'] = 0; $v['player_2_times_n2_forecast'] = 0; $v['player_2_times_n3_forecast'] = 0; $v['player_2_times_n4_forecast'] = 0; $v['player_2_times_n5_forecast'] = 0; $v['player_2_times_n6_forecast'] = 0; $v['player_2_times_n7_forecast'] = 0; $v['player_2_times_n8_forecast'] = 0; $v['player_2_times_n9_forecast'] = 0; $v['player_2_times_nn_forecast'] = 0; $v['player_2_times_bz_forecast'] = 0; $v['player_2_times_ths_forecast'] = 0; $v['player_2_times_hjths_forecast'] = 0; $v['player_3_times_n1_forecast'] = 0; $v['player_3_times_n2_forecast'] = 0; $v['player_3_times_n3_forecast'] = 0; $v['player_3_times_n4_forecast'] = 0; $v['player_3_times_n5_forecast'] = 0; $v['player_3_times_n6_forecast'] = 0; $v['player_3_times_n7_forecast'] = 0; $v['player_3_times_n8_forecast'] = 0; $v['player_3_times_n9_forecast'] = 0; $v['player_3_times_nn_forecast'] = 0; $v['player_3_times_bz_forecast'] = 0; $v['player_3_times_ths_forecast'] = 0; $v['player_3_times_hjths_forecast'] = 0; } $v['bet_info'] = array(); $number_bet = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$v['id']) ->where('b.boot_id',$v['boot_id']) ->where('b.number',$v['number']) ->where('u.is_sw',0) ->select(); $all_bet_info = array(); if($number_bet){ foreach($number_bet as $key =>$value){ $bet_info = array(); $bet_contect = ''; $bet_person ++; $parent_agent_arr = explode(",", $value['agent_parent_id_path']); $parent_agent_id = $parent_agent_arr[0]; $parent_agent_info = Db::name('user')->where('id',$parent_agent_id)->find(); if($v['game_id'] == 1){ if($value['banker_amount'] > 0){ $bet_contect .= '庄:'.round($value['banker_amount'],2).' '; } if($value['player_amount'] > 0){ $bet_contect .= '闲:'.round($value['player_amount'],2).' '; } if($value['tie_amount'] > 0){ $bet_contect .= '和:'.round($value['tie_amount'],2).' '; } if($value['banker_pair_amount'] > 0){ $bet_contect .= '庄对:'.round($value['banker_pair_amount'],2).' '; } if($value['player_pair_amount'] > 0){ $bet_contect .= '闲对:'.round($value['player_pair_amount'],2).' '; } if($value['luck_six_amount'] > 0){ $bet_contect .= '幸运六:'.round($value['luck_six_amount'],2); } $v['banker_forecast'] += $value['player_amount'] + $value['tie_amount'] + $value['luck_six_amount'] - ($value['banker_amount'] * $value['price_banker']); $v['player_forecast'] += $value['banker_amount'] + $value['tie_amount'] + $value['luck_six_amount'] - ($value['player_amount'] * $value['price_player']); $v['tie_forecast'] += $value['luck_six_amount'] - ($value['tie_amount'] * $value['price_tie_baccarat']); $v['banker_pair_forecast'] += 0 - ($value['banker_pair_amount'] * $value['price_pair']); $v['player_pair_forecast'] += 0 - ($value['player_pair_amount'] * $value['price_pair']); $v['luck_six_2_forecast'] += 0 - ($value['luck_six_amount'] * $value['price_luck_six_2']) - ($value['banker_amount'] * $value['price_banker']) + $value['player_amount'] + $value['tie_amount']; $v['luck_six_3_forecast'] += 0 - ($value['luck_six_amount'] * $value['price_luck_six_3']) - ($value['banker_amount'] * $value['price_banker']) + $value['player_amount'] + $value['tie_amount']; $v['big_forecast'] += $value['small_amount'] - ($value['big_amount'] * $value['price_big']);; $v['small_forecast'] += $value['big_amount'] - ($value['small_amount'] * $value['price_small']); }elseif($v['game_id'] == 2){ if($value['banker_amount'] > 0){ $bet_contect .= '龙:'.round($value['banker_amount'],2).' '; } if($value['player_amount'] > 0){ $bet_contect .= '虎:'.round($value['player_amount'],2).' '; } if($value['tie_amount'] > 0){ $bet_contect .= '和:'.round($value['tie_amount'],2).' '; } $v['banker_forecast'] += $value['player_amount'] + $value['tie_amount'] - ($value['banker_amount'] * $value['price_dragon']); $v['player_forecast'] += $value['banker_amount'] + $value['tie_amount'] - ($value['player_amount'] * $value['price_tiger']); $v['tie_forecast'] += ($value['banker_amount'] + $value['player_amount']) * 0.5 - ($value['tie_amount'] * $value['price_tie_dt']); }elseif($v['game_id'] == 4){ if($value['amount_player_1'] > 0){ $bet_contect .= '闲一平倍:'.round($value['amount_player_1'],2).' '; } if($value['amount_player_1_times'] > 0){ $bet_contect .= '闲一翻倍:'.round($value['amount_player_1_times'],2).' '; } if($value['amount_player_2'] > 0){ $bet_contect .= '闲二平倍:'.round($value['amount_player_2'],2).' '; } if($value['amount_player_2_times'] > 0){ $bet_contect .= '闲二翻倍:'.round($value['amount_player_2_times'],2).' '; } if($value['amount_player_3'] > 0){ $bet_contect .= '闲三平倍:'.round($value['amount_player_3'],2).' '; } if($value['amount_player_3_times'] > 0){ $bet_contect .= '闲三翻倍:'.round($value['amount_player_3_times'],2).' '; } $v['player_1_forecast'] += to_number($value['amount_player_1'] * 0.96); $v['player_1_times_n1_n6_forecast'] += to_number($value['amount_player_1_times'] * 0.96); $v['player_1_times_n7_n9_forecast'] += to_number($value['amount_player_1_times'] * $value['price_n7_n9']); $v['player_1_times_nn_forecast'] += to_number($value['amount_player_1_times'] * $value['price_nn']); $v['player_1_times_5n_forecast'] += to_number($value['amount_player_1_times'] * $value['price_5n']); $v['player_1_times_bomb_forecast'] += to_number($value['amount_player_1_times'] * $value['price_bomb']); $v['player_2_forecast'] += to_number($value['amount_player_2'] * 0.96); $v['player_2_times_n1_n6_forecast'] += to_number($value['amount_player_2_times'] * 0.96); $v['player_2_times_n7_n9_forecast'] += to_number($value['amount_player_2_times'] * $value['price_n7_n9']); $v['player_2_times_nn_forecast'] += to_number($value['amount_player_2_times'] * $value['price_nn']); $v['player_2_times_5n_forecast'] += to_number($value['amount_player_2_times'] * $value['price_5n']); $v['player_2_times_bomb_forecast'] += to_number($value['amount_player_2_times'] * $value['price_bomb']); $v['player_3_forecast'] += to_number($value['amount_player_3'] * 0.96); $v['player_3_times_n1_n6_forecast'] += to_number($value['amount_player_3_times'] * 0.96); $v['player_3_times_n7_n9_forecast'] += to_number($value['amount_player_3_times'] * $value['price_n7_n9']); $v['player_3_times_nn_forecast'] += to_number($value['amount_player_3_times'] * $value['price_nn']); $v['player_3_times_5n_forecast'] += to_number($value['amount_player_3_times'] * $value['price_5n']); $v['player_3_times_bomb_forecast'] += to_number($value['amount_player_3_times'] * $value['price_bomb']); }elseif($v['game_id'] == 5){ if($value['amount_player_1'] > 0){ $bet_contect .= '闲一平倍:'.round($value['amount_player_1'],2).' '; } if($value['amount_player_1_times'] > 0){ $bet_contect .= '闲一翻倍:'.round($value['amount_player_1_times'],2).' '; } if($value['amount_player_2'] > 0){ $bet_contect .= '闲二平倍:'.round($value['amount_player_2'],2).' '; } if($value['amount_player_2_times'] > 0){ $bet_contect .= '闲二翻倍:'.round($value['amount_player_2_times'],2).' '; } if($value['amount_player_3'] > 0){ $bet_contect .= '闲三平倍:'.round($value['amount_player_3'],2).' '; } if($value['amount_player_3_times'] > 0){ $bet_contect .= '闲三翻倍:'.round($value['amount_player_3_times'],2).' '; } $v['player_1_forecast'] += to_number($value['amount_player_1'] * 0.96); $v['player_2_forecast'] += to_number($value['amount_player_2'] * 0.96); $v['player_3_forecast'] += to_number($value['amount_player_3'] * 0.96); $v['player_1_times_n1_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n1']); $v['player_1_times_n2_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n2']); $v['player_1_times_n3_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n3']); $v['player_1_times_n4_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n4']); $v['player_1_times_n5_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n5']); $v['player_1_times_n6_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n6']); $v['player_1_times_n7_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n7']); $v['player_1_times_n8_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n8']); $v['player_1_times_n9_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n9']); $v['player_1_times_nn_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_nn']); $v['player_1_times_bz_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_bz']); $v['player_1_times_ths_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_ths']); $v['player_1_times_hjths_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_hjths']); $v['player_2_times_n1_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n1']); $v['player_2_times_n2_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n2']); $v['player_2_times_n3_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n3']); $v['player_2_times_n4_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n4']); $v['player_2_times_n5_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n5']); $v['player_2_times_n6_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n6']); $v['player_2_times_n7_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n7']); $v['player_2_times_n8_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n8']); $v['player_2_times_n9_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n9']); $v['player_2_times_nn_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_nn']); $v['player_2_times_bz_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_bz']); $v['player_2_times_ths_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_ths']); $v['player_2_times_hjths_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_hjths']); $v['player_3_times_n1_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n1']); $v['player_3_times_n2_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n2']); $v['player_3_times_n3_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n3']); $v['player_3_times_n4_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n4']); $v['player_3_times_n5_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n5']); $v['player_3_times_n6_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n6']); $v['player_3_times_n7_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n7']); $v['player_3_times_n8_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n8']); $v['player_3_times_n9_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n9']); $v['player_3_times_nn_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_nn']); $v['player_3_times_bz_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_bz']); $v['player_3_times_ths_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_ths']); $v['player_3_times_hjths_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_hjths']); } $bet_info['agent_parent_username'] = $parent_agent_info['username']; $bet_info['username'] = $value['username']; $bet_info['create_time'] = date('H:i:s',$value['create_time']); $bet_info['bet_contect'] = $bet_contect; $v['bet_info'] = array(); array_push($all_bet_info,$bet_info); $v['bet_info'] = $all_bet_info; } } $table_info[$k] = $v; } // return json($table_info); $on_line = Db::name('session')->select(); foreach($on_line as $key => $val){ $val['username'] = Db::name('user')->where('id',$val['user_id'])->value('username'); if($val['client'] == 1){ $val['client'] = 'PC端'; }elseif($val['client'] == 2){ $val['client'] = 'Wap端'; }elseif($val['client'] == 5){ $val['client'] = 'Line投'; }else{ $val['client'] = 'App端'; } if($val['table_id'] == 0){ $val['table_name'] = '游戏大厅'; }else{ $val['table_name'] = Db::name('table')->where('id',$val['table_id'])->value('table_name'); } $on_line[$key] = $val; } $this->assign('on_line',$on_line); $this->assign('user_info',$user_info); $this->assign('bet_person',$bet_person); $this->assign('table_info',$table_info); $this->assign('websocketUrl',$websocketUrl); $this->assign('websocketProtocol',$websocketProtocol); return $this->fetch(); } public function check_table(){ $game = Request::instance()->post('game'); $is_cs = Request::instance()->post('is_cs'); $table_list = Request::instance()->post('table_list'); $username = Request::instance()->post('username'); $user_list = array(); if($username){ $is_user = Db::name('user')->where('username',$username)->where('is_delete',0)->find(); if(!$is_user){ $check_table_info['msg'] = '该代理或玩家不存在或已被删除'; return json($check_table_info); }else{ if($is_user['agent'] == 0){ array_push($user_list,$is_user['id']); }else{ $user_list = Db::name('user')->where('agent',0)->where(array('agent_parent_id_path'=>array('like','%'.$is_user['id'].',%')))->column('id'); } } } $check_table_info['is_username'] = 1; $table_list = explode(",", $table_list); $check_table_info['bet_person'] = 0; if($game == 'baccarat'){ $table_info = Db::name('table')->where('game_id',1)->where('status = 1 or is_contracted = 1')->where('table_type',0)->whereNotIn('id',$table_list)->order('game_id asc')->field(['id','table_name','game_id','table_num','game_name','in_checkout', 'is_contracted'])->select(); }elseif($game == 'dt'){ $table_info = Db::name('table')->where('game_id',2)->where('status',1)->where('table_type',0)->whereNotIn('id',$table_list)->order('game_id asc')->field(['id','table_name','game_id','table_num','game_name','in_checkout', 'is_contracted'])->select(); }elseif($game == 'nn'){ $table_info = Db::name('table')->where('game_id',4)->where('status',1)->where('table_type',0)->whereNotIn('id',$table_list)->order('game_id asc')->field(['id','table_name','game_id','table_num','game_name','in_checkout', 'is_contracted'])->select(); }elseif($game == 'tc'){ $table_info = Db::name('table')->where('game_id',5)->where('status',1)->where('table_type',0)->whereNotIn('id',$table_list)->order('game_id asc')->field(['id','table_name','game_id','table_num','game_name','in_checkout', 'is_contracted'])->select(); }elseif($game == 'all'){ $table_info = Db::name('table')->where('game_id','in',[1,2,4,5])->where('status = 1 or is_contracted = 1')->where('table_type',0)->whereNotIn('id',$table_list)->order('game_id asc')->field(['id','table_name','game_id','table_num','game_name','in_checkout', 'is_contracted'])->select(); } foreach ($table_info as $k => $v) { $number_form = 'number_tab'; $bet_form = 'bet'; $number_tab = Db::name($number_form)->where('table_id',$v['id'])->order('id desc')->find(); if($number_tab['bet_status'] == 0){ $v['status'] = '等待'; }elseif($number_tab['bet_status'] == 1){ $v['status'] = '接受下注'; }elseif($number_tab['bet_status'] == 2){ $v['status'] = '下注结束'; }elseif($number_tab['bet_status'] == 3){ $v['status'] = '开出结果'; } if($number_tab['boot_num']){ $v['boot_num'] = $number_tab['boot_num']; }else{ $v['boot_num'] = 0; } if($number_tab['number']){ $v['number'] = $number_tab['number']; }else{ $v['number'] = 0; } if($number_tab['boot_id']){ $v['boot_id'] = $number_tab['boot_id']; }else{ $v['boot_id'] = 0; } $sw_amount = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$v['id']) ->where('b.game_id',$v['game_id']) ->where('b.boot_id',$v['boot_id']) ->where('b.number',$v['number']) ->where('b.status',1) ->where('u.is_sw',1) ->field('SUM(b.banker_amount) as banker_amount, SUM(b.player_amount) as player_amount, SUM(b.tie_amount) as tie_amount, SUM(b.luck_six_amount) as luck_six_amount, SUM(b.big_amount) as big_amount, SUM(b.small_amount) as small_amount, SUM(b.banker_pair_amount) as banker_pair_amount, SUM(b.player_pair_amount) as player_pair_amount, SUM(b.amount_player_1) as amount_player_1, SUM(b.amount_player_2) as amount_player_2, SUM(b.amount_player_3) as amount_player_3, SUM(b.amount_player_1_times) as amount_player_1_times, SUM(b.amount_player_2_times) as amount_player_2_times, SUM(b.amount_player_3_times) as amount_player_3_times' ) ->find(); if($v['game_id'] == 1 || $v['game_id'] == 2){ $v['banker_amount'] = floor($number_tab['banker_amount'] - (int)$sw_amount['banker_amount']); $v['player_amount'] = floor($number_tab['player_amount'] - (int)$sw_amount['player_amount']); $v['tie_amount'] = floor($number_tab['tie_amount'] - (int)$sw_amount['tie_amount']); if($v['game_id'] == 1){ $v['banker_pair_amount'] = floor($number_tab['banker_pair_amount'] - (int)$sw_amount['banker_pair_amount']); $v['player_pair_amount'] = floor($number_tab['player_pair_amount'] - (int)$sw_amount['player_pair_amount']); $v['luck_six_amount'] = floor($number_tab['luck_six_amount'] - (int)$sw_amount['luck_six_amount']); $v['big_amount'] = floor($number_tab['big_amount'] - (int)$sw_amount['big_amount']); $v['small_amount'] = floor($number_tab['small_amount'] - (int)$sw_amount['small_amount']); } $v['difference'] = $v['banker_amount'] - $v['player_amount']; if($v['difference'] > 0){ $v['difference_type'] = 1; }elseif($v['difference'] < 0){ $v['difference'] = to_number($v['difference']); $v['difference_type'] = 2; }else{ $v['difference_type'] = 3; } $ns = Db::name($number_form)->where(array('boot_id' => $number_tab['boot_id'], 'bet_status' => 3))->field('result,pair')->order('start_time ASC,id ASC')->select(); // 数据存在,输出路单 if($ns){ $result = waybill($ns); $v['waybill'] = $result; }else{ $waybill = array(); $waybill['bigEyeRoad'] = []; $waybill['bigRoad'] = []; $waybill['pathway'] = []; $waybill['roach'] = []; $waybill['showRoad'] = []; $v['waybill'] = ['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]; } } if($v['game_id'] == 4 || $v['game_id'] == 5){ $v['amount_player_1'] = $number_tab['amount_player_1'] - (int)$sw_amount['amount_player_1']; $v['amount_player_2'] = $number_tab['amount_player_2'] - (int)$sw_amount['amount_player_2']; $v['amount_player_3'] = $number_tab['amount_player_3'] - (int)$sw_amount['amount_player_3']; $v['amount_player_1_times'] = $number_tab['amount_player_1_times'] - (int)$sw_amount['amount_player_1_times']; $v['amount_player_2_times'] = $number_tab['amount_player_2_times'] - (int)$sw_amount['amount_player_2_times']; $v['amount_player_3_times'] = $number_tab['amount_player_3_times'] - (int)$sw_amount['amount_player_3_times']; $waybill = array(); $waybill['bigEyeRoad'] = []; $waybill['bigRoad'] = []; $waybill['pathway'] = []; $waybill['roach'] = []; $waybill['showRoad'] = []; $v['waybill'] = ['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]; } if($v['game_id'] == 1 || $v['game_id'] == 2){ $v['banker_forecast'] = 0; $v['player_forecast'] = 0; $v['tie_forecast'] = 0; $v['banker_pair_forecast'] = 0; $v['player_pair_forecast'] = 0; $v['luck_six_2_forecast'] = 0; $v['luck_six_3_forecast'] = 0; $v['big_forecast'] = 0; $v['small_forecast'] = 0; }elseif($v['game_id'] == 4){ $v['player_1_forecast'] = 0; $v['player_1_times_n1_n6_forecast'] = 0; $v['player_1_times_n7_n9_forecast'] = 0; $v['player_1_times_nn_forecast'] = 0; $v['player_1_times_5n_forecast'] = 0; $v['player_2_forecast'] = 0; $v['player_2_times_n1_n6_forecast'] = 0; $v['player_2_times_n7_n9_forecast'] = 0; $v['player_2_times_nn_forecast'] = 0; $v['player_2_times_5n_forecast'] = 0; $v['player_3_forecast'] = 0; $v['player_3_times_n1_n6_forecast'] = 0; $v['player_3_times_n7_n9_forecast'] = 0; $v['player_3_times_nn_forecast'] = 0; $v['player_3_times_5n_forecast'] = 0; }elseif($v['game_id'] == 5){ $v['player_1_forecast'] = 0; $v['player_2_forecast'] = 0; $v['player_3_forecast'] = 0; $v['player_1_times_n1_forecast'] = 0; $v['player_1_times_n2_forecast'] = 0; $v['player_1_times_n3_forecast'] = 0; $v['player_1_times_n4_forecast'] = 0; $v['player_1_times_n5_forecast'] = 0; $v['player_1_times_n6_forecast'] = 0; $v['player_1_times_n7_forecast'] = 0; $v['player_1_times_n8_forecast'] = 0; $v['player_1_times_n9_forecast'] = 0; $v['player_1_times_nn_forecast'] = 0; $v['player_1_times_bz_forecast'] = 0; $v['player_1_times_ths_forecast'] = 0; $v['player_1_times_hjths_forecast'] = 0; $v['player_2_times_n1_forecast'] = 0; $v['player_2_times_n2_forecast'] = 0; $v['player_2_times_n3_forecast'] = 0; $v['player_2_times_n4_forecast'] = 0; $v['player_2_times_n5_forecast'] = 0; $v['player_2_times_n6_forecast'] = 0; $v['player_2_times_n7_forecast'] = 0; $v['player_2_times_n8_forecast'] = 0; $v['player_2_times_n9_forecast'] = 0; $v['player_2_times_nn_forecast'] = 0; $v['player_2_times_bz_forecast'] = 0; $v['player_2_times_ths_forecast'] = 0; $v['player_2_times_hjths_forecast'] = 0; $v['player_3_times_n1_forecast'] = 0; $v['player_3_times_n2_forecast'] = 0; $v['player_3_times_n3_forecast'] = 0; $v['player_3_times_n4_forecast'] = 0; $v['player_3_times_n5_forecast'] = 0; $v['player_3_times_n6_forecast'] = 0; $v['player_3_times_n7_forecast'] = 0; $v['player_3_times_n8_forecast'] = 0; $v['player_3_times_n9_forecast'] = 0; $v['player_3_times_nn_forecast'] = 0; $v['player_3_times_bz_forecast'] = 0; $v['player_3_times_ths_forecast'] = 0; $v['player_3_times_hjths_forecast'] = 0; } $v['bet_info'] = array(); if(!$username){ $number_bet = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$v['id']) ->where('b.boot_id',$v['boot_id']) ->where('b.number',$v['number']) ->where('u.is_sw',0) ->select(); }else{ $number_bet = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$v['id']) ->where('b.boot_id',$v['boot_id']) ->where('b.number',$v['number']) ->where('u.is_sw',0) ->where('u.user_id','in',$user_list) ->select(); } $v['select_number_status'] = 0; $all_bet_info = array(); if($number_bet){ $check_table_info['bet_person'] ++; foreach($number_bet as $key =>$value){ $bet_info = array(); $bet_contect = ''; $v['select_number_status'] = 1; $parent_agent = Db::name('user')->where('id',$value['user_id'])->find(); $parent_agent_arr = explode(",", $parent_agent['agent_parent_id_path']); $parent_agent_id = $parent_agent_arr[0]; $parent_agent_info = Db::name('user')->where('id',$parent_agent_id)->find(); if($v['game_id'] == 1){ if($value['banker_amount'] > 0){ $bet_contect .= '庄:'.round($value['banker_amount'],2).' '; } if($value['player_amount'] > 0){ $bet_contect .= '闲:'.round($value['player_amount'],2).' '; } if($value['tie_amount'] > 0){ $bet_contect .= '和:'.round($value['tie_amount'],2).' '; } if($value['banker_pair_amount'] > 0){ $bet_contect .= '庄对:'.round($value['banker_pair_amount'],2).' '; } if($value['player_pair_amount'] > 0){ $bet_contect .= '闲对:'.round($value['player_pair_amount'],2).' '; } if($value['luck_six_amount'] > 0){ $bet_contect .= '幸运六:'.round($value['luck_six_amount'],2); } $v['banker_forecast'] += $value['player_amount'] + $value['tie_amount'] + $value['luck_six_amount'] - ($value['banker_amount'] * $value['price_banker']); $v['player_forecast'] += $value['banker_amount'] + $value['tie_amount'] + $value['luck_six_amount'] - ($value['player_amount'] * $value['price_player']); $v['tie_forecast'] += $value['luck_six_amount'] - ($value['tie_amount'] * $value['price_tie_baccarat']); $v['banker_pair_forecast'] += 0 - ($value['banker_pair_amount'] * $value['price_pair']); $v['player_pair_forecast'] += 0 - ($value['player_pair_amount'] * $value['price_pair']); $v['luck_six_2_forecast'] += 0 - ($value['luck_six_amount'] * $value['price_luck_six_2']) - ($value['banker_amount'] * $value['price_banker']) + $value['player_amount'] + $value['tie_amount']; $v['luck_six_3_forecast'] += 0 - ($value['luck_six_amount'] * $value['price_luck_six_3']) - ($value['banker_amount'] * $value['price_banker']) + $value['player_amount'] + $value['tie_amount']; $v['big_forecast'] += $value['small_amount'] - ($value['big_amount'] * $value['price_big']);; $v['small_forecast'] += $value['big_amount'] - ($value['small_amount'] * $value['price_small']); }elseif($v['game_id'] == 2){ if($value['banker_amount'] > 0){ $bet_contect .= '龙:'.round($value['banker_amount'],2).' '; } if($value['player_amount'] > 0){ $bet_contect .= '虎:'.round($value['player_amount'],2).' '; } if($value['tie_amount'] > 0){ $bet_contect .= '和:'.round($value['tie_amount'],2).' '; } $v['banker_forecast'] += $value['player_amount'] + $value['tie_amount'] - ($value['banker_amount'] * $value['price_dragon']); $v['player_forecast'] += $value['banker_amount'] + $value['tie_amount'] - ($value['player_amount'] * $value['price_tiger']); $v['tie_forecast'] += ($value['banker_amount'] + $value['player_amount']) * 0.5 - ($value['tie_amount'] * $value['price_tie_dt']); }elseif($v['game_id'] == 4){ if($value['amount_player_1'] > 0){ $bet_contect .= '闲一平倍:'.round($value['amount_player_1'],2).' '; } if($value['amount_player_1_times'] > 0){ $bet_contect .= '闲一翻倍:'.round($value['amount_player_1_times'],2).' '; } if($value['amount_player_2'] > 0){ $bet_contect .= '闲二平倍:'.round($value['amount_player_2'],2).' '; } if($value['amount_player_2_times'] > 0){ $bet_contect .= '闲二翻倍:'.round($value['amount_player_2_times'],2).' '; } if($value['amount_player_3'] > 0){ $bet_contect .= '闲三平倍:'.round($value['amount_player_3'],2).' '; } if($value['amount_player_3_times'] > 0){ $bet_contect .= '闲三翻倍:'.round($value['amount_player_3_times'],2).' '; } $v['player_1_forecast'] += round($value['amount_player_1'] * 0.96,2); $v['player_1_times_n1_n6_forecast'] += round($value['amount_player_1_times'] * 0.96,2); $v['player_1_times_n7_n9_forecast'] += round($value['amount_player_1_times'] * $value['price_n7_n9'],2); $v['player_1_times_nn_forecast'] += round($value['amount_player_1_times'] * $value['price_nn'],2); $v['player_1_times_5n_forecast'] += round($value['amount_player_1_times'] * $value['price_5n'],2); $v['player_1_times_bomb_forecast'] += round($value['amount_player_1_times'] * $value['price_bomb'],2); $v['player_2_forecast'] += round($value['amount_player_2'] * 0.96,2); $v['player_2_times_n1_n6_forecast'] += round($value['amount_player_2_times'] * 0.96,2); $v['player_2_times_n7_n9_forecast'] += round($value['amount_player_2_times'] * $value['price_n7_n9'],2); $v['player_2_times_nn_forecast'] += round($value['amount_player_2_times'] * $value['price_nn'],2); $v['player_2_times_5n_forecast'] += round($value['amount_player_2_times'] * $value['price_5n'],2); $v['player_2_times_bomb_forecast'] += round($value['amount_player_2_times'] * $value['price_bomb'],2); $v['player_3_forecast'] += round($value['amount_player_3'] * 0.96,2); $v['player_3_times_n1_n6_forecast'] += round($value['amount_player_3_times'] * 0.96,2); $v['player_3_times_n7_n9_forecast'] += round($value['amount_player_3_times'] * $value['price_n7_n9'],2); $v['player_3_times_nn_forecast'] += round($value['amount_player_3_times'] * $value['price_nn'],2); $v['player_3_times_5n_forecast'] += round($value['amount_player_3_times'] * $value['price_5n'],2); $v['player_3_times_bomb_forecast'] += round($value['amount_player_3_times'] * $value['price_bomb'],2); }elseif($v['game_id'] == 5){ if($value['amount_player_1'] > 0){ $bet_contect .= '闲一平倍:'.round($value['amount_player_1'],2).' '; } if($value['amount_player_1_times'] > 0){ $bet_contect .= '闲一翻倍:'.round($value['amount_player_1_times'],2).' '; } if($value['amount_player_2'] > 0){ $bet_contect .= '闲二平倍:'.round($value['amount_player_2'],2).' '; } if($value['amount_player_2_times'] > 0){ $bet_contect .= '闲二翻倍:'.round($value['amount_player_2_times'],2).' '; } if($value['amount_player_3'] > 0){ $bet_contect .= '闲三平倍:'.round($value['amount_player_3'],2).' '; } if($value['amount_player_3_times'] > 0){ $bet_contect .= '闲三翻倍:'.round($value['amount_player_3_times'],2).' '; } $v['player_1_forecast'] += round($value['amount_player_1'] * 0.96); $v['player_2_forecast'] += round($value['amount_player_2'] * 0.96); $v['player_3_forecast'] += round($value['amount_player_3'] * 0.96); $v['player_1_times_n1_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n1'],2); $v['player_1_times_n2_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n2'],2); $v['player_1_times_n3_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n3'],2); $v['player_1_times_n4_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n4'],2); $v['player_1_times_n5_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n5'],2); $v['player_1_times_n6_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n6'],2); $v['player_1_times_n7_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n7'],2); $v['player_1_times_n8_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n8'],2); $v['player_1_times_n9_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_n9'],2); $v['player_1_times_nn_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_nn'],2); $v['player_1_times_bz_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_bz'],2); $v['player_1_times_ths_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_ths'],2); $v['player_1_times_hjths_forecast'] += round($value['amount_player_1_times'] * $value['price_tc_hjths'],2); $v['player_2_times_n1_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n1'],2); $v['player_2_times_n2_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n2'],2); $v['player_2_times_n3_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n3'],2); $v['player_2_times_n4_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n4'],2); $v['player_2_times_n5_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n5'],2); $v['player_2_times_n6_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n6'],2); $v['player_2_times_n7_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n7'],2); $v['player_2_times_n8_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n8'],2); $v['player_2_times_n9_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_n9'],2); $v['player_2_times_nn_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_nn'],2); $v['player_2_times_bz_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_bz'],2); $v['player_2_times_ths_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_ths'],2); $v['player_2_times_hjths_forecast'] += round($value['amount_player_2_times'] * $value['price_tc_hjths'],2); $v['player_3_times_n1_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n1'],2); $v['player_3_times_n2_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n2'],2); $v['player_3_times_n3_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n3'],2); $v['player_3_times_n4_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n4'],2); $v['player_3_times_n5_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n5'],2); $v['player_3_times_n6_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n6'],2); $v['player_3_times_n7_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n7'],2); $v['player_3_times_n8_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n8'],2); $v['player_3_times_n9_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_n9'],2); $v['player_3_times_nn_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_nn'],2); $v['player_3_times_bz_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_bz'],2); $v['player_3_times_ths_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_ths'],2); $v['player_3_times_hjths_forecast'] += round($value['amount_player_3_times'] * $value['price_tc_hjths'],2); } $bet_info['agent_parent_username'] = $parent_agent_info['username']; $bet_info['username'] = $value['username']; $bet_info['create_time'] = date('H:i:s',$value['create_time']); $bet_info['bet_contect'] = $bet_contect; array_push($all_bet_info,$bet_info); $v['bet_info'] = $all_bet_info; } } $table_info[$k] = $v; } if($user_list){ $new_table_list = array(); foreach($table_info as $key=>$value){ if($value['select_number_status'] == 1){ array_push($new_table_list,$value); } } $check_table_info['table_info'] = $new_table_list; }else{ $check_table_info['table_info'] = $table_info; } return json($check_table_info); } public function table_bet_info(){ $table_id = Request::instance()->post('table_id'); $boot_id = Request::instance()->post('boot_id'); $number = Request::instance()->post('number'); $game_type = Db::name('table')->where('id',$table_id)->find(); $bet = 'bet'; $number_tab = 'number_tab'; $ns = Db::name($number_tab)->where(array('boot_id' => $boot_id, 'bet_status' => 3))->field('result,pair')->order('start_time ASC,id ASC')->select(); // 数据存在,输出路单 if($ns){ $result = waybill($ns); $check_number_bet['waybill'] = $result; }else{ $waybill = array(); $waybill['bigEyeRoad'] = []; $waybill['bigRoad'] = []; $waybill['pathway'] = []; $waybill['roach'] = []; $waybill['showRoad'] = []; $check_number_bet['waybill'] = ['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]; } $check_number_bet['game_id'] = $game_type['game_id']; $number_bet = Db::name($bet) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$table_id) ->where('b.boot_id',$boot_id) ->where('b.number',$number) ->where('u.is_sw',0) ->select(); $check_number_bet['online_player'] = 0; $check_number_bet['height_username'] = ''; if($number_tab){ $check_number_bet['online_player'] = Db::name($bet)->where('boot_id',$boot_id)->where('number',$number)->where('status',1)->count(); $hight_bet = Db::name($bet)->where('boot_id',$boot_id)->where('number',$number)->order('amount desc')->where('status',1)->find(); $check_number_bet['height_username'] = $hight_bet['username']; } foreach ($number_bet as $k => $v){ $user_info = Db::name('user')->where('id',$v['user_id'])->find(); if($user_info['is_sw'] == 1){ continue; } $v['agent_parent_username'] = $user_info['agent_parent_username']; $parent_agent_arr = explode(",", $user_info['agent_parent_id_path']); $parent_agent_id = $parent_agent_arr[0]; $parent_agent_info = Db::name('user')->where('id',$parent_agent_id)->find(); $v['parent_agent_cs'] = round($parent_agent_info['agent_cs'],2).'%'; $v['money'] = $user_info['money']; if($check_number_bet['game_id'] == 1 || $check_number_bet['game_id'] == 2){ $v['banker_amount'] = intval($v['banker_amount']); $v['player_amount'] = intval($v['player_amount']); $v['tie_amount'] = intval($v['tie_amount']); if($check_number_bet['game_id'] == 1){ $v['banker_pair_amount'] = intval($v['banker_pair_amount']); $v['player_pair_amount'] = intval($v['player_pair_amount']); } }else{ $v['amount_player_1'] = intval($v['amount_player_1']); $v['amount_player_1_times'] = intval($v['amount_player_1_times']); $v['amount_player_2'] = intval($v['amount_player_2']); $v['amount_player_2_times'] = intval($v['amount_player_2_times']); $v['amount_player_3'] = intval($v['amount_player_3']); $v['amount_player_3_times'] = intval($v['amount_player_3_times']); } $v['create_time'] = date('H:i:s',$v['create_time']); $number_bet[$k] = $v; } $check_number_bet['number_bet'] = $number_bet; return json($check_number_bet); } public function refresh_bet(){ $table_id = Request::instance()->post('table_id'); $is_cs = Request::instance()->post('is_cs'); $username = Request::instance()->post('username'); $user_list = array(); $new_table_info = array(); $new_table_info['bet_person'] = 0; if($username){ $is_user = Db::name('user')->where('username',$username)->where('is_delete',0)->find(); if($is_user){ if($is_user['agent'] == 0){ array_push($user_list,$is_user['id']); }else{ $user_list = Db::name('user')->where('agent',0)->where(array('agent_parent_id_path'=>array('like','%'.$is_user['id'].',%')))->column('id'); } } } $all_table_info = Db::name('table')->where('game_id','in',[1,2,4,5])->where('status',1)->where('table_type',0)->order('game_id asc')->select(); foreach ($all_table_info as $k => $v) { $number_form = 'number_tab'; $bet_form = 'bet'; $all_number_tab = Db::name($number_form)->where('table_id',$v['id'])->order('id desc')->find(); if($all_number_tab['boot_num']){ $v['boot_num'] = $all_number_tab['boot_num']; }else{ $v['boot_num'] = 0; } if($all_number_tab['number']){ $v['number'] = $all_number_tab['number']; }else{ $v['number'] = 0; } if($all_number_tab['boot_id']){ $v['boot_id'] = $all_number_tab['boot_id']; }else{ $v['boot_id'] = 0; } $all_number_bet = Db::name($bet_form)->where('table_id',$v['id'])->where('boot_id',$v['boot_id'])->where('number',$v['number'])->where('status',1)->select(); if($all_number_bet){ foreach ($all_number_bet as $keys => $values) { $new_table_info['bet_person'] ++; } } } $table_info = Db::name('table')->where('id',$table_id)->find(); $bet_form = 'bet'; $number_form = 'number_tab'; $number_tab = Db::name($number_form)->where('table_id',$table_id)->order('id desc')->find(); $sw_amount = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$v['id']) ->where('b.game_id',$v['game_id']) ->where('b.boot_id',$v['boot_id']) ->where('b.number',$v['number']) ->where('b.status',1) ->where('u.is_sw',1) ->field('SUM(b.banker_amount) as banker_amount, SUM(b.player_amount) as player_amount, SUM(b.tie_amount) as tie_amount, SUM(b.luck_six_amount) as luck_six_amount, SUM(b.big_amount) as big_amount, SUM(b.small_amount) as small_amount, SUM(b.banker_pair_amount) as banker_pair_amount, SUM(b.player_pair_amount) as player_pair_amount, SUM(b.amount_player_1) as amount_player_1, SUM(b.amount_player_2) as amount_player_2, SUM(b.amount_player_3) as amount_player_3, SUM(b.amount_player_1_times) as amount_player_1_times, SUM(b.amount_player_2_times) as amount_player_2_times, SUM(b.amount_player_3_times) as amount_player_3_times' ) ->find(); if($table_info['game_id'] == 1 || $table_info['game_id'] == 2){ $new_table_info['banker_amount'] = $number_tab['banker_amount'] - (int)$sw_amount['banker_amount']; $new_table_info['player_amount'] = $number_tab['player_amount'] - (int)$sw_amount['player_amount']; $new_table_info['tie_amount'] = $number_tab['tie_amount'] - (int)$sw_amount['tie_amount']; $new_table_info['banker_forecast'] = 0; $new_table_info['player_forecast'] = 0; $new_table_info['tie_forecast'] = 0; if($table_info['game_id'] == 1){ $new_table_info['banker_pair_amount'] = $number_tab['banker_pair_amount'] - (int)$sw_amount['banker_pair_amount']; $new_table_info['player_pair_amount'] = $number_tab['player_pair_amount'] - (int)$sw_amount['player_pair_amount']; $new_table_info['luck_six_amount'] = $number_tab['luck_six_amount'] - (int)$sw_amount['luck_six_amount']; $new_table_info['big_amount'] = $number_tab['big_amount'] - (int)$sw_amount['big_amount']; $new_table_info['small_amount'] = $number_tab['small_amount'] - (int)$sw_amount['small_amount']; $new_table_info['banker_pair_forecast'] = 0; $new_table_info['player_pair_forecast'] = 0; $new_table_info['luck_six_2_forecast'] = 0; $new_table_info['luck_six_3_forecast'] = 0; $new_table_info['big_forecast'] = 0; $new_table_info['small_forecast'] = 0; } $new_table_info['difference'] = $new_table_info['banker_amount'] - $new_table_info['player_amount']; if($new_table_info['difference'] > 0){ $new_table_info['difference_type'] = 1; }elseif($new_table_info['difference'] < 0){ $new_table_info['difference'] = to_number($new_table_info['difference']); $new_table_info['difference_type'] = 2; }else{ $new_table_info['difference_type'] = 3; } }elseif($table_info['game_id'] == 4){ $new_table_info['amount_player_1'] = $number_tab['amount_player_1'] - (int)$sw_amount['amount_player_1']; $new_table_info['amount_player_2'] = $number_tab['amount_player_2'] - (int)$sw_amount['amount_player_2']; $new_table_info['amount_player_3'] = $number_tab['amount_player_3'] - (int)$sw_amount['amount_player_3']; $new_table_info['amount_player_1_times'] = $number_tab['amount_player_1_times'] - (int)$sw_amount['amount_player_1_times']; $new_table_info['amount_player_2_times'] = $number_tab['amount_player_2_times'] - (int)$sw_amount['amount_player_2_times']; $new_table_info['amount_player_3_times'] = $number_tab['amount_player_3_times'] - (int)$sw_amount['amount_player_3_times']; $new_table_info['player_1_forecast'] = 0; $new_table_info['player_2_forecast'] = 0; $new_table_info['player_3_forecast'] = 0; $new_table_info['player_1_times_n1_n6_forecast'] = 0; $new_table_info['player_2_times_n1_n6_forecast'] = 0; $new_table_info['player_3_times_n1_n6_forecast'] = 0; $new_table_info['player_1_times_n7_n9_forecast'] = 0; $new_table_info['player_2_times_n7_n9_forecast'] = 0; $new_table_info['player_3_times_n7_n9_forecast'] = 0; $new_table_info['player_1_times_nn_forecast'] = 0; $new_table_info['player_2_times_nn_forecast'] = 0; $new_table_info['player_3_times_nn_forecast'] = 0; $new_table_info['player_1_times_5n_forecast'] = 0; $new_table_info['player_2_times_5n_forecast'] = 0; $new_table_info['player_3_times_5n_forecast'] = 0; }elseif($table_info['game_id'] == 5){ $new_table_info['amount_player_1'] = $number_tab['amount_player_1'] - (int)$sw_amount['amount_player_1']; $new_table_info['amount_player_2'] = $number_tab['amount_player_2'] - (int)$sw_amount['amount_player_2']; $new_table_info['amount_player_3'] = $number_tab['amount_player_3'] - (int)$sw_amount['amount_player_3']; $new_table_info['amount_player_1_times'] = $number_tab['amount_player_1_times'] - (int)$sw_amount['amount_player_1_times']; $new_table_info['amount_player_2_times'] = $number_tab['amount_player_2_times'] - (int)$sw_amount['amount_player_2_times']; $new_table_info['amount_player_3_times'] = $number_tab['amount_player_3_times'] - (int)$sw_amount['amount_player_3_times']; $new_table_info['player_1_forecast'] = 0; $new_table_info['player_2_forecast'] = 0; $new_table_info['player_3_forecast'] = 0; $new_table_info['player_1_times_n1_forecast'] = 0; $new_table_info['player_1_times_n2_forecast'] = 0; $new_table_info['player_1_times_n3_forecast'] = 0; $new_table_info['player_1_times_n4_forecast'] = 0; $new_table_info['player_1_times_n5_forecast'] = 0; $new_table_info['player_1_times_n6_forecast'] = 0; $new_table_info['player_1_times_n7_forecast'] = 0; $new_table_info['player_1_times_n8_forecast'] = 0; $new_table_info['player_1_times_n9_forecast'] = 0; $new_table_info['player_1_times_nn_forecast'] = 0; $new_table_info['player_1_times_bz_forecast'] = 0; $new_table_info['player_1_times_ths_forecast'] = 0; $new_table_info['player_1_times_hjths_forecast'] = 0; $new_table_info['player_2_times_n1_forecast'] = 0; $new_table_info['player_2_times_n2_forecast'] = 0; $new_table_info['player_2_times_n3_forecast'] = 0; $new_table_info['player_2_times_n4_forecast'] = 0; $new_table_info['player_2_times_n5_forecast'] = 0; $new_table_info['player_2_times_n6_forecast'] = 0; $new_table_info['player_2_times_n7_forecast'] = 0; $new_table_info['player_2_times_n8_forecast'] = 0; $new_table_info['player_2_times_n9_forecast'] = 0; $new_table_info['player_2_times_nn_forecast'] = 0; $new_table_info['player_2_times_bz_forecast'] = 0; $new_table_info['player_2_times_ths_forecast'] = 0; $new_table_info['player_2_times_hjths_forecast'] = 0; $new_table_info['player_3_times_n1_forecast'] = 0; $new_table_info['player_3_times_n2_forecast'] = 0; $new_table_info['player_3_times_n3_forecast'] = 0; $new_table_info['player_3_times_n4_forecast'] = 0; $new_table_info['player_3_times_n5_forecast'] = 0; $new_table_info['player_3_times_n6_forecast'] = 0; $new_table_info['player_3_times_n7_forecast'] = 0; $new_table_info['player_3_times_n8_forecast'] = 0; $new_table_info['player_3_times_n9_forecast'] = 0; $new_table_info['player_3_times_nn_forecast'] = 0; $new_table_info['player_3_times_bz_forecast'] = 0; $new_table_info['player_3_times_ths_forecast'] = 0; $new_table_info['player_3_times_hjths_forecast'] = 0; } if(!$username){ $number_bet = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$number_tab['table_id']) ->where('b.boot_id',$number_tab['boot_id']) ->where('b.number',$number_tab['number']) ->where('u.is_sw',0) ->select(); }else{ $number_bet = Db::name($bet_form) ->alias('b') ->join('user u','u.id = b.user_id') ->where('b.table_id',$number_tab['table_id']) ->where('b.boot_id',$number_tab['boot_id']) ->where('b.number',$number_tab['number']) ->where('u.is_sw',0) ->where('u.user_id','in',$user_list) ->select(); } $new_table_info['game_id'] = $table_info['game_id']; if($number_bet){ foreach($number_bet as $key =>$value){ if($table_info['game_id'] == 1){ $new_table_info['banker_forecast'] += $value['player_amount'] + $value['tie_amount'] + $value['luck_six_amount'] - ($value['banker_amount'] * $value['price_banker']); $new_table_info['player_forecast'] += $value['banker_amount'] + $value['tie_amount'] + $value['luck_six_amount'] - ($value['player_amount'] * $value['price_player']); $new_table_info['tie_forecast'] += $value['luck_six_amount'] - ($value['tie_amount'] * $value['price_tie_baccarat']); $new_table_info['banker_pair_forecast'] += 0 - ($value['banker_pair_amount'] * $value['price_pair']); $new_table_info['player_pair_forecast'] += 0 - ($value['player_pair_amount'] * $value['price_pair']); $new_table_info['luck_six_2_forecast'] += 0 - ($value['luck_six_amount'] * $value['price_luck_six_2']) - ($value['banker_amount'] * $value['price_banker']) + $value['player_amount'] + $value['tie_amount']; $new_table_info['luck_six_3_forecast'] += 0 - ($value['luck_six_amount'] * $value['price_luck_six_3']) - ($value['banker_amount'] * $value['price_banker']) + $value['player_amount'] + $value['tie_amount']; $new_table_info['big_forecast'] += $value['small_amount'] - ($value['big_amount'] * $value['price_big']);; $new_table_info['small_forecast'] += $value['big_amount'] - ($value['small_amount'] * $value['price_small']); }elseif($table_info['game_id'] == 2){ $new_table_info['banker_forecast'] += $value['player_amount'] + $value['tie_amount'] - ($value['banker_amount'] * $value['price_dragon']); $new_table_info['player_forecast'] += $value['banker_amount'] + $value['tie_amount'] - ($value['player_amount'] * $value['price_tiger']); $new_table_info['tie_forecast'] += ($value['banker_amount'] + $value['player_amount']) * 0.5 - ($value['tie_amount'] * $value['price_tie_dt']); }elseif($table_info['game_id'] == 4){ $new_table_info['player_1_forecast'] += to_number($value['amount_player_1'] * 0.96); $new_table_info['player_1_times_n1_n6_forecast'] += to_number($value['amount_player_1_times'] * 0.96); $new_table_info['player_1_times_n7_n9_forecast'] += to_number($value['amount_player_1_times'] * $value['price_n7_n9']); $new_table_info['player_1_times_nn_forecast'] += to_number($value['amount_player_1_times'] * $value['price_nn']); $new_table_info['player_1_times_5n_forecast'] += to_number($value['amount_player_1_times'] * $value['price_5n']); $new_table_info['player_1_times_bomb_forecast'] += to_number($value['amount_player_1_times'] * $value['price_bomb']); $new_table_info['player_2_forecast'] += to_number($value['amount_player_2'] * 0.96); $new_table_info['player_2_times_n1_n6_forecast'] += to_number($value['amount_player_2_times'] * 0.96); $new_table_info['player_2_times_n7_n9_forecast'] += to_number($value['amount_player_2_times'] * $value['price_n7_n9']); $new_table_info['player_2_times_nn_forecast'] += to_number($value['amount_player_2_times'] * $value['price_nn']); $new_table_info['player_2_times_5n_forecast'] += to_number($value['amount_player_2_times'] * $value['price_5n']); $new_table_info['player_2_times_bomb_forecast'] += to_number($value['amount_player_2_times'] * $value['price_bomb']); $new_table_info['player_3_forecast'] += to_number($value['amount_player_3'] * 0.96); $new_table_info['player_3_times_n1_n6_forecast'] += to_number($value['amount_player_3_times'] * 0.96); $new_table_info['player_3_times_n7_n9_forecast'] += to_number($value['amount_player_3_times'] * $value['price_n7_n9']); $new_table_info['player_3_times_nn_forecast'] += to_number($value['amount_player_3_times'] * $value['price_nn']); $new_table_info['player_3_times_5n_forecast'] += to_number($value['amount_player_3_times'] * $value['price_5n']); $new_table_info['player_3_times_bomb_forecast'] += to_number($value['amount_player_3_times'] * $value['price_bomb']); }elseif($table_info['game_id'] == 5){ $new_table_info['player_1_forecast'] += to_number($value['amount_player_1'] * 0.96); $new_table_info['player_2_forecast'] += to_number($value['amount_player_2'] * 0.96); $new_table_info['player_3_forecast'] += to_number($value['amount_player_3'] * 0.96); $new_table_info['player_1_times_n1_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n1']); $new_table_info['player_1_times_n2_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n2']); $new_table_info['player_1_times_n3_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n3']); $new_table_info['player_1_times_n4_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n4']); $new_table_info['player_1_times_n5_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n5']); $new_table_info['player_1_times_n6_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n6']); $new_table_info['player_1_times_n7_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n7']); $new_table_info['player_1_times_n8_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n8']); $new_table_info['player_1_times_n9_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_n9']); $new_table_info['player_1_times_nn_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_nn']); $new_table_info['player_1_times_bz_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_bz']); $new_table_info['player_1_times_ths_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_ths']); $new_table_info['player_1_times_hjths_forecast'] += to_number($value['amount_player_1_times'] * $value['price_tc_hjths']); $new_table_info['player_2_times_n1_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n1']); $new_table_info['player_2_times_n2_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n2']); $new_table_info['player_2_times_n3_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n3']); $new_table_info['player_2_times_n4_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n4']); $new_table_info['player_2_times_n5_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n5']); $new_table_info['player_2_times_n6_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n6']); $new_table_info['player_2_times_n7_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n7']); $new_table_info['player_2_times_n8_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n8']); $new_table_info['player_2_times_n9_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_n9']); $new_table_info['player_2_times_nn_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_nn']); $new_table_info['player_2_times_bz_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_bz']); $new_table_info['player_2_times_ths_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_ths']); $new_table_info['player_2_times_hjths_forecast'] += to_number($value['amount_player_2_times'] * $value['price_tc_hjths']); $new_table_info['player_3_times_n1_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n1']); $new_table_info['player_3_times_n2_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n2']); $new_table_info['player_3_times_n3_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n3']); $new_table_info['player_3_times_n4_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n4']); $new_table_info['player_3_times_n5_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n5']); $new_table_info['player_3_times_n6_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n6']); $new_table_info['player_3_times_n7_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n7']); $new_table_info['player_3_times_n8_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n8']); $new_table_info['player_3_times_n9_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_n9']); $new_table_info['player_3_times_nn_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_nn']); $new_table_info['player_3_times_bz_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_bz']); $new_table_info['player_3_times_ths_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_ths']); $new_table_info['player_3_times_hjths_forecast'] += to_number($value['amount_player_3_times'] * $value['price_tc_hjths']); } } } return json($new_table_info); } public function login_out(){ Session::set('user_info',""); $this->redirect('/login/index',302); } public function on_line(){ $on_line = Db::name('session')->select(); foreach($on_line as $key => $val){ $val['username'] = Db::name('user')->where('id',$val['user_id'])->value('username'); if($val['client'] == 1){ $val['client'] = 'PC端'; }elseif($val['client'] == 2){ $val['client'] = 'Wap端'; }else{ $val['client'] = 'App端'; } if($val['table_id'] == 0){ $val['table_name'] = '游戏大厅'; }else{ $val['table_name'] = Db::name('table')->where('id',$val['table_id'])->value('table_name'); } $on_line[$key] = $val; } return json($on_line); } public function get_banker(){ $table_id = Request::instance()->post('table_id'); $number_tab_info = DB::name('number_tab')->where('table_id',$table_id)->order('id desc')->find(); if($number_tab_info['rob_banker_id'] == 0){ $rob_banker_username = '系统坐庄'; }else{ $rob_banker_username = $number_tab_info['rob_banker_username']; } return $rob_banker_username; } public function refresh_waybill(){ $table_id = Request::instance()->post('table_id'); $boot_id = Request::instance()->post('boot_id'); $ns = Db::name('number_tab')->where(array('table_id' => $table_id, 'boot_id' => $boot_id, 'bet_status' => 3))->field('result,pair')->order('start_time ASC,id ASC')->select(); // 数据存在,输出路单 if($ns){ $result = waybill($ns); $waybill = $result; }else{ $waybill = array(); $waybill['bigEyeRoad'] = []; $waybill['bigRoad'] = []; $waybill['pathway'] = []; $waybill['roach'] = []; $waybill['showRoad'] = []; $waybill = ['status'=>false,'msg'=>'数据不存在','waybill'=>$waybill]; } return json($waybill); } }