name_chinese) ? trim($req->name_chinese) : null; $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on'; $request['account'] = isset($req->account) ? trim($req->account) : null; $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null; $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null; $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null; $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null; $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注 $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 0;//是否是冠军联赛投注 0否 1是 $request['status'] = isset($req->status) ? trim($req->status) : '-1'; $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1'; $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null; $request['game_status'] = isset($req->game_status) ? trim($req->game_status) : 0; $request['type'] = isset($req->type) ? trim($req->type) : 'zq'; $dt = \App\Lib\DataTable\DataTable::init(); $dt->setDataSource('/admin/SoccerNoteList/getinfo'); $dt->setLang('sportsnotelist'); //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80)); $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200)); $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100)); $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260)); $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250)); $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200)); $dt->addColsFields('order_status', array('sort' => false, 'width' => 80)); $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110)); // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114)); $dt->addColsFields('game_status', array('sort' => false, 'width' => 80)); // $arr[] = 'view';1 // if (checkRriv('/admin/SoccerNoteList/edit')) { // $arr[] = 'edit'; // } // $dt->setToolBar($arr, array('width' => 70)); $dt->enableCheckBox();//var_dump($request['type']); return view('sports/sports_notelist', $dt->render($request)); } //冠军注单手工结算1 public function championset(Req $req) { $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null; $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on'; $request['account'] = isset($req->account) ? trim($req->account) : null; $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null; $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null; $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null; $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null; $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注 $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 1;//是否是冠军联赛投注 0否 1是 $request['status'] = isset($req->status) ? trim($req->status) : '-1'; $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1'; $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null; $request['type'] = isset($req->type) ? trim($req->type) : 'zq'; $dt = \App\Lib\DataTable\DataTable::init(); $dt->setDataSource('/admin/SoccerNoteList/championsetinfo'); $dt->setLang('sportsnotelist'); //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80)); $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200)); $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100)); $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260)); $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250)); $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200)); $dt->addColsFields('order_status', array('sort' => false, 'width' => 80)); $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110)); // $dt->addColsFields('game_status', array('templet' => '#game_status', 'sort' => false, 'width' => 114)); $dt->addColsFields('game_status', array( 'sort' => false, 'width' => 114)); //$arr[] = 'view'; // if (checkRriv('/admin/SoccerNoteList/edit')) { // $arr[] = 'edit'; // } // $dt->setToolBar($arr, array('width' => 70)); $dt->enableCheckBox();//var_dump($request['type']); return view('sports/sports_notelist', $dt->render($request)); } function championsetinfo() { $page = Request::has('page') ? Request::get('page') : ''; $list = Request::has('limit') ? Request::get('limit') : 10; $account = Request::get('account') ? Request::get('account') : ''; $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' : ''; $order_id = Request::get('order_id') ? Request::get('order_id') : ''; $match_id = Request::get('match_id') ? Request::get('match_id') : ''; $lg_id = Request::get('lg_id') ? Request::get('lg_id') : ''; $status = Request::has('status') ? Request::get('status') : '-1'; $order_status = Request::has('order_status') ? Request::get('order_status') : ''; $p_codes = Request::has('p_codes') ? Request::get('p_codes') : ''; $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off'; $type = Request::has('type') ? Request::get('type') : 'zq'; $where = array(); $where[] = array('money_buy_simplex.is_champion', 1); if (!empty($account)) { if (empty($sureblur) || $sureblur == 'off') { $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%'); } else { $where[] = array('money_buy_simplex.account_name', '=', $account); } } if (!empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '>', $star_time); $where[] = array('money_buy_simplex.money_time', '<', $end_time); } else { $where[] = array('money_buy_simplex.money_time', '>', $star_time); } } else if (empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '<', $end_time); } } if (!empty($order_id)) { $where[] = array('money_buy_simplex.order_id', $order_id); } if (!empty($match_id)) { $where[] = array('money_buy_simplex.match_id', $match_id); } if (!empty($p_codes)) { $where[] = array('money_buy_match.p_code', $p_codes); } //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单 if ($order_status == 1 || $order_status == 2 || $order_status == 3) { $where[] = array('money_buy_simplex.status', '=', $order_status); } //4 5为结算状态 4未结算 5已结算 if ($order_status == 4) { $status = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status == 5) { $status = 2; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.settle_status', '=', $status); } //10进球无效 11红卡无效 if ($order_status == 10) { $use_mark = '进球无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } if ($order_status == 11) { $use_mark = '红卡无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局 if ($order_status == 6) { $result = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 7) { $result = -1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 8) { $result = 3; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 9) { $result = 4; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 12) { $result = 2; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if(!empty($lg_id)){ $where[] = array('money_buy_simplex.lg_id', $lg_id); } if ($status != -1) { $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status != -1) { $where[] = array('money_buy_simplex.status', '=', $order_status); } $where[] = array('money_buy_simplex.game_code', $type); $newapp = new \App\Models\SportsNoteList(); $data = $newapp->getinfo($list, $page, $where, $type); //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id'); return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where); } //修改冠军单订单结果 function orderupgj(Req $req) { $id = $req->id;//37 $orderid = $req->order;//S20190916094723915270970 if (intval($id) < 1) { return -1; } $data = \App\Models\SoccerLeague::where('id', $id)->first(); $odds_code = \App\Models\SoccerOdds::where('lg_id', $id)->where('type', 1)->where('odds_code', '!=', '')->select('odds_code')->distinct()->get()->toArray();//赔率表 for ($i = 0; $i < count($odds_code); $i++) { $allteam[] = \App\Models\SoccerOdds::where('odds_code', $odds_code[$i]['odds_code'])->where('lg_id', $id)->where('type', 1)->select('team')->distinct()->get()->toArray(); } $data = $data->toArray(); $isdisplay = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'status' => 1])->select("game_name")->distinct()->get()->toArray(); $idisplay = array_column($isdisplay, 'game_name'); $displays = implode(",", $idisplay);//转换成字符串 //新增纪录 foreach ($odds_code as $k => $v) { foreach ($allteam[$k] as $kk => $vv) { $name = $v['odds_code']; $isteam = $allteam[$k][$kk]['team']; $res = \App\Models\Stwqleagueresult::where(['lg_id' => $id, 'game_name' => $name, 'result' => $isteam])->first(); $addresult = [ 'lg_id' => $id, 'game_name' => $name, 'result' => $isteam, 'ctime' => date('Y-m-d H:i:s', time()), 'status' => 0, 'updated_at' => date('Y-m-d H:i:s', time()), ]; if (empty($res)) { \App\Models\Stwqleagueresult::insert($addresult); } } } $orderjg = \App\Models\SportsNoteList::where(['order_id' => $orderid])->select("single_result")->first(); $orderjg = json_decode($orderjg['single_result'], true); $data['allteam'] = $allteam; $data['odds_code'] = $odds_code; $data['displays'] = $displays; $data['isdisplay'] = $isdisplay; $data['orderjg'] = $orderjg; $data['orderid'] = $orderid; $data['lg_id'] = $id; return view('sports/orderupgj', $data); } //修改冠军单订单结果提交 function ajaxtj(Req $req) { $isstatus = $req->isstatus;//更新 $order = $req->order; if ($isstatus) { $gjresult = array( 'lg_id' => $req->lg_id ? $req->lg_id : '', 'game_name' => $req->odds_code ? $req->odds_code : '', 'result' => $req->team ? $req->team : '', 'updatetime' => date("Y-m-d H:i:s", time()), ); } else { $gjresult = array( 'lg_id' => '', 'game_name' => '', 'result' => '', ); } \App\Models\SportsNoteList::where(['order_id' => $order])->update(['single_result' => json_encode($gjresult, JSON_UNESCAPED_UNICODE)]); return responseToJson(1); } function info() { $page = Request::has('page') ? Request::get('page') : ''; $list = Request::has('limit') ? Request::get('limit') : 10; $account = Request::get('account') ? Request::get('account') : ''; $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' : ''; $order_id = Request::get('order_id') ? Request::get('order_id') : ''; $match_id = Request::get('match_id') ? Request::get('match_id') : ''; // $status = Request::has('status') ? Request::get('status') : ''; $order_status = Request::has('order_status') ? Request::get('order_status') : ''; $p_codes = Request::has('p_codes') ? Request::get('p_codes') : ''; $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off'; $type = Request::has('type') ? Request::get('type') : 'zq'; $where = array(); $where[] = array('money_buy_simplex.is_champion', '<>', 1); if (!empty($account)) { if (empty($sureblur) || $sureblur == 'off') { $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%'); } else { $where[] = array('money_buy_simplex.account_name', '=', $account); } } if (!empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '>', $star_time); $where[] = array('money_buy_simplex.money_time', '<', $end_time); } else { $where[] = array('money_buy_simplex.money_time', '>', $star_time); } } else if (empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '<', $end_time); } } if (!empty($order_id)) { $where[] = array('money_buy_simplex.order_id', $order_id); } if (!empty($match_id)) { $where[] = array('money_buy_simplex.match_id', $match_id); } if (!empty($p_codes)) { $where[] = array('money_buy_match.p_code', $p_codes); } //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单 if ($order_status == 1 || $order_status == 2 || $order_status == 3) { $where[] = array('money_buy_simplex.status', '=', $order_status); } //4 5为结算状态 4未结算 5已结算 if ($order_status == 4) { $status = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status == 5) { $status = 2; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.settle_status', '=', $status); } //10进球无效 11红卡无效 if ($order_status == 10) { $use_mark = '进球无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } if ($order_status == 11) { $use_mark = '红卡无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局 if ($order_status == 6) { $result = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 7) { $result = -1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 8) { $result = 3; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 9) { $result = 4; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 12) { $result = 2; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } /* if ($status != -1) { $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status != -1) { $where[] = array('money_buy_simplex.status', '=', $order_status); } */ $where[] = array('money_buy_simplex.game_code', $type); $newapp = new \App\Models\SportsNoteList(); $data = $newapp->getinfo($list, $page, $where, $type); return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where); } public function search(Req $req) { $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null; $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on'; $request['account'] = isset($req->account) ? trim($req->account) : null; $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null; $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null; $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null; $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null; $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注 $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 0;//是否是冠军联赛投注 0否 1是 $request['status'] = isset($req->status) ? trim($req->status) : '-1'; $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1'; $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null; $request['type'] = isset($req->type) ? trim($req->type) : 'zq'; $dt = \App\Lib\DataTable\DataTable::init(); $dt->setDataSource('/admin/SoccerNoteList/info'); $dt->setLang('sportsnotelist'); //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80)); $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 210, 'minWidth'=>200)); $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100)); $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260)); $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250)); $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200)); $dt->addColsFields('order_status', array('sort' => false, 'width' => 80)); $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110)); // $dt->addColsFields('settle_status', array('sort' => false, 'width' => 90)); //$arr[] = 'view'; // if (checkRriv('/admin/SoccerNoteList/edit')) { // $arr[] = 'edit'; // } // $dt->setToolBar($arr, array('width' => 70)); $dt->enableCheckBox(); return view('sports/sports_search', $dt->render($request)); } //冠军注单 public function champion(Req $req) { $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null; $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on'; $request['account'] = isset($req->account) ? trim($req->account) : null; $request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null; $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null; $request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null; $request['match_id'] = isset($req->match_id) ? trim($req->match_id) : null; $request['lg_id'] = isset($req->lg_id) ? trim($req->lg_id) : null;//联赛id 用于冠军联赛投注 $request['is_gj'] = isset($req->is_gj) ? trim($req->is_gj) : 1;//是否是冠军联赛投注 0否 1是 $request['status'] = isset($req->status) ? trim($req->status) : '-1'; $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1'; $request['p_codes'] = isset($req->p_codes) ? trim($req->p_codes) : null; $request['type'] = isset($req->type) ? trim($req->type) : 'zq'; $dt = \App\Lib\DataTable\DataTable::init(); $dt->setDataSource('/admin/SoccerNoteList/championinfo'); $dt->setLang('sportsnotelist'); //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80)); $dt->addColsFields('lg_id_order', array('sort' => true, 'width' => 210, 'minWidth' => 200)); $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100)); $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260)); $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250)); $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70)); $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200)); $dt->addColsFields('order_status', array('sort' => false, 'width' => 80)); $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110)); // $dt->addColsFields('game_status', array('sort' => false, 'width' => 90)); //$arr[] = 'view'; // if (checkRriv('/admin/SoccerNoteList/edit')) { // $arr[] = 'edit'; // } // $dt->setToolBar($arr, array('width' => 70)); $dt->enableCheckBox(); return view('sports/sports_search', $dt->render($request)); } function championinfo() { $page = Request::has('page') ? Request::get('page') : ''; $list = Request::has('limit') ? Request::get('limit') : 10; $account = Request::get('account') ? Request::get('account') : ''; $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' : ''; $order_id = Request::get('order_id') ? Request::get('order_id') : ''; $match_id = Request::get('match_id') ? Request::get('match_id') : ''; $lg_id = Request::get('lg_id') ? Request::get('lg_id') : ''; $status = Request::has('status') ? Request::get('status') : ''; $order_status = Request::has('order_status') ? Request::get('order_status') : ''; $p_codes = Request::has('p_codes') ? Request::get('p_codes') : ''; $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off'; $type = Request::has('type') ? Request::get('type') : 'zq'; $where = array(); $where[] = array('money_buy_simplex.is_champion', 1); if (!empty($account)) { if (empty($sureblur) || $sureblur == 'off') { $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%'); } else { $where[] = array('money_buy_simplex.account_name', '=', $account); } } if (!empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '>', $star_time); $where[] = array('money_buy_simplex.money_time', '<', $end_time); } else { $where[] = array('money_buy_simplex.money_time', '>', $star_time); } } else if (empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '<', $end_time); } } if (!empty($order_id)) { $where[] = array('money_buy_simplex.order_id', $order_id); } if (!empty($match_id)) { $where[] = array('money_buy_simplex.match_id', $match_id); } if(!empty($lg_id)){ $where[] = array('money_buy_simplex.lg_id', $lg_id); } if (!empty($p_codes)) { $where[] = array('money_buy_match.p_code', $p_codes); } //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单 if ($order_status == 1 || $order_status == 2 || $order_status == 3) { $where[] = array('money_buy_simplex.status', '=', $order_status); } //4 5为结算状态 4未结算 5已结算 if ($order_status == 4) { $status = 1; $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status == 5) { $status = 2; $where[] = array('money_buy_simplex.settle_status', '=', $status); } //10进球无效 11红卡无效 if ($order_status == 10) { $use_mark = '进球无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } if ($order_status == 11) { $use_mark = '红卡无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局 if ($order_status == 6) { $result = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 7) { $result = -1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 8) { $result = 3; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 9) { $result = 4; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 12) { $result = 2; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } /* if ($status != -1) { $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status != -1) { $where[] = array('money_buy_simplex.status', '=', $order_status); } */ $where[] = array('money_buy_simplex.game_code', $type); $newapp = new \App\Models\SportsNoteList(); $data = $newapp->getinfo($list, $page, $where, $type); return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where); } //查询赛事结果 // function Sairesult(Req $req){ // $did = $req->did; // $qlgame = $req->qlgame?$req->qlgame:'zq'; // $newapp = \App\Models\SportsNoteList::where('id', $did)->first(); // if($qlgame=='zq'){ // if($newapp['match_id']){ // $newre = new \App\Models\Stzqresult(); // $teamname = $newre->matchjg($newapp['match_id']); // }else{ // $teamname =''; // } // }elseif($qlgame=='lq'){ // if($newapp['match_id']){ // $newre = new \App\Models\Stlqresult(); // $teamname = $newre->matchjg($newapp['match_id']); // }else{ // $teamname =''; // } // }elseif($qlgame=='bq'){ // if($newapp['match_id']){ // $newre = new \App\Models\Stbqresult(); // $teamname = $newre->matchjg($newapp['match_id']); // }else{ // $teamname =''; // } // }elseif($qlgame=='wq'){ // if($newapp['match_id']){ // $newre = new \App\Models\Stwqresult(); // $teamname = $newre->matchjg($newapp['match_id']); // }else{ // $teamname =''; // } // }else{ // $data = "参数错误"; // } // $data =array( // 'singleresult' => json_decode($newapp['single_result'],true), // 'teamname' => $teamname, // ); // return $data; // } // function Sairesult(Req $req){ // $did = $req->did; // $model = \App\Models\SportsNoteList::where('id', $did)->first(); // $pid = $model['match_id']; // $saisjg = \App\Models\Stzqresult::where('match_id',$pid)->first()->toArray();//赛事结果 // $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'],true); // $saisjg['first_score'] = json_decode($saisjg['first_score'],true); // $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'],true); // $saisjg['warn_more'] = json_decode($saisjg['warn_more'],true); // } //结果添加 function addend(Req $req) { $did = $req->did;//59;// $qlgame = $req->qlgame;//1; $model = \App\Models\SportsNoteList::where('id', $did)->first(); $pid = $model['match_id']; if ($qlgame == 1) { if ($model['result_flag'] != 1) { $saisjg = \App\Models\Stzqresult::where('match_id', $pid)->first()->toArray();//赛事结果 $saisjg['corner_ball'] = json_decode($saisjg['corner_ball'], true); $saisjg['first_score'] = json_decode($saisjg['first_score'], true); $saisjg['penalty_card'] = json_decode($saisjg['penalty_card'], true); $saisjg['warn_more'] = json_decode($saisjg['warn_more'], true); $model->single_result = json_encode([$saisjg], JSON_UNESCAPED_UNICODE); $model->save(); } $newm = \App\Models\SportsNoteList::where('id', $did)->first(); return $newm['single_result']; } else { $new = \App\Models\SportsNoteList::where('id', $did)->first(); $newa = json_decode($new['single_result'], true); $newa[0]['home_score'] = $req->home_score;//主队进球 $newa[0]['guest_score'] = $req->guest_score;//客队进球 $newa[0]['all_goal'] = intval($req->guest_score) + intval($req->home_score);//总进球 $newa[0]['last_score'] = $req->lastscore ? $req->lastscore : '';//最后进球球队 $newa[0]['match_winer'] = $req->matchwiner ? $req->matchwiner : '';//赢球球队 $newa[0]['update_time'] = time();//更新时间 $newa[0]['u_guest_score'] = $req->u_guest_score;//上半场-主队进球数 $newa[0]['u_home_score'] = $req->u_home_score;//上半场-客队进球数 $newa[0]['penalty_card'] = array( 'home' => $req->homeallcard, 'guest' => $req->guestallcard, 'home_half' => $req->homehalfcard, 'guest_half' => $req->guesthalfcard, ); $newa[0]['corner_ball'] = array( 'home' => $req->homeallcorner, 'guest' => $req->guestallcorner, 'home_half' => $req->homehalfcorner, 'guest_half' => $req->guesthalfcorner, ); //最新进球 $newa[0]['first_score'] = array( 'teamscore' => $req->firstscore ? $req->firstscore : 0,//最先进球球队 'scoretime' => $req->onescoretime ? $req->onescoretime : '',//进球时间 'scoretype' => $req->firststye ? $req->firststye : '',//进球方式 ); $model->single_result = json_encode($newa, JSON_UNESCAPED_UNICODE); $model->result_flag = 1; $model->save(); return responseToJson(1); } } function getinfo() { $page = Request::has('page') ? Request::get('page') : ''; $list = Request::has('limit') ? Request::get('limit') : 10; $account = Request::get('account') ? Request::get('account') : ''; $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' : ''; $order_id = Request::get('order_id') ? Request::get('order_id') : ''; $match_id = Request::get('match_id') ? Request::get('match_id') : ''; $status = Request::has('status') ? Request::get('status') : '-1'; $order_status = Request::has('order_status') ? Request::get('order_status') : ''; $p_codes = Request::has('p_codes') ? Request::get('p_codes') : ''; $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off'; $type = Request::has('type') ? Request::get('type') : 'zq'; $where = array(); $where[] = array('money_buy_simplex.is_champion', '<>', 1); if (!empty($account)) { if (empty($sureblur) || $sureblur == 'off') { $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%'); } else { $where[] = array('money_buy_simplex.account_name', '=', $account); } } if (!empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '>', $star_time); $where[] = array('money_buy_simplex.money_time', '<', $end_time); } else { $where[] = array('money_buy_simplex.money_time', '>', $star_time); } } else if (empty($star_time)) { if (!empty($end_time)) { $where[] = array('money_buy_simplex.money_time', '<', $end_time); } } if (!empty($order_id)) { $where[] = array('money_buy_simplex.order_id', $order_id); } if (!empty($match_id)) { $where[] = array('money_buy_simplex.match_id', $match_id); } if (!empty($p_codes)) { $where[] = array('money_buy_match.p_code', $p_codes); } //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单 if ($order_status == 1 || $order_status == 2 || $order_status == 3) { $where[] = array('money_buy_simplex.status', '=', $order_status); } //4 5为结算状态 4未结算 5已结算 if ($order_status == 4) { $status = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status == 5) { $status = 2; $where[] = array('money_buy_simplex.status', '=', 1); $where[] = array('money_buy_simplex.settle_status', '=', $status); } //10进球无效 11红卡无效 if ($order_status == 10) { $use_mark = '进球无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } if ($order_status == 11) { $use_mark = '红卡无效'; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_simplex.use_mark', '=', $use_mark); } //6 7 8 9 12 为输赢 6赢 7输 8赢一半 9输一半 12和局 if ($order_status == 6) { $result = 1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 7) { $result = -1; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 8) { $result = 3; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 9) { $result = 4; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } if ($order_status == 12) { $result = 2; $where[] = array('money_buy_simplex.status', '=',1); $where[] = array('money_buy_match.result', '=', $result); } /* if ($status != -1) { $where[] = array('money_buy_simplex.settle_status', '=', $status); } if ($order_status != -1) { $where[] = array('money_buy_simplex.status', '=', $order_status); } */ $where[] = array('money_buy_simplex.game_code', $type); $newapp = new \App\Models\SportsNoteList(); $data = $newapp->getinfo($list, $page, $where, $type); //$alldata = Models\MoneyBuyMatch::where('bet_type',1)->where('is_rolling',1)->distinct('order_id')->count('order_id'); return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where); } /** * 取消结算 */ public function no_cancel_end(Req $req){ $order_id = $req->order_id; if(empty($order_id)){ return responseToJson(-1, '参数错误'); } try { //开启事务 DB::beginTransaction(); //处理注单数据 $orderModel = new \App\Models\SportsNoteList(); //取消结算处理 $ret = $orderModel->no_cancel_end($order_id); if($ret != 1) throw new \Exception('取消结算失败'); //提交事务 DB::commit(); return responseToJson(1, '成功'); } catch (\Exception $e) { //回滚事务 DB::rollBack(); return responseToJson(-1, $e->getMessage()); } } /** * 取消作废 */ public function no_cancel_invalid(Req $req){ $order_id = $req->order_id; if(empty($order_id)){ return responseToJson(-1, '参数错误'); } try { //开启事务 DB::beginTransaction(); //处理注单数据 $orderModel = new \App\Models\SportsNoteList(); //取消作废处理 $ret = $orderModel->no_cancel_invalid($order_id); if($ret != 1) throw new \Exception('取消作废失败'); //提交事务 DB::commit(); return responseToJson(1, '成功'); } catch (\Exception $e) { //回滚事务 DB::rollBack(); return responseToJson(-1, $e->getMessage()); } } /** *单式注单作废 */ public function invalid(Req $req) { $id = $req->id; $reason = $_GET['reason']; if (intval($id) < 1) { return -1; } $order = \App\Models\SportsNoteList::where('id', $id)->first(); //用戶账户金额 $account_money = \App\Models\Account_detailed::where('account_identity', $order->account_identity)->first(); //反水 $water_return_money = \App\Models\Money_details::where('trade_id', $order->order_id)->where('trade_type', '7')->first(); if (!empty($water_return_money)) { $water_return = $water_return_money->money; } else { $water_return = 0; } //撤单后用户账户金额 $available_cash = $account_money->available_cash; $new_available_cash = $available_cash + $order->money - $order->gain_money - $water_return; $model = new \App\Models\Money_details(); $model->info_identity = UUID(); $model->trade_id = $order->order_id; $model->account_name = $order->account_name; $model->account_identity = $order->account_identity; $model->money = abs($order->money - $order->gain_money - $water_return); $model->money_time = date("Y-m-d H:i:s", time()); if ($new_available_cash > $available_cash) { $model->money_type = '1'; } else { $model->money_type = '2'; } $model->money_cash = $new_available_cash; $model->trade_type = '3'; $model->trade_desc = '管理员作废单式注单'; $model->status = '1'; try { DB::beginTransaction();//开启事务 \App\Models\SportsNoteList::where('id', $id)->update(['status' => '2', 'gain_money' => '0', 'use_mark' => $reason]); \App\Models\Account_detailed::where('account_identity', $order->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]); $model->save(); DB::commit();//提交 return 1; } catch (Exception $e) { DB::rollback();//回滚 return -1; } } /** *单式注单首次结算 */ public function settlement(Req $req) { $id = $req->id; if (intval($id) < 1) { return -1; } $order = \App\Models\SportsNoteList::where('id', $id)->first(); $order_id = $order->order_id; $order_ids = array($order->order_id); $match_id = $order->match_id; $game_code = $order->game_code; $bet_type = 1;//单式注单 //return $match_id; //判断输赢 $settlementWinFail = new SettlementWinFail(); $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type); //结算 $SettlementOrder = new SettlementOrder(); $settype = 1; //首次结算 $data = $SettlementOrder->reSettlement($order_ids, $bet_type, $settype, $game_code, $match_id, $match_status = 0); return $data; } /** *单式注单重新结算 */ // public function resettlement(Req $req) { // $id = $req->id; // if (intval($id) < 1) { // return -1; // } // $order = \App\Models\SportsNoteList::where('id',$id)->first(); // $match_id = $order->match_id; // $game_code = $order->game_code; // $order_id = $order->order_id; // $order_ids = array($order->order_id); // //return $match_id; // $bet_type = 1;//单式注单 // //重新判断输赢 // $settlementWinFail = new SettlementWinFail(); // $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type); // //结算 // $SettlementOrder = new SettlementOrder(); // $settype = 2; //重新结算 // $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0); // return $data; // } public function resettlement(Req $req) { $order_id = $req->order_id; $type = $req->type; $match_id = $req->match_id; $jsurl = config('sconstant.url');//结算请求域名地址 $token = session('adminInfo.token'); //查询是否有订单 $newapp = new \App\Models\SportsNoteList(); $simplexnum = $newapp->onlyorder($order_id); if ($simplexnum == 1) { $requet = file_get_contents($jsurl . "/DoWinFailOneOrder?order_id=" . $order_id . "&token=" . $token); if (json_decode($requet, true)['status'] == 1) { $napp = new \App\Models\Stzqresult(); $simplex = array( 'token' => $token, 'order_ids' => $order_id, //订单id字符串,用半角都好分隔 'bettype' => 1, //结算类型 1单式 2串式 'settype' => 2, //结算次数 1首次 2非首冷饮 'game_code' => $type, //赛事类型 zq lq wq bq 'match_id' => $match_id, // 赛事ID 'change_status' => 0 //是否改状态 ); $url = $jsurl . '/Settelement'; $simplex_res = $napp->post_curls($url, $simplex);//返回json $huawei_res = json_decode($simplex_res, true); if ($huawei_res['status'] == 1) { return json_encode(['status' => 1, 'msg' => '结算成功']); } else { return json_encode(['status' => 4, 'msg' => '结算失败']); } } else { return json_encode(['status' => 3, 'msg' => '输赢判断错误']); } } else { return json_encode(['status' => 2, 'msg' => '订单不存在']); } } /** *单式注单批量结算 */ public function batchsettlement() { $orders = \App\Models\SportsNoteList::where('settle_status', '1')->get(); $order_ids = array(); for ($i = 0; $i < count($orders); $i++) { $result = \App\Models\MoneyBuyMatch::where('batch_id', $orders[$i]->batch_id)->where('match_id', $orders[$i]->match_id)->get(); $res = array(); for ($j = 0; $j < count($result); $j++) { $res[] = $result[$j]->result; } if (!in_array(0, $res)) { $order_ids[] = $orders[$i]->order_id; } } $SettlementOrder = new SettlementOrder(); $bet_type = 1;//单式注单 $data = $SettlementOrder->reSettlement($order_ids, $bet_type); return $data; } /** *删除订单 */ public function delete(Req $req) { $id = $req->input('id'); if (empty($id)) { return responseToJson(-2001); //id } $ids = explode(',', $id); if (!is_array($ids) && intval($ids) < 0) { return responseToJson(-2002); //id } if (is_array($ids) && count($ids) > 0) { foreach ($ids as $k => $v) { if (intval($v) < 1) { unset($ids[$k]); } } } $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete(); if (!$rows) { return responseToJson(-2003); //id } return responseToJson(1, trans('menu.delete_success')); //id } /** * 投注金额统计 */ function moneycount() { $where = Request::has('where') ? Request::get('where') : ''; $type = Request::has('type') ? Request::get('type') : 'zq'; $db = new \App\Models\SportsNoteList; $data = $db->MoneyCount($where, $type); return responseToJson($data); } //单式订单数据 public function manualmatchget(Req $req) { $order_id = isset($req->order_id) ? $req->order_id : 0; $model = new \App\Models\SportsNoteList(); $ret = $model->getorder($order_id); if ($ret) { // $league = db('st_'.$ret->game_code.'_league')->where('id',$ret->lg_id)->first(); // $ret->league = $league->name_chinese; $modelcode = new \App\Models\StoddsCode(); $opcode_nameArr = $modelcode->getTypeDatas($ret->game_code); $ret = $ret->toArray(); foreach ($ret['matchdatas'] as $key => $val) { $tmp_pcode = $val['p_code']; $tmp_code = $val['odds_code']; $ret['matchdatas'][$key]['odds_name'] = isset($opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name']) ? $opcode_nameArr[$tmp_pcode][$tmp_code]['odds_name'] : ''; } return responseToJson(1, '成功', $ret); } else { return responseToJson(-1, 'false', $ret); } } //单式订单直接手动更改输赢结果并结算 public function manualmatchpdate(Req $req) { $order_id = isset($req->order_id) ? $req->order_id : 0; $datas = isset($req->matchdata) ? $req->matchdata : []; $datas = json_decode($datas, true); if (empty($order_id) || empty($datas)) { return responseToJson(-1, '参数不能为空!'); } $model = new \App\Models\SportsNoteList(); $modeldata = $model->getorder($order_id); if (empty($modeldata)) { return responseToJson(-1, 'false'); } $sdataArr = []; foreach ($datas as $val) { $tmp_id = $val['id']; $tmp_result = intval($val['result']); $tmp_matchword = trim($val['matchresult']); if (!in_array($tmp_result, [-1, 1, 2, 3, 4])) { continue; } $sdataArr[$tmp_id] = ['result' => $tmp_result, 'matchresult' => $tmp_matchword]; } if (empty($sdataArr)) { return responseToJson(-2, '没有要更新的数据'); } $chageNum = 0; foreach ($modeldata->matchdatas as $key => $val) { $id = $val->id; if (isset($sdataArr[$id])) { if ($val->result != $sdataArr[$id]['result'] || $val->matchwork != $sdataArr[$id]['matchresult']) { $val->result = $sdataArr[$id]['result']; $val->matchresult = $sdataArr[$id]['matchresult']; $val->save(); $chageNum++; } } } if ($chageNum) { $modeldata->is_manual = 1; $modeldata->save(); } else { return responseToJson(1, '没有更新操作数据!'); } $data = [ 'token' => session('adminInfo.token'), //外网 'order_ids' => $modeldata->order_id, 'bettype' => 1, 'settype' => 2, 'game_code' => $modeldata->game_code, 'match_id' => $modeldata->match_id, 'change_status' => 0, 'is_manual' => 1, ]; $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data); $retjson = json_decode($ret, true); if (isset($retjson['status']) && $retjson['status'] == 1) { $model->where('order_id', $order_id)->update(['settle_status' => 2]); } return responseToJson(1, '更新成功'); } //冠军注单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算 public function matchpdate_v2(Req $req) { $order_id = isset($req->order_id) ? $req->order_id : 0; $game_code = isset($req->game_code) ? $req->game_code : 0; $match_id = isset($req->match_id) ? $req->match_id : 0; $pdatas = isset($req->matchdata) ? $req->matchdata : []; $pdatas = json_decode($pdatas, true); if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) { return responseToJson(0, '参数错误'); } $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first(); if (empty($buyModel)) { return responseToJson(0, '订单数据错误'); } $game_name = $pdatas['odds_code']; $result = $pdatas['result']; $res = []; $res['lg_id'] = $match_id; $res['game_name'] = $game_name; $res['result'] = $result; $buyModel->single_result = json_encode([$res], 256); //$buyModel->single_result = '{"lg_id":'.$match_id.',"game_name":'.$game_name.',"game_name":'.$result.',"game_name":'.time().'}'; $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]); } //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算 public function ___manualmatchpdate_v2(Req $req) { $order_id = isset($req->order_id) ? $req->order_id : 0; $game_code = isset($req->game_code) ? $req->game_code : 0; $match_id = isset($req->match_id) ? $req->match_id : 0; $pdatas = isset($req->matchdata) ? $req->matchdata : []; $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : '';//进程 $home_sorce = isset($req->home) ? $req->home : '';//主队比分 $guest_sorce = isset($req->guest) ? $req->guest : '';//客队比分 $pdatas = json_decode($pdatas, true); if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) { return responseToJson(0, '参数错误'); } if(in_array(-1,$pdatas)){ return responseToJson(-1, '输入比分错误'); } $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first(); if (empty($buyModel)) { return responseToJson(0, '订单数据错误'); } $restModel = ''; switch ($game_code) { case 'zq': $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first(); break; case 'lq': $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first(); break; case 'wq': $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first(); break; case 'bq': $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first(); break; } if (empty($restModel)) { return responseToJson(0, '赛事结果记录没有找到,数据错误'); } if ($game_code == 'zq') { $home = intval($pdatas['home']); $guest = intval($pdatas['guest']); $home_u = intval($pdatas['home_u']); $guest_u = intval($pdatas['guest_u']); $restModel->home_score = $home; $restModel->guest_score = $guest; $restModel->u_home_score = $home_u; $restModel->u_guest_score = $guest_u; $restModel->corner_ball = json_decode($restModel->corner_ball, 256); $restModel->penalty_card = json_decode($restModel->penalty_card, 256); $restModel->first_score = json_decode($restModel->first_score, 256); $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } if ($game_code == 'lq') { $home = $pdatas['home']; $guest = $pdatas['guest']; $restModel->home_score = ['1' => intval($home['0']), '2' => intval($home['1']), '3' => intval($home['2']), '4' => intval($home['3'])]; $restModel->guest_score = ['1' => intval($guest['0']), '2' => intval($guest['1']), '3' => intval($guest['2']), '4' => intval($guest['3'])]; $restModel->u_home_score = intval($home['0']) + intval($home['1']); $restModel->u_guest_score = intval($guest['0']) + intval($guest['1']); $all_home = intval($home['0']) + intval($home['1']) + intval($home['2']) + intval($home['3']); $all_guest = intval($guest['0']) + intval($guest['1']) + intval($guest['2']) + intval($guest['3']); $restModel->all_goal = $all_home + $all_guest; $restModel->match_score = $all_home . ':' . $all_guest; $restModel->match_winer = $all_home > $all_guest ? $restModel->home_team : $restModel->guest_team; $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } if ($game_code == 'bq') { $home = $pdatas['home']; $guest = $pdatas['guest']; $home_other = $pdatas['home_other']; $guest_other = $pdatas['guest_other']; $arrs = []; for ($i = 0; $i <= 8; $i++) { $j = $i + 1; $arrs[$j] = [ 'home' => intval($home[$i]), 'guest' => intval($guest[$i]), ]; } $arrs['other'] = [ 'home' => intval($home_other), 'guest' => intval($guest_other), ]; $restModel->match_score_t = $arrs; $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } if ($game_code == 'wq') { $home = $pdatas['home']; $guest = $pdatas['guest']; $arrs = []; for ($i = 0; $i <= 4; $i++) { $j = $i + 1; $arrs[$j] = [ 'home' => intval($home[$i]), 'guest' => intval($guest[$i]), ]; } $restModel->inning = $arrs; $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]); } //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算 public function manualmatchpdate_v2(Req $req) { $order_id = isset($req->order_id) ? $req->order_id : 0; $game_code = isset($req->game_code) ? $req->game_code : 0; $match_id = isset($req->match_id) ? $req->match_id : 0; $pdatas = isset($req->matchdata) ? $req->matchdata : []; $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : '';//进程 $home_sorce = isset($req->home) ? $req->home : '';//主队比分 $guest_sorce = isset($req->guest) ? $req->guest : '';//客队比分 $pdatas = json_decode($pdatas, true); if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) { return responseToJson(0, '参数错误'); } if(in_array(-1,$pdatas)){ return responseToJson(-1, '输入比分错误'); } $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first(); if (empty($buyModel)) { return responseToJson(0, '订单数据错误'); } $restModel = ''; switch ($game_code) { case 'zq': $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first(); break; case 'lq': $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first(); break; case 'wq': $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first(); break; case 'bq': $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first(); break; } if (empty($restModel)) { return responseToJson(0, '赛事结果记录没有找到,数据错误'); } if ($game_code == 'zq') { if($ScoreTitle == '上半'){ //替换上半场比分 $restModel->u_home_score = $home_sorce; $restModel->u_guest_score = $guest_sorce; } if($ScoreTitle == '全场'){ //替换全场比分 $restModel->home_score = $home_sorce; $restModel->guest_score = $guest_sorce; } if($ScoreTitle == '角球上半'){ //获取角球数据 arr {"home":0,"guest":0,"home_half":0,"guest_half":0} $corner_arr = json_decode($restModel->corner_ball,256); //替换上半场角球比分 $corner_arr['home_half'] = $home_sorce; $corner_arr['guest_half'] = $guest_sorce; $restModel->corner_ball = json_encode($corner_arr); } if($ScoreTitle == '角球全场'){ //获取角球数据 arr {"home":0,"guest":0,"home_half":0,"guest_half":0} $corner_arr = json_decode($restModel->corner_ball,256); //替换全场角球比分 $corner_arr['home'] = $home_sorce; $corner_arr['guest'] = $guest_sorce; $restModel->corner_ball = json_encode($corner_arr); } $restModel->corner_ball = json_decode($restModel->corner_ball, 256); $restModel->penalty_card = json_decode($restModel->penalty_card, 256); $restModel->first_score = json_decode($restModel->first_score, 256); $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } if ($game_code == 'lq') { if($ScoreTitle == '全场'){ $restModel->home_score = ['1' => intval($home_sorce), '2' => 0, '3' => 0, '4' => 0]; $restModel->guest_score = ['1' => intval($guest_sorce), '2' => 0, '3' => 0, '4' => 0]; } if($ScoreTitle == '上半'){ $restModel->home_score = ['1' => intval($home_sorce), '2' => 0, '3' => 0, '4' => 0]; $restModel->guest_score = ['1' => intval($guest_sorce), '2' => 0, '3' => 0, '4' => 0]; } if($ScoreTitle == '下半'){ $restModel->home_score = ['1' => 0, '2' => 0, '3' => intval($home_sorce), '4' => 0]; $restModel->guest_score = ['1' => 0, '2' => 0, '3' => intval($guest_sorce), '4' => 0]; } if($ScoreTitle == '第一节'){ $restModel->home_score = ['1' => intval($home_sorce), '2' => 0, '3' => 0, '4' => 0]; $restModel->guest_score = ['1' => intval($guest_sorce), '2' => 0, '3' => 0, '4' => 0]; } if($ScoreTitle == '第二节'){ $restModel->home_score = ['1' => 0, '2' => intval($home_sorce), '3' => 0, '4' => 0]; $restModel->guest_score = ['1' => 0, '2' => intval($guest_sorce), '3' => 0, '4' => 0]; } if($ScoreTitle == '第三节'){ $restModel->home_score = ['1' => 0, '2' => 0, '3' => intval($home_sorce), '4' => 0]; $restModel->guest_score = ['1' => 0, '2' => 0, '3' => intval($guest_sorce), '4' => 0]; } if($ScoreTitle == '第四节'){ $restModel->home_score = ['1' => 0, '2' => 0, '3' => 0, '4' => intval($home_sorce)]; $restModel->guest_score = ['1' => 0, '2' => 0, '3' => 0, '4' => intval($guest_sorce)]; } $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } if ($game_code == 'bq') { $home = $pdatas['home']; $guest = $pdatas['guest']; $home_other = $pdatas['home_other']; $guest_other = $pdatas['guest_other']; $arrs = []; for ($i = 0; $i <= 8; $i++) { $j = $i + 1; $arrs[$j] = [ 'home' => intval($home[$i]), 'guest' => intval($guest[$i]), ]; } $arrs['other'] = [ 'home' => intval($home_other), 'guest' => intval($guest_other), ]; $restModel->match_score_t = $arrs; $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } if ($game_code == 'wq') { //{"1":{"home":0,"guest":0},"2":{"home":0,"guest":0},"3":{"home":0,"guest":0},"4":{"home":0,"guest":0},"5":{"home":0,"guest":0},"all":{"home":0,"guest":0}} if($ScoreTitle == '全场'){ $arrs = [ '1'=>['home'=>$home_sorce,'guest'=>$guest_sorce], '2'=>['home'=>0,'guest'=>0], '3'=>['home'=>0,'guest'=>0], '4'=>['home'=>0,'guest'=>0], '5'=>['home'=>0,'guest'=>0], 'all'=>['home'=>0,'guest'=>0], ]; } if($ScoreTitle == '冠军'){ if($home_sorce > $guest_sorce){ $arrs = [ '1'=>['home'=>1,'guest'=>0], '2'=>['home'=>1,'guest'=>0], '3'=>['home'=>1,'guest'=>0], '4'=>['home'=>1,'guest'=>0], '5'=>['home'=>1,'guest'=>0], 'all'=>['home'=>0,'guest'=>0], ]; }else{ $arrs = [ '1'=>['home'=>0,'guest'=>1], '2'=>['home'=>0,'guest'=>1], '3'=>['home'=>0,'guest'=>1], '4'=>['home'=>0,'guest'=>1], '5'=>['home'=>0,'guest'=>1], 'all'=>['home'=>0,'guest'=>0], ]; } } if($ScoreTitle == '第一盘'){ $arrs = [ '1'=>['home'=>$home_sorce,'guest'=>$guest_sorce], '2'=>['home'=>0,'guest'=>0], '3'=>['home'=>0,'guest'=>0], '4'=>['home'=>0,'guest'=>0], '5'=>['home'=>0,'guest'=>0], 'all'=>['home'=>0,'guest'=>0], ]; } if($ScoreTitle == '第二盘'){ $arrs = [ '1'=>['home'=>0,'guest'=>0], '2'=>['home'=>$home_sorce,'guest'=>$guest_sorce], '3'=>['home'=>0,'guest'=>0], '4'=>['home'=>0,'guest'=>0], '5'=>['home'=>0,'guest'=>0], 'all'=>['home'=>0,'guest'=>0], ]; } if($ScoreTitle == '第三盘'){ $arrs = [ '1'=>['home'=>0,'guest'=>0], '2'=>['home'=>0,'guest'=>0], '3'=>['home'=>$home_sorce,'guest'=>$guest_sorce], '4'=>['home'=>0,'guest'=>0], '5'=>['home'=>0,'guest'=>0], 'all'=>['home'=>0,'guest'=>0], ]; } if($ScoreTitle == '第四盘'){ $arrs = [ '1'=>['home'=>0,'guest'=>0], '2'=>['home'=>0,'guest'=>0], '3'=>['home'=>0,'guest'=>0], '4'=>['home'=>$home_sorce,'guest'=>$guest_sorce], '5'=>['home'=>0,'guest'=>0], 'all'=>['home'=>0,'guest'=>0], ]; } if($ScoreTitle == '第五盘'){ $arrs = [ '1'=>['home'=>0,'guest'=>0], '2'=>['home'=>0,'guest'=>0], '3'=>['home'=>0,'guest'=>0], '4'=>['home'=>0,'guest'=>0], '5'=>['home'=>$home_sorce,'guest'=>$guest_sorce], 'all'=>['home'=>0,'guest'=>0], ]; } $restModel->inning = $arrs; $restModel->warn_more = json_decode($restModel->warn_more, 256); $buyModel->single_result = json_encode([$restModel], 256); $buyModel->result_flag = 1; $buyModel->is_manual = 1; $ret = $buyModel->save(); if ($ret) { $ret2 = $this->do_win_set($order_id, $game_code, $match_id); if ($ret2['status'] == 1) { return responseToJson(1, '操作成功!'); } else { return responseToJson(0, '操作失败2!--' . $ret2['data']); } } return responseToJson(0, '更新失败1'); } return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]); } //修复比分时用到订单信息及比赛结果数据 public function manualmatchget_v2(Req $req) { $order_id = isset($req->order_id) ? $req->order_id : 0; $ScoreTitle = isset($req->ScoreTitle) ? $req->ScoreTitle : 0; $model = new MoneyBuySimplexModel(); $ret = $model->OrderinfoResult($order_id,$ScoreTitle); if ($ret && !empty($ret['result'])) { return responseToJson(1, '成功', $ret); } else { return responseToJson(-1, 'false', $ret); } } //先提交输赢,再结算 private function do_win_set($order_id, $game_code, $match_id) { $winret = $this->do_winfail($order_id, $game_code, $match_id); if ($winret['status'] == 1) { $setret = $this->do_settelement($order_id, $game_code, $match_id); if ($setret['status'] == 1) { return ['status' => 1, 'msg' => 'success', 'data' => []]; } else { return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']]; } } else { return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']]; } } //单订单手动提交输赢计算 private function do_winfail($order_id, $game_code, $match_id) { $data = [ 'token' => session('adminInfo.token'), //外网 'order_id' => $order_id, ]; $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data); return json_decode($ret, true); } //单订单手动提交结算 private function do_settelement($order_id, $game_code, $match_id) { $data = [ 'token' => session('adminInfo.token'), //外网 'order_ids' => $order_id, 'bettype' => 1, 'settype' => 2, 'game_code' => $game_code, 'match_id' => $match_id, 'change_status' => 0, 'is_manual' => 1, ]; $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data); return json_decode($ret, true); } private function request_post($url = '', $param = '') { if (empty($url) || empty($param)) { return false; } $postUrl = $url; $curlPost = $param; $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页 curl_setopt($ch, CURLOPT_HEADER, 0);//设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec($ch);//运行curl curl_close($ch); return $data; } //获取球类分类下的父级玩法数据 public function getpcode(){ $game_type = $_GET["game_type"]; $pcode = new \App\Models\StoddsCode(); $p_code = $pcode->getpcode($game_type); return json_encode($p_code); } }