RollingBall.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. return $data;
  49. }
  50. /**
  51. * @throws \Exception
  52. * 首页篮球滚球
  53. */
  54. public function lqrollingball(){
  55. $models = $this->commonFunction->getModels('lq',1);
  56. $model_result = $models['model_result'];
  57. $model_match = $models['model_match'];
  58. $model_league = $models['model_league'];
  59. //获取 滚球查询条件
  60. $where = $this->commonFunction->getState('StRollBall',$model_match);
  61. $result =lm($model_match,"Sports")
  62. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  63. ->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')
  64. ->where($where)
  65. ->where([[$model_league.'.name_chinese','!=','']])
  66. ->get()
  67. ->toarray();
  68. //===获取当前赛事是否有赔率,如果没有则去除===
  69. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  70. foreach ($result as $k=>$v){
  71. $v['home_score'] = 0;
  72. $v['guest_score'] = 0;
  73. $v['match_time'] = 0;
  74. $v['match_process'] = '';
  75. $result[$k] = $v;
  76. }
  77. $data = [
  78. 'game_code'=>'lq',
  79. 'gameName'=>'篮球',
  80. 'matchData'=>$result
  81. ];
  82. return $data;
  83. }
  84. public function wqrollingball(){
  85. $models = $this->commonFunction->getModels('wq',1);
  86. $model_result = $models['model_result'];
  87. $model_match = $models['model_match'];
  88. $model_league = $models['model_league'];
  89. //获取 滚球查询条件
  90. $where = $this->commonFunction->getState('StRollBall',$model_match);
  91. $result =lm($model_match,"Sports")
  92. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  93. ->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')
  94. ->where($where)
  95. ->where([[$model_league.'.name_chinese','!=','']])
  96. ->get()
  97. ->toarray();
  98. //===获取当前赛事是否有赔率,如果没有则去除===
  99. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  100. foreach ($result as $k=>$v){
  101. $v['first_inning_score'] = 0;
  102. $v['second_inning_score'] = 0;
  103. $v['third_inning_score'] = 0;
  104. $v['match_time'] = 0;
  105. $v['match_process'] = '';
  106. $result[$k] = $v;
  107. }
  108. $data = [
  109. 'game_code'=>'wq',
  110. 'gameName'=>'网球',
  111. 'matchData'=>$result
  112. ];
  113. return $data;
  114. }
  115. public function bqrollingball(){
  116. $models = $this->commonFunction->getModels('bq',1);
  117. $model_result = $models['model_result'];
  118. $model_match = $models['model_match'];
  119. $model_league = $models['model_league'];
  120. //获取 滚球查询条件
  121. $where = $this->commonFunction->getState('StRollBall',$model_match);
  122. $result =lm($model_match,"Sports")
  123. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  124. ->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')
  125. ->where($where)
  126. ->where([[$model_league.'.name_chinese','!=','']])
  127. ->get()
  128. ->toarray();
  129. //===获取当前赛事是否有赔率,如果没有则去除===
  130. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  131. foreach ($result as $k=>$v){
  132. $v['home_score'] = 0;
  133. $v['guest_score'] = 0;
  134. $v['match_time'] = 0;
  135. $v['match_process'] = '';
  136. $result[$k] = $v;
  137. }
  138. $data = [
  139. 'game_code'=>'bq',
  140. 'gameName'=>'棒球',
  141. 'matchData'=>$result
  142. ];
  143. return $data;
  144. }
  145. /**
  146. * 获取所有球类滚球
  147. */
  148. public function getRollingBall(){
  149. $zqRollingBall = $this->zqrollingball();
  150. $lqRollingBall = $this->lqrollingball();
  151. $wqRollingBall = $this->wqrollingball();
  152. $bqRollingBall = $this->bqrollingball();
  153. $data = [
  154. 'zqData' =>$zqRollingBall,
  155. 'lqData' =>$lqRollingBall,
  156. 'wqData' =>$wqRollingBall,
  157. 'bqData' =>$bqRollingBall,
  158. ];
  159. Render($data, '1', lang('Tips','Sports')->get('success'));
  160. }
  161. }