SportsbkController.php 20 KB

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