SportsfootController.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  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 SportsfootController extends Controller {
  14. function Settlement(Req $req){
  15. $jsurl = config('sconstant.url');//结算请求域名地址
  16. $match_id = $req->match_id;
  17. $type = $req->type;
  18. $token = session('adminInfo.token');
  19. $notice = \App\Models\Comendnotice::where('match_id', $match_id)->first();
  20. if(!$notice){
  21. return json_encode(['status'=>5,'msg'=>'请先核对结果,并提交结果']);
  22. }
  23. $noticeid = $notice['id'];
  24. //查询赛事单式是否有订单(足球)
  25. $newapp = new \App\Models\MoneyBuyMatch();
  26. $simplex_ids = array_column($newapp->allsimplexorder($match_id,'zq'),'order_id');
  27. $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
  28. // //判断赛事下注单输赢
  29. // $datas = array('noticeid' => $noticeid , 'token' => $token);
  30. // $settlementAuto = new \App\Lib\Settlement\SettlementAuto();
  31. // $winfail = $settlementAuto->SubmitSettelement('w',$datas);
  32. // if($winfail == false){
  33. // return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);//输赢错误
  34. // }
  35. // $sim = array(
  36. // 'token'=>$token,
  37. // 'order_ids'=>$simplex_ids, //订单id字符串,用半角都好分隔
  38. // 'bettype'=>1, //结算类型 1单式 2串式
  39. // 'settype'=>2, //结算次数 1首次 2非首冷饮
  40. // 'game_code'=>$type, //赛事类型 zq lq wq bq
  41. // 'match_id'=>$match_id, // 赛事ID
  42. // 'change_status'=>1 //是否改状态
  43. // );
  44. // $str = array(
  45. // 'token'=>$token,
  46. // 'order_ids'=>$str_ids, //订单id字符串,用半角都好分隔
  47. // 'bettype'=>2, //结算类型 1单式 2串式
  48. // 'settype'=>2, //结算次数 1首次 2非首冷饮
  49. // 'game_code'=>$type, //赛事类型 zq lq wq bq
  50. // 'match_id'=>$match_id, // 赛事ID
  51. // 'change_status'=>1 //是否改状态
  52. // );
  53. // if(count($simplex_ids)>0 || count($str_ids)>0){
  54. // //单式结算
  55. // if(count($simplex_ids)>0){
  56. // $sim['order_ids'] = json_encode($simplex_ids);
  57. // $settlesim = $settlementAuto->SubmitSettelement('s',$sim);
  58. // if($settlesim == false){
  59. // return json_encode(['status'=>3,'msg'=>'单式注单结算有误,请联系管理员!!!']);
  60. // }
  61. // }
  62. // if(count($str_ids)>0){
  63. // $str['order_ids'] = json_encode($str_ids);
  64. // $settlestr = $settlementAuto->SubmitSettelement('s',$str);
  65. // if($settlestr == false){
  66. // return json_encode(['status'=>3,'msg'=>'串式注单结算有误,请联系管理员!!!']);
  67. // }
  68. // }
  69. // return json_encode(['status'=>1,'msg'=>'结算成功']);
  70. // }else{
  71. // $log = array(
  72. // session('adminInfo.admin_name'),
  73. // );
  74. // OperationLog(session('adminInfo.admin_id'), '足球结算', $log);
  75. // $res = \App\Models\Stzqresult::where ('match_id', $match_id)->update(['status' =>3]);
  76. // $res = \App\Models\SportsSoccer::where ('id', $match_id)->update(['status' =>3]);
  77. // return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
  78. // }
  79. if(count($simplex_ids)>0 || count($str_ids)>0){
  80. $requet = file_get_contents($jsurl."/WinFail?noticeid=".$noticeid."&token=".$token);
  81. if(json_decode($requet,true)['status']==1){
  82. $napp = new \App\Models\Stzqresult();
  83. //单式结算
  84. if(count($simplex_ids)>0 && count($str_ids)==0){
  85. $huawei_res = $napp->simplexs($token,$match_id,$jsurl,'zq');
  86. if($huawei_res['status']==1){
  87. return json_encode(['status'=>1,'msg'=>'单式结算成功,没有串式订单']);
  88. }else{
  89. return json_encode(['status'=>3,'msg'=>'单式结算有误,请联系管理员!!!('.$huawei_res['msg'].')']);//结算错误
  90. }
  91. }elseif(count($str_ids)>0 && count($simplex_ids)==0){
  92. //串式结算
  93. $tandem_res = $napp->tandems($token,$match_id,$jsurl,'zq');
  94. if($tandem_res['status']==1){
  95. return json_encode(['status'=>1,'msg'=>'串式结算成功,没有单式订单']);
  96. }else{
  97. return json_encode(['status'=>3,'msg'=>'串式结算有误,请联系管理员!!!('.$tandem_res['msg'].')']);//结算错误
  98. }
  99. }elseif(count($str_ids)>0 && count($simplex_ids)>0){
  100. //既有单式又有串式
  101. $huawei_res = $napp->simplexs($token,$match_id,$jsurl,'zq');
  102. //串式结算
  103. $tandem_res = $napp->tandems($token,$match_id,$jsurl,'zq');
  104. if($tandem_res['status']==1 && $huawei_res['status']==1){
  105. return json_encode(['status'=>1,'msg'=>'结算成功']);
  106. }elseif($tandem_res['status']!=1 || $huawei_res['status']!=1){
  107. return json_encode(['status'=>3,'msg'=>'结算有误,请联系管理员!!!('.$tandem_res['msg'].$huawei_res['msg'].')']);
  108. }else{
  109. return json_encode(['status'=>3,'msg'=>'返回参数不对']);
  110. }
  111. }
  112. }else{
  113. return json_encode(['status'=>2,'msg'=>'判断输赢错误,请联系管理员!!!']);;//输赢错误
  114. }
  115. }else{
  116. $log = array(
  117. session('adminInfo.admin_name'),
  118. );
  119. OperationLog(session('adminInfo.admin_id'), '足球结算', $log);
  120. $res = \App\Models\Stzqresult::where ('match_id', $match_id)->update(['status' =>3]);
  121. $res = \App\Models\SportsSoccer::where ('match_id', $match_id)->update(['status' =>3]);
  122. return json_encode(['status'=>4,'msg'=>'该赛事没有任何订单,将会结束该赛事!!!']);
  123. }
  124. }
  125. //添加危险球列表
  126. function addwarn(Req $req){
  127. $match_id = $req->match_id;
  128. $warn = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more")->first();
  129. $warnmore = json_decode($warn['warn_more'],true);
  130. $sousuo = $req->sousuo?$req->sousuo:'';
  131. if($sousuo){
  132. $shuzu = array();
  133. for ($i=0; $i < count($warnmore); $i++) {
  134. if($warnmore[$i]['rtype']==$sousuo){
  135. $shuzu[$i]['timei'] = $warnmore[$i]['timei'];
  136. $shuzu[$i]['rtype'] = $warnmore[$i]['rtype'];
  137. $shuzu[$i]['timep'] = $warnmore[$i]['timep'];
  138. }
  139. }
  140. $shuzu = array_values($shuzu);
  141. $warnmore = $shuzu;
  142. // $warnmore[0]['timei'] = 10000;
  143. }
  144. if($warnmore[0]['timei']!="1970-1-1 0:0:1"){
  145. $request['warnmore'] = $warnmore;
  146. // $request['warnmore'][0]['rtype'] = $sousuo;1
  147. }else{
  148. $request['warnmore'] = '';
  149. }
  150. $request['match_id'] = $match_id;
  151. $request['sousuo'] = $sousuo;
  152. return view('admin.sportsfoot/addwarn', $request);
  153. }
  154. //获取指定赛事危险球数据
  155. function getWarnData(Req $req){
  156. $match_id = $req->match_id;
  157. $warnonlys = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more","start_time")->first();
  158. $warn_more = json_decode($warnonlys['warn_more'],true);
  159. if(!empty($warn_more)){
  160. $data = [];
  161. foreach($warn_more as $k=>$v){
  162. $v['id'] =$k+1;
  163. $data[$k] = $v;
  164. }
  165. }
  166. if($data[0]['timei']=="1970-1-1 0:0:1"){
  167. $data = [];
  168. }
  169. return \App\Lib\DataTable\DataTable::init()->toJson($data);
  170. }
  171. //危险球查询
  172. function warnresult(Req $req){
  173. $match_id = $req->match_id;
  174. $wid = $req->wid;
  175. $typenum = $req->typenum;
  176. $warnonlys = \App\Models\Stzqresult::where('match_id', $match_id)->select("warn_more","start_time")->first();
  177. $warn_data = json_decode($warnonlys['warn_more'],true);
  178. if($typenum == 10000){ //添加危险球时,默认出现时间为赛事开始时间
  179. $warn_data[0] =[
  180. 'timei' =>$warnonlys['start_time'],
  181. 'rtype' =>0,
  182. 'timep' =>90
  183. ];
  184. }
  185. $warno = array(
  186. 'warn_more' => $warn_data,
  187. 'starttime' => $warnonlys['start_time'],
  188. 'endtime'=> date("Y-m-d H:i:s", strtotime("+2 hour",strtotime($warnonlys['start_time']))),//$warnonlys['start_time']
  189. );
  190. return $warno;
  191. }
  192. //添加编辑危险球
  193. function addwarnonly(Req $req){
  194. //编辑对象值
  195. $wid = ($req->wid);
  196. //赛事id
  197. $matchid = $req->match_id;
  198. /*
  199. //出现危险球的分钟数
  200. $time_i = $req->time_i;
  201. //出现危险球的秒数
  202. $time_s = $req->time_s;
  203. //危险球审核有效时间 秒
  204. */
  205. $timei = $req->time_i;
  206. $timep = $req->time_p;
  207. //危险球类型
  208. $rtype = $req->warn_type;
  209. //验证是否是首次添加危险球
  210. $typenum = $req->type_num;
  211. if(empty($matchid) || empty($timep) || empty($rtype)) return json_encode(['status'=>2,'msg'=>'设置数据异常']);
  212. $model = \App\Models\Stzqresult::where('match_id', $matchid)->select("warn_more","start_time","status")->first()->toArray();
  213. // if($model['status'] != 2) return json_encode(['status'=>3,'msg'=>'赛事未结束,不能设置危险球']);
  214. /*
  215. //赛事开赛时间
  216. $match_time = $model['start_time'];
  217. //危险球出现进行时间 秒
  218. $warn_time_s = ($time_i*60)+$time_s;
  219. //危险球出现时间 == 开赛时间+进行时间 秒
  220. $timei = date('Y-m-d H:i:s',strtotime($match_time)+$warn_time_s);
  221. */
  222. //该赛事的单式注单
  223. $orders = array();
  224. $otherorders = array();
  225. $account_identitys = array();
  226. $order_ids = array();
  227. $order = \App\Models\SportsNoteList::where('match_id',$matchid)->get();
  228. if(!empty($order)){
  229. for ($c=0; $c < count($order); $c++){
  230. if(strtotime($timei) >= strtotime($order[$c]['money_time']) && strtotime($timei)-$timep <= strtotime($order[$c]['money_time'])){
  231. $orders[] = $order[$c];
  232. $account_identitys[] = $order[$c]['account_identity'];
  233. $order_ids[] = $order[$c]['order_id'];
  234. }else{
  235. $otherorders[] = $order[$c]['id'];
  236. }
  237. }
  238. }
  239. //危险球范围外的注单自动审核通过
  240. //return $otherorders;
  241. if(!empty($otherorders)){
  242. \App\Models\SportsNoteList::wherein('id', $otherorders)->update(['roll_ratify' => '1']);
  243. }
  244. //return $account_identitys;
  245. $sel = json_decode($model['warn_more'],true);
  246. $addru = array(
  247. array(
  248. 'timei'=>$timei,
  249. 'timep'=>$timep,
  250. 'rtype'=>$rtype,
  251. ),
  252. );
  253. if($typenum==10000){
  254. if($sel[0]['timei']=="1970-1-1 0:0:1"){
  255. //首次添加
  256. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru,JSON_UNESCAPED_UNICODE)]);
  257. }else{
  258. //再次添加
  259. $upnum = array_merge_recursive($sel,$addru);
  260. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum,JSON_UNESCAPED_UNICODE)]);
  261. }
  262. }else{
  263. //编辑
  264. for ($i=0; $i < count($sel); $i++) {
  265. $sel[$wid]['timei'] = $timei;
  266. $sel[$wid]['timep'] = $timep;
  267. $sel[$wid]['rtype'] = $rtype;
  268. }
  269. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel,JSON_UNESCAPED_UNICODE)]);
  270. }
  271. //用戶账户金额
  272. $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get();
  273. //反水
  274. $water_return_money = \App\Models\Money_details::wherein('trade_id',$order_ids)->where('trade_type', '7')->get();
  275. if(!empty($orders)){
  276. for($i=0;$i<count($orders);$i++){
  277. for($a=0;$a<count($account_money);$a++){
  278. if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
  279. $available_cash = $account_money[$a]['available_cash'];
  280. }
  281. }
  282. for($b=0;$b<count($water_return_money);$b++){
  283. if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
  284. $water_return = $water_return_money[$b]['money'];
  285. } else {
  286. $water_return = 0;
  287. }
  288. }
  289. $new_available_cash = $available_cash + $orders[$i]->money - $orders[$i]->gain_money - $water_return;
  290. $models = new \App\Models\Money_details();
  291. $models->info_identity = UUID();
  292. $models->trade_id = $orders[$i]->order_id;
  293. $models->account_name = $orders[$i]->account_name;
  294. $models->account_identity = $orders[$i]->account_identity;
  295. $models->money = abs($orders[$i]->money - $orders[$i]->gain_money - $water_return);
  296. $models->money_time = date("Y-m-d H:i:s", time());
  297. if ($new_available_cash > $available_cash) {
  298. $models->money_type = '1';
  299. } else {
  300. $models->money_type = '2';
  301. }
  302. $models->money_cash = $new_available_cash;
  303. $models->trade_type = '25';
  304. $models->trade_desc = '单式注单审核不通过回款';
  305. $models->status = '1';
  306. try {
  307. DB::beginTransaction();//开启事务
  308. \App\Models\SportsNoteList::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2']);
  309. \App\Models\Account_detailed::where('account_identity', $orders[$i]->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  310. $models->save();
  311. DB::commit();//提交
  312. } catch (Exception $e) {
  313. DB::rollback();//回滚
  314. }
  315. }
  316. }
  317. return responseToJson(1);
  318. }
  319. //弃用
  320. function addwarnonly__(Req $req){
  321. $matchid = $req->matchid;
  322. $wid = $req->wid;//编辑对象值
  323. $timei = $req->timei?$req->timei:"1970-11-1 0:0:1";
  324. $timep = $req->timep?$req->timep:"90";
  325. $rtype = $req->warntype?$req->warntype:0;
  326. $typenum = $req->typenum;
  327. $model = \App\Models\Stzqresult::where('match_id', $matchid)->select("warn_more","start_time")->first()->toArray();
  328. //该赛事的单式注单
  329. $orders = array();
  330. $otherorders = array();
  331. $account_identitys = array();
  332. $order_ids = array();
  333. $order = \App\Models\SportsNoteList::where('match_id',$matchid)->get();
  334. if(!empty($order)){
  335. for ($c=0; $c < count($order); $c++){
  336. if(strtotime($timei) >= strtotime($order[$c]['money_time']) && strtotime($timei)-$timep <= strtotime($order[$c]['money_time'])){
  337. $orders[] = $order[$c];
  338. $account_identitys[] = $order[$c]['account_identity'];
  339. $order_ids[] = $order[$c]['order_id'];
  340. }else{
  341. $otherorders[] = $order[$c]['id'];
  342. }
  343. }
  344. }
  345. //危险球范围外的注单自动审核通过
  346. //return $otherorders;
  347. if(!empty($otherorders)){
  348. \App\Models\SportsNoteList::wherein('id', $otherorders)->update(['roll_ratify' => '1']);
  349. }
  350. //return $account_identitys;
  351. $sel = json_decode($model['warn_more'],true);
  352. $addru = array(
  353. array(
  354. 'timei'=>$timei,
  355. 'timep'=>$timep,
  356. 'rtype'=>$rtype,
  357. ),
  358. );
  359. $only =$model['start_time'];
  360. $t = strtotime($only);
  361. $tt = date('Y-m-d H:i:s', $t+1*3*60*60);
  362. //timei']!="1970-1-1 0:0:1"
  363. if($only<$timei && $timei<$tt){
  364. if($typenum==10000){
  365. if($sel[0]['timei']=="1970-1-1 0:0:1"){
  366. //首次添加
  367. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru,JSON_UNESCAPED_UNICODE)]);
  368. }else{
  369. //再次添加
  370. $upnum = array_merge_recursive($sel,$addru);
  371. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum,JSON_UNESCAPED_UNICODE)]);
  372. }
  373. }else{
  374. //编辑
  375. for ($i=0; $i < count($sel); $i++) {
  376. $sel[$wid]['timei'] = $timei;
  377. $sel[$wid]['timep'] = $timep;
  378. $sel[$wid]['rtype'] = $rtype;
  379. }
  380. $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel,JSON_UNESCAPED_UNICODE)]);
  381. }
  382. //用戶账户金额
  383. $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get();
  384. //反水
  385. $water_return_money = \App\Models\Money_details::wherein('trade_id',$order_ids)->where('trade_type', '7')->get();
  386. //return $water_return_money;
  387. if(!empty($orders)){
  388. for($i=0;$i<count($orders);$i++){
  389. for($a=0;$a<count($account_money);$a++){
  390. if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
  391. $available_cash = $account_money[$a]['available_cash'];
  392. }
  393. }
  394. for($b=0;$b<count($water_return_money);$b++){
  395. if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
  396. $water_return = $water_return_money[$b]['money'];
  397. } else {
  398. $water_return = 0;
  399. }
  400. }
  401. $new_available_cash = $available_cash + $orders[$i]->money - $orders[$i]->gain_money - $water_return;
  402. $models = new \App\Models\Money_details();
  403. $models->info_identity = UUID();
  404. $models->trade_id = $orders[$i]->order_id;
  405. $models->account_name = $orders[$i]->account_name;
  406. $models->account_identity = $orders[$i]->account_identity;
  407. $models->money = abs($orders[$i]->money - $orders[$i]->gain_money - $water_return);
  408. $models->money_time = date("Y-m-d H:i:s", time());
  409. if ($new_available_cash > $available_cash) {
  410. $models->money_type = '1';
  411. } else {
  412. $models->money_type = '2';
  413. }
  414. $models->money_cash = $new_available_cash;
  415. $models->trade_type = '25';
  416. $models->trade_desc = '单式注单审核不通过回款';
  417. $models->status = '1';
  418. try {
  419. DB::beginTransaction();//开启事务
  420. \App\Models\SportsNoteList::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2']);
  421. \App\Models\Account_detailed::where('account_identity', $orders[$i]->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
  422. $models->save();
  423. DB::commit();//提交
  424. } catch (Exception $e) {
  425. DB::rollback();//回滚
  426. }
  427. }
  428. }
  429. }else{
  430. return json_encode(['status'=>2,'msg'=>'请设置正确时间']);
  431. }
  432. return responseToJson(1);
  433. }
  434. //足球结果列表 1
  435. function outcome(Req $req) {
  436. $request=array();
  437. $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
  438. $request['status'] = isset($req->status) ? trim($req->status) : '-1';
  439. $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
  440. $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
  441. $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
  442. $newapp = new \App\Models\SoccerLeague();
  443. $data = $newapp->allleague();
  444. $request['league'] = $data;//联赛id
  445. $request['token'] = session('adminInfo.token');//token 变量
  446. $dt = \App\Lib\DataTable\DataTable::init();
  447. $dt->setDataSource('/admin/sportsfoot/outcomeinfo');
  448. $dt->setLang('sportsfoot');
  449. $dt->addColsFields('newtime', array('templet' => '#newtime', 'sort' => false, 'width' => 200));
  450. $dt->addColsFields('totime', array('templet' => '#totime', 'sort' => false, 'width' => 155));
  451. $dt->addColsFields('home_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
  452. $dt->addColsFields('guest_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
  453. $dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 100));
  454. $dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 100));
  455. //$dt->addColsFields('match_score', array('sort' => false, 'width' => 210));
  456. $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 180));
  457. $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 100,'align' => 'left'));
  458. $dt->addColsFields('operation', array('templet' => '#status', 'sort' => false, 'width' => 300));
  459. // $arr[] = 'view';
  460. // if (checkRriv('/admin/sportsfoot/edit')) {
  461. // $arr[] = 'edit';
  462. // }
  463. // $dt->setToolBar($arr, array('width' => 200));1
  464. $dt->enableCheckBox();
  465. return view('admin.sportsfoot/outcome', $dt->render($request));
  466. }
  467. //结果添加
  468. function addend(Req $req){
  469. $match_id = $req->matchid;
  470. $model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  471. $match = \App\Models\SportsSoccer::where('id', $match_id)->first();
  472. $match_status = $match['status'];
  473. $data = array(
  474. "half" => array(
  475. 'home' => intval($req->homehalf)?intval($req->homehalf):0,
  476. 'guest' => intval($req->guesthalf)?intval($req->guesthalf):0,
  477. ),
  478. "all" => array(
  479. 'home' => intval($req->homeall)?intval($req->homeall):0,
  480. 'guest' => intval($req->guestall)?intval($req->guestall):0,
  481. ),
  482. );
  483. foreach($data as $key){
  484. $array[] = $key['home'];
  485. $array[] = $key['guest'];
  486. }
  487. //赛事下注单作废 处理
  488. commonFunction::HandleInvalid($data,$match_id,$match_status,'zq');
  489. $penaltycard = array(
  490. 'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
  491. 'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
  492. 'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
  493. 'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
  494. );
  495. $cornerball = array(
  496. 'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
  497. 'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
  498. 'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
  499. 'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
  500. );
  501. $firstone = array(
  502. 'teamscore'=>$req->firstscore ? $req->firstscore:0,
  503. 'scoretime'=>intval($req->onescoretime)?intval($req->onescoretime):0,
  504. 'scoretype'=>$req->firststye ? $req->firststye:0,
  505. );
  506. $model->match_score = $data['all']['home'].':'.$data['all']['guest'];
  507. $model->u_home_score = $data['half']['home'];
  508. $model->u_guest_score = $data['half']['guest'];
  509. $model->home_score = $data['all']['home'];
  510. $model->guest_score = $data['all']['guest'];
  511. $model->last_score = $req->lastscore?$req->lastscore:'';
  512. $model->match_winer = $req->matchwiner?$req->matchwiner:'';
  513. $model->penalty_card = json_encode($penaltycard,JSON_UNESCAPED_UNICODE);
  514. $model->corner_ball = json_encode($cornerball,JSON_UNESCAPED_UNICODE);
  515. $model->first_score = json_encode($firstone,JSON_UNESCAPED_UNICODE);
  516. $model->is_correct = 1;
  517. $model->save();
  518. $update = $this->addcomendnotice($match_id);
  519. $twoapp = new \App\Models\SportsSoccer();
  520. $twoapp->updatestatus('id',$match_id,['status'=>2,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
  521. $newapp = new \App\Models\Stzqresult();
  522. $newapp->updatestatus('match_id',$match_id,['status'=>2,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
  523. //添加赛事结果记录
  524. $lastLog = \App\Models\Stzqresultlog::where([
  525. ['match_id', $match_id],
  526. ['type', 1]
  527. ])->orderBy('id', 'desc')->first();
  528. if(empty($lastLog) || !($lastLog['penalty_card'] == $model->penalty_card
  529. && $lastLog['corner_ball'] == $model->corner_ball
  530. && $lastLog['first_score'] == $model->first_score
  531. && $lastLog['last_score'] == $model->last_score
  532. && $lastLog['match_winer'] == $model->match_winer
  533. && $lastLog['u_home_score'] == $data['half']['home']
  534. && $lastLog['u_guest_score'] == $data['half']['guest']
  535. && $lastLog['home_score'] == $data['all']['home']
  536. && $lastLog['guest_score'] == $data['all']['guest']
  537. )){
  538. \App\Models\Stzqresultlog::insert([
  539. 'u_home_score' => $data['half']['home'],
  540. 'u_guest_score' => $data['half']['guest'],
  541. 'home_score' => $data['all']['home'],
  542. 'guest_score' => $data['all']['guest'],
  543. 'match_id' => $match_id,
  544. 'penalty_card' => $model->penalty_card ,
  545. 'corner_ball' => $model->corner_ball,
  546. 'first_score' => $model->first_score,
  547. 'last_score' => $model->last_score,
  548. 'match_winer' => $model->match_winer,
  549. 'user_id' => session('adminInfo.admin_id'),
  550. 'type' => 1,
  551. 'create_at' => now()
  552. ]);
  553. }
  554. return responseToJson(1);
  555. }
  556. //查询赛事结果
  557. function Matchresult(Req $req){
  558. $match_id = $req->match_id;
  559. $newapp = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  560. $array =array(
  561. 'corner_ball' => json_decode($newapp['corner_ball'],true),
  562. 'penalty_card' => json_decode($newapp['penalty_card'],true),
  563. 'first_score' => json_decode($newapp['first_score'],true),
  564. 'newapp' => $newapp,
  565. );
  566. return $array;
  567. }
  568. //查询赛事结果记录
  569. function resultLog(Req $req){
  570. $match_id = $req->match_id;
  571. $list = \App\Models\Stzqresultlog::leftJoin('system_user', 'user_id', '=', 'system_user.id')
  572. ->select('st_zq_result_log.*', 'system_user.loginname')->where('match_id', $match_id)->orderBy('id', 'asc')->get();
  573. foreach ($list as $key=>$value){
  574. $list[$key]['penalty_card'] = json_decode($value['penalty_card'], true);
  575. $list[$key]['corner_ball'] = json_decode($value['corner_ball'], true);
  576. $list[$key]['first_score'] = empty($value['first_score']) ? '' : json_decode($value['first_score'], true);
  577. }
  578. $result =array(
  579. 'status' => 200,
  580. 'list' => $list
  581. );
  582. echo json_encode($result);die;
  583. }
  584. function onlyresult(Req $req){
  585. $match_id = $req->matchid;
  586. $newapp = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  587. return $newapp;
  588. }
  589. //作废
  590. function revokeft(Req $req){
  591. $iszf = $req->iszf?$req->iszf:'';//赛事id
  592. if(intval($iszf)){
  593. $id = $req->input('id');
  594. if (empty($id)) {
  595. return responseToJson(-2001); //
  596. }
  597. $ids = explode(',', $id);
  598. if (!is_array($ids) && intval($ids) < 0) {
  599. return responseToJson(-2002); //
  600. }
  601. if (is_array($ids) && count($ids) > 0) {
  602. foreach ($ids as $k => $v) {
  603. if (intval($v) < 1) {
  604. unset($ids[$k]);
  605. }
  606. }
  607. }
  608. for ($ii=0; $ii < count($ids); $ii++) {
  609. $model = \App\Models\Stzqresult::where('match_id', $ids[$ii])->first();
  610. $model->status = 4;
  611. $model->save();
  612. $ssid = $model['match_id'];//赛事id
  613. $smodel = \App\Models\SportsSoccer::where('id', $ssid)->first();
  614. if($smodel){
  615. $smodel->status = 4;
  616. $smodel->save();
  617. }
  618. //赛事下单式注单作废,串关注单下此赛事按平局处理
  619. $upapp = new \App\Models\SportsNoteList();
  620. $upapp->delorder($ssid,'zq');
  621. // $upapp = new \App\Models\SportsNoteList();
  622. // $data = $upapp->updatesimplex($ssid,'zq');//修改单式状态
  623. //单式撤单返现
  624. // $newapp = new \App\Models\MoneyBuyMatch();
  625. // $all = $newapp->allsimplexorder($ssid,'zq');
  626. // for ($i=0; $i < count($all); $i++) {
  627. // $appgx = new \App\Lib\Settlement\SettlementOrder();
  628. // $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']);
  629. // }
  630. //
  631. // //串式撤单只改状态
  632. // $str_ids = array_column($newapp->allstrorder($ssid),'order_id');
  633. // $csapp = new \App\Models\MoneyBuyStr();
  634. // $csapp->updatestatus($str_ids);//var_dump($ss);die;
  635. // //修改money_buy_match 投注结果result=2为平
  636. // $newapp->updatast($ssid);
  637. }
  638. return responseToJson(1);
  639. }else{
  640. $match_id = $req->match_id;//赛事id
  641. $model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
  642. $model->status = 4;
  643. $model->save();
  644. $smodel = \App\Models\SportsSoccer::where('id', $match_id)->first();
  645. if($smodel){
  646. $smodel->status = 4;
  647. $smodel->save();
  648. }
  649. //赛事下单式注单作废,串关注单下此赛事按平局处理
  650. $upapp = new \App\Models\SportsNoteList();
  651. $upapp->delorder($match_id,'zq');
  652. // $upapp = new \App\Models\SportsNoteList();
  653. // $data = $upapp->updatesimplex($match_id,'zq');//修改单式状态
  654. // //单式撤单返现
  655. // $newapp = new \App\Models\MoneyBuyMatch();
  656. // $all = $newapp->allsimplexorder($match_id,'zq');
  657. // for ($i=0; $i < count($all); $i++) {
  658. // $appgx = new \App\Lib\Settlement\SettlementOrder();
  659. // $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']);
  660. // }
  661. // //串式撤单只改状态
  662. // $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
  663. // $csapp = new \App\Models\MoneyBuyStr();
  664. // $csapp->updatestatus($str_ids);//var_dump($ss);die;
  665. // //修改money_buy_match 投注结果result=2为平
  666. // $newapp->updatast($match_id);
  667. return responseToJson(1);
  668. }
  669. }
  670. //赛事结果修改
  671. function edit(Req $req) {
  672. $id = $req->id;
  673. if (intval($id) < 1) {
  674. return -1;
  675. }
  676. if (!$req->isMethod('post')) {
  677. $data = \App\Models\Stzqresult::where('id', $id)->first();
  678. if (!$data) {
  679. return -2;
  680. }
  681. $data = $data->toArray();
  682. return view('admin.sportsfoot/edit', $data);
  683. } else {
  684. $model = \App\Models\Stzqresult::where('id', $id)->first();
  685. $model->home_team = $req->input('home_team');
  686. $model->guest_team = $req->input('guest_team');
  687. $model->home_rate = $req->input('home_rate');
  688. $model->guest_rate = $req->input('guest_rate');
  689. $model->status = $req->input('status');
  690. //$model->update_time = time();
  691. $model->save();
  692. return responseToJson(1);
  693. }
  694. }
  695. function outcomeinfo() {
  696. $page = Request::has('page') ? Request::get('page') : '';
  697. $list = Request::has('limit') ? Request::get('limit') : 10;
  698. $home_team = Request::has('home_team') ? Request::get('home_team') : '';
  699. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
  700. $status = Request::has('status') ? Request::get('status') : '';
  701. $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
  702. $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
  703. $where = array();
  704. $orwhere = array();
  705. if (!empty($home_team)) {
  706. if (empty($sureblur) || $sureblur == 'off') {
  707. $where[] = array('st_zq_result.home_team', 'like', '%' . $home_team . '%');
  708. $orwhere[] = array('st_zq_result.guest_team', 'like', '%' . $home_team . '%');
  709. } else {
  710. if(is_numeric($home_team)){
  711. $where[] = array('st_zq_result.match_id', '=', $home_team);
  712. $orwhere[] = array('st_zq_result.match_id', '=', $home_team);
  713. }else{
  714. $where[] = array('st_zq_result.home_team', '=', $home_team);
  715. $orwhere[] = array('st_zq_result.guest_team', '=', $home_team);
  716. }
  717. }
  718. }
  719. //
  720. if ($status != -1) {
  721. $where[] = array('st_zq_competition.status', '=', $status);
  722. $orwhere[] = array('st_zq_competition.status', '=', $status);
  723. }
  724. if (!empty($star_time) and empty($home_team)) {
  725. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  726. $where[] = array('st_zq_result.start_time', '>', $star_time);
  727. $orwhere[] = array('st_zq_result.start_time', '>', $star_time);
  728. }
  729. if (!empty($end_time) and empty($home_team)) {
  730. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  731. $where[] = array('st_zq_result.start_time', '<', $end_time);
  732. $orwhere[] = array('st_zq_result.start_time', '<', $end_time);
  733. }
  734. $newapp = new \App\Models\Stzqresult();
  735. $data = $newapp->resultlist($list, $page, $where, $orwhere);
  736. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  737. }
  738. function saislist(Req $req){
  739. $lgid = $req->lgid;//赛事id
  740. $newstzqcompetition = new \App\Models\Stzqcompetition();
  741. $league_data = $newstzqcompetition->allcompetition($lgid);//赛事id
  742. return $league_data;
  743. }
  744. //赛事结果添加 guest_score 客队进球 all_goal总进球数
  745. function addoutcome(Req $req) {
  746. if (!$req->isMethod('post')) {
  747. $lange = trans('menu');
  748. $newapp = new \App\Models\SoccerLeague();
  749. $league_data = $newapp->allleague();//联赛id
  750. return view('admin.sportsfoot/addoutcome',['data'=>$league_data]);
  751. } else {
  752. $match_id = trim($req->input('match_id'));//赛事id
  753. //添加足球比赛结果表
  754. $alldata = $req->input();
  755. unset($alldata['_token']);
  756. $all_goal = intval($alldata['home_score'])+intval($alldata['guest_score']);//总进球数
  757. $penaltycard = array(
  758. 'home'=>intval($alldata['homeallcard'])?intval($alldata['homeallcard']):0,
  759. 'guest'=>intval($alldata['guestallcard'])?intval($alldata['guestallcard']):0,
  760. 'home_half'=>intval($alldata['homehalfcard'])?intval($alldata['homehalfcard']):0,
  761. 'guest_half'=>intval($alldata['guesthalfcard'])?intval($alldata['guesthalfcard']):0,
  762. );
  763. $cornerball = array(
  764. 'home'=>intval($alldata['homeallcorner'])?intval($alldata['homeallcorner']):0,
  765. 'guest'=>intval($alldata['guestallcorner'])?intval($alldata['guestallcorner']):0,
  766. 'home_half'=>intval($alldata['homehalfcorner'])?intval($alldata['homehalfcorner']):0,
  767. 'guest_half'=>intval($alldata['guesthalfcorner'])?intval($alldata['guesthalfcorner']):0,
  768. );
  769. $ret = \App\Models\Stzqresult::updateOrCreate(['match_id'=>$match_id],array_merge($alldata,['match_time'=>'00:01','update_time'=>date('Y-m-d H:i:s'),'all_goal'=>$all_goal,'penalty_card'=>json_encode($penaltycard),'corner_ball'=>json_encode($cornerball)]));
  770. //添加足球比赛结果记录表
  771. \App\Models\Stzqresultrecord::updateOrCreate(['match_id'=>$match_id,'update_time'=>date('Y-m-d H:i:s')],array_merge($alldata,['match_time'=>'00:01','update_time'=>date('Y-m-d H:i:s')]));
  772. }
  773. return responseToJson(1);
  774. }
  775. //删除赛事结果
  776. function deleteoutcome(Req $req) {
  777. $id = $req->input('id');
  778. if (empty($id)) {
  779. return responseToJson(-2001); //
  780. }
  781. $ids = explode(',', $id);
  782. if (!is_array($ids) && intval($ids) < 0) {
  783. return responseToJson(-2002); //
  784. }
  785. if (is_array($ids) && count($ids) > 0) {
  786. foreach ($ids as $k => $v) {
  787. if (intval($v) < 1) {
  788. unset($ids[$k]);
  789. }
  790. }
  791. }
  792. $rows = \App\Models\Stzqresult::whereIn('id', $ids)->delete();
  793. if (!$rows) {
  794. return responseToJson(-2003);
  795. }
  796. return responseToJson(1);
  797. }
  798. /**
  799. * 更新赛事比分
  800. * 追加 赛事及所属注单作废处理
  801. */
  802. function updatenum(Req $req){
  803. $match_id = $req->match_id;
  804. $newapp = new \App\Models\Stzqresult();
  805. //赛事状态
  806. $match_status = intval($req->match_status)?intval($req->match_status):0;
  807. $data['u_home_score'] = intval($req->u_home_score)?intval($req->u_home_score):0;
  808. $data['u_guest_score'] = intval($req->u_guest_score)?intval($req->u_guest_score):0;
  809. $data['home_score'] = intval($req->home_score)?intval($req->home_score):0;
  810. $data['guest_score'] = intval($req->guest_score)?intval($req->guest_score):0;
  811. $data['is_correct'] = 1;//追加手动更改标识
  812. //更新比分 默认 status
  813. $status = 2;
  814. //赛事下注单作废 处理
  815. if(in_array(-1,$data)){
  816. commonFunction::HandleInvalid($data,$match_id,$match_status,'zq');
  817. // $this->HandleInvalid($data,$match_id,$match_status,'zq');
  818. }
  819. $newapp->updateInfo($data,$match_id);//联赛id
  820. $newapp->totalgoal($match_id);
  821. $update = $this->addcomendnotice($match_id);
  822. $twoapp = new \App\Models\SportsSoccer();
  823. $twoapp->updatestatus('match_id',$match_id,['status'=>$status,'utime'=>date('Y-m-d H:i:s')]);//修改赛事状态
  824. $newapp->updatestatus('match_id',$match_id,['status'=>$status,'update_time'=>date('Y-m-d H:i:s')]);//修改结果状态
  825. //添加赛事结果比较记录
  826. $lastLog = \App\Models\Stzqresultlog::where([
  827. ['match_id', $match_id],
  828. ['type', 2]
  829. ])->orderBy('id', 'desc')->first();
  830. if(empty($lastLog) || !(
  831. $lastLog['u_home_score'] == $data['u_home_score']
  832. && $lastLog['u_guest_score'] == $data['u_guest_score']
  833. && $lastLog['home_score'] == $data['home_score']
  834. && $lastLog['guest_score'] == $data['guest_score']
  835. )){
  836. $logData = $data;
  837. unset($logData['is_correct']);
  838. $logData['type'] = 2;
  839. $logData['match_id'] = $match_id;
  840. $logData['user_id'] = session('adminInfo.admin_id');
  841. $logData['create_at'] = now();
  842. \App\Models\Stzqresultlog::insert($logData);
  843. }
  844. return responseToJson(1);
  845. }
  846. /**
  847. * 赛事下注单作废处理
  848. * 弃用 保留备份
  849. */
  850. function HandleInvalid($data=[],$match_id='',$match_status='',$game_code=''){
  851. //===作废处理===
  852. $moneyBuyMatch = new \App\Models\MoneyBuyMatch();
  853. //获取赛事下所有单式注单
  854. $select = ['money_buy_simplex.order_id', 'money_buy_simplex.match_id', 'money_buy_simplex.account_identity', 'money_buy_simplex.account_name','money_buy_simplex.money', 'money_buy_simplex.gain_money','money_buy_match.odds_code','st_odds_code.odds_name'];
  855. //obj
  856. $match_order_sim_obj = $moneyBuyMatch->allsimplexorder($match_id,$game_code,$select);
  857. //获取赛事下所有串式注单
  858. $select = ['money_buy_str.order_id', 'money_buy_match.match_id', 'money_buy_str.account_identity', 'money_buy_str.account_name','money_buy_str.money', 'money_buy_str.gain_money','st_odds_code.odds_name','money_buy_match.odds_code'];
  859. //obj
  860. $match_order_str_obj = $moneyBuyMatch->allstrorder($match_id,$game_code,$select);
  861. //如果赛事下有 单式 注单
  862. if(!empty($match_order_sim_obj)){
  863. //获取单式注单中 待处理注单
  864. $oddsData_sim = $this->getOrderData($data,$match_order_sim_obj,$game_code);
  865. }
  866. //如果赛事下有 串式 注单
  867. if(!empty($match_order_str_obj)){
  868. //获取串式注单中 待处理注单
  869. $oddsData_str = $this->getOrderData($data,$match_order_str_obj,$game_code);
  870. }
  871. //如果是已结算赛事
  872. if($match_status == 3){
  873. //合并上半场/全场 待处理 单式+串式订单
  874. $oddsData = array_merge($oddsData_sim,$oddsData_str);
  875. //去重
  876. $oddsData = commonFunction::uniquArrV2($oddsData,'order_id');
  877. $url = 'http://stadmin.bocai108.com:9094/UnsetOneOrder';
  878. $data_up = [
  879. 'token'=>session('adminInfo.token'),
  880. 'game_code'=>$game_code,
  881. 'match_id'=>$match_id,
  882. ];
  883. //返回请求状态码
  884. $set_status = [];
  885. foreach($oddsData as $k=>$v){
  886. $data_up['order_id'] = $v['order_id'];
  887. $ret_json = commonFunction::https_request($url,$data_up);
  888. $ret_arr = json_decode($ret_json,true);
  889. $set_status[] = $ret_arr['status'];
  890. }
  891. if(in_array(0,$set_status)){
  892. return responseToJson(-20003);
  893. }
  894. }else{
  895. //未结算赛事 处理 下单式注单作废,串关注单下此赛事按平局处理
  896. $oddsData_str = $oddsData_str->toArray();
  897. $upapp = new \App\Models\SportsNoteList();
  898. $upapp->delorder($match_id,$game_code,$match_order_sim_obj,$oddsData_str);
  899. }
  900. //=== end ===
  901. }
  902. /**
  903. * 获取赛事下 符合条件 待处理注单
  904. * 弃用 保留备份
  905. */
  906. function getOrderData($data,$match_order,$game_code){
  907. //足球 获取 上半场/全场
  908. if($game_code == 'zq'){
  909. // 获取上半场作废 需处理 单式注单
  910. $matchOdds_h = [];
  911. if($data['u_home_score'] == -1 and $data['u_guest_score'] == -1){
  912. foreach($match_order as $k=>$v){
  913. $tmparray = explode('上半场',$v->odds_name);
  914. if(count($tmparray) > 1){
  915. $matchOdds_h[] = $v;
  916. }
  917. }
  918. }
  919. //获取全场作废 需处理 单式注单
  920. $matchOdds_f = [];
  921. if($data['home_score'] == -1 and $data['guest_score'] == -1){
  922. foreach($match_order as $k=>$v){
  923. $tmparray = explode('全场',$v->odds_name);
  924. if(count($tmparray) > 1){
  925. $matchOdds_f[] = $v;
  926. }
  927. }
  928. }
  929. $orderData = array_merge($matchOdds_h,$matchOdds_f);
  930. }
  931. return $orderData;
  932. }
  933. //添加赛事结束纪录
  934. function addcomendnotice($match_id){
  935. $data = \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->first();
  936. if(!$data){
  937. $model = new \App\Models\Comendnotice();
  938. $model->status = 0;//联赛id
  939. $model->game_code = 'zq';
  940. $model->match_id = $match_id;//赛事id
  941. $model->ctime = date('Y-m-d H:i:s');
  942. $model->save();
  943. }
  944. }
  945. }