date = date('Y-m-d');//当前日期时间戳 } /* * 首页体育-足球比赛数据 */ private function football(){ $data=[]; $data['name'] = '足球'; $data['game_code'] = 'zq'; //查询今日正在进行的和未开始的足球比赛 $data['match'] = lm("st_zq_competition","Sports") ->leftjoin('st_zq_odds','st_zq_odds.match_id','=','st_zq_competition.match_id') ->leftjoin('st_zq_league','st_zq_league.id','=','st_zq_competition.lg_id') ->select('st_zq_competition.match_id','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time') ->where('st_zq_competition.match_date',$this->date) ->where('st_zq_league.source',$this->source) ->whereIn('st_zq_competition.status',['0','1']) ->limit('2') ->get(); //今日联赛 $lg_id = lm('st_zq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray(); if (!empty($lg_id)) { foreach($lg_id as $k => $v){ $data['league'][$k]['lg_id'] = $v['lg_id']; $data['league'][$k]['name'] = lm('st_zq_league','Sports')->where('lg_id',$v['lg_id'])->where('source',$this->source)->value('name_chinese'); $data['league'][$k]['count'] = lm('st_zq_competition','Sports')->where('source',$this->source)->where('lg_id',$v['lg_id'])->count(); } }else { $data['league'] =[]; } return $data; } /* * 首页体育-篮球比赛数据 */ private function basketball(){ $data=[]; $data['name']='篮球'; $data['game_code'] = 'lq'; //查询今日正在进行的和未开始的足球比赛/2 $data['match'] = lm("st_lq_competition","Sports") ->leftjoin('st_lq_odds','st_lq_odds.match_id','=','st_lq_competition.match_id') ->leftjoin('st_lq_league','st_lq_league.id','=','st_lq_competition.lg_id') ->select('st_lq_competition.match_id','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time') ->where('st_lq_competition.match_date',$this->date) ->where('st_lq_competition.source',$this->source) ->whereIn('st_lq_competition.status',['0','1']) ->limit('2') ->get(); //今日联赛 $lg_id = lm('st_lq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray(); if (!empty($lg_id)) { foreach($lg_id as $k => $v){ $data['league'][$k]['lg_id'] = $v['lg_id']; $data['league'][$k]['name'] = lm('st_lq_league','Sports') ->where($this->source) ->where('lg_id',$v['lg_id']) ->value('name_chinese'); $data['league'][$k]['count'] = lm('st_lq_league','Sports') ->where($this->source) ->where('lg_id',$v['lg_id']) ->count(); } }else { $data['league'] =[]; } return $data; } /* * 首页体育-网球比赛数据 */ private function tennis(){ $data=[]; $data['name']='网球'; $data['game_code'] = 'wq'; //查询今日正在进行的和未开始的足球比赛/2 $data['match'] = lm("st_wq_competition","Sports") ->leftjoin('st_wq_odds','st_wq_odds.match_id','=','st_wq_competition.match_id') ->leftjoin('st_wq_league','st_wq_league.id','=','st_wq_competition.lg_id') ->select('st_wq_competition.match_id','st_wq_competition.home_team','st_wq_competition.guest_team','st_wq_competition.match_date','st_wq_competition.match_time') ->where('st_wq_competition.match_date',$this->date) ->where('st_wq_competition.source',$this->source) ->whereIn('st_wq_competition.status',['0','1']) ->limit('2') ->get(); //今日联赛 $lg_id = lm('st_wq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray(); if (!empty($lg_id)) { foreach($lg_id as $k => $v){ $data['league'][$k]['lg_id'] = $v['lg_id']; $data['league'][$k]['name'] = lm('st_wq_league','Sports') ->where('source',$this->source) ->where('lg_id',$v['lg_id']) ->value('name_chinese'); $data['league'][$k]['count'] = lm('st_wq_competition','Sports') ->where('source',$this->source) ->where('lg_id',$v['lg_id']) ->count(); } }else { $data['league'] =[]; } return $data; } /* * 首页体育-棒球比赛数据 */ private function baseball(){ $data=[]; $data['name']='棒球'; $data['game_code'] = 'bq'; //查询今日正在进行的和未开始的足球比赛/2 $data['match'] = lm("st_bq_competition","Sports") ->leftjoin('st_bq_odds','st_bq_odds.match_id','=','st_bq_competition.match_id') ->leftjoin('st_bq_league','st_bq_league.id','=','st_bq_competition.lg_id') ->select('st_bq_competition.match_id','st_bq_competition.home_team','st_bq_competition.guest_team','st_bq_competition.match_date','st_bq_competition.match_time') ->where('st_bq_competition.match_date',$this->date) ->where('st_bq_competition.source',$this->source) ->whereIn('st_bq_competition.status',['0','1']) ->limit('2') ->get(); //今日联赛 $lg_id = lm('st_bq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray(); if (!empty($lg_id)) { foreach($lg_id as $k => $v){ $data['league'][$k]['lg_id'] = $v['lg_id']; $data['league'][$k]['name'] = lm('st_bq_league','Sports') ->where('source',$this->source) ->where('lg_id',$v['lg_id']) ->value('name_chinese'); $data['league'][$k]['count'] = lm('st_bq_competition','Sports') ->where('source',$this->source) ->where('lg_id',$v['lg_id']) ->count(); } }else { $data['league'] =[]; } return $data; } /* * 返回数据 */ public function data(){ $lq[] = $this->basketball(); $wq[] = $this->tennis(); $bq[] = $this->baseball(); $zq[] = $this->football(); $data = array_add($zq,$lq,$wq,$bq); Render($data,'1', lang('Tips','Sports')->get('success')); } }