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['status'] = isset($req->status) ? trim($req->status) : '-1'; $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('templet' => '#userdetail', 'sort' => true, 'width' => 200)); $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 120)); $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 120)); $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 240)); $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 80)); $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200)); $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 120)); $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_notelist', $dt->render($request)); } 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') : ''; $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off'; $type = Request::has('type') ? Request::get('type') : 'zq'; $where = array(); 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 ($status != -1) { $where[] = array('money_buy_simplex.settle_status', '=', $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 settlement(Req $req) { $id = $req->id; if (intval($id) < 1) { return -1; } $order = \App\Models\SportsNoteList::where('id', $id)->first(); $order_ids = array($order->order_id); //return $order_ids; $SettlementOrder = new SettlementOrder(); $bet_type = 1;//单式注单 $data = $SettlementOrder->reSettlement($order_ids, $bet_type); return $data; } /** *单式注单重新结算 */ public function resettlement(Req $req) { $id = $req->id; if (intval($id) < 1) { return -1; } $order = \App\Models\SportsNoteList::where('id',$id)->first(); $order_ids = array($order->order_id); //return $order_ids; $SettlementOrder = new SettlementOrder(); $bet_type = 1;//单式注单 $data = $SettlementOrder->reSettlement($order_ids,$bet_type); return $data; //获取此订单下包含的赛事玩法 $matchs = \App\Models\MoneyBuyMatch::where('batch_id',$order->batch_id)->where('match_id',$order->match_id)->where('bet_type','1')->get()->toArray(); $win_money = 0; //减本金 // for($i=0;$ibet_money; // if($matchs[$i]->result == 0){ //未处理 // return ""; // }else if($matchs[$i]->result == -1){ //输 // $money = 0-$matchs[$i]->bet_money; // }else if($matchs[$i]->result == 1){ //赢 // $odds = $matchs[$i]->odds; // $money = $money*$odds-$matchs[$i]->bet_money; // }else if($matchs[$i]->result == 2){ //平 // $money = 0; // }else if($matchs[$i]->result == 3){ //赢半平半 // $odds = $matchs[$i]->odds; // $money = $money/2*$odds+$money/2*1-$matchs[$i]->bet_money; // }else if($matchs[$i]->result == 4){ //输半平半 // $money = $money/2*1-$matchs[$i]->bet_money; // } // $win_money = $win_money+$money; // } //不减本金 for($i=0;$ibet_money; if($matchs[$i]->result == 0){ //未处理 return ""; }else if($matchs[$i]->result == -1){ //输 $money = 0; }else if($matchs[$i]->result == 1){ //赢 $odds = $matchs[$i]->odds; $money = $money*$odds; }else if($matchs[$i]->result == 2){ //平 $money = $money*1; }else if($matchs[$i]->result == 3){ //赢半平半 $odds = $matchs[$i]->odds; $money = $money/2*$odds+$money/2*1; }else if($matchs[$i]->result == 4){ //输半平半 $money = $money/2*1; } $win_money = $win_money+$money; } $model = new \App\Models\SportsNoteList(); $model = $model::find($id); if($win_money < $order->money){ $model->game_status = 2; }else if($win_money >= $order->money){ $model->game_status = 1; } $model->settle_status = 2; $model->gain_money = $win_money; $model->save(); return ""; } /** *单式注单批量结算 */ public function batchsettlement(){ $orders = \App\Models\SportsNoteList::where('settle_status','1')->get(); $order_ids = array(); for($i=0;$ibatch_id)->where('match_id',$orders[$i]->match_id)->get(); $res = array(); for($j=0;$jresult; } if(!in_array(0,$res)){ $order_ids[] = $orders[$i]->order_id; } } //return $order_ids; $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); } }