SportsfootController.php 40 KB

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