AllRollingBall.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/22
  6. * Time: 15:54
  7. */
  8. namespace App\Sports\Controller;
  9. use BaseController\Controller;
  10. use \System\Model;
  11. class AllRollingBall extends Controller{
  12. public function allzqleague(){
  13. $allzq = lm("SoccerResult","Sports")
  14. ->join('st_zq_league','st_zq_result.cp_id','=','st_zq_league.id')
  15. ->select('st_zq_result.cp_id','st_zq_league.name_chinese')
  16. ->distinct('st_zq_result.cp_id')
  17. ->where('st_zq_result.status','1')
  18. ->get();
  19. for($i=0;$i<count($allzq);$i++){
  20. $allzqnum = count(lm("SoccerResult","Sports")->where('st_zq_result.status','1')->where('st_zq_result.cp_id',$allzq[$i]->cp_id)->get());
  21. $allzq[$i]->num = $allzqnum;
  22. $allzqmatch = lm("SoccerResult","Sports")
  23. ->select('id','host_name','guest_name','match_time','match_process','tag','match_id')
  24. ->where('status','1')
  25. ->where('cp_id',$allzq[$i]->cp_id)
  26. ->distinct('cp_id')
  27. ->get();
  28. $allzq[$i]->list = $allzqmatch;
  29. $zqleague->name = '足球';
  30. $zqleague->match[$i]->cp_id = $allzq[$i]->cp_id;
  31. $zqleague->match[$i]->league_name = $allzq[$i]->name_chinese;
  32. $zqleague->match[$i]->num = $allzq[$i]->num;
  33. for($j=0;$j<count($allzqmatch);$j++){
  34. $zqleague->match[$i]->list[$j]->id = $allzqmatch[$j]->id;
  35. $zqleague->match[$i]->list[$j]->host_name = $allzqmatch[$j]->host_name;
  36. $zqleague->match[$i]->list[$j]->guest_name = $allzqmatch[$j]->guest_name;
  37. $zqleague->match[$i]->list[$j]->match_time = $allzqmatch[$j]->match_time;
  38. $zqleague->match[$i]->list[$j]->match_process = $allzqmatch[$j]->match_process;
  39. $zqleague->match[$i]->list[$j]->tag = $allzqmatch[$j]->tag;
  40. $zqodds = lm('St_zq_odds','Sports')
  41. ->select('id','odds_code','odds','condition','sort')
  42. ->where(function ($query) {
  43. $query->where('odds_code', 'concede_home')
  44. ->orWhere('odds_code', 'concede_guest')
  45. ->orWhere('odds_code', 'size_home')
  46. ->orWhere('odds_code', 'size_guest');
  47. })
  48. ->where('match_id',$allzqmatch[$j]->match_id)
  49. ->get()->toArray();
  50. //根据 排序 获取 最新让球/大小玩法赔率
  51. $sort = array_column($zqodds,'sort');
  52. array_multisort($sort,SORT_DESC,$zqodds);
  53. $zqodds = array_slice($zqodds,0,4);
  54. for($a=0;$a<count($zqodds);$a++){
  55. $zqleague->match[$i]->list[$j]->zqodds[$a] = $zqodds[$a];
  56. }
  57. }
  58. }
  59. Render($zqleague, '1', lang('Tips','Sports')->get('success'));
  60. }
  61. public function alllqleague(){
  62. $alllq = lm("BasketballResult","Sports")
  63. ->join('st_lq_league','st_lq_result.cp_id','=','st_lq_league.id')
  64. ->select('st_lq_result.cp_id','st_lq_league.name_chinese')
  65. ->distinct('st_lq_result.cp_id')
  66. ->where('st_lq_result.status','1')
  67. ->get();
  68. for($i=0;$i<count($alllq);$i++){
  69. $alllqnum = count(lm("BasketballResult","Sports")->where('st_lq_result.status','1')->where('st_lq_result.cp_id',$alllq[$i]->cp_id)->get());
  70. $alllq[$i]->num = $alllqnum;
  71. $alllqmatch = lm("BasketballResult","Sports")
  72. ->select('id','host_name','guest_name','match_score','match_time','match_process','tag','match_id')
  73. ->where('status','1')
  74. ->where('cp_id',$alllq[$i]->cp_id)
  75. ->distinct('cp_id')
  76. ->get();
  77. $alllq[$i]->list = $alllqmatch;
  78. $lqleague->name = '篮球';
  79. $lqleague->match[$i]->cp_id = $alllq[$i]->cp_id;
  80. $lqleague->match[$i]->league_name = $alllq[$i]->name_chinese;
  81. $lqleague->match[$i]->num = $alllq[$i]->num;
  82. for($j=0;$j<count($alllqmatch);$j++){
  83. $lqleague->match[$i]->list[$j]->id = $alllqmatch[$j]->id;
  84. $lqleague->match[$i]->list[$j]->host_name = $alllqmatch[$j]->host_name;
  85. $lqleague->match[$i]->list[$j]->guest_name = $alllqmatch[$j]->guest_name;
  86. $lqleague->match[$i]->list[$j]->match_score = $alllqmatch[$j]->match_score;
  87. $lqleague->match[$i]->list[$j]->match_time = $alllqmatch[$j]->match_time;
  88. $lqleague->match[$i]->list[$j]->match_process = $alllqmatch[$j]->match_process;
  89. $lqleague->match[$i]->list[$j]->tag = $alllqmatch[$j]->tag;
  90. $lqodds = lm('St_lq_odds','Sports')
  91. ->select('id','odds_code','odds','condition','sort')
  92. ->where(function ($query) {
  93. $query->where('odds_code', 'concede_home')
  94. ->orWhere('odds_code', 'concede_guest')
  95. ->orWhere('odds_code', 'size_home')
  96. ->orWhere('odds_code', 'size_guest');
  97. })
  98. ->where('match_id',$alllqmatch[$j]->match_id)
  99. ->get()->toArray();
  100. //根据 排序 获取 最新让球/大小玩法赔率
  101. $sort = array_column($lqodds,'sort');
  102. array_multisort($sort,SORT_DESC,$lqodds);
  103. $lqodds = array_slice($lqodds,0,4);
  104. for($a=0;$a<count($lqodds);$a++){
  105. $lqleague->match[$i]->list[$j]->lqodds[$a] = $lqodds[$a];
  106. }
  107. }
  108. }
  109. Render($lqleague, '1', lang('Tips','Sports')->get('success'));
  110. }
  111. /**
  112. * @throws \Exception
  113. */
  114. public function allwqleague(){
  115. $allwq = lm("TennisResult","Sports")
  116. ->join('st_wq_league','st_wq_result.cp_id','=','st_wq_league.id')
  117. ->select('st_wq_result.cp_id','st_wq_league.name_chinese')
  118. ->distinct('st_wq_result.cp_id')
  119. ->where('st_wq_result.status','1')
  120. ->get();
  121. for($i=0;$i<count($allwq);$i++){
  122. $allwqnum = count(lm("TennisResult","Sports")->where('st_wq_result.status','1')->where('st_wq_result.cp_id',$allwq[$i]->cp_id)->get());
  123. $allwq[$i]->num = $allwqnum;
  124. $allwqmatch = lm("TennisResult","Sports")
  125. ->select('id','host_player_name','guest_player_name','first_inning_score','second_inning_score','third_inning_score','match_time','match_process','tag','match_id')
  126. ->where('status','1')
  127. ->where('cp_id',$allwq[$i]->cp_id)
  128. ->distinct('cp_id')
  129. ->get();
  130. //$allwq[$i]->list = $allwqmatch;
  131. $wqleague->name = '网球';
  132. $wqleague->match[$i]->cp_id = $allwq[$i]->cp_id;
  133. $wqleague->match[$i]->league_name = $allwq[$i]->name_chinese;
  134. $wqleague->match[$i]->num = $allwq[$i]->num;
  135. for($j=0;$j<count($allwqmatch);$j++){
  136. $wqleague->match[$i]->list[$j]->id = $allwqmatch[$j]->id;
  137. $wqleague->match[$i]->list[$j]->host_player_name = $allwqmatch[$j]->host_player_name;
  138. $wqleague->match[$i]->list[$j]->guest_player_name = $allwqmatch[$j]->guest_player_name;
  139. $wqleague->match[$i]->list[$j]->first_inning_score = $allwqmatch[$j]->first_inning_score;
  140. $wqleague->match[$i]->list[$j]->second_inning_score = $allwqmatch[$j]->second_inning_score;
  141. $wqleague->match[$i]->list[$j]->third_inning_score = $allwqmatch[$j]->third_inning_score;
  142. $wqleague->match[$i]->list[$j]->match_time = $allwqmatch[$j]->match_time;
  143. $wqleague->match[$i]->list[$j]->match_process = $allwqmatch[$j]->match_process;
  144. $wqleague->match[$i]->list[$j]->tag = $allwqmatch[$j]->tag;
  145. $wqodds = lm('St_wq_odds','Sports')
  146. ->select('id','odds_code','odds','condition','sort')
  147. ->where(function ($query) {
  148. $query->where('odds_code', 'concede_home')
  149. ->orWhere('odds_code', 'concede_guest')
  150. ->orWhere('odds_code', 'size_home')
  151. ->orWhere('odds_code', 'size_guest');
  152. })
  153. ->where('match_id',$allwqmatch[$j]->match_id)
  154. ->get()->toArray();
  155. //根据 排序 获取 最新让球/大小玩法赔率
  156. $sort = array_column($wqodds,'sort');
  157. array_multisort($sort,SORT_DESC,$wqodds);
  158. $wqodds = array_slice($wqodds,0,4);
  159. for($a=0;$a<count($wqodds);$a++){
  160. $wqleague->match[$i]->list[$j]->wqodds[$a] = $wqodds[$a];
  161. }
  162. }
  163. }
  164. Render($wqleague, '1', lang('Tips','Sports')->get('success'));
  165. }
  166. public function allbqleague(){
  167. $allbq = lm("BaseballResult","Sports")
  168. ->join('st_bq_league','st_bq_result.cp_id','=','st_bq_league.id')
  169. ->select('st_bq_result.cp_id','st_bq_league.name_chinese')
  170. ->distinct('st_bq_result.cp_id')
  171. ->where('st_bq_result.status','1')
  172. ->get();
  173. for($i=0;$i<count($allbq);$i++){
  174. $allbqnum = count(lm("BaseballResult","Sports")->where('st_bq_result.status','1')->where('st_bq_result.cp_id',$allbq[$i]->cp_id)->get());
  175. $allbq[$i]->num = $allbqnum;
  176. $allbqmatch = lm("BaseballResult","Sports")
  177. ->select('id','host_name','guest_name','match_score','match_time','match_process','tag','match_id')
  178. ->where('status','1')
  179. ->where('cp_id',$allbq[$i]->cp_id)
  180. ->distinct('cp_id')
  181. ->get();
  182. $allbq[$i]->list = $allbqmatch;
  183. $bqleague->name = '棒球';
  184. $bqleague->match[$i]->cp_id = $allbq[$i]->cp_id;
  185. $bqleague->match[$i]->league_name = $allbq[$i]->name_chinese;
  186. $bqleague->match[$i]->num = $allbq[$i]->num;
  187. for($j=0;$j<count($allbqmatch);$j++){
  188. $bqleague->match[$i]->list[$j]->id = $allbqmatch[$j]->id;
  189. $bqleague->match[$i]->list[$j]->host_name = $allbqmatch[$j]->host_name;
  190. $bqleague->match[$i]->list[$j]->guest_name = $allbqmatch[$j]->guest_name;
  191. $bqleague->match[$i]->list[$j]->match_score = $allbqmatch[$j]->match_score;
  192. $bqleague->match[$i]->list[$j]->match_time = $allbqmatch[$j]->match_time;
  193. $bqleague->match[$i]->list[$j]->match_process = $allbqmatch[$j]->match_process;
  194. $bqleague->match[$i]->list[$j]->tag = $allbqmatch[$j]->tag;
  195. $bqodds = lm('St_bq_odds','Sports')
  196. ->select('id','odds_code','odds','condition','sort')
  197. ->where(function ($query) {
  198. $query->where('odds_code', 'concede_home')
  199. ->orWhere('odds_code', 'concede_guest')
  200. ->orWhere('odds_code', 'size_home')
  201. ->orWhere('odds_code', 'size_guest');
  202. })
  203. ->where('match_id',$allbqmatch[$j]->match_id)
  204. ->get()->toArray();
  205. //根据 排序 获取 最新让球/大小玩法赔率
  206. $sort = array_column($bqodds,'sort');
  207. array_multisort($sort,SORT_DESC,$bqodds);
  208. $bqodds = array_slice($bqodds,0,4);
  209. for($a=0;$a<count($bqodds);$a++){
  210. $bqleague->match[$i]->list[$j]->bqodds[$a] = $bqodds[$a];
  211. }
  212. }
  213. }
  214. Render($bqleague, '1', lang('Tips','Sports')->get('success'));
  215. }
  216. }