RollingBall.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. //获取 滚球查询条件
  25. $where = $this->commonFunction->getState('StRollBall',$model_match);
  26. $result =lm($model_match,"Sports")
  27. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  28. ->join($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
  29. ->select($model_match.'.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','home_score','guest_score',$model_result.'.match_time','match_process')
  30. ->where($model_match.'.source',$this->source['source'])
  31. ->where([[$model_league.'.name_chinese','!=','']])
  32. ->where($where)
  33. ->get()
  34. ->toarray();
  35. $data = [
  36. 'game_code'=>'zq',
  37. 'gameName'=>'足球',
  38. 'matchData'=>$result
  39. ];
  40. return $data;
  41. // Render($data, '1', lang('Tips','Sports')->get('success'));
  42. }
  43. /**
  44. * @throws \Exception
  45. * 首页篮球滚球
  46. */
  47. public function lqrollingball(){
  48. $models = $this->commonFunction->getModels('lq',1);
  49. $model_result = $models['model_result'];
  50. $model_match = $models['model_match'];
  51. $model_league = $models['model_league'];
  52. //获取 滚球查询条件
  53. $where = $this->commonFunction->getState('StRollBall',$model_match);
  54. $result =lm($model_match,"Sports")
  55. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  56. ->join($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
  57. ->select($model_match.'.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','home_score','guest_score',$model_result.'.match_time','match_process')
  58. ->where($model_match.'.source',$this->source['source'])
  59. ->where($where)
  60. ->where([[$model_league.'.name_chinese','!=','']])
  61. ->get()
  62. ->toarray();
  63. $data = [
  64. 'game_code'=>'lq',
  65. 'gameName'=>'篮球',
  66. 'matchData'=>$result
  67. ];
  68. return $data;
  69. // Render($data, '1', lang('Tips','Sports')->get('success'));
  70. }
  71. public function wqrollingball(){
  72. $models = $this->commonFunction->getModels('wq',1);
  73. $model_result = $models['model_result'];
  74. $model_match = $models['model_match'];
  75. $model_league = $models['model_league'];
  76. //获取 滚球查询条件
  77. $where = $this->commonFunction->getState('StRollBall',$model_match);
  78. $result =lm($model_match,"Sports")
  79. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  80. ->join($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
  81. ->select($model_match.'.match_id',$model_match.'.tag','match_date as start_date',$model_match.'.match_time as start_time','home_player_name','guest_player_name','first_inning_score','second_inning_score','third_inning_score',$model_result.'.match_time','match_process')
  82. ->where($model_match.'.source',$this->source['source'])
  83. ->where($where)
  84. ->where([[$model_league.'.name_chinese','!=','']])
  85. ->get()
  86. ->toarray();
  87. $data = [
  88. 'game_code'=>'wq',
  89. 'gameName'=>'网球',
  90. 'matchData'=>$result
  91. ];
  92. return $data;
  93. // Render($data, '1', lang('Tips','Sports')->get('success'));
  94. }
  95. public function bqrollingball(){
  96. $models = $this->commonFunction->getModels('bq',1);
  97. $model_result = $models['model_result'];
  98. $model_match = $models['model_match'];
  99. $model_league = $models['model_league'];
  100. //获取 滚球查询条件
  101. $where = $this->commonFunction->getState('StRollBall',$model_match);
  102. $result =lm($model_match,"Sports")
  103. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  104. ->join($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
  105. ->select($model_match.'.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','home_score','guest_score',$model_result.'.match_time','match_process')
  106. ->where($model_match.'.source',$this->source['source'])
  107. ->where($where)
  108. ->where([[$model_league.'.name_chinese','!=','']])
  109. ->get()
  110. ->toarray();
  111. $data = [
  112. 'game_code'=>'bq',
  113. 'gameName'=>'棒球',
  114. 'matchData'=>$result
  115. ];
  116. return $data;
  117. // Render($data, '1', lang('Tips','Sports')->get('success'));
  118. }
  119. /**
  120. * 获取所有球类滚球
  121. */
  122. public function getRollingBall(){
  123. $zqRollingBall = $this->zqrollingball();
  124. $lqRollingBall = $this->lqrollingball();
  125. $wqRollingBall = $this->wqrollingball();
  126. $bqRollingBall = $this->bqrollingball();
  127. $data = [
  128. 'zqData' =>$zqRollingBall,
  129. 'lqData' =>$lqRollingBall,
  130. 'wqData' =>$wqRollingBall,
  131. 'bqData' =>$bqRollingBall,
  132. ];
  133. Render($data, '1', lang('Tips','Sports')->get('success'));
  134. }
  135. }