SportsfootController.php 40 KB

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