RollingBall.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. // $result = lm($model_result,'Sports')
  24. // ->leftjoin($model_match,$model_match.'.match_id',$model_result.'.match_id')
  25. // ->select($model_result.'.match_id',$model_result.'.home_team',$model_result.'.guest_team',$model_result.'.status',$model_result.'.home_score',$model_result.'.guest_score',$model_match.'.match_date as start_date',$model_match.'.match_time as start_time',$model_result.'.match_time',$model_result.'.match_process')
  26. // ->where('status',1)
  27. // ->orderby('match_time','desc')
  28. // ->get()->toArray();
  29. //获取 滚球查询条件
  30. $where = $this->commonFunction->getState('StRollBall',$model_match);
  31. $result =lm($model_match,"Sports")
  32. ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
  33. ->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')
  34. ->where($model_match.'.source',$this->source['source'])
  35. ->where($where)
  36. ->get()
  37. ->toarray();
  38. $da = [];
  39. foreach ($result as $key =>$item){
  40. if($item['match_process'] ==""){
  41. $mark = substr($item['match_time'],0,strrpos($item['match_time'],":"));
  42. if((int)$mark < 45){
  43. $item['match_process'] = '上半场';
  44. }else{
  45. $item['match_process'] = '下半场';
  46. }
  47. }
  48. $da[$key]= $item;
  49. }
  50. $data = [
  51. 'game_code'=>'zq',
  52. 'gameName'=>'足球',
  53. 'matchData'=>$da
  54. ];
  55. Render($data, '1', lang('Tips','Sports')->get('success'));
  56. }
  57. /**
  58. * @throws \Exception
  59. * 首页篮球滚球
  60. */
  61. public function lqrollingball(){
  62. $models = $this->commonFunction->getModels('lq',1);
  63. $model_result = $models['model_result'];
  64. $model_match = $models['model_match'];
  65. //获取 滚球查询条件
  66. $where = $this->commonFunction->getState('StRollBall',$model_match);
  67. $result =lm($model_match,"Sports")
  68. ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
  69. ->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')
  70. ->where($model_match.'.source',$this->source['source'])
  71. ->where($where)
  72. ->get()
  73. ->toarray();
  74. // $lq = lm($model_result,'Sports')
  75. // ->select('id','home_team','guest_team','home_score','guest_score','status','match_score','update_time','match_time','match_process')
  76. // ->where('status','1')
  77. // ->orderby('update_time','desc')
  78. // ->get()->toArray();
  79. $data = [
  80. 'game_code'=>'lq',
  81. 'gameName'=>'篮球',
  82. 'matchData'=>$result
  83. ];
  84. Render($data, '1', lang('Tips','Sports')->get('success'));
  85. }
  86. public function wqrollingball(){
  87. $models = $this->commonFunction->getModels('wq',1);
  88. $model_result = $models['model_result'];
  89. $model_match = $models['model_match'];
  90. //获取 滚球查询条件
  91. $where = $this->commonFunction->getState('StRollBall',$model_match);
  92. $result =lm($model_match,"Sports")
  93. ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
  94. ->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')
  95. ->where($model_match.'.source',$this->source['source'])
  96. ->where($where)
  97. ->get()
  98. ->toarray();
  99. // $wq = lm($model_result,'Sports')
  100. // ->select('id','host_player_name','guest_player_name','status','first_inning_score','second_inning_score','third_inning_score','update_time','match_time','match_process')
  101. // ->where('status','1')
  102. // ->orderby('update_time','desc')
  103. // ->get()->toArray();
  104. $data = [
  105. 'game_code'=>'wq',
  106. 'gameName'=>'网球',
  107. 'matchData'=>$result
  108. ];
  109. Render($data, '1', lang('Tips','Sports')->get('success'));
  110. }
  111. public function bqrollingball(){
  112. $models = $this->commonFunction->getModels('bq',1);
  113. $model_result = $models['model_result'];
  114. $model_match = $models['model_match'];
  115. //获取 滚球查询条件
  116. $where = $this->commonFunction->getState('StRollBall',$model_match);
  117. $result =lm($model_match,"Sports")
  118. ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
  119. ->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')
  120. ->where($model_match.'.source',$this->source['source'])
  121. ->where($where)
  122. ->get()
  123. ->toarray();
  124. // $bq = lm($model_result,'Sports')
  125. // ->select('id','home_team','guest_team','home_score','guest_score','status','match_score','update_time','match_time','match_process')
  126. // ->where('status','1')
  127. // ->orderby('update_time','desc')
  128. // ->get()->toArray();
  129. $data = [
  130. 'game_code'=>'bq',
  131. 'gameName'=>'棒球',
  132. 'matchData'=>$result
  133. ];
  134. Render($data, '1', lang('Tips','Sports')->get('success'));
  135. }
  136. }