RollingBall.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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_result,$model_result.'.match_id',$model_match.'.id')
  29. // ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  30. // ->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','home_score','guest_score',$model_result.'.match_time','match_process')
  31. // ->where([[$model_league.'.name_chinese','!=','']])
  32. // ->where($where)
  33. // ->get()
  34. // ->toarray();
  35. $result =lm($model_match,"Sports")
  36. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  37. ->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')
  38. ->where([[$model_league.'.name_chinese','!=','']])
  39. ->where($where)
  40. ->get()
  41. ->toarray();
  42. foreach ($result as $k=>$v){
  43. $v['home_score'] = 0;
  44. $v['guest_score'] = 0;
  45. $v['match_time'] = 0;
  46. $v['match_process'] = '';
  47. $result[$k] = $v;
  48. }
  49. $data = [
  50. 'game_code'=>'zq',
  51. 'gameName'=>'足球',
  52. 'matchData'=>$result
  53. ];
  54. return $data;
  55. }
  56. /**
  57. * @throws \Exception
  58. * 首页篮球滚球
  59. */
  60. public function lqrollingball(){
  61. $models = $this->commonFunction->getModels('lq',1);
  62. $model_result = $models['model_result'];
  63. $model_match = $models['model_match'];
  64. $model_league = $models['model_league'];
  65. //获取 滚球查询条件
  66. $where = $this->commonFunction->getState('StRollBall',$model_match);
  67. // $result =lm($model_match,"Sports")
  68. // ->join($model_result,$model_result.'.match_id',$model_match.'.id')
  69. // ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  70. // ->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','home_score','guest_score',$model_result.'.match_time','match_process')
  71. // ->where($where)
  72. // ->where([[$model_league.'.name_chinese','!=','']])
  73. // ->get()
  74. // ->toarray();
  75. $result =lm($model_match,"Sports")
  76. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  77. ->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')
  78. ->where($where)
  79. ->where([[$model_league.'.name_chinese','!=','']])
  80. ->get()
  81. ->toarray();
  82. foreach ($result as $k=>$v){
  83. $v['home_score'] = 0;
  84. $v['guest_score'] = 0;
  85. $v['match_time'] = 0;
  86. $v['match_process'] = '';
  87. $result[$k] = $v;
  88. }
  89. $data = [
  90. 'game_code'=>'lq',
  91. 'gameName'=>'篮球',
  92. 'matchData'=>$result
  93. ];
  94. return $data;
  95. }
  96. public function wqrollingball(){
  97. $models = $this->commonFunction->getModels('wq',1);
  98. $model_result = $models['model_result'];
  99. $model_match = $models['model_match'];
  100. $model_league = $models['model_league'];
  101. //获取 滚球查询条件
  102. $where = $this->commonFunction->getState('StRollBall',$model_match);
  103. // $result =lm($model_match,"Sports")
  104. // ->join($model_result,$model_result.'.match_id',$model_match.'.id')
  105. // ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  106. // ->select($model_match.'.id as 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')
  107. // ->where($where)
  108. // ->where([[$model_league.'.name_chinese','!=','']])
  109. // ->get()
  110. // ->toarray();
  111. $result =lm($model_match,"Sports")
  112. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  113. ->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')
  114. ->where($where)
  115. ->where([[$model_league.'.name_chinese','!=','']])
  116. ->get()
  117. ->toarray();
  118. foreach ($result as $k=>$v){
  119. $v['first_inning_score'] = 0;
  120. $v['second_inning_score'] = 0;
  121. $v['third_inning_score'] = 0;
  122. $v['match_time'] = 0;
  123. $v['match_process'] = '';
  124. $result[$k] = $v;
  125. }
  126. $data = [
  127. 'game_code'=>'wq',
  128. 'gameName'=>'网球',
  129. 'matchData'=>$result
  130. ];
  131. return $data;
  132. }
  133. public function bqrollingball(){
  134. $models = $this->commonFunction->getModels('bq',1);
  135. $model_result = $models['model_result'];
  136. $model_match = $models['model_match'];
  137. $model_league = $models['model_league'];
  138. //获取 滚球查询条件
  139. $where = $this->commonFunction->getState('StRollBall',$model_match);
  140. // $result =lm($model_match,"Sports")
  141. // ->join($model_result,$model_result.'.match_id',$model_match.'.id')
  142. // ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  143. // ->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','home_score','guest_score',$model_result.'.match_time','match_process')
  144. // ->where($where)
  145. // ->where([[$model_league.'.name_chinese','!=','']])
  146. // ->get()
  147. // ->toarray();
  148. $result =lm($model_match,"Sports")
  149. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  150. ->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')
  151. ->where($where)
  152. ->where([[$model_league.'.name_chinese','!=','']])
  153. ->get()
  154. ->toarray();
  155. foreach ($result as $k=>$v){
  156. $v['home_score'] = 0;
  157. $v['guest_score'] = 0;
  158. $v['match_time'] = 0;
  159. $v['match_process'] = '';
  160. $result[$k] = $v;
  161. }
  162. $data = [
  163. 'game_code'=>'bq',
  164. 'gameName'=>'棒球',
  165. 'matchData'=>$result
  166. ];
  167. return $data;
  168. }
  169. /**
  170. * 获取所有球类滚球
  171. */
  172. public function getRollingBall(){
  173. $zqRollingBall = $this->zqrollingball();
  174. $lqRollingBall = $this->lqrollingball();
  175. $wqRollingBall = $this->wqrollingball();
  176. $bqRollingBall = $this->bqrollingball();
  177. $data = [
  178. 'zqData' =>$zqRollingBall,
  179. 'lqData' =>$lqRollingBall,
  180. 'wqData' =>$wqRollingBall,
  181. 'bqData' =>$bqRollingBall,
  182. ];
  183. Render($data, '1', lang('Tips','Sports')->get('success'));
  184. }
  185. }