IndexNav.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/26
  6. * Time: 9:16
  7. */
  8. namespace App\Sports\Controller;
  9. use BaseController\Controller;
  10. use \System\Model;
  11. class IndexNav extends Controller{
  12. public function navlist(){
  13. if(!empty($_REQUEST['type_code'])){
  14. $type_code = $_REQUEST['type_code'];
  15. }else{
  16. $type_code = 'StRollBall';
  17. }
  18. if(!empty($_REQUEST['gametype'])){
  19. $gametype = $_REQUEST['gametype'];
  20. }else{
  21. $gametype = 'zq';
  22. }
  23. //滚球
  24. if($type_code == 'StRollBall'){
  25. $leagues = lm('st_'.$gametype.'_competition','Sports')
  26. ->join('st_'.$gametype.'_league','st_'.$gametype.'_competition.lg_id','=','st_'.$gametype.'_league.id')
  27. ->select('st_'.$gametype.'_competition.lg_id','st_'.$gametype.'_league.name_chinese','st_'.$gametype.'_league.name_english')
  28. ->where('st_'.$gametype.'_competition.status','1')
  29. ->where('st_'.$gametype.'_competition.match_date',date("Y-m-d"))
  30. //->where('st_'.$gametype.'_competition.match_time','>',date("h:i:s"))
  31. ->distinct('st_'.$gametype.'_competition.lg_id')
  32. ->get();
  33. $match->name = $gametype;
  34. for($i=0;$i<count($leagues);$i++){
  35. $match->leaguedata[$i]->league_id = $leagues[$i]->lg_id;
  36. $match->leaguedata[$i]->league_name_chinese = $leagues[$i]->name_chinese;
  37. $match->leaguedata[$i]->league_name_english = $leagues[$i]->name_english;
  38. $num = lm('St_'.$gametype.'_competition','Sports')
  39. ->select('match_id')
  40. ->where('status','1')
  41. ->where('match_date',date("Y-m-d"))
  42. //->where('match_time','>',date("h:i:s"))
  43. ->where('lg_id',$leagues[$i]->lg_id)
  44. ->get();
  45. $match->leaguedata[$i]->num = count($num);
  46. $gamematch = lm('st_'.$gametype.'_competition','Sports')
  47. ->select('match_id','home_team','guest_team','match_date','match_time','status','tag')
  48. ->where('status','1')
  49. ->where('match_date',date("Y-m-d"))
  50. ->where('match_time','>',date("h:i:s"))
  51. ->where('lg_id',$leagues[$i]->lg_id)
  52. ->get();
  53. for($j=0;$j<count($gamematch);$j++){
  54. $match->leaguedata[$i]->matchdata[$j]->match_id = $gamematch[$j]->match_id;
  55. $match->leaguedata[$i]->matchdata[$j]->home_team = $gamematch[$j]->home_team;
  56. $match->leaguedata[$i]->matchdata[$j]->guest_team = $gamematch[$j]->guest_team;
  57. $match->leaguedata[$i]->matchdata[$j]->match_date = $gamematch[$j]->match_date;
  58. $match->leaguedata[$i]->matchdata[$j]->match_time = $gamematch[$j]->match_time;
  59. $match->leaguedata[$i]->matchdata[$j]->status = $gamematch[$j]->status;
  60. $match->leaguedata[$i]->matchdata[$j]->tag = $gamematch[$j]->tag;
  61. $odds = lm('st_'.$gametype.'_odds','Sports')
  62. ->select('id','odds_code','odds','condition','sort')
  63. ->where(function ($query) {
  64. $query->where('odds_code', 'concede_home')
  65. ->orWhere('odds_code', 'concede_guest')
  66. ->orWhere('odds_code', 'size_home')
  67. ->orWhere('odds_code', 'size_guest');
  68. })
  69. ->where('match_id',$gamematch[$j]->match_id)
  70. ->get()
  71. ->toArray();
  72. //根据 排序 获取 最新让球/大小玩法赔率
  73. $sort = array_column($odds,'sort');
  74. array_multisort($sort,SORT_DESC,$odds);
  75. $odds = array_slice($odds,0,4);
  76. for($a=0;$a<count($odds);$a++){
  77. $match->leaguedata[$i]->matchdata[$j]->oddsdata[$a] = $odds[$a];
  78. }
  79. }
  80. }
  81. Render($match, '1', lang('Tips','Sports')->get('success'));
  82. }
  83. // 即将
  84. else if($type_code == 'StSoon'){
  85. $leagues = lm('st_'.$gametype.'_competition','Sports')
  86. ->join('st_'.$gametype.'_league','st_'.$gametype.'_competition.lg_id','=','st_'.$gametype.'_league.id')
  87. ->select('st_'.$gametype.'_competition.lg_id','st_'.$gametype.'_league.name_chinese','st_'.$gametype.'_league.name_english')
  88. ->where('st_'.$gametype.'_competition.status','0')
  89. ->where('st_'.$gametype.'_competition.match_date',date("Y-m-d"))
  90. ->where('st_'.$gametype.'_competition.match_time','>',date("h:i:s"))
  91. ->distinct('st_'.$gametype.'_competition.lg_id')
  92. ->get();
  93. $match->name = $gametype;
  94. for($i=0;$i<count($leagues);$i++){
  95. $match->leaguedata[$i]->league_id = $leagues[$i]->lg_id;
  96. $match->leaguedata[$i]->league_name_chinese = $leagues[$i]->name_chinese;
  97. $match->leaguedata[$i]->league_name_english = $leagues[$i]->name_english;
  98. $num = lm('St_'.$gametype.'_competition','Sports')
  99. ->select('match_id')
  100. ->where('status','0')
  101. ->where('match_date',date("Y-m-d"))
  102. ->where('match_time','>',date("h:i:s"))
  103. ->where('lg_id',$leagues[$i]->lg_id)
  104. ->get();
  105. $match->leaguedata[$i]->num = count($num);
  106. $gamematch = lm('st_'.$gametype.'_competition','Sports')
  107. ->select('match_id','home_team','guest_team','match_date','match_time','status','tag')
  108. ->where('status','0')
  109. ->where('match_date',date("Y-m-d"))
  110. ->where('match_time','>',date("h:i:s"))
  111. ->where('lg_id',$leagues[$i]->lg_id)
  112. ->get();
  113. for($j=0;$j<count($gamematch);$j++){
  114. $match->leaguedata[$i]->matchdata[$j]->match_id = $gamematch[$j]->match_id;
  115. $match->leaguedata[$i]->matchdata[$j]->home_team = $gamematch[$j]->home_team;
  116. $match->leaguedata[$i]->matchdata[$j]->guest_team = $gamematch[$j]->guest_team;
  117. $match->leaguedata[$i]->matchdata[$j]->match_date = $gamematch[$j]->match_date;
  118. $match->leaguedata[$i]->matchdata[$j]->match_time = $gamematch[$j]->match_time;
  119. $match->leaguedata[$i]->matchdata[$j]->status = $gamematch[$j]->status;
  120. $match->leaguedata[$i]->matchdata[$j]->tag = $gamematch[$j]->tag;
  121. $odds = lm('st_'.$gametype.'_odds','Sports')
  122. ->select('id','odds_code','odds','condition','sort')
  123. ->where(function ($query) {
  124. $query->where('odds_code', 'concede_home')
  125. ->orWhere('odds_code', 'concede_guest')
  126. ->orWhere('odds_code', 'size_home')
  127. ->orWhere('odds_code', 'size_guest');
  128. })
  129. ->where('match_id',$gamematch[$j]->match_id)
  130. ->get()
  131. ->toArray();
  132. //根据 排序 获取 最新让球/大小玩法赔率
  133. $sort = array_column($odds,'sort');
  134. array_multisort($sort,SORT_DESC,$odds);
  135. $odds = array_slice($odds,0,4);
  136. for($a=0;$a<count($odds);$a++){
  137. $match->leaguedata[$i]->matchdata[$j]->oddsdata[$a] = $odds[$a];
  138. }
  139. }
  140. }
  141. Render($match, '1', lang('Tips','Sports')->get('success'));
  142. }
  143. //今日
  144. else if($type_code = 'StToday'){
  145. $leagues = lm('st_'.$gametype.'_competition','Sports')
  146. ->join('st_'.$gametype.'_league','st_'.$gametype.'_competition.lg_id','=','st_'.$gametype.'_league.id')
  147. ->select('st_'.$gametype.'_competition.lg_id','st_'.$gametype.'_league.name_chinese','st_'.$gametype.'_league.name_english')
  148. ->where('st_'.$gametype.'_competition.status','!=','2')
  149. ->where('st_'.$gametype.'_competition.match_date',date("Y-m-d"))
  150. ->where('st_'.$gametype.'_competition.match_time','>',date("h:i:s"))
  151. ->distinct('st_'.$gametype.'_competition.lg_id')
  152. ->get();
  153. $match->name = $gametype;
  154. for($i=0;$i<count($leagues);$i++){
  155. $match->leaguedata[$i]->league_id = $leagues[$i]->lg_id;
  156. $match->leaguedata[$i]->league_name_chinese = $leagues[$i]->name_chinese;
  157. $match->leaguedata[$i]->league_name_english = $leagues[$i]->name_english;
  158. $num = lm('St_'.$gametype.'_competition','Sports')
  159. ->select('match_id')
  160. ->where('status','!=','2')
  161. ->where('match_date',date("Y-m-d"))
  162. ->where('match_time','>',date("h:i:s"))
  163. ->where('lg_id',$leagues[$i]->lg_id)
  164. ->get();
  165. $match->leaguedata[$i]->num = count($num);
  166. $gamematch = lm('st_'.$gametype.'_competition','Sports')
  167. ->select('match_id','home_team','guest_team','match_date','match_time','status','tag')
  168. ->where('status','!=','2')
  169. ->where('match_date',date("Y-m-d"))
  170. ->where('match_time','>',date("h:i:s"))
  171. ->where('lg_id',$leagues[$i]->lg_id)
  172. ->get();
  173. for($j=0;$j<count($gamematch);$j++){
  174. $match->leaguedata[$i]->matchdata[$j]->match_id = $gamematch[$j]->match_id;
  175. $match->leaguedata[$i]->matchdata[$j]->home_team = $gamematch[$j]->home_team;
  176. $match->leaguedata[$i]->matchdata[$j]->guest_team = $gamematch[$j]->guest_team;
  177. $match->leaguedata[$i]->matchdata[$j]->match_date = $gamematch[$j]->match_date;
  178. $match->leaguedata[$i]->matchdata[$j]->match_time = $gamematch[$j]->match_time;
  179. $match->leaguedata[$i]->matchdata[$j]->status = $gamematch[$j]->status;
  180. $match->leaguedata[$i]->matchdata[$j]->tag = $gamematch[$j]->tag;
  181. $odds = lm('st_'.$gametype.'_odds','Sports')
  182. ->select('id','odds_code','odds','condition','sort')
  183. ->where(function ($query) {
  184. $query->where('odds_code', 'concede_home')
  185. ->orWhere('odds_code', 'concede_guest')
  186. ->orWhere('odds_code', 'size_home')
  187. ->orWhere('odds_code', 'size_guest');
  188. })
  189. ->where('match_id',$gamematch[$j]->match_id)
  190. ->get()
  191. ->toArray();
  192. //根据 排序 获取 最新让球/大小玩法赔率
  193. $sort = array_column($odds,'sort');
  194. array_multisort($sort,SORT_DESC,$odds);
  195. $odds = array_slice($odds,0,4);
  196. for($a=0;$a<count($odds);$a++){
  197. $match->leaguedata[$i]->matchdata[$j]->oddsdata[$a] = $odds[$a];
  198. }
  199. }
  200. }
  201. Render($match, '1', lang('Tips','Sports')->get('success'));
  202. }
  203. //早盘
  204. else if($type_code = 'StMorningPlate'){
  205. $leagues = lm('st_'.$gametype.'_competition','Sports')
  206. ->join('st_'.$gametype.'_league','st_'.$gametype.'_competition.lg_id','=','st_'.$gametype.'_league.id')
  207. ->select('st_'.$gametype.'_competition.lg_id','st_'.$gametype.'_league.name_chinese','st_'.$gametype.'_league.name_english')
  208. ->where('st_'.$gametype.'_competition.status','!=','2')
  209. ->where('st_'.$gametype.'_competition.match_date',date("Y-m-d"))
  210. ->where('st_'.$gametype.'_competition.match_time','>',date("h:i:s"))
  211. ->distinct('st_'.$gametype.'_competition.lg_id')
  212. ->get();
  213. $match->name = $gametype;
  214. for($i=0;$i<count($leagues);$i++){
  215. $match->leaguedata[$i]->league_id = $leagues[$i]->lg_id;
  216. $match->leaguedata[$i]->league_name_chinese = $leagues[$i]->name_chinese;
  217. $match->leaguedata[$i]->league_name_english = $leagues[$i]->name_english;
  218. $num = lm('St_'.$gametype.'_competition','Sports')
  219. ->select('match_id')
  220. ->where('status','!=','2')
  221. ->where('match_date',date("Y-m-d"))
  222. ->where('match_time','>',date("h:i:s"))
  223. ->where('lg_id',$leagues[$i]->lg_id)
  224. ->get();
  225. $match->leaguedata[$i]->num = count($num);
  226. $gamematch = lm('st_'.$gametype.'_competition','Sports')
  227. ->select('match_id','home_team','guest_team','match_date','match_time','status','tag')
  228. ->where('status','!=','2')
  229. ->where('match_date',date("Y-m-d"))
  230. ->where('match_time','>',date("h:i:s"))
  231. ->where('lg_id',$leagues[$i]->lg_id)
  232. ->get();
  233. for($j=0;$j<count($gamematch);$j++){
  234. $match->leaguedata[$i]->matchdata[$j]->match_id = $gamematch[$j]->match_id;
  235. $match->leaguedata[$i]->matchdata[$j]->home_team = $gamematch[$j]->home_team;
  236. $match->leaguedata[$i]->matchdata[$j]->guest_team = $gamematch[$j]->guest_team;
  237. $match->leaguedata[$i]->matchdata[$j]->match_date = $gamematch[$j]->match_date;
  238. $match->leaguedata[$i]->matchdata[$j]->match_time = $gamematch[$j]->match_time;
  239. $match->leaguedata[$i]->matchdata[$j]->status = $gamematch[$j]->status;
  240. $match->leaguedata[$i]->matchdata[$j]->tag = $gamematch[$j]->tag;
  241. $odds = lm('st_'.$gametype.'_odds','Sports')
  242. ->select('id','odds_code','odds','condition','sort')
  243. ->where(function ($query) {
  244. $query->where('odds_code', 'concede_home')
  245. ->orWhere('odds_code', 'concede_guest')
  246. ->orWhere('odds_code', 'size_home')
  247. ->orWhere('odds_code', 'size_guest');
  248. })
  249. ->where('match_id',$gamematch[$j]->match_id)
  250. ->get()
  251. ->toArray();
  252. //根据 排序 获取 最新让球/大小玩法赔率
  253. $sort = array_column($odds,'sort');
  254. array_multisort($sort,SORT_DESC,$odds);
  255. $odds = array_slice($odds,0,4);
  256. for($a=0;$a<count($odds);$a++){
  257. $match->leaguedata[$i]->matchdata[$j]->oddsdata[$a] = $odds[$a];
  258. }
  259. }
  260. }
  261. Render($match, '1', lang('Tips','Sports')->get('success'));
  262. }
  263. //串场
  264. else if($type_code = 'StStringScene'){
  265. $leagues = lm('st_'.$gametype.'_competition','Sports')
  266. ->join('st_'.$gametype.'_league','st_'.$gametype.'_competition.lg_id','=','st_'.$gametype.'_league.id')
  267. ->select('st_'.$gametype.'_competition.lg_id','st_'.$gametype.'_league.name_chinese','st_'.$gametype.'_league.name_english')
  268. ->where('st_'.$gametype.'_competition.status','!=','2')
  269. ->where('st_'.$gametype.'_competition.match_date',date("Y-m-d"))
  270. ->where('st_'.$gametype.'_competition.match_time','>',date("h:i:s"))
  271. ->distinct('st_'.$gametype.'_competition.lg_id')
  272. ->get();
  273. $match->name = $gametype;
  274. for($i=0;$i<count($leagues);$i++){
  275. $match->leaguedata[$i]->league_id = $leagues[$i]->lg_id;
  276. $match->leaguedata[$i]->league_name_chinese = $leagues[$i]->name_chinese;
  277. $match->leaguedata[$i]->league_name_english = $leagues[$i]->name_english;
  278. $num = lm('St_'.$gametype.'_competition','Sports')
  279. ->select('match_id')
  280. ->where('status','!=','2')
  281. ->where('match_date',date("Y-m-d"))
  282. ->where('match_time','>',date("h:i:s"))
  283. ->where('lg_id',$leagues[$i]->lg_id)
  284. ->get();
  285. $match->leaguedata[$i]->num = count($num);
  286. $gamematch = lm('st_'.$gametype.'_competition','Sports')
  287. ->select('match_id','home_team','guest_team','match_date','match_time','status','tag')
  288. ->where('status','!=','2')
  289. ->where('match_date',date("Y-m-d"))
  290. ->where('match_time','>',date("h:i:s"))
  291. ->where('lg_id',$leagues[$i]->lg_id)
  292. ->get();
  293. for($j=0;$j<count($gamematch);$j++){
  294. $match->leaguedata[$i]->matchdata[$j]->match_id = $gamematch[$j]->match_id;
  295. $match->leaguedata[$i]->matchdata[$j]->home_team = $gamematch[$j]->home_team;
  296. $match->leaguedata[$i]->matchdata[$j]->guest_team = $gamematch[$j]->guest_team;
  297. $match->leaguedata[$i]->matchdata[$j]->match_date = $gamematch[$j]->match_date;
  298. $match->leaguedata[$i]->matchdata[$j]->match_time = $gamematch[$j]->match_time;
  299. $match->leaguedata[$i]->matchdata[$j]->status = $gamematch[$j]->status;
  300. $match->leaguedata[$i]->matchdata[$j]->tag = $gamematch[$j]->tag;
  301. $odds = lm('st_'.$gametype.'_odds','Sports')
  302. ->select('id','odds_code','odds','condition','sort')
  303. ->where(function ($query) {
  304. $query->where('odds_code', 'concede_home')
  305. ->orWhere('odds_code', 'concede_guest')
  306. ->orWhere('odds_code', 'size_home')
  307. ->orWhere('odds_code', 'size_guest');
  308. })
  309. ->where('match_id',$gamematch[$j]->match_id)
  310. ->get()
  311. ->toArray();
  312. //根据 排序 获取 最新让球/大小玩法赔率
  313. $sort = array_column($odds,'sort');
  314. array_multisort($sort,SORT_DESC,$odds);
  315. $odds = array_slice($odds,0,4);
  316. for($a=0;$a<count($odds);$a++){
  317. $match->leaguedata[$i]->matchdata[$j]->oddsdata[$a] = $odds[$a];
  318. }
  319. }
  320. }
  321. Render($match, '1', lang('Tips','Sports')->get('success'));
  322. }
  323. //冠军
  324. else if($type_code = 'StChampion'){
  325. $leagues = lm('st_'.$gametype.'_competition','Sports')
  326. ->join('st_'.$gametype.'_league','st_'.$gametype.'_competition.lg_id','=','st_'.$gametype.'_league.id')
  327. ->select('st_'.$gametype.'_competition.lg_id','st_'.$gametype.'_league.name_chinese','st_'.$gametype.'_league.name_english')
  328. ->where('st_'.$gametype.'_competition.status','!=','2')
  329. ->where('st_'.$gametype.'_competition.match_date',date("Y-m-d"))
  330. ->where('st_'.$gametype.'_competition.match_time','>',date("h:i:s"))
  331. ->distinct('st_'.$gametype.'_competition.lg_id')
  332. ->get();
  333. $match->name = $gametype;
  334. for($i=0;$i<count($leagues);$i++){
  335. $match->leaguedata[$i]->league_id = $leagues[$i]->lg_id;
  336. $match->leaguedata[$i]->league_name_chinese = $leagues[$i]->name_chinese;
  337. $match->leaguedata[$i]->league_name_english = $leagues[$i]->name_english;
  338. $num = lm('St_'.$gametype.'_competition','Sports')
  339. ->select('match_id')
  340. ->where('status','!=','2')
  341. ->where('match_date',date("Y-m-d"))
  342. ->where('match_time','>',date("h:i:s"))
  343. ->where('lg_id',$leagues[$i]->lg_id)
  344. ->get();
  345. $match->leaguedata[$i]->num = count($num);
  346. $gamematch = lm('st_'.$gametype.'_competition','Sports')
  347. ->select('match_id','home_team','guest_team','match_date','match_time','status','tag')
  348. ->where('status','!=','2')
  349. ->where('match_date',date("Y-m-d"))
  350. ->where('match_time','>',date("h:i:s"))
  351. ->where('lg_id',$leagues[$i]->lg_id)
  352. ->get();
  353. for($j=0;$j<count($gamematch);$j++){
  354. $match->leaguedata[$i]->matchdata[$j]->match_id = $gamematch[$j]->match_id;
  355. $match->leaguedata[$i]->matchdata[$j]->home_team = $gamematch[$j]->home_team;
  356. $match->leaguedata[$i]->matchdata[$j]->guest_team = $gamematch[$j]->guest_team;
  357. $match->leaguedata[$i]->matchdata[$j]->match_date = $gamematch[$j]->match_date;
  358. $match->leaguedata[$i]->matchdata[$j]->match_time = $gamematch[$j]->match_time;
  359. $match->leaguedata[$i]->matchdata[$j]->status = $gamematch[$j]->status;
  360. $match->leaguedata[$i]->matchdata[$j]->tag = $gamematch[$j]->tag;
  361. $odds = lm('st_'.$gametype.'_odds','Sports')
  362. ->select('id','odds_code','odds','condition','sort')
  363. ->where(function ($query) {
  364. $query->where('odds_code', 'concede_home')
  365. ->orWhere('odds_code', 'concede_guest')
  366. ->orWhere('odds_code', 'size_home')
  367. ->orWhere('odds_code', 'size_guest');
  368. })
  369. ->where('match_id',$gamematch[$j]->match_id)
  370. ->get()
  371. ->toArray();
  372. //根据 排序 获取 最新让球/大小玩法赔率
  373. $sort = array_column($odds,'sort');
  374. array_multisort($sort,SORT_DESC,$odds);
  375. $odds = array_slice($odds,0,4);
  376. for($a=0;$a<count($odds);$a++){
  377. $match->leaguedata[$i]->matchdata[$j]->oddsdata[$a] = $odds[$a];
  378. }
  379. }
  380. }
  381. Render($match, '1', lang('Tips','Sports')->get('success'));
  382. }
  383. }
  384. }