|
@@ -339,7 +339,7 @@ class GetmatchData {
|
|
|
return $leagueData;
|
|
return $leagueData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $data = $this->getMatch($source,$model_league,$model_match,'',$search,$where);
|
|
|
|
|
|
|
+ $data = $this->getMatch($source,$models,$search,$where);
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -359,7 +359,7 @@ class GetmatchData {
|
|
|
return $leagueData;
|
|
return $leagueData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $data = $this->getMatch($source,$model_league,$model_match,'',$search,$where,$time);
|
|
|
|
|
|
|
+ $data = $this->getMatch($source,$models,$search,$where,$time);
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -380,7 +380,7 @@ class GetmatchData {
|
|
|
return $leagueData;
|
|
return $leagueData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $data = $this->getMatch($source,$model_league,$model_match,'',$search,$where,$time);
|
|
|
|
|
|
|
+ $data = $this->getMatch($source,$models,$search,$where,$time);
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -424,38 +424,38 @@ class GetmatchData {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//获取国家/洲下所有联赛及数量
|
|
//获取国家/洲下所有联赛及数量
|
|
|
- $data = $this->getMatch($source,$model_league,'',$model_odds,$search,$where,'',$type_code);
|
|
|
|
|
|
|
+ $data = $this->getMatch($source,$models,$search,$where,'',$type_code);
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取国家/洲 下联赛
|
|
* 获取国家/洲 下联赛
|
|
|
*/
|
|
*/
|
|
|
- public function getMatch($source,$model_league,$model_match='',$model_odds='',$search,$where,$time='',$type_code=''){
|
|
|
|
|
|
|
+ public function getMatch($source,$models,$search,$where,$time='',$type_code=''){
|
|
|
//国家下所有联赛
|
|
//国家下所有联赛
|
|
|
- $country = lm($model_league,"Sports")
|
|
|
|
|
- ->leftjoin('st_area_country','st_area_country.id',$model_league.'.country_id')
|
|
|
|
|
|
|
+ $country = lm($models['model_league'],"Sports")
|
|
|
|
|
+ ->leftjoin('st_area_country','st_area_country.id',$models['model_league'].'.country_id')
|
|
|
->select('st_area_country.id as country_id','st_area_country.name as region')
|
|
->select('st_area_country.id as country_id','st_area_country.name as region')
|
|
|
->distinct('st_area_country.name')
|
|
->distinct('st_area_country.name')
|
|
|
- ->where([[$model_league.'.name_chinese','!=','']])
|
|
|
|
|
- ->where($model_league.'.name_chinese','like','%'.$search.'%')
|
|
|
|
|
|
|
+ ->where([[$models['model_league'].'.name_chinese','!=','']])
|
|
|
|
|
+ ->where($models['model_league'].'.name_chinese','like','%'.$search.'%')
|
|
|
->get()
|
|
->get()
|
|
|
->toArray();
|
|
->toArray();
|
|
|
//洲下所有联赛
|
|
//洲下所有联赛
|
|
|
- $area = lm($model_league,"Sports")
|
|
|
|
|
- ->leftjoin('st_area_country','st_area_country.id',$model_league.'.area_id')
|
|
|
|
|
|
|
+ $area = lm($models['model_league'],"Sports")
|
|
|
|
|
+ ->leftjoin('st_area_country','st_area_country.id',$models['model_league'].'.area_id')
|
|
|
->select('st_area_country.id as area_id','st_area_country.name as region')
|
|
->select('st_area_country.id as area_id','st_area_country.name as region')
|
|
|
->distinct('st_area_country.name')
|
|
->distinct('st_area_country.name')
|
|
|
- ->where([[$model_league.'.name_chinese','!=','']])
|
|
|
|
|
- ->where($model_league.'.name_chinese','like','%'.$search.'%')
|
|
|
|
|
|
|
+ ->where([[$models['model_league'].'.name_chinese','!=','']])
|
|
|
|
|
+ ->where($models['model_league'].'.name_chinese','like','%'.$search.'%')
|
|
|
->get()
|
|
->get()
|
|
|
->toArray();
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
if($type_code != 'StChampion'){//非冠军赛事
|
|
if($type_code != 'StChampion'){//非冠军赛事
|
|
|
- $data = $this->getMatchNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
|
|
|
|
|
|
|
+ $data = $this->getMatchNum($source,$country,$area,$models,$where,$search,$time);
|
|
|
}else{//冠军赛事
|
|
}else{//冠军赛事
|
|
|
- $data = $this->getMatchStChampionNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
|
|
|
|
|
|
|
+ $data = $this->getMatchStChampionNum($source,$country,$area,$models,$where,$search,$time);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
return $data;
|
|
@@ -465,14 +465,15 @@ class GetmatchData {
|
|
|
* 获取联赛下赛事 数量
|
|
* 获取联赛下赛事 数量
|
|
|
* 非冠军盘口
|
|
* 非冠军盘口
|
|
|
*/
|
|
*/
|
|
|
- public function getMatchNum($source,$country,$area,$model_league,$model_match='',$model_odds='',$where,$search,$time='',$type=0){
|
|
|
|
|
- $leagueData = lm($model_league,'Sports')
|
|
|
|
|
|
|
+ public function getMatchNum($source,$country,$area,$models,$where,$search,$time='',$type=0){
|
|
|
|
|
+ $leagueData = lm($models['model_league'],'Sports')
|
|
|
->select('id as lg_id','name_chinese as league','country_id','area_id')
|
|
->select('id as lg_id','name_chinese as league','country_id','area_id')
|
|
|
- ->where([[$model_league.'.name_chinese','!=','']])
|
|
|
|
|
- ->where($model_league.'.name_chinese','like','%'.$search.'%')
|
|
|
|
|
|
|
+ ->where([[$models['model_league'].'.name_chinese','!=','']])
|
|
|
|
|
+ ->where($models['model_league'].'.name_chinese','like','%'.$search.'%')
|
|
|
->get()
|
|
->get()
|
|
|
->toArray();
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
+ //如果有时间条件
|
|
|
$timeWhere = [];
|
|
$timeWhere = [];
|
|
|
if(!empty($time)){
|
|
if(!empty($time)){
|
|
|
if($time == 'other'){
|
|
if($time == 'other'){
|
|
@@ -481,16 +482,49 @@ class GetmatchData {
|
|
|
$timeWhere[] = ['match_date',$time];
|
|
$timeWhere[] = ['match_date',$time];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $matchData = lm($model_match,'Sports')
|
|
|
|
|
|
|
+ //获取赛事
|
|
|
|
|
+ $matchData = lm($models['model_match'],'Sports')
|
|
|
->select('id as match_id','lg_id')
|
|
->select('id as match_id','lg_id')
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->where($timeWhere)
|
|
->where($timeWhere)
|
|
|
->get()
|
|
->get()
|
|
|
->toArray();
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
+ //如果赛事为空,直接返回
|
|
|
|
|
+ if(empty($matchData)) return $matchData;
|
|
|
|
|
+
|
|
|
|
|
+ //===获取当前赛事是否有赔率,如果没有则去除===
|
|
|
|
|
+ //获取当前match_id
|
|
|
|
|
+ $match_ids = [];
|
|
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
|
|
+ $match_ids[] = $v['match_id'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取下赛事赔率
|
|
|
|
|
+ $oddsData = lm($models['model_odds'],'Sports')
|
|
|
|
|
+ ->select('id','match_id')
|
|
|
|
|
+ ->whereIn('match_id',$match_ids)
|
|
|
|
|
+ ->get()
|
|
|
|
|
+ ->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ //根据match_id 去重
|
|
|
|
|
+ $oddsData = $this->commonFunction->array_unset_tt($oddsData,'match_id');
|
|
|
|
|
+ sort($oddsData);
|
|
|
|
|
+
|
|
|
|
|
+ //如果赔率为空,则返回空
|
|
|
|
|
+ if(empty($oddsData)) return $oddsData;
|
|
|
|
|
+ $matchData_new = [];
|
|
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
|
|
+ foreach($oddsData as $kk=>$vv){
|
|
|
|
|
+ if($v['match_id'] == $vv['match_id']){
|
|
|
|
|
+ $matchData_new[] = $matchData[$k];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //===赛事空赔率 处理end ===
|
|
|
|
|
+
|
|
|
//按国家
|
|
//按国家
|
|
|
$countryData = [];
|
|
$countryData = [];
|
|
|
- if(!empty($country) and !empty($leagueData) and !empty($matchData)){
|
|
|
|
|
|
|
+ if(!empty($country) and !empty($leagueData) and !empty($matchData_new)){
|
|
|
foreach ($country as $k=>$v){
|
|
foreach ($country as $k=>$v){
|
|
|
if($v['country_id']){
|
|
if($v['country_id']){
|
|
|
$countryData[$k] = $v;
|
|
$countryData[$k] = $v;
|
|
@@ -512,7 +546,7 @@ class GetmatchData {
|
|
|
|
|
|
|
|
//按地区
|
|
//按地区
|
|
|
$areaData = [];
|
|
$areaData = [];
|
|
|
- if(!empty($area) and !empty($leagueData) and($matchData)){
|
|
|
|
|
|
|
+ if(!empty($area) and !empty($leagueData) and($matchData_new)){
|
|
|
foreach ($area as $k=>$v){
|
|
foreach ($area as $k=>$v){
|
|
|
if($v['area_id']){
|
|
if($v['area_id']){
|
|
|
$areaData[$k] = $v;
|
|
$areaData[$k] = $v;
|
|
@@ -531,8 +565,8 @@ class GetmatchData {
|
|
|
unset($areaData[$k]);
|
|
unset($areaData[$k]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $countryData = $this->commonFunction->array_other_tt($countryData,$matchData);
|
|
|
|
|
- $areaData = $this->commonFunction->array_other_tt($areaData,$matchData);
|
|
|
|
|
|
|
+ $countryData = $this->commonFunction->array_other_tt($countryData,$matchData_new);
|
|
|
|
|
+ $areaData = $this->commonFunction->array_other_tt($areaData,$matchData_new);
|
|
|
$data = array_merge($countryData,$areaData);
|
|
$data = array_merge($countryData,$areaData);
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
@@ -541,16 +575,16 @@ class GetmatchData {
|
|
|
* 获取联赛下赛事 数量
|
|
* 获取联赛下赛事 数量
|
|
|
* 冠军盘口
|
|
* 冠军盘口
|
|
|
*/
|
|
*/
|
|
|
- public function getMatchStChampionNum($source,$country,$area,$model_league,$model_match='',$model_odds='',$where,$search,$time='',$type=0){
|
|
|
|
|
|
|
+ public function getMatchStChampionNum($source,$country,$area,$models,$where,$search,$time='',$type=0){
|
|
|
|
|
|
|
|
- $leagueData = lm($model_league,'Sports')
|
|
|
|
|
|
|
+ $leagueData = lm($models['model_league'],'Sports')
|
|
|
->select('id as lg_id','name_chinese as league','country_id','area_id')
|
|
->select('id as lg_id','name_chinese as league','country_id','area_id')
|
|
|
- ->where([[$model_league.'.name_chinese','!=','']])
|
|
|
|
|
- ->where($model_league.'.name_chinese','like','%'.$search.'%')
|
|
|
|
|
|
|
+ ->where([[$models['model_league'].'.name_chinese','!=','']])
|
|
|
|
|
+ ->where($models['model_league'].'.name_chinese','like','%'.$search.'%')
|
|
|
->get()
|
|
->get()
|
|
|
->toArray();
|
|
->toArray();
|
|
|
|
|
|
|
|
- $oddsData = lm($model_odds,'Sports')
|
|
|
|
|
|
|
+ $oddsData = lm($models['model_odds'],'Sports')
|
|
|
->select('id','lg_id','p_code')
|
|
->select('id','lg_id','p_code')
|
|
|
->distinct("p_code")//去重
|
|
->distinct("p_code")//去重
|
|
|
->where($where)
|
|
->where($where)
|
|
@@ -654,20 +688,52 @@ class GetmatchData {
|
|
|
->get()
|
|
->get()
|
|
|
->toarray();
|
|
->toarray();
|
|
|
|
|
|
|
|
|
|
+ //如果赛事为空,直接返回
|
|
|
|
|
+ if(empty($matchData)) return $matchData;
|
|
|
|
|
+
|
|
|
|
|
+ //===获取当前赛事是否有赔率,如果没有则去除===
|
|
|
|
|
+ //获取当前match_id
|
|
|
|
|
+ $match_ids = [];
|
|
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
|
|
+ $match_ids[] = $v['match_id'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取下赛事赔率
|
|
|
|
|
+ $oddsData = lm($model_odds,'Sports')
|
|
|
|
|
+ ->select('id','match_id')
|
|
|
|
|
+ ->whereIn('match_id',$match_ids)
|
|
|
|
|
+ ->get()
|
|
|
|
|
+ ->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ //根据match_id 去重
|
|
|
|
|
+ $oddsData = $this->commonFunction->array_unset_tt($oddsData,'match_id');
|
|
|
|
|
+ sort($oddsData);
|
|
|
|
|
+
|
|
|
|
|
+ //如果赔率为空,则返回空
|
|
|
|
|
+ if(empty($oddsData)) return $oddsData;
|
|
|
|
|
+ $matchData_new = [];
|
|
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
|
|
+ foreach($oddsData as $kk=>$vv){
|
|
|
|
|
+ if($v['match_id'] == $vv['match_id']){
|
|
|
|
|
+ $matchData_new[] = $matchData[$k];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //===赛事空赔率 处理end ===
|
|
|
|
|
+
|
|
|
//获取各球类默认赔率
|
|
//获取各球类默认赔率
|
|
|
$game_code = $_REQUEST['game_code'];
|
|
$game_code = $_REQUEST['game_code'];
|
|
|
switch ($game_code) {
|
|
switch ($game_code) {
|
|
|
case 'zq'://足球
|
|
case 'zq'://足球
|
|
|
- $matchData = $this->getOddsData->getOddsZQ($matchData, $model_odds, $source,$oddsTypeWhere);
|
|
|
|
|
|
|
+ $matchData = $this->getOddsData->getOddsZQ($matchData_new, $model_odds, $source,$oddsTypeWhere);
|
|
|
break;
|
|
break;
|
|
|
case 'lq'://篮球
|
|
case 'lq'://篮球
|
|
|
- $matchData = $this->getOddsData->getOddsLQ($matchData, $model_odds, $source,$oddsTypeWhere);
|
|
|
|
|
|
|
+ $matchData = $this->getOddsData->getOddsLQ($matchData_new, $model_odds, $source,$oddsTypeWhere);
|
|
|
break;
|
|
break;
|
|
|
case 'wq'://网球
|
|
case 'wq'://网球
|
|
|
- $matchData = $this->getOddsData->getOddsWQ($matchData, $model_odds, $source,$oddsTypeWhere);
|
|
|
|
|
|
|
+ $matchData = $this->getOddsData->getOddsWQ($matchData_new, $model_odds, $source,$oddsTypeWhere);
|
|
|
break;
|
|
break;
|
|
|
case 'bq'://棒球
|
|
case 'bq'://棒球
|
|
|
- $matchData = $this->getOddsData->getOddsBQ($matchData, $model_odds, $source,$oddsTypeWhere);
|
|
|
|
|
|
|
+ $matchData = $this->getOddsData->getOddsBQ($matchData_new, $model_odds, $source,$oddsTypeWhere);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
$leagueData->matchNum = count($matchData);
|
|
$leagueData->matchNum = count($matchData);
|