| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Jonlin
- * Date: 2019/3/21
- * Time: 14:07
- */
- namespace App\Sports\Controller;
- use BaseController\Controller;
- use App\Sports\Model\St_zq_competition as matchModel;
- use \System\Model;
- class RollingBall extends Controller{
- public function init() {
- $this->commonFunction = C()->get('commonFunction');
- }
- /**
- * @throws \Exception
- * 首页足球滚球
- */
- public function zqrollingball(){
- $models = $this->commonFunction->getModels('zq',1);
- $model_match = $models['model_match'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'zq');
- //统计联赛下的赛事及查询赛事
- $ret['game_code'] = 'zq';
- $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
- //如果赛事为空,直接返回
- if(empty($matchData)) return $matchData;
- //===获取当前赛事是否有赔率,如果没有则去除===
- $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
- $data = [
- 'game_code'=>'zq',
- 'gameName'=>'足球',
- 'matchData'=>$matchData_new
- ];
- return $data;
- }
- public function __zqrollingball(){
- $models = $this->commonFunction->getModels('zq',1);
- $model_result = $models['model_result'];
- $model_match = $models['model_match'];
- $model_league = $models['model_league'];
- $result_record = $models['model_result_record'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'zq');
- $result =lm($model_match,"Sports")
- ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
- ->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')
- ->where([[$model_league.'.name_chinese','!=','']])
- ->where($where)
- ->get()
- ->toarray();
- //===获取当前赛事是否有赔率,如果没有则去除===
- $result = $this->commonFunction->Handle_Odds_Null($result,$models);
- foreach ($result as $k=>$v){
- $v['home_score'] = 0;
- $v['guest_score'] = 0;
- $v['match_time'] = 0;
- $v['match_process'] = '';
- $result[$k] = $v;
- }
- $data = [
- 'game_code'=>'zq',
- 'gameName'=>'足球',
- 'matchData'=>$result
- ];
- return $data;
- }
- /**
- * @throws \Exception
- * 首页篮球滚球
- */
- public function lqrollingball(){
- $models = $this->commonFunction->getModels('lq',1);
- $model_match = $models['model_match'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'lq');
- //统计联赛下的赛事及查询赛事
- $ret['game_code'] = 'lq';
- $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
- //如果赛事为空,直接返回
- if(empty($matchData)) return $matchData;
- //===获取当前赛事是否有赔率,如果没有则去除===
- $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
- $data = [
- 'game_code'=>'lq',
- 'gameName'=>'篮球',
- 'matchData'=>$matchData_new
- ];
- return $data;
- }
- public function __lqrollingball(){
- $models = $this->commonFunction->getModels('lq',1);
- $model_result = $models['model_result'];
- $model_match = $models['model_match'];
- $model_league = $models['model_league'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'lq');
- $result =lm($model_match,"Sports")
- ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
- ->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')
- ->where($where)
- ->where([[$model_league.'.name_chinese','!=','']])
- ->get()
- ->toarray();
-
- //===获取当前赛事是否有赔率,如果没有则去除===
- $result = $this->commonFunction->Handle_Odds_Null($result,$models);
- foreach ($result as $k=>$v){
- $v['home_score'] = 0;
- $v['guest_score'] = 0;
- $v['match_time'] = 0;
- $v['match_process'] = '';
- $result[$k] = $v;
- }
- $data = [
- 'game_code'=>'lq',
- 'gameName'=>'篮球',
- 'matchData'=>$result
- ];
- return $data;
- }
- public function wqrollingball(){
- $models = $this->commonFunction->getModels('wq',1);
- $model_match = $models['model_match'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'wq');
- //统计联赛下的赛事及查询赛事
- $ret['game_code'] = 'wq';
- $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
- //如果赛事为空,直接返回
- if(empty($matchData)) return $matchData;
- //===获取当前赛事是否有赔率,如果没有则去除===
- $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
- $data = [
- 'game_code'=>'wq',
- 'gameName'=>'网球',
- 'matchData'=>$matchData_new
- ];
- return $data;
- }
- public function __wqrollingball(){
- $models = $this->commonFunction->getModels('wq',1);
- $model_result = $models['model_result'];
- $model_match = $models['model_match'];
- $model_league = $models['model_league'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'wq');
- $result =lm($model_match,"Sports")
- ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
- ->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')
- ->where($where)
- ->where([[$model_league.'.name_chinese','!=','']])
- ->get()
- ->toarray();
- //===获取当前赛事是否有赔率,如果没有则去除===
- $result = $this->commonFunction->Handle_Odds_Null($result,$models);
- foreach ($result as $k=>$v){
- $v['first_inning_score'] = 0;
- $v['second_inning_score'] = 0;
- $v['third_inning_score'] = 0;
- $v['match_time'] = 0;
- $v['match_process'] = '';
- $result[$k] = $v;
- }
- $data = [
- 'game_code'=>'wq',
- 'gameName'=>'网球',
- 'matchData'=>$result
- ];
- return $data;
- }
- public function bqrollingball(){
- $models = $this->commonFunction->getModels('bq',1);
- $model_match = $models['model_match'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'bq');
- //统计联赛下的赛事及查询赛事
- $ret['game_code'] = 'bq';
- $matchData = matchModel::getRollMatchDataAll('',$models,$where,[],$ret);
- //如果赛事为空,直接返回
- if(empty($matchData)) return $matchData;
- //===获取当前赛事是否有赔率,如果没有则去除===
- $matchData_new = $this->commonFunction->Handle_Odds_Null($matchData,$models);
- $data = [
- 'game_code'=>'bq',
- 'gameName'=>'棒球',
- 'matchData'=>$matchData_new
- ];
- return $data;
- }
- public function __bqrollingball(){
- $models = $this->commonFunction->getModels('bq',1);
- $model_result = $models['model_result'];
- $model_match = $models['model_match'];
- $model_league = $models['model_league'];
- //获取 滚球查询条件
- $where = $this->commonFunction->getState('StRollBall',$model_match,'bq');
- $result =lm($model_match,"Sports")
- ->join($model_league,$model_league.'.id',$model_match.'.lg_id')
- ->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')
- ->where($where)
- ->where([[$model_league.'.name_chinese','!=','']])
- ->get()
- ->toarray();
- //===获取当前赛事是否有赔率,如果没有则去除===
- $result = $this->commonFunction->Handle_Odds_Null($result,$models);
- foreach ($result as $k=>$v){
- $v['home_score'] = 0;
- $v['guest_score'] = 0;
- $v['match_time'] = 0;
- $v['match_process'] = '';
- $result[$k] = $v;
- }
- $data = [
- 'game_code'=>'bq',
- 'gameName'=>'棒球',
- 'matchData'=>$result
- ];
- return $data;
- }
- /**
- * 获取所有球类滚球
- */
- public function getRollingBall(){
- $zqRollingBall = $this->zqrollingball();
- $lqRollingBall = $this->lqrollingball();
- $wqRollingBall = $this->wqrollingball();
- $bqRollingBall = $this->bqrollingball();
- $data = [
- 'zqData' =>$zqRollingBall,
- 'lqData' =>$lqRollingBall,
- 'wqData' =>$wqRollingBall,
- 'bqData' =>$bqRollingBall,
- ];
- Render($data, '1', lang('Tips','Sports')->get('success'));
- }
- }
|