SportsbkController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Illuminate\Support\Facades\DB;
  6. Use App\Lib\Settlement\SettlementOrder;
  7. use App\Models;
  8. use Request;
  9. use App\Lib\Biz\Sport\Common as commonFunction;
  10. /**
  11. *篮球结果结算
  12. */
  13. class SportsbkController extends Controller {
  14. public $code = "lq";
  15. //篮球结果列表
  16. public function outcome(Req $req) {
  17. $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
  18. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  19. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  20. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
  21. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
  22. $dt = \App\Lib\DataTable\DataTable::init();
  23. $dt->setDataSource('/admin/Sportsbk/info');
  24. $dt->setLang('sportsbk');
  25. $dt->addColsFields('lg_id', array('templet' => '#liansai', 'sort' => true, 'width' => 160));
  26. $dt->addColsFields('start_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 160));
  27. $dt->addColsFields('home_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  28. $dt->addColsFields('guest_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
  29. $dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 100));
  30. $dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 100));
  31. $dt->addColsFields('match_score', array('templet' => '#match_score','sort' => false, 'width' => 170));
  32. // $dt->addColsFields('sectionone_two', array('templet' => '#sectionone_two', 'sort' => false, 'width' => 170));
  33. // $dt->addColsFields('sectionthere_four', array('templet' => '#sectionthere_four', 'sort' => false, 'width' => 220));
  34. $dt->addColsFields('status', array('templet' => '#matchstatus', 'sort' => false, 'width' => 80));
  35. $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
  36. $dt->enableCheckBox();
  37. // if (checkRriv('/admin/Sportsbk/edit')) {
  38. // $arr[] = 'edit';
  39. // }
  40. // $dt->setToolBar($arr, array('width' => 200));
  41. // $dt->enableCheckBox();
  42. return view('admin/sportsbk/outcome', $dt->render($request));
  43. }
  44. //篮球赛事作废
  45. function revoke(Req $req){
  46. $match_id = $req->match_id;//赛事id
  47. \App\Models\Stlqresult::where('match_id', $match_id)->update(['status'=>4]);
  48. \App\Models\SportsBasket::where('id', $match_id)->update(['status'=>4]);
  49. //赛事下单式注单作废,串关注单下此赛事按平局处理
  50. $upapp = new \App\Models\SportsNoteList();
  51. $upapp->delorder($match_id,'lq');
  52. // $upapp = new \App\Models\SportsNoteList();
  53. // $data = $upapp->updatesimplex($match_id,$this->code);//修改单式状态
  54. //
  55. // //单式撤单返现
  56. // $newapp = new \App\Models\MoneyBuyMatch();
  57. // $all = $newapp->allsimplexorder($match_id,$this->code);
  58. // for ($i=0; $i < count($all); $i++) {
  59. // $appgx = new SettlementOrder();
  60. // $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']);
  61. // }
  62. //
  63. // //串式撤单只改状态
  64. // $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
  65. // $csapp = new \App\Models\MoneyBuyStr();
  66. // $csapp->updatestatus($str_ids);
  67. // //修改money_buy_match 投注结果result=2为平
  68. // $newapp->updatast($match_id);
  69. return responseToJson(1);
  70. }
  71. //结果添加
  72. function addend(Req $req){
  73. $match_id = $req->matchid;
  74. $model = \App\Models\Stlqresult::where('match_id', $match_id)->first();
  75. $match = \App\Models\SportsBasket::where('id', $match_id)->first();
  76. $match_status = $match['status'];
  77. $data = array(
  78. "1" => array(
  79. 'home' => intval($req->homeo)?intval($req->homeo):0,
  80. 'guest' => intval($req->guesto)?intval($req->guesto):0,
  81. ),
  82. "2" => array(
  83. 'home' => intval($req->homet)?intval($req->homet):0,
  84. 'guest' => intval($req->guestt)?intval($req->guestt):0,
  85. ),
  86. "3" => array(
  87. 'home' => intval($req->homes)?intval($req->homes):0,
  88. 'guest' => intval($req->guests)?intval($req->guests):0,
  89. ),
  90. "4" => array(
  91. 'home' => intval($req->homef)?intval($req->homef):0,
  92. 'guest' => intval($req->guestf)?intval($req->guestf):0,
  93. ),
  94. "5" => array(
  95. 'home' => intval($req->homeu)?intval($req->homeu):0,
  96. 'guest' => intval($req->guestu)?intval($req->guestu):0,
  97. ),
  98. "6" => array(
  99. 'home' => intval($req->homeb)?intval($req->homeb):0,
  100. 'guest' => intval($req->guestb)?intval($req->guestb):0,
  101. ),
  102. "all" => array(
  103. 'home' => intval($req->homen)?intval($req->homen):0,
  104. 'guest' => intval($req->guestn)?intval($req->guestn):0,
  105. ),
  106. );
  107. // $array = array();
  108. // foreach($data as $key){
  109. // $array[] = $key['home'];
  110. // $array[] = $key['guest'];
  111. // }
  112. //赛事下注单作废 处理
  113. commonFunction::HandleInvalid($data,$match_id,$match_status,'lq');
  114. $guestscore =array(
  115. '1' => $data[1]['guest'],//第一节客队比分
  116. '2' => $data[2]['guest'],//第二节客队比分
  117. '3' => $data[3]['guest'],//第三节客队比分
  118. '4' => $data[4]['guest'],//第四节客队比分
  119. );
  120. $homescore =array(
  121. '1' => $data[1]['home'],//第一节客队比分
  122. '2' => $data[2]['home'],//第二节客队比分
  123. '3' => $data[3]['home'],//第三节客队比分
  124. '4' => $data[4]['home'],//第四节客队比分
  125. );
  126. $updatainfo = [
  127. "home_score"=>json_encode($homescore),
  128. "guest_score"=>json_encode($guestscore),
  129. "inning"=>json_encode($data),
  130. "u_home_score"=>$data[5]['home'],
  131. "u_guest_score"=>$data[5]['guest'],
  132. "s_home_score"=>$data[6]['home'],
  133. "s_guest_score"=>$data[6]['guest'],
  134. "match_score"=>$data['all']['home'].':'.$data['all']['guest'],
  135. 'is_correct'=>1
  136. ];
  137. \App\Models\Stlqresult::where('match_id', $match_id)->update($updatainfo);
  138. $addnew = new \App\Models\Comendnotice();
  139. $addnew->addcomendnotice($match_id,'lq');
  140. $twoapp = new \App\Models\SportsBasket();
  141. $twoapp->updatestatus('id',$match_id,['status'=>2,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
  142. $newapp = new \App\Models\Stlqresult();
  143. $newapp->updatestatus('match_id',$match_id,['status'=>2,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
  144. //添加赛事结果记录
  145. $lastLog = \App\Models\Stlqresultlog::where([
  146. ['match_id', $match_id],
  147. ['type', 1]
  148. ])->orderBy('id', 'asc')->first();
  149. if(empty($lastLog) || $lastLog['inning'] != json_encode($data)){
  150. \App\Models\Stlqresultlog::insert([
  151. 'match_id' => $match_id,
  152. 'home_score' => json_encode($homescore),
  153. 'guest_score' => json_encode($guestscore),
  154. 'inning' => json_encode($data),
  155. 'user_id' => session('adminInfo.admin_id'),
  156. 'type' => 1,
  157. 'create_at' => now()
  158. ]);
  159. }
  160. return responseToJson(1);
  161. }
  162. //查询赛事结果
  163. function Matchresult(Req $req){
  164. $match_id = $req->match_id;
  165. $newapp = \App\Models\Stlqresult::where('match_id', $match_id)->first();
  166. // $array =array(
  167. // 'corner_ball' => json_decode($newapp['corner_ball'],true),
  168. // 'penalty_card' => json_decode($newapp['penalty_card'],true),
  169. // 'newapp' => $newapp,
  170. // );
  171. $array =array(
  172. 'lqresult' => json_decode($newapp['inning'],true),
  173. );
  174. return $array;
  175. }
  176. //查询赛事结果记录
  177. function resultLog(Req $req){
  178. $match_id = $req->match_id;
  179. $list = \App\Models\Stlqresultlog::leftJoin('system_user', 'user_id', '=', 'system_user.id')
  180. ->select('st_lq_result_log.*', 'system_user.loginname')->where('match_id', $match_id)->orderBy('id', 'asc')->get();
  181. foreach ($list as $key=>$value){
  182. // $list[$key]['home_score'] = json_decode($value['home_score'], true);
  183. // $list[$key]['guest_score'] = json_decode($value['guest_score'], true);
  184. $list[$key]['inning'] = json_decode($value['inning'], true);
  185. }
  186. $result =array(
  187. 'status' => 200,
  188. 'list' => $list
  189. );
  190. echo json_encode($result);die;
  191. }
  192. //结算
  193. function Settlementlq(Req $req){
  194. $jsurl = config('sconstant.url');//结算请求域名地址
  195. $match_id = $req->match_id;
  196. $type = $req->type;
  197. $token = session('adminInfo.token');
  198. $notice = \App\Models\Comendnotice::where('match_id', $match_id)->first();
  199. $noticeid = $notice['id'];
  200. if(!$notice){
  201. return json_encode(['status'=>5,'msg'=>'请先核对结果,并提交结果']);
  202. }
  203. //查询赛事单式是否有订单(篮球)
  204. $newapp = new \App\Models\MoneyBuyMatch();
  205. $simplex_ids = array_column($newapp->allsimplexorder($match_id,'lq'),'order_id');
  206. $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
  207. if(count($simplex_ids)>0 || count($str_ids)>0){
  208. $requet = file_get_contents($jsurl."/WinFail?noticeid=".$noticeid."&token=".$token);
  209. if(json_decode($requet,true)['status']==1){
  210. $napp = new \App\Models\Stzqresult();
  211. //单式结算
  212. if(count($simplex_ids)>0 && count($str_ids)==0){
  213. $huawei_res = $napp->simplexs($token,$match_id,$jsurl,'lq');
  214. if($huawei_res['status']==1){
  215. return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
  216. }else{
  217. return json_encode(['status'=>3,'msg'=>'单式结算有误,请联系管理员!!!('.$huawei_res['msg'].')']);//结算错误
  218. }
  219. }elseif(count($str_ids)>0 && count($simplex_ids)==0){
  220. //串式结算
  221. $tandem_res = $napp->tandems($token,$match_id,$jsurl,'lq');
  222. if($tandem_res['status']==1){
  223. return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
  224. }else{
  225. return json_encode(['status'=>3,'msg'=>'串式结算有误,请联系管理员!!!('.$tandem_res['msg'].')']);//结算错误
  226. }
  227. }elseif(count($str_ids)>0 && count($simplex_ids)>0){
  228. //既有单式又有串式
  229. $huawei_res = $napp->simplexs($token,$match_id,$jsurl,'lq');
  230. //串式结算
  231. $tandem_res = $napp->tandems($token,$match_id,$jsurl,'lq');
  232. if($tandem_res['status']==1 && $huawei_res['status']==1){
  233. return json_encode(['status'=>1,'msg'=>'结算成功']);
  234. }elseif($tandem_res['status']!=1 || $huawei_res['status']!=1){
  235. return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!('.$tandem_res['msg'].$huawei_res['msg'].')']);
  236. }else{
  237. return json_encode(['status'=>3,'msg'=>'返回参数不对']);
  238. }
  239. }
  240. }else{
  241. return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);;//输赢错误
  242. }
  243. }else{
  244. $res = \App\Models\Stlqresult::where ('match_id', $match_id)->update(['status' =>3]);
  245. $res = \App\Models\SportsBasket::where ('match_id', $match_id)->update(['status' =>3]);
  246. return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
  247. }
  248. }
  249. function info() {
  250. $page = Request::has('page') ? Request::get('page') : '';
  251. $list = Request::has('limit') ? Request::get('limit') : 1;
  252. $home_team = Request::has('home_team') ? Request::get('home_team') : '';
  253. $sureblurs = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  254. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  255. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  256. $status = Request::has('status') ? Request::get('status') : '';
  257. $where = array();
  258. $orwhere = array();
  259. if (!empty($home_team)) {
  260. if (empty($sureblurs) || $sureblurs == 'off') {
  261. $where[] = array('st_lq_result.home_team', 'like', '%' . $home_team . '%');
  262. $orwhere[] = array('st_lq_result.guest_team', 'like', '%' . $home_team . '%');
  263. } else {
  264. if(is_numeric($home_team)){
  265. $where[] = array('st_lq_result.match_id', '=', $home_team);
  266. $orwhere[] = array('st_lq_result.match_id', '=', $home_team);
  267. }else{
  268. $where[] = array('st_lq_result.home_team', '=', $home_team);
  269. $orwhere[] = array('st_lq_result.guest_team', '=', $home_team);
  270. }
  271. }
  272. }
  273. if (!empty($star_time) and empty($home_team)) {
  274. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  275. $where[] = array('st_lq_result.start_time', '>', $star_time);
  276. $orwhere[] = array('st_lq_result.start_time', '>', $star_time);
  277. }
  278. if (!empty($end_time) and empty($home_team)) {
  279. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  280. $where[] = array('st_lq_result.start_time', '<', $end_time);
  281. $orwhere[] = array('st_lq_result.start_time', '<', $end_time);
  282. }
  283. if ($status != -1) {
  284. $where[] = array('st_lq_competition.status', '=', $status);
  285. $orwhere[] = array('st_lq_competition.status', '=', $status);
  286. }
  287. $newapp = new \App\Models\Stlqresult();
  288. $data = $newapp->resultbklist($list, $page, $where, $orwhere);
  289. for ($i=0; $i < count($data['data']); $i++) {
  290. $home_score = json_decode($data['data'][$i]['home_score'],true);
  291. $guest_score = json_decode($data['data'][$i]['guest_score'],true);
  292. $data['data'][$i]['okteamscore'] = $guest_score[1];//第一节客队比分
  293. $data['data'][$i]['ozteamscore'] = $home_score[1];//第一节主队比分
  294. $data['data'][$i]['tkteamscore'] = $guest_score[2];//第二节客队比分
  295. $data['data'][$i]['tzteamscore'] = $home_score[2];//第二节主队比分
  296. $data['data'][$i]['skteamscore'] = $guest_score[3];//第三节客队比分
  297. $data['data'][$i]['szteamscore'] = $home_score[3];//第三节主队比分
  298. $data['data'][$i]['akteamscore'] = $guest_score[4];//第四节客队比分
  299. $data['data'][$i]['azteamscore'] = $home_score[4];//第四节主队比分
  300. if(empty($data['data'][$i]['match_score'])){
  301. $data['data'][$i]['home_scores'] = 0;
  302. $data['data'][$i]['guest_scores'] = 0;
  303. }else{
  304. $scores = explode(':',$data['data'][$i]['match_score']);
  305. $data['data'][$i]['home_scores'] = $scores[0];
  306. $data['data'][$i]['guest_scores'] = $scores[1];
  307. }
  308. }
  309. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  310. }
  311. //修改添加赛事比分
  312. function updatascore(Req $req){
  313. $match_id = $req->match_id;//节数唯一标识
  314. $model = \App\Models\Stlqresult::where('match_id', $match_id)->first();
  315. $model->update_time = date('Y-m-d H:i:s');
  316. //赛事状态
  317. $match_status = intval($req->match_status)?intval($req->match_status):0;
  318. $guestscore =array(
  319. '1' => intval($req->okteamscore)?intval($req->okteamscore):0,//第一节客队比分
  320. '2' => intval($req->tkteamscore)?intval($req->tkteamscore):0,//第二节客队比分
  321. '3' => intval($req->skteamscore)?intval($req->skteamscore):0,//第三节客队比分
  322. '4' => intval($req->akteamscore)?intval($req->akteamscore):0,//第四节客队比分
  323. );
  324. $homescore =array(
  325. '1' => intval($req->ozteamscore)?intval($req->ozteamscore):0,//第一节主队比分
  326. '2' => intval($req->tzteamscore)?intval($req->tzteamscore):0,//第二节主队比分
  327. '3' => intval($req->szteamscore)?intval($req->szteamscore):0,//第三节主队比分
  328. '4' => intval($req->azteamscore)?intval($req->azteamscore):0,//第四节主队比分
  329. );
  330. $model->guest_score = json_encode($guestscore);
  331. $model->home_score = json_encode($homescore);
  332. $model->is_correct = 1;//追加手动更改标识
  333. $model->save();
  334. //更新比分 默认 status
  335. $status = 2;
  336. //赛事下注单作废 处理
  337. $data = array_merge($guestscore,$homescore);
  338. if(in_array(-1,$data)){
  339. commonFunction::HandleInvalid($data,$match_id,$match_status,'lq');
  340. }
  341. /*
  342. //追加判断比分 如果都== -1,则作废该赛事
  343. if($guestscore[1] < 0 and $guestscore[2] < 0 and $guestscore[3] < 0 and $guestscore[4] < 0 and $homescore[1] < 0 and $homescore[2] < 0 and $homescore[3] < 0 and $homescore[4] < 0 ){
  344. //已结算作废赛事处理
  345. if($match_status == 3){
  346. $url = 'http://stadmin.bocai108.com:9094/UnSettelement';
  347. $data_up = [
  348. 'token'=>session('adminInfo.token'),
  349. 'game_code'=>'lq',
  350. 'match_id'=>$match_id,
  351. ];
  352. $ret_json = commonFunction::https_request($url,$data_up);
  353. // $ret_json = '{"status":1,"msg":"撤销成功!2019-10-26 16:28:30 取消赛事处理--结束end:game_code= zq match_id= 40986 \n","data":[]}';
  354. $ret_arr = json_decode($ret_json,true);
  355. if($ret_arr['status'] != 1){
  356. return responseToJson(-20003);
  357. }
  358. }
  359. //赛事下单式注单作废,串关注单下此赛事按平局处理
  360. $upapp = new \App\Models\SportsNoteList();
  361. $upapp->delorder($match_id,'lq');
  362. $status = 4;
  363. }
  364. */
  365. $addnew = new \App\Models\Comendnotice();
  366. $addnew->addcomendnotice($match_id,'lq');
  367. $twoapp = new \App\Models\SportsBasket();
  368. $twoapp->updatestatus('match_id',$match_id,['status'=>$status,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
  369. $newapp = new \App\Models\Stlqresult();
  370. $newapp->updatestatus('match_id',$match_id,['status'=>$status,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
  371. //添加赛事结果比较记录
  372. $lastLog = \App\Models\Stlqresultlog::where([
  373. ['match_id', $match_id],
  374. ['type', 2]
  375. ])->orderBy('id', 'desc')->first();
  376. if(empty($lastLog) || !(
  377. $lastLog['guest_score'] == $model->guest_score
  378. && $lastLog['home_score'] == $model->home_score
  379. )){
  380. $logData = [
  381. 'guest_score' => $model->guest_score,
  382. 'home_score' => $model->home_score,
  383. 'type' => 2,
  384. 'match_id' => $match_id,
  385. 'user_id' => session('adminInfo.admin_id'),
  386. 'create_at' => now()
  387. ];
  388. \App\Models\Stlqresultlog::insert($logData);
  389. }
  390. return responseToJson(1);
  391. }
  392. function saislist(){
  393. $lgid = $_POST['lgid'];//赛事id
  394. $newstzqcompetition = new \App\Models\SportsBasket();
  395. $league_data = $newstzqcompetition->allcompetition($lgid);//赛事id
  396. return $league_data;
  397. }
  398. function addoutcome(Req $req) {
  399. if (!$req->isMethod('post')) {
  400. $lange = trans('menu');
  401. $newapp = new \App\Models\BasketLeague();
  402. $league_data = $newapp->allleague();//联赛id
  403. return view('admin.sportsbk/addoutcome',['data'=>$league_data]);
  404. }else{
  405. $model = new \App\Models\Stlqresult();
  406. $model->lg_id = trim($req->input('lg_id'));//联赛id
  407. $model->home_team = trim($req->input('home_team'));
  408. $model->guest_team = trim($req->input('guest_team'));
  409. $model->home_rate = trim($req->input('home_rate'));
  410. $model->guest_rate = trim($req->input('guest_rate'));
  411. $model->home_score = trim($req->input('home_score'));
  412. $model->guest_score = trim($req->input('guest_score'));
  413. $model->all_goal = trim($req->input('all_goal'));
  414. $model->match_score = trim($req->input('match_score'));
  415. $model->u_home_score = trim($req->input('u_home_score'));
  416. $model->u_guest_score = trim($req->input('u_guest_score'));
  417. $model->update_time = date('Y-m-d h:i:s', time());//更新时间
  418. $model->match_time = "11:22";//trim($req->input('match_time'));
  419. $model->tag = trim($req->input('tag'));
  420. $model->status = trim($req->input('status'));
  421. $model->match_process = trim($req->input('match_process'));
  422. $model->match_id = trim($req->input('match_id'));//赛事id
  423. $model->save();
  424. return responseToJson(1);
  425. }
  426. }
  427. //赛事结果修改
  428. function edit(Req $req) {
  429. $id = $req->id;
  430. if (intval($id) < 1) {
  431. return -1;
  432. }
  433. if (!$req->isMethod('post')) {
  434. $data = \App\Models\Stlqresult::where('id', $id)->first();
  435. if (!$data) {
  436. return -2;
  437. }
  438. $data = $data->toArray();
  439. return view('admin.sportsbk/edit', $data);
  440. } else {
  441. $model = \App\Models\Stlqresult::where('id', $id)->first();
  442. $model->home_team = $req->input('home_team');
  443. $model->guest_team = $req->input('guest_team');
  444. $model->home_rate = $req->input('home_rate');
  445. $model->guest_rate = $req->input('guest_rate');
  446. $model->status = $req->input('status');
  447. //$model->update_time = time();
  448. $model->save();
  449. return responseToJson(1);
  450. }
  451. }
  452. //删除赛事结果
  453. function deleteoutcome(Req $req) {
  454. $id = $req->input('id');
  455. if (empty($id)) {
  456. return responseToJson(-2001); //
  457. }
  458. $ids = explode(',', $id);
  459. if (!is_array($ids) && intval($ids) < 0) {
  460. return responseToJson(-2002); //
  461. }
  462. if (is_array($ids) && count($ids) > 0) {
  463. foreach ($ids as $k => $v) {
  464. if (intval($v) < 1) {
  465. unset($ids[$k]);
  466. }
  467. }
  468. }
  469. // echo '敬请期待';die;
  470. $rows = \App\Models\Stlqresult::whereIn('id', $ids)->delete();
  471. if (!$rows) {
  472. return responseToJson(-2003);
  473. }
  474. return responseToJson(1);
  475. }
  476. }