RollingBall.php 6.2 KB

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