where($where)->orderBy($sort,$orderby)->get(); return $matchData; } /* * 获取各球类 滚球赛事关联赛事结果数据 */ public static function getRollMatchDataAll($source,$models,$where,$lg_ids=[]){ $model_match = $models['model_match']; $model_result = $models['model_result']; $select = [$model_match.'.lg_id',$model_match.'.id as match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team']; //获取赛事数据 $matchData = lm($model_match,"Sports") ->select($select) ->whereIn($model_match.'.lg_id',$lg_ids) ->where($where) ->get() ->toarray(); $match_ids = []; foreach ($matchData as $k=>$v){ $match_ids[] = $v['match_id']; } //查询 赛事结果记录最新的一条 $match_ids_str = implode(",", $match_ids); $result_record = $models['model_result_record']; $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process from $result_record a, (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b where a.match_id = b.match_id and a.id = b.id "; //如果是网球 if($result_record == 'st_wq_result_record'){ $sql = "select a.match_id,a.home_player_score,a.guest_player_score,a.match_time as a_time,a.match_process from $result_record a, (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b where a.match_id = b.match_id and a.id = b.id "; } $match_result_record = S ('DB')->select ($sql); //处理赛事数据,追加比分及进程 foreach ($matchData as $k=>$v){ foreach ($match_result_record as $kk => $vv){ if($v['match_id'] == $vv->match_id){ //如果是网球 if($model_result == 'st_wq_result'){ $matchData[$k]['home_player_score'] = $vv->home_player_score; $matchData[$k]['guest_player_score'] = $vv->guest_player_score; }else{ $matchData[$k]['home_score'] = $vv->home_score; $matchData[$k]['guest_score'] = $vv->guest_score; } $matchData[$k]['a_time'] = $vv->a_time; $matchData[$k]['match_process'] = $vv->match_process; } } } return $matchData; } /* * 获取各球类 非滚球赛事关联赛事结果数据 */ public static function getSoonMatchDataAll($source,$models,$where,$lg_ids=[]){ $model_match = $models['model_match']; $data = lm($model_match,"Sports") ->select($model_match.'.lg_id',$model_match.'.id as match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team',$model_match.'.us_time') ->where($where) ->whereIn($model_match.'.lg_id',$lg_ids) ->orderBy('match_time','asc') ->get() ->toarray(); return $data; } }