SportsfootController.php 40 KB

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