where('game_code',$game_code)->value('game_name'); $data['game_code'] = 'zq'; //===查询该球类Models=== $getModels = getModels($game_code); $st_league = $getModels['model_league']; $st_competition = $getModels['model_match']; //查询足球早盘其他球的所有赛事 if ($data['game_code'] == 'zq'){ $data['today']['name'] ='今日赛事'; $data['today']['count'] = lm('st_zq_competition','Sports') ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id') ->where(getState('StToday')) ->where('st_zq_competition.source',$this->source['source']) ->distinct('st_zq_competition.match_id') ->count('*'); } else { $data['all']['name'] = '所有赛事'; $data['today']['count'] = lm($st_competition,'Sports') ->where([[$st_competition.'.status', '<', '2'], [$st_competition.'.source',$this->source['source']]]) ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)) ->count('*'); } //查询正在进行的和未开始的球类比赛 $data['match'] = lm($st_competition,"Sports") ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id') ->select($st_competition.'.match_id',$st_competition.'.home_team',$st_competition.'.guest_team',$st_competition.'.match_date',$st_competition.'.match_time') ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]]) ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)) ->where($where) ->limit($limit_mt) ->get(); if(!empty($data['match'])){ $data['match'] = $data['match']->toarray(); } //获取正在进行的和未开始联赛 $data['league'] = lm($st_competition,"Sports") ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id') ->select($st_league.'.lg_id',$st_league.'.name_chinese') ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]]) ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)) ->where($where) ->limit($limit_lg) ->distinct($st_league.'lg_id') ->get(); if (!empty($data['league'])) { $data['league'] = $data['league']->toarray(); foreach($data['league'] as $k => $v){ //统计当前联赛下的联赛 $data['league'][$k]['count'] = lm($st_competition,'Sports') ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]]) ->where('lg_id',$v['lg_id']) ->where($where) ->count('*'); } } return $data; } /* * 获取首页体育信息数据接口 */ public function data(){ $where = [];//球类额外条件 $lq[] = $this->Sports_info('lq',$where); $wq[] = $this->Sports_info('wq',$where); $bq[] = $this->Sports_info('bq',$where); $zq[] = $this->Sports_info('zq',$where); $data = array_merge_recursive($zq,$lq,$bq,$wq); Render($data,'1', lang('Tips','Sports')->get('success')); } }