WriteSportsController.php 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jun.peng
  5. * Date: 2019/5/13
  6. * Time: 10:19
  7. */
  8. namespace App\Http\Controllers\Api;
  9. use Illuminate\Routing\Controller as BaseController;
  10. use App\Http\Response\Response;
  11. use Illuminate\Http\Request as Req;
  12. use Illuminate\Support\Facades\DB;
  13. use App\Lib\Biz\Sport\Common as commonFunction;
  14. use App\Http\Model\StBqResult as BqResultModel;
  15. use App\Http\Model\StBroadcast as broadcastModel;
  16. use App\Http\Model\StGameType as gameModel;
  17. use App\Http\Model\StLqResult as LqResultModel;
  18. use App\Http\Model\StWqResult as WqResultModel;
  19. use App\Http\Model\StZqLocalLeague as LeagueModel;
  20. use App\Http\Model\StZqLocalMatch as MatchModel;
  21. use App\Http\Model\StZqOdds as OddsModel;
  22. use App\Http\Model\StZqOddsRecord as OddsRecordModel;
  23. use App\Http\Model\StZqResult as ZqResultModel;
  24. use App\Http\Model\St_area_country as StAreaCountryModel;
  25. /**
  26. * 体育数据入库接口
  27. */
  28. class WriteSportsController extends BaseController{
  29. /*
  30. * 用户 用户 token
  31. */
  32. public function getToken(Req $req){
  33. if ($req->isMethod('post')) {
  34. $user = new \App\Models\System_user;
  35. $str = $user->adminLogin($_POST['account'], $_POST['password']);
  36. if($str>0){
  37. $token=refreshToken($str['admin_id']);
  38. $str['token']=$token;
  39. $data = $str;
  40. $req->session()->put('adminInfo',$str);
  41. $str=1;
  42. }
  43. $log = array(
  44. session('adminInfo.admin_name'),
  45. $_POST['account']
  46. );
  47. OperationLog(session('adminInfo.admin_id'), 'login', $log);
  48. return Response::success($data);
  49. }
  50. }
  51. /**
  52. * 根据联赛名称 获取 国家 地区
  53. */
  54. public function getArea($leagueName = ''){
  55. //如果联赛名称有括号,去除
  56. $leagueName = preg_replace('/\(.*?\)/', '', $leagueName);
  57. //获取所有国家/地区
  58. $areaData = StAreaCountryModel::select('id','pid','name')->get()->toArray();
  59. //获取当前联赛所属国家
  60. if(strpos($leagueName,'NBA') !== false){
  61. $data = [
  62. 'id'=>247,
  63. 'pid'=>0,
  64. 'name'=>'世界'
  65. ];
  66. return $data;
  67. }
  68. //识别本地 国家地区数据
  69. foreach($areaData as $v => $k){
  70. if(strpos($leagueName,$k['name']) !== false){
  71. return $k;
  72. }
  73. }
  74. //如果不能识别,则返回世界
  75. $data = [
  76. 'id'=>247,
  77. 'pid'=>0,
  78. 'name'=>'世界'
  79. ];
  80. return $data;
  81. }
  82. /*
  83. * 写 联赛 数据
  84. * 每个请求 包含 N个联赛
  85. */
  86. public function setLeague(Req $data){
  87. //验证token
  88. $user = new \App\Models\System_user;
  89. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  90. $token = $user::where(['token'=>$data->token])->value('token');
  91. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  92. try {
  93. //开启事务
  94. DB::beginTransaction();
  95. $obt = $data->data;
  96. //请求 数据 为空
  97. if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
  98. $getData = $this->getAddData($obt);
  99. //不是 联赛 数据
  100. if($getData['title'] != 'league') throw new \Exception(Response::generate('不是联赛数据,',Response::ABNORMAL));
  101. //获取球类代码
  102. $game_code = $getData['game_code'];
  103. //获取数据源
  104. $source = $getData['source'];
  105. //获取球类名称
  106. $gameName = gameModel::getGameName($game_code);
  107. //获取 model
  108. $models = commonFunction::getModels($game_code, 1);
  109. //获取 联赛 数据
  110. $leagueData = $getData['data'];
  111. //获取 当前请求 所有 联赛 uuid
  112. $identity = [];
  113. foreach($leagueData as $k=>$v){
  114. $identity[] = $v['uuid'];
  115. }
  116. $identity = array_unique($identity);
  117. sort($identity);
  118. //获取 本地 已存在 联赛
  119. $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id')->get()->toArray();
  120. //二维数组去重
  121. $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
  122. //循环对比 请求identity->本地identity
  123. foreach($l_lg_data as $k=>$v){
  124. foreach($identity as $kk=> $uuid){
  125. if($v['identity'] == $uuid){
  126. unset($identity[$kk]);
  127. }
  128. }
  129. }
  130. //去除本地和请求里都存在的联赛,如果还有剩余联赛uuid,则将其写入
  131. if(!empty($identity)) {
  132. //没有 决赛时间 默认获取本年最后一天
  133. $last_time = date('Y-12-31 23:59:59');
  134. foreach($leagueData as $k=>$v){
  135. foreach($identity as $kk=> $uuid){
  136. if($v['uuid'] == $uuid){
  137. //如有 决赛时间
  138. if($v['last_time']){
  139. $last_time = $v['last_time'];
  140. }
  141. //获取联赛所属国家或地区
  142. $getArea = $this->getArea($v['name_chinese']);
  143. if($getArea['pid'] == 0){
  144. $area_id = $getArea['id'];
  145. $country_id = 0;
  146. }else{
  147. $area_id = $getArea['pid'];
  148. $country_id = $getArea['id'];
  149. }
  150. if(empty($v['uuid'])) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$v['lg_id'].';',Response::LG__UUID_NULL));
  151. $set_lg['name_chinese'] = $v['name_chinese'];
  152. $set_lg['kind'] = $v['kind'];
  153. $set_lg['match_mode'] = $v['match_mode'];
  154. $set_lg['if_stop'] = $v['if_stop'];
  155. $set_lg['identity'] = $v['uuid'];
  156. $set_lg['last_time'] = $last_time;
  157. $set_lg['utime'] = date('Y-m-d H:i:s');
  158. $set_lg['area_id'] = $area_id;
  159. $set_lg['country_id'] = $country_id;
  160. //写入联赛
  161. $id = $models['model_league']::insertGetId($set_lg);
  162. $m_lg_id = $id;
  163. if($m_lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$v['lg_id'].';',Response::INSERT_ERROR));
  164. //写入 本地 联赛记录
  165. $set_local = [
  166. 'lg_id'=>$id,
  167. 'others_lg_id'=>$v['lg_id'],
  168. 'source'=>$source,
  169. 'ctime'=>date('Y-m-d H:i:s'),
  170. 'identity'=>$v['uuid'],
  171. ];
  172. $ret = $models['model_local_league']::insertGetId($set_local);
  173. if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LOCAL_LEAGUE_ERROR)) ;//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
  174. }
  175. }
  176. }
  177. }
  178. //提交事务
  179. DB::commit();
  180. return Response::success();
  181. } catch (\Exception $e) {
  182. //回滚事务
  183. DB::rollBack();
  184. return $e->getMessage();
  185. }
  186. }
  187. /*
  188. * 写 赛事 数据
  189. * 每个请求 包含 N个联赛 下 N个赛事
  190. */
  191. public function setMatch(Req $data){
  192. //验证token
  193. $user = new \App\Models\System_user;
  194. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  195. $token = $user::where(['token'=>$data->token])->value('token');
  196. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  197. try {
  198. //开启事务
  199. DB::beginTransaction();
  200. $obt = $data->data;
  201. //请求 数据 为空
  202. if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
  203. $getData = $this->getAddData($obt);
  204. //不是 赛事 数据
  205. if($getData['title'] != 'match') throw new \Exception(Response::generate('不是赛事数据,',Response::ABNORMAL));
  206. //获取球类代码
  207. $game_code = $getData['game_code'];
  208. //获取数据源
  209. $source = $getData['source'];
  210. //获取球类名称
  211. $gameName = gameModel::getGameName($game_code);
  212. //获取 model
  213. $models = commonFunction::getModels($game_code, 1);
  214. //获取 赛事 数据
  215. $matchData = $getData['data'];
  216. //获取 当前请求 所有 uuid /match_id
  217. $identity = [];
  218. $s_match_ids = [];
  219. foreach($matchData as $k=>$v){
  220. $identity[] = $v['uuid'];
  221. $s_match_ids[] = $v['match_id'];
  222. }
  223. //====验证 赛事 所属 联赛 是否存在====
  224. $identity = array_unique($identity);
  225. sort($identity);
  226. //获取 本地 已存在 联赛
  227. $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id')->get()->toArray();
  228. //二维数组去重
  229. $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
  230. //循环对比 请求uuid->本地identity
  231. foreach($l_lg_data as $k=>$v){
  232. foreach($identity as $kk=> $uuid){
  233. if($v['identity'] == $uuid){
  234. unset($identity[$kk]);
  235. }
  236. }
  237. }
  238. sort($identity);
  239. //去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常
  240. if(!empty($identity)) throw new \Exception(Response::generate($gameName.'联赛:uuid-'.$identity[0].';',Response::LEAGUE_ERROR));
  241. //====end====
  242. //====获取 本地 已存在 赛事====
  243. $s_match_ids = array_unique($s_match_ids);
  244. sort($s_match_ids);
  245. $l_match_data = $models['model_local_match']::whereIn('others_match_id',$s_match_ids)->where('source',$source)->select('others_match_id','match_id')->get()->toArray();
  246. //二维数组去重
  247. $l_match_data = commonFunction::uniquArrV2($l_match_data,'others_match_id');
  248. //循环对比 请求match_id->本地others_match_id
  249. foreach($l_match_data as $k=>$v){
  250. foreach($s_match_ids as $kk=> $s_match_id){
  251. if($v['others_match_id'] == $s_match_id){
  252. unset($s_match_ids[$kk]);
  253. }
  254. }
  255. }
  256. //剩余 赛事 数据 写入
  257. if(!empty($s_match_ids)){
  258. foreach($matchData as $k=>$v){
  259. foreach($s_match_ids as $kk=> $s_match_id){
  260. if($v['match_id'] == $s_match_id){
  261. $data = $v;
  262. $half_match_id = 0;
  263. //获取 本地 联赛 ID
  264. $lg_id = commonFunction::searcharray($data['lg_id'],'others_lg_id',$l_lg_data,'lg_id');
  265. //如果有上半场赛事id 获取上半场赛事是否存在
  266. if(!empty($data['half_match_id'])){
  267. $half_match_id = $models['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$source])
  268. ->value('match_id');
  269. if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'上半场赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
  270. }
  271. //如果赛事没有开始日期,则为冠军盘口赛事
  272. if(empty($data['match_date'])){
  273. //冠军盘口赛事获取所属联赛结束时间
  274. $last_time = $models['model_league']::where(['id'=>$lg_id])
  275. ->value('last_time');
  276. if(empty($last_time)) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LG_LASTTIME_ERROR)) ;//Render([], '10023', lang('Tips','Sports')->get('lg_lastTime_error'));
  277. //给冠军盘口赛事 赋值时间
  278. $time = strtotime($last_time);
  279. $data['match_date'] = date('Y-m-d',$time);
  280. $data['match_time'] = date('H:i:s',$time);
  281. }
  282. $set_match = [
  283. 'ctime'=>date('Y-m-d H:i:s'),
  284. 'utime'=>date('Y-m-d H:i:s'),
  285. 'expire_time'=>date('Y-m-d H:i:s',time()+60),
  286. 'home_team'=>$data['home_team']?:'',
  287. 'guest_team'=>$data['guest_team']?:'no_team',
  288. 'lg_id'=>$lg_id,
  289. 'status'=>$data['status'],
  290. 'match_date'=>$data['match_date']?:date('Y-m-d'),
  291. 'match_time'=>$data['match_time']?:date('H:i:s'),
  292. // 'tag'=>$data['tag']?:0,
  293. 'is_rollball'=>$data['is_rollball']?:0,
  294. 'is_today'=>$data['is_today']?:0,
  295. 'is_morningplate'=>$data['is_morningplate']?:0,
  296. 'is_stringscene'=>$data['is_stringscene']?:0,
  297. 'us_time'=>$data['us_time']?:commonFunction::qgmdate('Y-m-d H:i:s', '', -4),
  298. 'half_match_id'=>$half_match_id?:0,
  299. 'identity' => $data['uuid'],
  300. ];
  301. //写入赛事 返回id
  302. $id = $models['model_match']::insertGetId($set_match);
  303. if($id < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::INSERT_ERROR)) ;
  304. //写关联记录
  305. $set_local = [
  306. 'match_id'=>$id,
  307. 'others_match_id'=>$data['match_id'],
  308. 'source'=>$source,
  309. 'ctime'=>date('Y-m-d H:i:s')
  310. ];
  311. $ret = $models['model_local_match']::insertGetId($set_local);
  312. if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::LOCAL_MATCH_ERROR)) ;//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
  313. }
  314. }
  315. }
  316. }
  317. //提交事务
  318. DB::commit();
  319. return Response::success();
  320. } catch (\Exception $e) {
  321. //回滚事务
  322. DB::rollBack();
  323. return $e->getMessage();
  324. }
  325. }
  326. /*
  327. * 写 赛事 结果 记录 数据
  328. * 每个请求 包含 N个联赛 下 N个赛事 结果数据
  329. */
  330. public function setMatchResult(Req $data){
  331. //验证token
  332. $user = new \App\Models\System_user;
  333. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  334. $token = $user::where(['token'=>$data->token])->value('token');
  335. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  336. try {
  337. //开启事务
  338. DB::beginTransaction();
  339. $obt = $data->data;
  340. //请求 数据 为空
  341. if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
  342. $getData = $this->getAddData($obt);
  343. //不是 赛事 结果 记录 数据
  344. if($getData['title'] != 'match_result_r') throw new \Exception(Response::generate('不是赛事结果记录数据,',Response::ABNORMAL));
  345. //获取球类代码
  346. $game_code = $getData['game_code'];
  347. //获取数据源
  348. $source = $getData['source'];
  349. //获取球类名称
  350. $gameName = gameModel::getGameName($game_code);
  351. //获取 model
  352. $models = commonFunction::getModels($game_code, 1);
  353. //获取 赛事 数据
  354. $match_r_data = $getData['data'];
  355. //获取 当前请求 所有 uuid /match_id
  356. $identity = [];
  357. $s_match_ids = [];
  358. foreach($match_r_data as $k=>$v){
  359. $identity[] = $v['uuid'];
  360. $s_match_ids[] = $v['match_id'];
  361. }
  362. //====验证 赛事 所属 联赛 是否存在====
  363. $identity = array_unique($identity);
  364. sort($identity);
  365. //获取 本地 已存在 联赛
  366. $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id')->get()->toArray();
  367. //二维数组去重
  368. $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
  369. //循环对比 请求uuid->本地identity
  370. foreach($l_lg_data as $k=>$v){
  371. foreach($identity as $kk=> $uuid){
  372. if($v['identity'] == $uuid){
  373. unset($identity[$kk]);
  374. }
  375. }
  376. }
  377. sort($identity);
  378. //去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常
  379. if(!empty($identity)) throw new \Exception(Response::generate($gameName.'联赛:uuid-'.$identity[0].';',Response::LEAGUE_ERROR));
  380. //====end====
  381. //====验证 赛事结果记录 所属赛事 是否存在====
  382. $s_match_ids = array_unique($s_match_ids);
  383. sort($s_match_ids);
  384. //获取 本地 已存在 赛事
  385. $l_match_data = $models['model_local_match']::whereIn('others_match_id',$s_match_ids)->where('source',$source)->select('others_match_id','match_id')->get()->toArray();
  386. //二维数组去重
  387. $l_match_data = commonFunction::uniquArrV2($l_match_data,'others_match_id');
  388. //循环对比 请求match_id->本地others_match_id
  389. foreach($l_match_data as $k=>$v){
  390. foreach($s_match_ids as $kk=> $s_match_id){
  391. if($v['others_match_id'] == $s_match_id){
  392. unset($s_match_ids[$kk]);
  393. }
  394. }
  395. }
  396. sort($s_match_ids);
  397. //去除本地和请求里都存在的赛事,如果还有剩余赛事id,则返回异常
  398. if(!empty($s_match_ids)) throw new \Exception(Response::generate($gameName.'赛事-match_id'.$s_match_ids[0].';',Response::MATCH_ERROR));
  399. //====end====
  400. //处理 赛事 结果记录 数据
  401. foreach($match_r_data as $k=>$v){
  402. $data = $v;
  403. //获取 本地 联赛 ID
  404. $lg_id = commonFunction::searcharray($data['lg_id'],'others_lg_id',$l_lg_data,'lg_id');
  405. //获取 本地 赛事 ID
  406. $match_id = commonFunction::searcharray($data['match_id'],'others_match_id',$l_match_data,'match_id');
  407. //根据球类 获取 赛事结果记录字段
  408. $set_match_r = $this->get_match_r($game_code,$lg_id,$match_id,$data);
  409. //写 赛事 结果 记录
  410. $ret = $models['model_result_record']::insert($set_match_r);
  411. if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));
  412. }
  413. //提交事务
  414. DB::commit();
  415. return Response::success();
  416. } catch (\Exception $e) {
  417. //回滚事务
  418. DB::rollBack();
  419. return $e->getMessage();
  420. }
  421. }
  422. /*
  423. * 写 普通 赔率 数据
  424. * 每个请求 只包含 一场赛事下 N条赔率
  425. */
  426. public function setOdds(Req $data){
  427. //验证token
  428. $user = new \App\Models\System_user;
  429. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  430. $token = $user::where(['token'=>$data->token])->value('token');
  431. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  432. try {
  433. //开启事务
  434. DB::beginTransaction();
  435. $obt = $data->data;
  436. //请求 数据 为空
  437. if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
  438. $getData = $this->getAddData($obt);
  439. //不是 赔率 数据
  440. if($getData['title'] != 'odds') throw new \Exception(Response::generate('不是赔率数据,',Response::ABNORMAL));
  441. //获取球类代码
  442. $game_code = $getData['game_code'];
  443. //获取数据源
  444. $source = $getData['source'];
  445. //获取源数据联赛ID
  446. $uuid = $getData['uuid'];
  447. //获取源数据赛事ID
  448. $s_match_id = $getData['match_id'];
  449. //获取赔率所属赛事 tag 值 玩法数量
  450. $tag = $getData['tag'];
  451. //获取球类名称
  452. $gameName = gameModel::getGameName($game_code);
  453. //验证本次请求所属联赛/赛事是否存在 返回本地联赛/赛事ID
  454. $models = commonFunction::getModels($game_code, 1);
  455. $lg_id = $this->leagueVerify($models,$uuid,$source,$gameName);
  456. $match_id = $this->matchVerify($models,$s_match_id,$source,$gameName);
  457. //更新赛事 tag 值
  458. $upMatch = $models['model_match']::where(['id'=>$match_id])
  459. ->update(['tag'=>$tag,'utime'=>date('Y-m-d H:i:s')]);
  460. if($upMatch < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::UPMATCHTAG_ERROR)) ;
  461. //获取 赔率数据
  462. $oddsData = $getData['data'];
  463. if(!empty($oddsData)){
  464. //获取 当前 所有 可用 赔率 sole
  465. $odds_only = $getData['odds_only'];
  466. //更新赛事下所有 不在本次请求的赔率 状态
  467. $ret= OddsModel::upOddsStatus($models,$s_match_id,'',$source,$odds_only);
  468. if($ret != true) throw new \Exception(Response::generate($gameName,Response::ODDS_SOLE_ERR));
  469. //拼装 待写入 赔率数据
  470. foreach($oddsData as $k=>$v){
  471. //组装数据
  472. $set_odds = [
  473. 'match_id'=> $match_id?:0,
  474. 'others_match_id'=> $v['match_id']?:0,
  475. 'odds_code'=> $v['odds_code']?:'',
  476. 'status'=> $v['status']?:0,
  477. 'sort'=> $v['sort']?:0,
  478. 'p_code'=> $v['p_code']?:'',
  479. 'odds'=> $v['odds']?:0,
  480. 'condition'=> $v['condition'],
  481. 'odds_only'=> $v['odds_only']?:'',
  482. 'source'=> $v['source']?:'',
  483. 'type'=> $v['type']?:0,
  484. 'team'=> $v['team']?:'',
  485. 'lg_id'=> $lg_id,
  486. 'others_lg_id'=> $v['lg_id'],
  487. 'ctime'=> date('Y-m-d H:i:s'),
  488. 'utime'=> date('Y-m-d H:i:s'),
  489. ];
  490. //写赔率记录数据
  491. $ret = $models['model_odds_record']->updateOrCreate(
  492. ['odds_only'=>$v['odds_only']],$set_odds
  493. );
  494. if(empty($ret)) throw new \Exception(Response::generate($gameName.'赔率记录-odds_only:'.$v['odds_only'].';',Response::ADD_ODDS_R_ERROR));
  495. //追加参数
  496. $set_odds['sole'] = $v['sole'];
  497. $set_odds['expire_time'] = date('Y-m-d H:i:s',time()+60);
  498. //写赔率 数据
  499. $ret = $models['model_odds']->updateOrCreate(
  500. ['odds_only'=>$v['odds_only']],$set_odds
  501. );
  502. if(empty($ret)) throw new \Exception(Response::generate($gameName.'赔率-odds_only:'.$v['odds_only'].';',Response::ADD_ODDS_ERROR));
  503. }
  504. }
  505. //提交事务
  506. DB::commit();
  507. return Response::success();
  508. } catch (\Exception $e) {
  509. //回滚事务
  510. DB::rollBack();
  511. return $e->getMessage();
  512. }
  513. }
  514. /*
  515. *写 冠军联赛 赔率 数据
  516. *每个请求 包含 N个联赛 下 N条赔率
  517. */
  518. public function setOddsCH(Req $data){
  519. //验证token
  520. $user = new \App\Models\System_user;
  521. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  522. $token = $user::where(['token'=>$data->token])->value('token');
  523. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  524. try {
  525. //开启事务
  526. DB::beginTransaction();
  527. $obt = $data->data;
  528. //请求 数据 为空
  529. if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
  530. $getData = $this->getAddData($obt);
  531. //不是 冠军 赔率 数据
  532. if($getData['title'] != 'odds_ch') throw new \Exception(Response::generate('不是冠军赔率数据,',Response::ABNORMAL));
  533. //获取球类代码
  534. $game_code = $getData['game_code'];
  535. //获取数据源
  536. $source = $getData['source'];
  537. //获取球类名称
  538. $gameName = gameModel::getGameName($game_code);
  539. //获取 model
  540. $models = commonFunction::getModels($game_code, 1);
  541. //获取 赔率数据
  542. $oddsData = $getData['data'];
  543. //获取 当前 所有 可用 赔率 sole
  544. // $odds_only = $getData['odds_only'];
  545. //====验证 请求里 所有赔率 所属联赛 是否存在 ====
  546. //获取 当前请求 所有 联赛 uuid
  547. $uuids = [];
  548. foreach($oddsData as $k=>$v){
  549. $uuids[] = $v['uuid'];
  550. }
  551. $uuids = array_unique($uuids);
  552. sort($uuids);
  553. //更新赛事下所有 不在本次请求的赔率 状态
  554. // $ret= OddsModel::upOddsStatus($models,'',$s_lg_ids,$source,$odds_only);
  555. // if($ret != true) throw new \Exception(Response::generate($gameName,Response::ODDS_SOLE_ERR));
  556. //获取 本地 已存在 联赛
  557. $l_lg_data = $models['model_local_league']::whereIn('identity',$uuids)->select('identity','lg_id')->get()->toArray();
  558. //二维数组去重
  559. $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
  560. //循环对比 请求uuid->本地uuid
  561. foreach($l_lg_data as $k=>$v){
  562. foreach($uuids as $kk=> $uuid){
  563. if($v['identity'] == $uuid){
  564. unset($uuids[$kk]);
  565. }
  566. }
  567. }
  568. //去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常;
  569. if(!empty($uuids)) throw new \Exception(Response::generate($gameName.'冠军联赛:uuid-'.$uuids[0].';',Response::LEAGUE_ERROR));
  570. //====end====
  571. //拼装 待写入 赔率数据
  572. foreach($oddsData as $k=>$v){
  573. //获取 本地 联赛 ID
  574. $lg_id = commonFunction::searcharray($v['lg_id'],'others_lg_id',$l_lg_data,'lg_id');
  575. //组装数据
  576. $set_odds = [
  577. 'match_id'=>0,
  578. 'others_match_id'=> $v['match_id']?:0,
  579. 'odds_code'=> $v['odds_code']?:'',
  580. 'status'=> $v['status']?:0,
  581. 'sort'=> $v['sort']?:0,
  582. 'p_code'=> $v['p_code']?:'',
  583. 'odds'=> $v['odds']?:0,
  584. 'condition'=> $v['condition'],
  585. 'odds_only'=> $v['odds_only']?:'',
  586. 'source'=> $v['source']?:'',
  587. 'type'=> $v['type']?:1,
  588. 'team'=> $v['team']?:'',
  589. 'lg_id'=> $lg_id,
  590. 'others_lg_id'=> $v['lg_id'],
  591. 'ctime'=> date('Y-m-d H:i:s'),
  592. 'utime'=> date('Y-m-d H:i:s'),
  593. ];
  594. //写赔率记录数据
  595. $ret = $models['model_odds_record']->updateOrCreate(
  596. ['odds_only'=>$v['odds_only']],$set_odds
  597. );
  598. if(empty($ret)) throw new \Exception(Response::generate($gameName.'赔率记录-odds_only:'.$v['odds_only'].';',Response::ADD_ODDS_R_ERROR));
  599. //追加参数
  600. $set_odds['sole'] = $v['sole'];
  601. $set_odds['expire_time'] = date('Y-m-d H:i:s',time()+60);
  602. //写赔率 数据
  603. $ret = $models['model_odds']->updateOrCreate(
  604. ['odds_only'=>$v['odds_only']],$set_odds
  605. );
  606. if(empty($ret)) throw new \Exception(Response::generate($gameName.'赔率-odds_only:'.$v['odds_only'].';',Response::ADD_ODDS_ERROR));
  607. }
  608. //提交事务
  609. DB::commit();
  610. return Response::success();
  611. } catch (\Exception $e) {
  612. //回滚事务
  613. DB::rollBack();
  614. return $e->getMessage();
  615. }
  616. }
  617. /*
  618. * 写入直播 数据
  619. */
  620. public function setBroadCast(Req $data){
  621. //验证token
  622. $user = new \App\Models\System_user;
  623. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  624. $token = $user::where(['token'=>$data->token])->value('token');
  625. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  626. try {
  627. //开启事务
  628. DB::beginTransaction();
  629. $obt = $data->data;
  630. //请求 数据 为空
  631. if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
  632. $getData = $this->getAddData($obt);
  633. //不是 直播 数据
  634. if($getData['title'] != 'broad_cast') throw new \Exception(Response::generate('不是直播数据,',Response::ABNORMAL));
  635. //获取 球类
  636. $game_code = $getData['game_code'];
  637. //获取 直播 数据
  638. $BroadCast = $getData['data'];
  639. $set_broadcast = [];
  640. foreach($BroadCast as $k=>$data){
  641. //组装数据
  642. $set_broadcast[] = [
  643. "doing" => $data['doing'],
  644. "game_type" => $data['game_type'],
  645. "game_code" => $game_code,
  646. "guest_team" => $data['guest_team'],
  647. "host_team" => $data['host_team'],
  648. "league_name" => $data['league_name'],
  649. "shower" => $data['shower'],
  650. "showid" => (int)$data['showid'],
  651. "start_time" => $data['start_time'],
  652. "ctime" =>date('Y-m-d H:i:s'),
  653. "utime" =>date('Y-m-d H:i:s'),
  654. ];
  655. }
  656. //写入 直播 数据
  657. $ret = broadcastModel::insert($set_broadcast);
  658. if($ret == false) throw new \Exception(Response::generate('',Response::BROADCAST_ERROR));
  659. //提交事务
  660. DB::commit();
  661. return Response::success();
  662. } catch (\Exception $e) {
  663. //回滚事务
  664. DB::rollBack();
  665. return $e->getMessage();
  666. }
  667. }
  668. /*
  669. * 验证所属 联赛 是否存在
  670. */
  671. public function leagueVerify($models=[],$uuid='',$source='',$gameName=''){
  672. if(empty($models) || empty($uuid)) throw new \Exception(Response::generate('',Response::ABNORMAL));
  673. $l_lg_id = $models['model_local_league']::where(['identity'=>$uuid])->value('lg_id');
  674. if($l_lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛:lg_id-'.$uuid,Response::LEAGUE_ERROR));
  675. return $l_lg_id;
  676. }
  677. /*
  678. * 验证所属 赛事 是否存在
  679. */
  680. public function matchVerify($models=[],$s_match_id='',$source='',$gameName=''){
  681. if(empty($models) || empty($s_match_id)) throw new \Exception(Response::generate('',Response::ABNORMAL));
  682. $l_match_id = $models['model_local_match']::where(['others_match_id'=>$s_match_id,'source'=>$source])->value('match_id');
  683. if($l_match_id < 1) throw new \Exception(Response::generate($gameName.'赛事:match_id-'.$s_match_id,Response::MATCH_ERROR));
  684. return $l_match_id;
  685. }
  686. /*
  687. * 写入数据 接口
  688. */
  689. public function setSports(Req $data){
  690. try {
  691. //开启事务
  692. DB::beginTransaction();
  693. if($data->game_code){
  694. //用于后台 将所有进行中的赛事写入结果
  695. $this->match_result($data->game_code);
  696. }else{
  697. //验证token
  698. $dd = $data->session()->get('adminInfo');
  699. if(empty($data->token) ||($dd['token'] != $data->token)) return Response::generate('',Response::TOKEN_ERR);
  700. //写赛事数据
  701. $obt = $data->data;
  702. if($obt){
  703. $getData = $this->getAddData($obt);
  704. $league = [];
  705. $competition = [];
  706. $odds = [];
  707. $odds_soly = [];
  708. $league_result = [];
  709. $match_result = [];
  710. $match_result_record = [];
  711. $odds_record = [];
  712. $broadcast = [];
  713. //指定排序 联赛->赛事->赔率->联赛结果->赛事结果->赛事结果记录->赔率记录->直播数据
  714. foreach ($getData as $k=>$v){
  715. $game_code = $v['game_code'];
  716. if($v['title'] == 'league') $league[] = $v;
  717. if($v['title'] == 'competition') $competition[] = $v;
  718. if($v['title'] == 'odds') $odds[] = $v;
  719. if($v['title'] == 'odds_sole') $odds_soly[] = $v;
  720. if($v['title'] == 'league_result') $league_result[] = $v;
  721. if($v['title'] == 'match_result') $match_result[] = $v;
  722. if($v['title'] == 'match_result_record') $match_result_record[] = $v;
  723. if($v['title'] == 'odds_record') $odds_record[] = $v;
  724. if($v['title'] == 'broadcast') $broadcast[] = $v;
  725. }
  726. $matchData = [$league,$competition,$odds_soly,$odds,$league_result,$match_result,$match_result_record,$odds_record,$broadcast];
  727. //排空处理
  728. foreach ($matchData as $k=>$v){
  729. if($v == []) unset($matchData[$k]);
  730. }
  731. sort($matchData);
  732. //根据顺序写入数据
  733. //降维数据
  734. $mentData = [];
  735. foreach ($matchData as $k=>$v){
  736. foreach ($v as $kk=>$vv){
  737. $mentData[] = $vv;
  738. }
  739. }
  740. //获取各球类model
  741. $models = commonFunction::getModels($game_code,1);
  742. //获取球类名称
  743. $gameName = gameModel::getGameName($game_code);
  744. //===获取验证数据===
  745. //获取一段时间内所有联赛本地记录
  746. $lg_data = LeagueModel::getLeagueID($models);
  747. //获取一段时间内所有赛事本地记录
  748. $match_data = MatchModel::getMatchID($models);
  749. //获取一段时间内所有赔率
  750. $odds_data = OddsModel::getOddsID($models);
  751. //获取一段时间内所有赔率记录
  752. $odds_record_data = OddsRecordModel::getOddsRecordID($models);
  753. //===获取验证数据===
  754. $others_lg_id = '';//继承 源联赛id
  755. $others_match_id = '';//继承 源赛事id
  756. $s_lg_id = '';//源 联赛ID
  757. $l_lg_id = '';//本地 联赛 ID
  758. $s_match_id = '';//源 赛事ID
  759. $l_match_id = '';//本地 赛事 ID
  760. foreach ($mentData as $kk =>$vv){
  761. switch ($vv['title']){
  762. case 'area'://地区
  763. throw new \Exception(Response::generate('地区数据-area:',Response::AUTH_ERROR)) ;
  764. break;
  765. case 'country'://国家
  766. throw new \Exception(Response::generate('国家数据-country:',Response::AUTH_ERROR));
  767. break;
  768. case 'league'://联赛
  769. $others_lg_id = $vv['data']['lg_id'];
  770. $s_lg_id = $vv['data']['lg_id'];
  771. $source = $vv['data']['source'];
  772. //验证联赛记录是否已存在
  773. $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
  774. if($ret_lg != false) {
  775. $l_lg_id = $ret_lg;
  776. break;
  777. }
  778. //执行 联赛数据
  779. $lg_data = $this->league($vv,$gameName);
  780. $l_lg_id = $lg_data['lg_id'];
  781. break;
  782. case 'competition'://赛事
  783. $others_match_id = $vv['data']['match_id'];
  784. $s_lg_id = $vv['data']['lg_id'];
  785. $s_match_id = $vv['data']['match_id'];
  786. $source = $vv['data']['source'];
  787. //本次请求是否包含 联赛数据
  788. if(empty($others_lg_id)){
  789. //验证本地是否存在
  790. $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
  791. if($ret_lg == false) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
  792. $l_lg_id = $ret_lg;
  793. }else{
  794. //本次有 联赛数据 验证属于同联赛
  795. if($s_lg_id != $others_lg_id) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
  796. }
  797. //验证赛事记录是否已存在
  798. $ret_match = commonFunction::ver_match($s_match_id,$source,$match_data);
  799. if($ret_match != false){
  800. $l_match_id = $ret_match;
  801. break;
  802. }
  803. //执行 赛事数据
  804. $match_data = $this->competition($vv,$gameName,$l_lg_id);
  805. $l_match_id = $match_data['match_id'];
  806. break;
  807. case 'odds'://赔率
  808. $s_lg_id = $vv['data']['lg_id'];
  809. $s_match_id = $vv['data']['match_id'];
  810. $source = $vv['data']['source'];
  811. $odds_only = $vv['data']['odds_only'];
  812. $sole = $vv['data']['sole'];
  813. $odds_type = $vv['data']['type'];//0普通 1冠军盘口
  814. //本次请求是否包含 联赛数据
  815. if(empty($others_lg_id)){
  816. //无联赛数据 验证本地是否存在
  817. $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
  818. //联赛 不存在
  819. if($ret_lg == false) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
  820. $l_lg_id = $ret_lg;
  821. }else{
  822. //有联赛数据 验证属于同请求联赛
  823. if($s_lg_id != $others_lg_id) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
  824. }
  825. //如果是普通 赔率,则验证所属赛事
  826. if($odds_type == 0){
  827. //验证赛事记录是否已存在
  828. if(empty($others_match_id)){
  829. //无赛事数据 验证本地是否存在
  830. $ret_match = commonFunction::ver_match($s_match_id,$source,$match_data);
  831. //赛事 不存在
  832. if($ret_match == false) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
  833. $l_match_id = $ret_match;
  834. }else{
  835. //有赛事数据 验证属于同请求赛事
  836. if($s_match_id != $others_match_id) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
  837. }
  838. }
  839. //验证赔率 是否存在
  840. $ret_odds = '';
  841. $ret_odds = commonFunction::ver_odds($sole,$source,$odds_data);
  842. //验证赔率记录 是否存在
  843. $ret_odds_record = '';
  844. $ret_odds_record = commonFunction::ver_odds_record($odds_only,$source,$odds_record_data);
  845. $this->odds($vv,$gameName,$l_lg_id,$l_match_id,$ret_odds,$ret_odds_record);
  846. break;
  847. case 'odds_sole':
  848. $this->upOddsStatus($vv,$gameName);
  849. break;
  850. case 'league_result'://联赛结果
  851. $this->league_result($vv,$gameName);
  852. break;
  853. case 'match_result'://赛事结果
  854. throw new \Exception(Response::generate('赛事结果数据-match_result:',Response::AUTH_ERROR));
  855. $this->match_result($vv,$gameName);
  856. break;
  857. case 'match_result_record'://赛事结果记录
  858. $s_lg_id = $vv['data']['lg_id'];
  859. $s_match_id = $vv['data']['match_id'];
  860. $source = $vv['data']['source'];
  861. //如果本次请求没有 联赛数据
  862. if(empty($others_lg_id)){
  863. //验证本地是否存在
  864. $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
  865. //联赛 不存在
  866. if($ret_lg == false) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
  867. $l_lg_id = $ret_lg;
  868. }else{
  869. //有联赛数据 验证属于同请求联赛
  870. if($s_lg_id != $others_lg_id) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
  871. }
  872. //验证赛事记录是否已存在
  873. if(empty($others_match_id)){
  874. //无赛事数据 验证本地是否存在
  875. $ret_match = commonFunction::ver_match($s_match_id,$source,$match_data);
  876. //联赛 不存在
  877. if($ret_match == false) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
  878. $l_match_id = $ret_match;
  879. }else{
  880. //有赛事数据 验证属于同请求赛事
  881. if($s_match_id != $others_match_id) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
  882. }
  883. //处理 赛事结果 记录
  884. $this->com_result_record($vv,$gameName,$l_lg_id,$l_match_id);
  885. break;
  886. case 'broadcast'://直播数据
  887. $this->broadcast($vv,$game_code);
  888. break;
  889. default:
  890. throw new \Exception(Response::generate('',Response::ABNORMAL)) ;
  891. }
  892. }
  893. }
  894. }
  895. //提交事务
  896. DB::commit();
  897. return Response::success();
  898. } catch (\Exception $e) {
  899. //回滚事务
  900. DB::rollBack();
  901. return $e->getMessage();
  902. }
  903. }
  904. /**
  905. * @param Req $data
  906. * @return string
  907. * @throws \App\Lib\Biz\Sport\Exception
  908. * 更新赛事状态
  909. */
  910. public function upMatch(Req $data){
  911. //验证token
  912. $user = new \App\Models\System_user;
  913. if(empty($data->token)) return Response::generate('未获取到token',Response::TOKEN_ERR);
  914. $token = $user::where(['token'=>$data->token])->value('token');
  915. if(empty($token)) return Response::generate('token验证不通过',Response::TOKEN_ERR);
  916. try {
  917. //开启事务
  918. DB::beginTransaction();
  919. //获取待更新赛事
  920. $obt = $data->data;
  921. if($obt){
  922. //json转数组
  923. $data = $this->getAddData($obt);
  924. //获取 球类代码
  925. $game_code = $data['game_code'];
  926. //获取 数据源
  927. $source = $data['source'];
  928. //获取所有数据源赛事 match_id
  929. $others_match_ids = [];
  930. foreach ($data['data'] as $k=>$v){
  931. $others_match_ids[] = $v['match_id'];
  932. }
  933. //根据球类代码 获取model
  934. $model =commonFunction::getModels($game_code,1);
  935. //获取所有赛事 match_id
  936. $local_match = $model['model_local_match']::SELECT('others_match_id','match_id')
  937. ->where(['source'=>$source])
  938. ->whereIn('others_match_id',$others_match_ids)
  939. ->get()->toArray();
  940. if(empty($local_match)) throw new \Exception(Response::generate('',Response::MATCHID_NULL));
  941. //更新状态字段
  942. foreach ($local_match as $k=>$v){
  943. $set_status = [
  944. 'status'=>$v['status'],
  945. 'is_rollball'=>$v['is_rollball'],
  946. 'stais_todaytus'=>$v['is_today'],
  947. 'is_morningplate'=>$v['is_morningplate'],
  948. 'is_stringscene'=>$v['is_stringscene'],
  949. 'is_horn'=>$v['is_horn'],
  950. ];
  951. $ret = $model['model_match']::where(['id'=>$v['match_id']])
  952. -> update($set_status);
  953. if($ret<1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$v['others_match_id'],Response::UPSTATUS_ERROR));
  954. }
  955. }
  956. //提交事务
  957. DB::commit();
  958. return Response::success();
  959. } catch (\Exception $e) {
  960. //回滚事务
  961. DB::rollBack();
  962. return $e->getMessage();
  963. }
  964. }
  965. /*
  966. * 写入直播 数据
  967. */
  968. public function broadcast($opt = [],$game_code=''){
  969. $data = $opt['data'];
  970. $set_broadcast = [
  971. "doing" => $data['doing'],
  972. "game_type" => $data['game_type'],
  973. "game_code" => $game_code,
  974. "guest_team" => $data['guest_team'],
  975. "host_team" => $data['host_team'],
  976. "league_name" => $data['league_name'],
  977. "shower" => $data['shower'],
  978. "showid" => (int)$data['showid'],
  979. "start_time" => $data['start_time'],
  980. "ctime" =>date('Y-m-d H:i:s'),
  981. "utime" =>date('Y-m-d H:i:s'),
  982. ];
  983. $ret = broadcastModel::insert($set_broadcast);
  984. if($ret == false) throw new \Exception(Response::generate('',Response::BROADCAST_ERROR));
  985. }
  986. /*
  987. * 写入 赛事 初始 结果
  988. */
  989. public function match_result($game_code = ''){
  990. $model =commonFunction::getModels($game_code,1);
  991. if($game_code == 'zq') ZqResultModel::ZQresult($model);
  992. if($game_code == 'lq') LqResultModel::LQresult($model);
  993. if($game_code == 'wq') WqResultModel::WQresult($model);
  994. if($game_code == 'bq') BqResultModel::BQresult($model);
  995. }
  996. /*
  997. * 写入联赛数据
  998. */
  999. public function league($opt = [],$gameName=''){
  1000. $game_code = $opt['game_code'];
  1001. //根据球类代码获取相关model
  1002. $model =commonFunction::getModels($game_code,1);
  1003. $data = $opt['data'];
  1004. //查询联赛是否已存在
  1005. $id = $model['model_league']::where('name_chinese','=',$data['name_chinese'])
  1006. ->value('id');
  1007. //默认获取本年最后一天
  1008. $last_time = date('Y-12-31 23:59:59');
  1009. //决赛时间
  1010. if($data['last_time']){
  1011. $last_time = $data['last_time'];
  1012. }
  1013. $set_lg['name_chinese'] = $data['name_chinese'];
  1014. $set_lg['kind'] = $data['kind'];
  1015. $set_lg['match_mode'] = $data['match_mode'];
  1016. $set_lg['if_stop'] = $data['if_stop'];
  1017. $set_lg['identity'] = $data['uuid']?:'';
  1018. $set_lg['last_time'] = $last_time;
  1019. $set_lg['utime'] = date('Y-m-d H:i:s');
  1020. if(empty($id)){
  1021. //写入联赛
  1022. $id = $model['model_league']::insertGetId($set_lg);
  1023. $m_lg_id = $id;
  1024. if($m_lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::INSERT_ERROR));
  1025. }else{
  1026. //更新联赛
  1027. $ret = $model['model_league']::where(['id'=>$id])
  1028. -> update($set_lg);
  1029. if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::UPDATE_ERROR));
  1030. }
  1031. $set_local = [
  1032. 'lg_id'=>$id,
  1033. 'others_lg_id'=>$data['lg_id'],
  1034. 'source'=>$data['source'],
  1035. 'ctime'=>date('Y-m-d H:i:s')
  1036. ];
  1037. $ret = $model['model_local_league']::insertGetId($set_local);
  1038. if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LOCAL_LEAGUE_ERROR)) ;//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
  1039. //执行成功返回源数据 联赛ID
  1040. $data = ['others_lg_id'=>$data['lg_id'],'lg_id'=>$id];
  1041. return $data;
  1042. }
  1043. /*
  1044. * 写入赛事数据
  1045. */
  1046. public function competition($opt = [],$gameName='',$lg_id=''){
  1047. $game_code = $opt['game_code'];
  1048. //根据球类代码获取相关model
  1049. $model = commonFunction::getModels($game_code,1);
  1050. $data = $opt['data'];
  1051. if(empty($data['lg_id'])) throw new \Exception(Response::generate('',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
  1052. //查询赛事是否存在
  1053. $id = $model['model_match']::where(['home_team'=>$data['home_team'],'guest_team'=>$data['guest_team'],'match_date'=>$data['match_date'],'match_time'=>$data['match_time']])
  1054. ->value('id');
  1055. $half_match_id = 0;
  1056. //如果有上半场赛事id 获取上半场赛事是否存在
  1057. if(!empty($data['half_match_id'])){
  1058. $half_match_id = $match_id = $model['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$data['source']])
  1059. ->value('match_id');
  1060. if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
  1061. }
  1062. //如果赛事没有开始日期,则为冠军盘口赛事
  1063. if(empty($data['match_date'])){
  1064. //冠军盘口赛事获取所属联赛结束时间
  1065. $last_time = $model['model_league']::where(['id'=>$lg_id])
  1066. ->value('last_time');
  1067. if(empty($last_time)) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LG_LASTTIME_ERROR)) ;//Render([], '10023', lang('Tips','Sports')->get('lg_lastTime_error'));
  1068. //给冠军盘口赛事 赋值时间
  1069. $time = strtotime($last_time);
  1070. $data['match_date'] = date('Y-m-d',$time);
  1071. $data['match_time'] = date('H:i:s',$time);
  1072. }
  1073. $set_match = [
  1074. 'ctime'=>date('Y-m-d H:i:s'),
  1075. 'utime'=>date('Y-m-d H:i:s'),
  1076. 'expire_time'=>date('Y-m-d H:i:s',time()+60),
  1077. 'home_team'=>$data['home_team']?:'',
  1078. 'guest_team'=>$data['guest_team']?:'no_team',
  1079. 'lg_id'=>$lg_id,
  1080. 'status'=>$data['status'],
  1081. 'match_date'=>$data['match_date']?:date('Y-m-d'),
  1082. 'match_time'=>$data['match_time']?:date('H:i:s'),
  1083. 'tag'=>$data['tag']?:0,
  1084. 'is_rollball'=>$data['is_rollball']?:0,
  1085. 'is_today'=>$data['is_today']?:0,
  1086. 'is_morningplate'=>$data['is_morningplate']?:0,
  1087. 'is_stringscene'=>$data['is_stringscene']?:0,
  1088. 'us_time'=>$data['us_time']?:commonFunction::qgmdate('Y-m-d H:i:s', '', -4),
  1089. 'half_match_id'=>$half_match_id?:0,
  1090. 'identity' => $data['uuid'],
  1091. ];
  1092. //写入赛事
  1093. if(empty($id)){
  1094. //写入赛事 返回id
  1095. $id = $model['model_match']::insertGetId($set_match);
  1096. if($id < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::INSERT_ERROR)) ;
  1097. }else{
  1098. //更新赛事
  1099. $ret = $model['model_match']::where(['id'=>$id])->update($set_match);
  1100. if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::UPDATE_ERROR)) ;
  1101. }
  1102. //写关联记录
  1103. $set_local = [
  1104. 'match_id'=>$id,
  1105. 'others_match_id'=>$data['match_id'],
  1106. 'source'=>$data['source'],
  1107. 'ctime'=>date('Y-m-d H:i:s')
  1108. ];
  1109. $ret = $model['model_local_match']::insertGetId($set_local);
  1110. if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::LOCAL_MATCH_ERROR)) ;//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
  1111. //返回 源数据 赛事ID
  1112. $data = ['others_match_id'=>$data['match_id'],'match_id'=>$id];
  1113. return $data;
  1114. }
  1115. /*
  1116. * 写入赔率/赔率记录数据
  1117. */
  1118. public function odds($opt=[],$gameName='',$lg_id=0,$match_id=0,$oddsID='',$oddsRecordID=''){
  1119. $game_code = $opt['game_code'];
  1120. //根据球类代码获取相关model
  1121. $model = commonFunction::getModels($game_code,1);
  1122. $data = $opt['data'];
  1123. //获取赛事 本地/源ID
  1124. $others_match_id = $data['match_id'];
  1125. //获取联赛 本地/源ID
  1126. $others_lg_id = $data['lg_id'];
  1127. //===写赔率记录===
  1128. $set_odds_r = [
  1129. 'match_id'=> $match_id?:0,
  1130. 'others_match_id'=> $others_match_id?:0,
  1131. 'odds_code'=> $data['odds_code']?:'',
  1132. 'status'=> $data['status']?:0,
  1133. 'sort'=> $data['sort']?:0,
  1134. 'p_code'=> $data['p_code']?:'',
  1135. 'odds'=> $data['odds']?:0,
  1136. 'condition'=> $data['condition'],
  1137. 'odds_only'=> $data['odds_only']?:'',
  1138. 'source'=> $data['source']?:'',
  1139. 'type'=> $data['type']?:0,
  1140. 'team'=> $data['team']?:'',
  1141. 'lg_id'=> $lg_id,
  1142. 'others_lg_id'=> $others_lg_id,
  1143. 'ctime'=> date('Y-m-d H:i:s'),
  1144. ];
  1145. //更新或写入赔率记录
  1146. if($oddsRecordID != false){
  1147. $ret = $model['model_odds_record']::where(['id'=>$oddsRecordID])
  1148. -> update($set_odds_r);
  1149. if($ret < 1) throw new \Exception(Response::generate($gameName.'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
  1150. }else{
  1151. $ret = $model['model_odds_record']::insert($set_odds_r);
  1152. if($ret != true) throw new \Exception(Response::generate($gameName.'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
  1153. }
  1154. //===写赔率===
  1155. $set_odds = [
  1156. 'match_id'=> $match_id?:0,
  1157. 'others_match_id'=> $others_match_id?:0,
  1158. 'odds_code'=> $data['odds_code']?:'',
  1159. 'status'=> $data['status']?:0,
  1160. 'sort'=> $data['sort']?:0,
  1161. 'p_code'=> $data['p_code']?:'',
  1162. 'odds'=> $data['odds']?:0,
  1163. 'condition'=> $data['condition'],
  1164. 'odds_only'=> $data['odds_only']?:'',
  1165. 'sole'=> $data['sole']?:'',
  1166. 'source'=> $data['source']?:'',
  1167. 'type'=> $data['type']?:0,
  1168. 'team'=> $data['team']?:'',
  1169. 'lg_id'=> $lg_id,
  1170. 'others_lg_id'=> $others_lg_id,
  1171. 'ctime'=> date('Y-m-d H:i:s'),
  1172. 'utime'=> date('Y-m-d H:i:s'),
  1173. 'expire_time'=>date('Y-m-d H:i:s',time()+60),
  1174. ];
  1175. //更新或写入赔率数据
  1176. if($oddsID != false){
  1177. $ret = $model['model_odds']::where(['id'=>$oddsID])
  1178. -> update($set_odds);
  1179. if($ret < 1) throw new \Exception(Response::generate($gameName.'赔率-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
  1180. }else{
  1181. $ret = $model['model_odds']::insert($set_odds);
  1182. if($ret != true) throw new \Exception(Response::generate($gameName.'赔率-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
  1183. }
  1184. //===end===
  1185. }
  1186. /*
  1187. * 更新 赛事下 所有不在本次请求的 赔率状态
  1188. */
  1189. public function upOddsStatus($opt = [],$gameName=''){
  1190. //获取球类代码
  1191. $game_code = $opt['game_code'];
  1192. //获取球类model
  1193. $model = commonFunction::getModels($game_code,1);
  1194. //赛事下 所有 赔率sole
  1195. $odds_sole = $opt['data'];
  1196. //数据源 赛事 id
  1197. $others_match_id = $opt['match_id'];
  1198. //数据源
  1199. $source = $opt['source'];
  1200. //更新赛事下所有 不在本次请求的赔率 状态
  1201. $ret= OddsModel::upOddsStatus($model,$others_match_id,'',$source,$odds_sole);
  1202. if($ret != true) throw new \Exception(Response::generate($gameName,Response::ODDS_SOLE_ERR));
  1203. }
  1204. /*
  1205. * 写入联赛结果
  1206. */
  1207. public function league_result($opt,$gameName){
  1208. $game_code = $opt['game_code'];
  1209. //根据球类代码获取相关model
  1210. $model = commonFunction::getModels($game_code,1);
  1211. $data = $opt['data'];
  1212. //验证结果所属联赛
  1213. $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
  1214. ->value('lg_id');
  1215. if($lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));
  1216. $lg_result_id = $model['model_league_result']::where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
  1217. ->value('id');
  1218. $set_lg_result = [
  1219. 'lg_id'=>$lg_id,
  1220. 'game_name'=>$data['game_name'],
  1221. 'result'=>json_encode($data['result'],JSON_UNESCAPED_UNICODE),
  1222. 'status'=>$data['status'],
  1223. 'ctime'=> date('Y-m-d H:i:s'),
  1224. 'utime'=> date('Y-m-d H:i:s'),
  1225. ];
  1226. //联赛结果数据处理
  1227. if(!empty($lg_result_id)){
  1228. $ret = $model['model_league_result']::where(['id'=>$lg_result_id])
  1229. -> update($set_lg_result);
  1230. if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
  1231. }else{
  1232. $ret = $model['model_league_result']::insert($set_lg_result);
  1233. if($ret != true) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
  1234. }
  1235. }
  1236. /*
  1237. * 写入赛事结果
  1238. */
  1239. public function com_result($opt=[],$gameName='',$lg_id='',$match_id=''){
  1240. $game_code = $opt['game_code'];
  1241. //根据球类代码获取相关model
  1242. $model = commonFunction::getModels($game_code,1);
  1243. $data = $opt['data'];
  1244. //查询结果是否存在
  1245. $match_r_id = $model['model_result']::where(['match_id'=>$match_id])
  1246. ->value('id');
  1247. $set_match_r = [
  1248. "home_team"=>$data['home_team'],
  1249. "guest_team"=>$data['guest_team'],
  1250. "lg_id"=>$lg_id,
  1251. "home_rate"=> $data['home_rate'],
  1252. "guest_rate"=> $data['guest_rate'],
  1253. "home_score"=> $data['home_score'],
  1254. "guest_score"=> $data['guest_score'],
  1255. "all_goal"=> $data['all_goal'],
  1256. "status"=>$data['status'],
  1257. "first_score"=>$data['first_score'],
  1258. "last_score"=> $data['last_score'],
  1259. "match_score"=> $data['match_score'],
  1260. "match_winer"=> $data['match_winer'],
  1261. "match_time"=> $data['match_time'],
  1262. "match_process"=> $data['match_process'],
  1263. "tag"=> $data['tag'],
  1264. "match_id"=> $match_id,
  1265. "u_home_score"=> $data['u_home_score'],
  1266. "u_guest_score"=> $data['u_guest_score'],
  1267. "p_code"=> $data['p_code'],
  1268. "update_time"=>date('Y-m-d H:i:s')
  1269. ];
  1270. //赛事结果数据处理
  1271. if(!empty($match_r_id)){
  1272. $ret = $model['model_result']::where(['id'=>$match_r_id])
  1273. -> update($set_match_r);
  1274. if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
  1275. }else{
  1276. $ret = $model['model_result']::insert($set_match_r);
  1277. if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
  1278. }
  1279. // return Response::success();
  1280. }
  1281. //写入赛事结果记录
  1282. public function com_result_record($opt=[],$gameName='',$lg_id='',$match_id=''){
  1283. $game_code = $opt['game_code'];
  1284. //根据球类代码获取相关model
  1285. $model = commonFunction::getModels($game_code,1);
  1286. $data = $opt['data'];
  1287. $match_r_id = $model['model_result_record']::where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
  1288. ->value('id');
  1289. //根据球类 获取 赛事结果记录字段
  1290. $set_match_r = $this->get_match_r($game_code,$lg_id,$match_id,$data);
  1291. //赛事结果记录处理
  1292. if($match_r_id > 0){
  1293. $ret = $model['model_result_record']::where(['id'=>$match_r_id])
  1294. ->update($set_match_r);
  1295. if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
  1296. }else{
  1297. $ret = $model['model_result_record']::insert($set_match_r);
  1298. if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
  1299. }
  1300. }
  1301. /**
  1302. * @param $data
  1303. * @return mixed
  1304. * json转数组
  1305. */
  1306. public function getAddData($data){
  1307. $data = json_decode($data,true);
  1308. return $data;
  1309. }
  1310. /*
  1311. * 根据球类获取 赛事结果记录字段
  1312. */
  1313. public function get_match_r($game_code,$lg_id,$match_id,$data){
  1314. $set_match_r = [];
  1315. if($game_code == 'zq'){
  1316. $set_match_r = [
  1317. "home_team"=>$data['home_team']?:'',
  1318. "guest_team"=>$data['guest_team']?:'',
  1319. "lg_id"=>$lg_id,
  1320. "all_goal"=>$data['all_goal']?:0,
  1321. "home_rate"=> $data['home_rate']?:0,
  1322. "guest_rate"=> $data['guest_rate']?:0,
  1323. "home_score"=> $data['home_score']?:0,
  1324. "guest_score"=> $data['guest_score']?:0,
  1325. "status"=>$data['status']?:0,
  1326. "first_score"=>$data['first_score']?:0,
  1327. "last_score"=> $data['last_score']?:0,
  1328. "match_score"=> $data['match_score']?:0,
  1329. "match_winer"=> $data['match_winer']?:'',
  1330. "match_time"=> $data['match_time']?:0,
  1331. "match_process"=> $data['match_process']?:'',
  1332. // "tag"=> $data['tag']?:0,
  1333. "match_id"=> $match_id,
  1334. "update_time"=>date('Y-m-d H:i:s')
  1335. ];
  1336. };
  1337. if($game_code == 'lq'){
  1338. $set_match_r = [
  1339. "home_team"=>$data['home_team']?:'',
  1340. "guest_team"=>$data['guest_team']?:'',
  1341. "lg_id"=>$lg_id,
  1342. "home_rate"=> $data['home_rate']?:0,
  1343. "guest_rate"=> $data['guest_rate']?:0,
  1344. "home_score"=> $data['home_score']?:0,
  1345. "guest_score"=> $data['guest_score']?:0,
  1346. "status"=>$data['status']?:0,
  1347. "first_score"=>$data['first_score']?:0,
  1348. "last_score"=> $data['last_score']?:0,
  1349. "match_score"=> $data['match_score']?:0,
  1350. "match_winer"=> $data['match_winer']?:'',
  1351. "match_time"=> $data['match_time']?:0,
  1352. "match_process"=> $data['match_process']?:'',
  1353. // "tag"=> $data['tag']?:0,
  1354. "match_id"=> $match_id,
  1355. "update_time"=>date('Y-m-d H:i:s')
  1356. ];
  1357. }
  1358. if($game_code == 'wq'){
  1359. $set_match_r = [
  1360. "home_player_name"=>$data['home_player_name']?:'',
  1361. "guest_player_name"=>$data['guest_player_name']?:'',
  1362. "lg_id"=>$lg_id,
  1363. "home_player_let_plate"=>$data['home_player_let_plate']?:0,
  1364. "guest_player_let_plate"=>$data['guest_player_let_plate']?:0,
  1365. "home_player_let_inning"=>$data['home_player_let_inning']?:0,
  1366. "guest_player_let_inning"=>$data['guest_player_let_inning']?:0,
  1367. "all_inning"=>$data['all_inning']?:0,
  1368. "home_player_score"=>$data['home_player_score']?:0,
  1369. "guest_player_score"=>$data['guest_player_score']?:0,
  1370. "status"=>$data['status']?:0,
  1371. "first_score_player"=>$data['first_score_player']?:'',
  1372. "last_score_player"=>$data['last_score_player']?:'',
  1373. "first_inning_score"=>$data['first_inning_score']?:0,
  1374. "second_inning_score"=>$data['second_inning_score']?:0,
  1375. "third_inning_score"=>$data['third_inning_score']?:0,
  1376. "match_winer_player"=>$data['match_winer_player']?:'',
  1377. "update_time"=>date('Y-m-d H:i:s'),
  1378. "match_time"=>$data['match_time']?:0,
  1379. "match_process"=>$data['match_process']?:'',
  1380. // "tag"=>$data['tag']?:0,
  1381. "match_id"=>$match_id,
  1382. "result_mark" =>$data['result_mark']?:'',
  1383. ];
  1384. }
  1385. if($game_code == 'bq'){
  1386. $set_match_r = [
  1387. "home_team"=>$data['home_team']?:'',
  1388. "guest_team"=>$data['guest_team']?:'',
  1389. "lg_id"=>$lg_id,
  1390. "home_rate"=> $data['home_rate']?:0,
  1391. "guest_rate"=> $data['guest_rate']?:0,
  1392. "home_score"=> $data['home_score']?:0,
  1393. "guest_score"=> $data['guest_score']?:0,
  1394. "status"=>$data['status']?:0,
  1395. "first_score"=>$data['first_score']?:0,
  1396. "last_score"=> $data['last_score']?:0,
  1397. "match_score"=> $data['match_score']?:0,
  1398. "match_winer"=> $data['match_winer']?:'',
  1399. "match_time"=> $data['match_time']?:0,
  1400. "match_process"=> $data['match_process']?:'',
  1401. // "tag"=> $data['tag']?:0,
  1402. "match_id"=> $match_id,
  1403. "all_inning"=>$data['all_inning']?:9,
  1404. "update_time"=>date('Y-m-d H:i:s'),
  1405. "result_mark" =>$data['result_mark']?:'',
  1406. ];
  1407. }
  1408. return $set_match_r;
  1409. }
  1410. }