RollingBall.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/21
  6. * Time: 14:07
  7. */
  8. namespace App\Sports\Controller;
  9. use BaseController\Controller;
  10. use \System\Model;
  11. class RollingBall extends Controller{
  12. public function init() {
  13. $this->commonFunction = C()->get('commonFunction');
  14. }
  15. /**
  16. * @throws \Exception
  17. * 首页足球滚球
  18. */
  19. public function zqrollingball(){
  20. $models = $this->commonFunction->getModels('zq',1);
  21. $model_result = $models['model_result'];
  22. $model_match = $models['model_match'];
  23. $model_league = $models['model_league'];
  24. $result_record = $models['model_result_record'];
  25. //获取 滚球查询条件
  26. $where = $this->commonFunction->getState('StRollBall',$model_match);
  27. $result =lm($model_match,"Sports")
  28. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  29. ->select($model_match.'.id as match_id',$model_match.'.tag','match_date as start_date',$model_match.'.match_time as start_time',$model_match.'.home_team',$model_match.'.guest_team')
  30. ->where([[$model_league.'.name_chinese','!=','']])
  31. ->where($where)
  32. ->get()
  33. ->toarray();
  34. //===获取当前赛事是否有赔率,如果没有则去除===
  35. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  36. foreach ($result as $k=>$v){
  37. $v['home_score'] = 0;
  38. $v['guest_score'] = 0;
  39. $v['match_time'] = 0;
  40. $v['match_process'] = '';
  41. $result[$k] = $v;
  42. }
  43. $data = [
  44. 'game_code'=>'zq',
  45. 'gameName'=>'足球',
  46. 'matchData'=>$result
  47. ];
  48. dd($data);
  49. return $data;
  50. }
  51. /**
  52. * @throws \Exception
  53. * 首页篮球滚球
  54. */
  55. public function lqrollingball(){
  56. $models = $this->commonFunction->getModels('lq',1);
  57. $model_result = $models['model_result'];
  58. $model_match = $models['model_match'];
  59. $model_league = $models['model_league'];
  60. //获取 滚球查询条件
  61. $where = $this->commonFunction->getState('StRollBall',$model_match);
  62. $result =lm($model_match,"Sports")
  63. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  64. ->select($model_match.'.id as match_id',$model_match.'.tag','match_date as start_date',$model_match.'.match_time as start_time',$model_match.'.home_team',$model_match.'.guest_team')
  65. ->where($where)
  66. ->where([[$model_league.'.name_chinese','!=','']])
  67. ->get()
  68. ->toarray();
  69. //===获取当前赛事是否有赔率,如果没有则去除===
  70. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  71. foreach ($result as $k=>$v){
  72. $v['home_score'] = 0;
  73. $v['guest_score'] = 0;
  74. $v['match_time'] = 0;
  75. $v['match_process'] = '';
  76. $result[$k] = $v;
  77. }
  78. $data = [
  79. 'game_code'=>'lq',
  80. 'gameName'=>'篮球',
  81. 'matchData'=>$result
  82. ];
  83. return $data;
  84. }
  85. public function wqrollingball(){
  86. $models = $this->commonFunction->getModels('wq',1);
  87. $model_result = $models['model_result'];
  88. $model_match = $models['model_match'];
  89. $model_league = $models['model_league'];
  90. //获取 滚球查询条件
  91. $where = $this->commonFunction->getState('StRollBall',$model_match);
  92. $result =lm($model_match,"Sports")
  93. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  94. ->select($model_match.'.id as match_id',$model_match.'.tag','match_date as start_date',$model_match.'.match_time as start_time',$model_match.'.home_team as home_player_name',$model_match.'.guest_team as guest_player_name')
  95. ->where($where)
  96. ->where([[$model_league.'.name_chinese','!=','']])
  97. ->get()
  98. ->toarray();
  99. //===获取当前赛事是否有赔率,如果没有则去除===
  100. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  101. foreach ($result as $k=>$v){
  102. $v['first_inning_score'] = 0;
  103. $v['second_inning_score'] = 0;
  104. $v['third_inning_score'] = 0;
  105. $v['match_time'] = 0;
  106. $v['match_process'] = '';
  107. $result[$k] = $v;
  108. }
  109. $data = [
  110. 'game_code'=>'wq',
  111. 'gameName'=>'网球',
  112. 'matchData'=>$result
  113. ];
  114. return $data;
  115. }
  116. public function bqrollingball(){
  117. $models = $this->commonFunction->getModels('bq',1);
  118. $model_result = $models['model_result'];
  119. $model_match = $models['model_match'];
  120. $model_league = $models['model_league'];
  121. //获取 滚球查询条件
  122. $where = $this->commonFunction->getState('StRollBall',$model_match);
  123. $result =lm($model_match,"Sports")
  124. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  125. ->select($model_match.'.id as match_id',$model_match.'.tag','match_date as start_date',$model_match.'.match_time as start_time',$model_match.'.home_team',$model_match.'.guest_team')
  126. ->where($where)
  127. ->where([[$model_league.'.name_chinese','!=','']])
  128. ->get()
  129. ->toarray();
  130. //===获取当前赛事是否有赔率,如果没有则去除===
  131. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  132. foreach ($result as $k=>$v){
  133. $v['home_score'] = 0;
  134. $v['guest_score'] = 0;
  135. $v['match_time'] = 0;
  136. $v['match_process'] = '';
  137. $result[$k] = $v;
  138. }
  139. $data = [
  140. 'game_code'=>'bq',
  141. 'gameName'=>'棒球',
  142. 'matchData'=>$result
  143. ];
  144. return $data;
  145. }
  146. /**
  147. * 获取所有球类滚球
  148. */
  149. public function getRollingBall(){
  150. $zqRollingBall = $this->zqrollingball();
  151. $lqRollingBall = $this->lqrollingball();
  152. $wqRollingBall = $this->wqrollingball();
  153. $bqRollingBall = $this->bqrollingball();
  154. $data = [
  155. 'zqData' =>$zqRollingBall,
  156. 'lqData' =>$lqRollingBall,
  157. 'wqData' =>$wqRollingBall,
  158. 'bqData' =>$bqRollingBall,
  159. ];
  160. Render($data, '1', lang('Tips','Sports')->get('success'));
  161. }
  162. }