|
|
@@ -28,8 +28,9 @@ class MatchListWeb extends Controller{
|
|
|
public function gameList(){
|
|
|
|
|
|
$type = $_REQUEST['type'];//状态代码
|
|
|
- $game_code= $_REQUEST['game_code'];//球类代码
|
|
|
- $p_code= $_REQUEST['p_code'];//父级玩法代码
|
|
|
+ $game_code = $_REQUEST['game_code'];//球类代码
|
|
|
+ $p_code = $_REQUEST['p_code'];//父级玩法代码
|
|
|
+ $time = $_REQUEST['match_date'];//时间条件
|
|
|
|
|
|
try {
|
|
|
if(empty($type) ){
|
|
|
@@ -40,16 +41,16 @@ class MatchListWeb extends Controller{
|
|
|
$this->getRollBall($type,$game_code,$p_code);
|
|
|
break;
|
|
|
case 'StSoon'://即将
|
|
|
- $this->Other($type,$game_code,$p_code);
|
|
|
+ $this->Other($type,$game_code,$p_code,$time);
|
|
|
break;
|
|
|
case 'StToday'://今日
|
|
|
- $this->Other($type,$game_code,$p_code);
|
|
|
+ $this->Other($type,$game_code,$p_code,$time);
|
|
|
break;
|
|
|
case 'StMorningPlate'://早盘
|
|
|
- $this->Other($type,$game_code,$p_code);
|
|
|
+ $this->Other($type,$game_code,$p_code,$time);
|
|
|
break;
|
|
|
case 'StStringScene'://串场
|
|
|
- $this->Other($type,$game_code,$p_code);
|
|
|
+ $this->Other($type,$game_code,$p_code,$time);
|
|
|
break;
|
|
|
default:
|
|
|
throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
|
|
|
@@ -70,30 +71,11 @@ class MatchListWeb extends Controller{
|
|
|
}
|
|
|
|
|
|
$game = lm('GameType', 'Sports')->select('game_code')->where('status',1)->get()->toArray();
|
|
|
-// $gameData = [];
|
|
|
-// foreach ($game as $k=>$v){
|
|
|
-// if($v['game_code'] !='gj'){
|
|
|
-// $where = $this->commonFunction->getState($type);
|
|
|
-// $models = $this->commonFunction->getModels($v['game_code'],1);
|
|
|
-// $matchNum = lm($models['model_league'],"Sports")
|
|
|
-// ->join($models['model_match'],$models['model_match'].'.lg_id',$models['model_league'].'.lg_id')
|
|
|
-// ->where($models['model_match'].'.source',$this->source['source'])
|
|
|
-// ->where($where)
|
|
|
-// ->count("*");
|
|
|
-// //获取满足状态的球类
|
|
|
-// if($matchNum != 0){
|
|
|
-// $gameData[$v['game_code']] = $matchNum;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $gameData['all_num'] = array_sum($gameData);
|
|
|
-// $data[] = $gameData;
|
|
|
-// Render($data, '1', lang('Tips','Sports')->get('success'));
|
|
|
$gameData = [];
|
|
|
foreach ($game as $k=>$v){
|
|
|
if($v['game_code'] !='gj'){
|
|
|
- $where = $this->commonFunction->getState($type);
|
|
|
$models = $this->commonFunction->getModels($v['game_code'],1);
|
|
|
+ $where = $this->commonFunction->getState($type,$models['model_match']);
|
|
|
$matchNum = lm($models['model_league'],"Sports")
|
|
|
->join($models['model_match'],$models['model_match'].'.lg_id',$models['model_league'].'.lg_id')
|
|
|
->where($models['model_match'].'.source',$this->source['source'])
|
|
|
@@ -116,10 +98,10 @@ class MatchListWeb extends Controller{
|
|
|
Render($gameData, '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
|
//获取非滚球数据
|
|
|
- public function Other($type,$game_code,$p_code){
|
|
|
+ public function Other($type,$game_code,$p_code,$time=''){
|
|
|
//根据球类代码及玩法代码 获取相关赛事赔率数据
|
|
|
if(!empty($game_code) and !empty($p_code)){
|
|
|
- $matchData = $this->getMatchData($type,$game_code,$p_code);
|
|
|
+ $matchData = $this->getMatchData($type,$game_code,$p_code,$time);
|
|
|
|
|
|
Render($matchData, '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
|
@@ -143,27 +125,43 @@ class MatchListWeb extends Controller{
|
|
|
}
|
|
|
|
|
|
//获取赛事数据
|
|
|
- public function getMatchData($type,$game_code,$p_code=''){
|
|
|
+ public function getMatchData($type,$game_code,$p_code='',$time=''){
|
|
|
//$p_code 获取具体玩法下的赛事数据
|
|
|
- $where = $this->commonFunction->getState($type);
|
|
|
$models = $this->commonFunction->getModels($game_code,1);
|
|
|
+ $where = $this->commonFunction->getState($type,$models['model_match']);
|
|
|
+
|
|
|
$select = [$models['model_match'].'.match_id'];
|
|
|
+ $timeWhere = [];
|
|
|
if($p_code){
|
|
|
+ //时间条件
|
|
|
+ if(!empty($time)){
|
|
|
+ if($time == 'other'){
|
|
|
+ $timeWhere[] = ['match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time()))))];
|
|
|
+ }else{
|
|
|
+ $timeWhere[] = ['match_date',$time];
|
|
|
+ }
|
|
|
+ }
|
|
|
if($p_code == 'kemp'){
|
|
|
- $select = [$models['model_league'].'.lg_id',$models['model_league'].'.name_chinese as leagueName','last_time'];
|
|
|
+ $select = [$models['model_league'].'.lg_id',$models['model_league'].'.name_chinese as leagueName','last_time','country_id','area_id'];
|
|
|
}else{
|
|
|
- $select = [$models['model_league'].'.lg_id',$models['model_league'].'.name_chinese as leagueName',$models['model_match'].'.match_id','home_team','guest_team','match_date','match_time','tag'];
|
|
|
+ $select = [$models['model_league'].'.lg_id',$models['model_league'].'.name_chinese as leagueName',$models['model_match'].'.match_id','home_team','guest_team','match_date','match_time','tag','country_id','area_id'];
|
|
|
}
|
|
|
}
|
|
|
+ //国家数据
|
|
|
+ $country = lm('st_country',"Sports")
|
|
|
+ ->select('country_id','name_chinese')
|
|
|
+ ->get()->toArray();
|
|
|
|
|
|
+ //赛事数据
|
|
|
$matchNum = lm($models['model_league'],"Sports")
|
|
|
->join($models['model_match'],$models['model_match'].'.lg_id',$models['model_league'].'.lg_id')
|
|
|
-// ->select($models['model_league'].'.lg_id',$models['model_league'].'.name_chinese as leagueName',$models['model_match'].'.match_id','home_team','guest_team','match_date','match_time','tag')
|
|
|
->select($select)
|
|
|
->where($models['model_match'].'.source',$this->source['source'])
|
|
|
->where($where)
|
|
|
+ ->where($timeWhere)
|
|
|
->get()->toArray();
|
|
|
|
|
|
+ //赔率数据
|
|
|
$oddsCodeNum = $this->getOddsData($game_code,$models['model_odds'],$matchNum,$p_code);
|
|
|
if($p_code){
|
|
|
$match_odds = [];
|
|
|
@@ -218,15 +216,34 @@ class MatchListWeb extends Controller{
|
|
|
foreach ($matchNum as $k=>$v){
|
|
|
foreach ($match_odds as $kk=>$vv){
|
|
|
if($v['lg_id'] == $vv['lg_id']){
|
|
|
+ $data[$k]['area_id'] = $v['area_id'];
|
|
|
+ $data[$k]['country_id'] = $v['country_id'];
|
|
|
$data[$k]['lg_id'] = $v['lg_id'];
|
|
|
$data[$k]['leagueName'] = $v['leagueName'];
|
|
|
$data[$k]['matchData'][] = $vv;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //去重
|
|
|
- $data = $this->uniquArr($data,'lg_id');
|
|
|
+ //赛事详细数据 去重
|
|
|
+ $matchData = $this->uniquArr($data,'lg_id');
|
|
|
+
|
|
|
+ //获取国家联赛列表
|
|
|
+ $leagueList = [];
|
|
|
+ foreach ($country as $k=>$v){
|
|
|
+ foreach ($matchData as $kk=>$vv){
|
|
|
+ if($v['country_id'] == $vv['country_id']){
|
|
|
+ //联赛下赛事数量
|
|
|
+ $vv['matchNum'] = count($vv['matchData']);
|
|
|
+ unset($vv['matchData']);
|
|
|
+ $v['lg_list'][] = $vv;
|
|
|
+ $leagueList[$k] = $v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sort($leagueList);
|
|
|
|
|
|
+ //国家-联赛列表
|
|
|
+ $data = [$matchData,$leagueList];
|
|
|
return $data;
|
|
|
}
|
|
|
return $oddsCodeNum;
|
|
|
@@ -364,4 +381,14 @@ class MatchListWeb extends Controller{
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
+
|
|
|
+ //获取直播数据
|
|
|
+ public function getBroadcast(){
|
|
|
+ $data = lm('st_broadcast',"Sports")
|
|
|
+ ->select('id','showid','shower','league_name','game_type','host_team','guest_team','start_time','doing')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ Render($data, '1', lang('Tips','Sports')->get('success'));
|
|
|
+ }
|
|
|
}
|