home_team) ? trim($req->home_team) : null; $request['status'] = isset($req->status) ? trim($req->status) : '-1'; $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on'; $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ; $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime'); $dt = \App\Lib\DataTable\DataTable::init(); $dt->setDataSource('/admin/Sportsbk/info'); $dt->setLang('sportsbk'); $dt->addColsFields('lg_id', array('templet' => '#liansai', 'sort' => true, 'width' => 160)); $dt->addColsFields('start_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 160)); $dt->addColsFields('home_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 100)); $dt->addColsFields('guest_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 100)); $dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 70)); $dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 70)); $dt->addColsFields('sectionone_two', array('templet' => '#sectionone_two', 'sort' => false, 'width' => 180)); $dt->addColsFields('sectionthere_four', array('templet' => '#sectionthere_four', 'sort' => false, 'width' => 180)); $dt->addColsFields('status', array('templet' => '#matchstatus', 'sort' => false, 'width' => 80)); $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300)); // if (checkRriv('/admin/Sportsbk/edit')) { // $arr[] = 'edit'; // } // $dt->setToolBar($arr, array('width' => 200)); // $dt->enableCheckBox(); return view('admin/sportsbk/outcome', $dt->render($request)); } //篮球赛事作废 function revoke(Req $req){ $match_id = $req->match_id;//赛事id \App\Models\Stlqresult::where('match_id', $match_id)->update(['status'=>4]); \App\Models\SportsBasket::where('match_id', $match_id)->update(['status'=>4]); $upapp = new \App\Models\SportsNoteList(); $data = $upapp->updatesimplex($match_id,$this->code);//修改单式状态 //单式撤单返现 $newapp = new \App\Models\MoneyBuyMatch(); $all = $newapp->allsimplexorder($match_id,$this->code); for ($i=0; $i < count($all); $i++) { $appgx = new SettlementOrder(); $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'zq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']); } //串式撤单只改状态 $str_ids = array_column($newapp->allstrorder($match_id),'order_id'); $csapp = new \App\Models\MoneyBuyStr(); $csapp->updatestatus($str_ids); //修改money_buy_match 投注结果result=2为平 $newapp->updatast($match_id); return responseToJson(1); } //结果添加 function addend(Req $req){ $match_id = $req->input('match_id'); $model = \App\Models\Stlqresult::where('match_id', $match_id)->first(); // $penaltycard = array( // 'home'=>intval($req->homeallcard)?intval($req->homeallcard):0, // 'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0, // 'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0, // 'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0, // ); // $cornerball = array( // 'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0, // 'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0, // 'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0, // 'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0, // ); $model->first_score = $req->firstscore; $model->last_score = $req->lastscore; $model->match_winer = $req->matchwiner; $model->u_home_score = $req->uhomescore; $model->u_guest_score = $req->uguestscore; // $model->penalty_card = json_encode($penaltycard); // $model->corner_ball = json_encode($cornerball); $model->save(); return responseToJson(1); } //查询赛事结果 function Matchresult(Req $req){ $match_id = $req->match_id; $newapp = \App\Models\Stlqresult::where('match_id', $match_id)->first(); $array =array( 'corner_ball' => json_decode($newapp['corner_ball'],true), 'penalty_card' => json_decode($newapp['penalty_card'],true), 'newapp' => $newapp, ); return $array; } //结算 // function Settlementlq(Req $req){ // //查询赛事下所有订单 // $ssid = $req->match_id;//赛事id // $type = $req->type;//是否再结算1,首次结算2,再次结算 // $newapp = new \App\Models\MoneyBuyMatch(); // $simplex_ids = array_column($newapp->allsimplexorder($ssid,'lq'),'order_id'); // $str_ids = array_column($newapp->allstrorder($ssid),'order_id'); // $addnew = new \App\Models\Comendnotice(); // $update = $addnew->addcomendnotice($ssid,'lq'); // if($update['status']==1){ // $SettlementOrder = new SettlementOrder(); // $SettlementOrder->reSettlement($str_ids, 2,$type,$this->code,$ssid);//串式 // $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,$this->code,$ssid);//单式注单 // return responseToJson($data); // }else{ // return responseToJson($update); // } // } function Settlement(Req $req){ $jsurl = config('sconstant.url');//结算请求域名地址 $match_id = $req->match_id; $type = $req->type; $token = session('adminInfo.token'); $notice = \App\Models\Comendnotice::where('match_id', $match_id)->first(); $noticeid = $notice['id']; //查询赛事单式是否有订单(篮球) $newapp = new \App\Models\MoneyBuyMatch(); $simplex_ids = array_column($newapp->allsimplexorder($match_id,'lq'),'order_id'); $str_ids = array_column($newapp->allstrorder($match_id),'order_id'); if(count($simplex_ids)>0 || count($str_ids)>0){ $requet = file_get_contents($jsurl."/WinFail?noticeid=".$noticeid."&token=".$token); if(json_decode($requet,true)['status']==1){ //单式结算 if($simplex_ids){ $simplex = array( 'token'=>$token, 'order_ids'=>'', //订单id字符串,用半角都好分隔 'bettype'=>1, //结算类型 1单式 2串式 'settype'=>2, //结算次数 1首次 2非首冷饮 'game_code'=>'lq', //赛事类型 zq lq wq bq 'match_id'=>$match_id, // 赛事ID 'change_status'=>1 //是否改状态 ); $url=$jsurl.'/Settelement'; $newapp = new \App\Models\Stzqresult(); $simplex_res = $newapp->post_curls($url,$simplex);//返回json $huawei_res = json_decode($simplex_res,true); } //串式结算 if($str_ids){ $tandem = array( 'token'=>$token, 'order_ids'=>'', //订单id字符串,用半角都好分隔 'bettype'=>2, //结算类型 1单式 2串式 'settype'=>2, //结算次数 1首次 2非首冷饮 'game_code'=>'lq', //赛事类型 zq lq wq bq 'match_id'=>$match_id, // 赛事ID 'change_status'=>1 //是否改状态 ); $url=$jsurl.'/Settelement'; $tandem_res = $newapp->post_curls($url,$tandem);//返回json $tandem_res = json_decode($tandem_res,true); } if($huawei_res['status']==1 || $tandem_res['status']==1){ return json_encode(['status'=>1,'msg'=>'结算成功']); }else{ return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!']);//结算错误 } }else{ return json_encode(['status'=>2,'msg'=>'结算有错,请联系管理员!!!']);;//输赢错误 } }else{ $res = \App\Models\Stlqresult::where ('match_id', $match_id)->update(['status' =>3]); $res = \App\Models\SportsBasket::where ('match_id', $match_id)->update(['status' =>3]); return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']); } } function info() { $page = Request::has('page') ? Request::get('page') : ''; $list = Request::has('limit') ? Request::get('limit') : 1; $home_team = Request::has('home_team') ? Request::get('home_team') : ''; $sureblurs = Request::has('sureblurs') ? Request::get('sureblurs') : 'off'; $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : ''; $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : ''; $status = Request::has('status') ? Request::get('status') : ''; $where = array(); $orwhere = array(); if (!empty($home_team)) { if (empty($sureblurs) || $sureblurs == 'off') { $where[] = array('st_lq_result.home_team', 'like', '%' . $home_team . '%'); $orwhere[] = array('st_lq_result.guest_team', 'like', '%' . $home_team . '%'); } else { $where[] = array('st_lq_result.home_team', '=', $home_team); $orwhere[] = array('st_lq_result.guest_team', '=', $home_team); } } if ($status != -1) { $where[] = array('st_lq_result.status', '=', $status); $orwhere[] = array('st_lq_result.status', '=', $status); } if (!empty($star_time)) { $star_time = date('Y-m-d H:i:s', strtotime($star_time)); $where[] = array('st_lq_result.start_time', '>', $star_time); $orwhere[] = array('st_lq_result.start_time', '>', $star_time); } if (!empty($end_time)) { $end_time = date('Y-m-d H:i:s', strtotime($end_time)); $where[] = array('st_lq_result.start_time', '<', $end_time); $orwhere[] = array('st_lq_result.start_time', '<', $end_time); } $newapp = new \App\Models\Stlqresult(); $data = $newapp->resultbklist($list, $page, $where, $orwhere); for ($i=0; $i < count($data['data']); $i++) { $home_score = json_decode($data['data'][$i]['home_score'],true); $guest_score = json_decode($data['data'][$i]['guest_score'],true); $data['data'][$i]['okteamscore'] = $guest_score[1];//第一节客队比分 $data['data'][$i]['ozteamscore'] = $home_score[1];//第一节主队比分 $data['data'][$i]['tkteamscore'] = $guest_score[2];//第二节客队比分 $data['data'][$i]['tzteamscore'] = $home_score[2];//第二节主队比分 $data['data'][$i]['skteamscore'] = $guest_score[3];//第三节客队比分 $data['data'][$i]['szteamscore'] = $home_score[3];//第三节主队比分 $data['data'][$i]['akteamscore'] = $guest_score[4];//第四节客队比分 $data['data'][$i]['azteamscore'] = $home_score[4];//第四节主队比分 } return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']); } //修改添加赛事比分 function updatascore(Req $req){ $only = $req->only;//节数唯一标识 $match_id = $req->match_id;//节数唯一标识 $okteamscore = intval($req->okteamscore);//第一节客队比分 $ozteamscore = intval($req->ozteamscore);//第一节主队比分 $tkteamscore = intval($req->tkteamscore);//第二节客队比分 $tzteamscore = intval($req->tzteamscore);//第二节主队比分 $skteamscore = intval($req->skteamscore);//第三节客队比分 $szteamscore = intval($req->szteamscore);//第三节主队比分 $akteamscore = intval($req->akteamscore);//第四节客队比分 $azteamscore = intval($req->azteamscore);//第四节主队比分 $model = \App\Models\Stlqresult::where('match_id', $match_id)->first(); $model->update_time = date('Y-m-d H:i:s'); $model->match_process = 1; if($only==1 || $only==3 || $only==5 || $only==7){ $guestscore =array( '1' => $okteamscore, '2' => $tkteamscore, '3' => $skteamscore, '4' => $akteamscore, ); $model->guest_score = json_encode($guestscore); } if($only==2 || $only==4 || $only==6 || $only==8){ $homescore =array( '1' => $ozteamscore, '2' => $tzteamscore, '3' => $szteamscore, '4' => $azteamscore, ); $model->home_score = json_encode($homescore); } $model->save(); $addnew = new \App\Models\Comendnotice(); $addnew->addcomendnotice($match_id,'lq'); $twoapp = new \App\Models\SportsBasket(); $twoapp->updatestatus('match_id',$match_id,['status'=>2]);//修改赛事状态 $newapp = new \App\Models\Stlqresult(); $newapp->updatestatus('match_id',$match_id,['status'=>2]);//修改结果状态 return responseToJson(1); } function saislist(){ $lgid = $_POST['lgid'];//赛事id $newstzqcompetition = new \App\Models\SportsBasket(); $league_data = $newstzqcompetition->allcompetition($lgid);//赛事id return $league_data; } function addoutcome(Req $req) { if (!$req->isMethod('post')) { $lange = trans('menu'); $newapp = new \App\Models\BasketLeague(); $league_data = $newapp->allleague();//联赛id return view('admin.sportsbk/addoutcome',['data'=>$league_data]); }else{ $model = new \App\Models\Stlqresult(); $model->lg_id = trim($req->input('lg_id'));//联赛id $model->home_team = trim($req->input('home_team')); $model->guest_team = trim($req->input('guest_team')); $model->home_rate = trim($req->input('home_rate')); $model->guest_rate = trim($req->input('guest_rate')); $model->home_score = trim($req->input('home_score')); $model->guest_score = trim($req->input('guest_score')); $model->all_goal = trim($req->input('all_goal')); $model->match_score = trim($req->input('match_score')); $model->u_home_score = trim($req->input('u_home_score')); $model->u_guest_score = trim($req->input('u_guest_score')); $model->update_time = date('Y-m-d h:i:s', time());//更新时间 $model->match_time = "11:22";//trim($req->input('match_time')); $model->tag = trim($req->input('tag')); $model->status = trim($req->input('status')); $model->match_process = trim($req->input('match_process')); $model->match_id = trim($req->input('match_id'));//赛事id $model->save(); return responseToJson(1); } } //赛事结果修改 function edit(Req $req) { $id = $req->id; if (intval($id) < 1) { return -1; } if (!$req->isMethod('post')) { $data = \App\Models\Stlqresult::where('id', $id)->first(); if (!$data) { return -2; } $data = $data->toArray(); return view('admin.sportsbk/edit', $data); } else { $model = \App\Models\Stlqresult::where('id', $id)->first(); $model->home_team = $req->input('home_team'); $model->guest_team = $req->input('guest_team'); $model->home_rate = $req->input('home_rate'); $model->guest_rate = $req->input('guest_rate'); $model->status = $req->input('status'); //$model->update_time = time(); $model->save(); return responseToJson(1); } } //删除赛事结果 function deleteoutcome(Req $req) { $id = $req->input('id'); if (empty($id)) { return responseToJson(-2001); // } $ids = explode(',', $id); if (!is_array($ids) && intval($ids) < 0) { return responseToJson(-2002); // } if (is_array($ids) && count($ids) > 0) { foreach ($ids as $k => $v) { if (intval($v) < 1) { unset($ids[$k]); } } } // echo '敬请期待';die; $rows = \App\Models\Stlqresult::whereIn('id', $ids)->delete(); if (!$rows) { return responseToJson(-2003); } return responseToJson(1); } }