RollingBall.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 App\Sports\Model\St_zq_competition as matchModel;
  11. use \System\Model;
  12. class RollingBall extends Controller{
  13. public function init() {
  14. $this->commonFunction = C()->get('commonFunction');
  15. }
  16. /**
  17. * @throws \Exception
  18. * 首页足球滚球
  19. */
  20. public function zqrollingball(){
  21. $models = $this->commonFunction->getModels('zq',1);
  22. $model_match = $models['model_match'];
  23. //获取 滚球查询条件
  24. $where = $this->commonFunction->getState('StRollBall',$model_match,'zq');
  25. //统计联赛下的赛事及查询赛事
  26. $ret['game_code'] = 'zq';
  27. $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
  28. //如果赛事为空,直接返回
  29. if(empty($matchData)) return $matchData;
  30. //===获取当前赛事是否有赔率,如果没有则去除===
  31. $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
  32. $data = [
  33. 'game_code'=>'zq',
  34. 'gameName'=>'足球',
  35. 'matchData'=>$matchData_new
  36. ];
  37. return $data;
  38. }
  39. public function __zqrollingball(){
  40. $models = $this->commonFunction->getModels('zq',1);
  41. $model_result = $models['model_result'];
  42. $model_match = $models['model_match'];
  43. $model_league = $models['model_league'];
  44. $result_record = $models['model_result_record'];
  45. //获取 滚球查询条件
  46. $where = $this->commonFunction->getState('StRollBall',$model_match,'zq');
  47. $result =lm($model_match,"Sports")
  48. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  49. ->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')
  50. ->where([[$model_league.'.name_chinese','!=','']])
  51. ->where($where)
  52. ->get()
  53. ->toarray();
  54. //===获取当前赛事是否有赔率,如果没有则去除===
  55. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  56. foreach ($result as $k=>$v){
  57. $v['home_score'] = 0;
  58. $v['guest_score'] = 0;
  59. $v['match_time'] = 0;
  60. $v['match_process'] = '';
  61. $result[$k] = $v;
  62. }
  63. $data = [
  64. 'game_code'=>'zq',
  65. 'gameName'=>'足球',
  66. 'matchData'=>$result
  67. ];
  68. return $data;
  69. }
  70. /**
  71. * @throws \Exception
  72. * 首页篮球滚球
  73. */
  74. public function lqrollingball(){
  75. $models = $this->commonFunction->getModels('lq',1);
  76. $model_match = $models['model_match'];
  77. //获取 滚球查询条件
  78. $where = $this->commonFunction->getState('StRollBall',$model_match,'lq');
  79. //统计联赛下的赛事及查询赛事
  80. $ret['game_code'] = 'lq';
  81. $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
  82. //如果赛事为空,直接返回
  83. if(empty($matchData)) return $matchData;
  84. //===获取当前赛事是否有赔率,如果没有则去除===
  85. $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
  86. $data = [
  87. 'game_code'=>'lq',
  88. 'gameName'=>'篮球',
  89. 'matchData'=>$matchData_new
  90. ];
  91. return $data;
  92. }
  93. public function __lqrollingball(){
  94. $models = $this->commonFunction->getModels('lq',1);
  95. $model_result = $models['model_result'];
  96. $model_match = $models['model_match'];
  97. $model_league = $models['model_league'];
  98. //获取 滚球查询条件
  99. $where = $this->commonFunction->getState('StRollBall',$model_match,'lq');
  100. $result =lm($model_match,"Sports")
  101. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  102. ->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')
  103. ->where($where)
  104. ->where([[$model_league.'.name_chinese','!=','']])
  105. ->get()
  106. ->toarray();
  107. //===获取当前赛事是否有赔率,如果没有则去除===
  108. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  109. foreach ($result as $k=>$v){
  110. $v['home_score'] = 0;
  111. $v['guest_score'] = 0;
  112. $v['match_time'] = 0;
  113. $v['match_process'] = '';
  114. $result[$k] = $v;
  115. }
  116. $data = [
  117. 'game_code'=>'lq',
  118. 'gameName'=>'篮球',
  119. 'matchData'=>$result
  120. ];
  121. return $data;
  122. }
  123. public function wqrollingball(){
  124. $models = $this->commonFunction->getModels('wq',1);
  125. $model_match = $models['model_match'];
  126. //获取 滚球查询条件
  127. $where = $this->commonFunction->getState('StRollBall',$model_match,'wq');
  128. //统计联赛下的赛事及查询赛事
  129. $ret['game_code'] = 'wq';
  130. $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
  131. //如果赛事为空,直接返回
  132. if(empty($matchData)) return $matchData;
  133. //===获取当前赛事是否有赔率,如果没有则去除===
  134. $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
  135. $data = [
  136. 'game_code'=>'wq',
  137. 'gameName'=>'网球',
  138. 'matchData'=>$matchData_new
  139. ];
  140. return $data;
  141. }
  142. public function __wqrollingball(){
  143. $models = $this->commonFunction->getModels('wq',1);
  144. $model_result = $models['model_result'];
  145. $model_match = $models['model_match'];
  146. $model_league = $models['model_league'];
  147. //获取 滚球查询条件
  148. $where = $this->commonFunction->getState('StRollBall',$model_match,'wq');
  149. $result =lm($model_match,"Sports")
  150. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  151. ->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')
  152. ->where($where)
  153. ->where([[$model_league.'.name_chinese','!=','']])
  154. ->get()
  155. ->toarray();
  156. //===获取当前赛事是否有赔率,如果没有则去除===
  157. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  158. foreach ($result as $k=>$v){
  159. $v['first_inning_score'] = 0;
  160. $v['second_inning_score'] = 0;
  161. $v['third_inning_score'] = 0;
  162. $v['match_time'] = 0;
  163. $v['match_process'] = '';
  164. $result[$k] = $v;
  165. }
  166. $data = [
  167. 'game_code'=>'wq',
  168. 'gameName'=>'网球',
  169. 'matchData'=>$result
  170. ];
  171. return $data;
  172. }
  173. public function bqrollingball(){
  174. $models = $this->commonFunction->getModels('bq',1);
  175. $model_match = $models['model_match'];
  176. //获取 滚球查询条件
  177. $where = $this->commonFunction->getState('StRollBall',$model_match,'bq');
  178. //统计联赛下的赛事及查询赛事
  179. $ret['game_code'] = 'bq';
  180. $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
  181. //如果赛事为空,直接返回
  182. if(empty($matchData)) return $matchData;
  183. //===获取当前赛事是否有赔率,如果没有则去除===
  184. $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
  185. $data = [
  186. 'game_code'=>'bq',
  187. 'gameName'=>'棒球',
  188. 'matchData'=>$matchData_new
  189. ];
  190. return $data;
  191. }
  192. public function __bqrollingball(){
  193. $models = $this->commonFunction->getModels('bq',1);
  194. $model_result = $models['model_result'];
  195. $model_match = $models['model_match'];
  196. $model_league = $models['model_league'];
  197. //获取 滚球查询条件
  198. $where = $this->commonFunction->getState('StRollBall',$model_match,'bq');
  199. $result =lm($model_match,"Sports")
  200. ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
  201. ->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')
  202. ->where($where)
  203. ->where([[$model_league.'.name_chinese','!=','']])
  204. ->get()
  205. ->toarray();
  206. //===获取当前赛事是否有赔率,如果没有则去除===
  207. $result = $this->commonFunction->Handle_Odds_Null($result,$models);
  208. foreach ($result as $k=>$v){
  209. $v['home_score'] = 0;
  210. $v['guest_score'] = 0;
  211. $v['match_time'] = 0;
  212. $v['match_process'] = '';
  213. $result[$k] = $v;
  214. }
  215. $data = [
  216. 'game_code'=>'bq',
  217. 'gameName'=>'棒球',
  218. 'matchData'=>$result
  219. ];
  220. return $data;
  221. }
  222. /**
  223. * 获取所有球类滚球
  224. */
  225. public function getRollingBall(){
  226. $zqRollingBall = $this->zqrollingball();
  227. $lqRollingBall = $this->lqrollingball();
  228. $wqRollingBall = $this->wqrollingball();
  229. $bqRollingBall = $this->bqrollingball();
  230. $data = [
  231. 'zqData' =>$zqRollingBall,
  232. 'lqData' =>$lqRollingBall,
  233. 'wqData' =>$wqRollingBall,
  234. 'bqData' =>$bqRollingBall,
  235. ];
  236. Render($data, '1', lang('Tips','Sports')->get('success'));
  237. }
  238. }