|
|
@@ -7,9 +7,14 @@
|
|
|
*/
|
|
|
|
|
|
namespace Biz\Match;
|
|
|
+use Biz\Match\GetOddsData;
|
|
|
|
|
|
class GetmatchData {
|
|
|
|
|
|
+ public function __construct() {
|
|
|
+ $this->getOddsData = new GetOddsData();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param $ret 提交参数
|
|
|
* @param $source 数据源条件
|
|
|
@@ -49,10 +54,10 @@ class GetmatchData {
|
|
|
if(empty($ret['match_date'])){
|
|
|
$match_date = date("Y-m-d");
|
|
|
}else{
|
|
|
- if($ret['match_date'] == 'other'){
|
|
|
+ if($ret['match_date'] != 'other'){
|
|
|
$match_date = $ret['match_date'];
|
|
|
}else{
|
|
|
- $match_date = date("Y-m-d");
|
|
|
+ $match_date = 'other';
|
|
|
}
|
|
|
}
|
|
|
$data = $this->getMorningPlate($source,$models,$where,$lg_id,$search,$match_date);
|
|
|
@@ -67,11 +72,11 @@ class GetmatchData {
|
|
|
}
|
|
|
if($ret['str_type'] == 2){//冠军盘口
|
|
|
$where = getState('StChampion',$model_match);
|
|
|
- $data = $this->getChampion($source,$models,$where,$lg_id,$search);
|
|
|
+ $data = $this->getChampion($source,$models,$where,$lg_id,$search,'StChampion');
|
|
|
}
|
|
|
break;
|
|
|
case 'StChampion'://冠军
|
|
|
- $data = $this->getChampion($source,$models,$where,$lg_id,$search);
|
|
|
+ $data = $this->getChampion($source,$models,$where,$lg_id,$search,$ret['type_code']);
|
|
|
break;
|
|
|
default:
|
|
|
throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
|
|
|
@@ -339,7 +344,7 @@ class GetmatchData {
|
|
|
/**
|
|
|
* 获取冠军数据
|
|
|
*/
|
|
|
- public function getChampion($source,$models,$where,$lg_id=0,$search=''){
|
|
|
+ public function getChampion($source,$models,$where,$lg_id=0,$search='',$type_code=''){
|
|
|
|
|
|
//获取model
|
|
|
$model_odds = $models['model_odds'];
|
|
|
@@ -379,18 +384,18 @@ class GetmatchData {
|
|
|
}
|
|
|
|
|
|
//获取国家/洲下所有联赛及数量
|
|
|
- $data = $this->getMatch($source,$model_league,'',$model_odds,$search,$where,'');
|
|
|
+ $data = $this->getMatch($source,$model_league,'',$model_odds,$search,$where,'',$type_code);
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取国家/洲 下联赛
|
|
|
*/
|
|
|
- public function getMatch($source,$model_league,$model_match='',$model_odds='',$search,$where,$time=''){
|
|
|
+ public function getMatch($source,$model_league,$model_match='',$model_odds='',$search,$where,$time='',$type_code=''){
|
|
|
//国家下所有联赛
|
|
|
$country = lm($model_league,"Sports")
|
|
|
->leftjoin('st_country','st_country.country_id',$model_league.'.country_id')
|
|
|
- ->select('st_country.country_id as region_id','st_country.name_chinese as region')
|
|
|
+ ->select('st_country.country_id','st_country.name_chinese as region')
|
|
|
// ->select('st_country.country_id as region_id','st_country.name_chinese as region',$model_league.'.lg_id', $model_league.'.name_chinese as league')
|
|
|
->distinct('st_country.name_chinese')
|
|
|
->where($model_league.'.source',$source['source'])
|
|
|
@@ -400,7 +405,7 @@ class GetmatchData {
|
|
|
//洲下所有联赛
|
|
|
$area = lm($model_league,"Sports")
|
|
|
->leftjoin('st_area','st_area.id',$model_league.'.area_id')
|
|
|
- ->select('st_area.id as region_id','st_area.title as region')
|
|
|
+ ->select('st_area.id as area_id','st_area.title as region')
|
|
|
// ->select('st_area.id as region_id','st_area.title as region',$model_league.'.lg_id', $model_league.'.name_chinese as league')
|
|
|
->distinct('st_area.title')
|
|
|
->where($model_league.'.source',$source['source'])
|
|
|
@@ -409,39 +414,33 @@ class GetmatchData {
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
- $data = $this->getMatchNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
|
|
|
+ if($type_code != 'StChampion'){//非冠军赛事
|
|
|
+ $data = $this->getMatchNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
|
|
|
+ }else{//冠军赛事
|
|
|
+ $data = $this->getMatchStChampionNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
|
|
|
+ }
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取联赛下赛事/盘口 数量
|
|
|
+ * 获取联赛下赛事 数量
|
|
|
+ * 非冠军盘口
|
|
|
*/
|
|
|
public function getMatchNum($source,$country,$area,$model_league,$model_match='',$model_odds='',$where,$search,$time='',$type=0){
|
|
|
//统计国家下联赛-赛事/盘口数量
|
|
|
if(!empty($country)){
|
|
|
+
|
|
|
foreach($country as $k => $v) {
|
|
|
$country[$k]['league_count'] = lm($model_league, 'Sports')
|
|
|
->select('lg_id', 'name_chinese as league')
|
|
|
->where($source)
|
|
|
- ->where('country_id', $v['region_id'])
|
|
|
+ ->where('country_id', $v['country_id'])
|
|
|
->where($model_league.'.name_chinese','like','%'.$search.'%')
|
|
|
->get()->toarray();
|
|
|
}
|
|
|
foreach ($country as $k => $v) {
|
|
|
foreach($v['league_count'] as $kk => $vv ){
|
|
|
- if(!empty($model_odds)){//冠军玩法,获取赔率盘口数量
|
|
|
- $where = getState('StChampion');
|
|
|
- $country[$k]['league_count'][$kk]['count'] = lm($model_odds, 'Sports')
|
|
|
- ->select("p_code")
|
|
|
- ->where($source)
|
|
|
- ->where('lg_id',$vv['lg_id'])
|
|
|
- ->where($where)
|
|
|
-// ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
|
|
|
- ->distinct("p_code")
|
|
|
- ->count("p_code");
|
|
|
- }
|
|
|
-
|
|
|
if(!empty($model_match)){//非冠军玩法,获取联赛下赛事数量
|
|
|
if(empty($time)){
|
|
|
$country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
@@ -450,8 +449,8 @@ class GetmatchData {
|
|
|
->where('lg_id',$vv['lg_id'])
|
|
|
->where($where)
|
|
|
->count("*");
|
|
|
- }else{
|
|
|
- if($time == 'other'){
|
|
|
+ }else{//今日赛事 下有时间查询
|
|
|
+ if($time == 'other'){//今日 一周后
|
|
|
$country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
->select("match_id")
|
|
|
->where($source)
|
|
|
@@ -460,13 +459,24 @@ class GetmatchData {
|
|
|
->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
|
|
|
->count("*");
|
|
|
}else{
|
|
|
- $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
- ->select("match_id")
|
|
|
- ->where($source)
|
|
|
- ->where('lg_id',$vv['lg_id'])
|
|
|
- ->where($where)
|
|
|
- ->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
|
|
|
- ->count("*");
|
|
|
+ if($time != date("Y-m-d")){//大于今日
|
|
|
+ $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
+ ->select("match_id")
|
|
|
+ ->where($source)
|
|
|
+ ->where('lg_id',$vv['lg_id'])
|
|
|
+ ->where($where)
|
|
|
+ ->where('match_date',$time)
|
|
|
+ ->count("*");
|
|
|
+ }else{//如果是今天,则获取今天未开始
|
|
|
+ $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
+ ->select("match_id")
|
|
|
+ ->where($source)
|
|
|
+ ->where('lg_id',$vv['lg_id'])
|
|
|
+ ->where('is_morningplate','=',1)
|
|
|
+ ->where('match_time','>',date("H:i:s", time()))
|
|
|
+ ->where('match_date',$time)
|
|
|
+ ->count("*");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -484,23 +494,12 @@ class GetmatchData {
|
|
|
$area[$k]['league_count'] = lm($model_league, 'Sports')
|
|
|
->select('lg_id', 'name_chinese as league')
|
|
|
->where($source)
|
|
|
- ->where('area_id', $v['region_id'])
|
|
|
+ ->where('area_id', $v['area_id'])
|
|
|
->where($model_league.'.name_chinese','like','%'.$search.'%')
|
|
|
->get()->toarray();
|
|
|
}
|
|
|
foreach ($area as $k => $v) {
|
|
|
foreach($v['league_count'] as $kk => $vv ){
|
|
|
- if(!empty($model_odds)){//冠军玩法,获取赔率盘口数量
|
|
|
- $where = getState('StChampion');
|
|
|
- $area[$k]['league_count'][$kk]['count'] = lm($model_odds, 'Sports')
|
|
|
- ->select("p_code")
|
|
|
- ->where($source)
|
|
|
- ->where('lg_id',$vv['lg_id'])
|
|
|
- ->where($where)
|
|
|
-// ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
|
|
|
- ->distinct("p_code")
|
|
|
- ->count("p_code");
|
|
|
- }
|
|
|
if(!empty($model_match)){//非冠军玩法,获取联赛下赛事数量
|
|
|
if(empty($time)){
|
|
|
$area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
@@ -510,7 +509,7 @@ class GetmatchData {
|
|
|
->where($where)
|
|
|
->count("*");
|
|
|
}else {
|
|
|
- if ($time == 'other') {
|
|
|
+ if ($time == 'other') {// 今日 一周后
|
|
|
$area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
->select("match_id")
|
|
|
->where($source)
|
|
|
@@ -518,17 +517,28 @@ class GetmatchData {
|
|
|
->where($where)
|
|
|
->where('match_date', '>', date("Y-m-d", strtotime("+1weeks", strtotime(date('Y-m-d', time())))))
|
|
|
->count("*");
|
|
|
- } else {
|
|
|
- $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
- ->select("match_id")
|
|
|
- ->where($source)
|
|
|
- ->where('lg_id', $vv['lg_id'])
|
|
|
- ->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
|
|
|
- ->where('match_date', $time)
|
|
|
- ->count("*");
|
|
|
+ } else {//今日 大于今日
|
|
|
+ if($time != date("Y-m-d")){//如果查询时间不是今天,则大于今天
|
|
|
+ $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
+ ->select("match_id")
|
|
|
+ ->where($source)
|
|
|
+ ->where('lg_id',$vv['lg_id'])
|
|
|
+ ->where($where)
|
|
|
+ ->where('match_date',$time)
|
|
|
+ ->count("*");
|
|
|
+ }else{//如果是今天,则获取今天未开始
|
|
|
+ $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
|
|
|
+ ->select("match_id")
|
|
|
+ ->where($source)
|
|
|
+ ->where('lg_id',$vv['lg_id'])
|
|
|
+ ->where('is_morningplate','=',1)
|
|
|
+ ->where('match_time','>',date("H:i:s", time()))
|
|
|
+ ->where('match_date',$time)
|
|
|
+ ->count("*");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
if($area[$k]['league_count'][$kk]['count'] == 0){
|
|
|
unset($area[$k]['league_count'][$kk]);
|
|
|
}
|
|
|
@@ -546,6 +556,76 @@ class GetmatchData {
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取联赛下赛事 数量
|
|
|
+ * 冠军盘口
|
|
|
+ */
|
|
|
+ public function getMatchStChampionNum($source,$country,$area,$model_league,$model_match='',$model_odds='',$where,$search,$time='',$type=0){
|
|
|
+
|
|
|
+ $leagueData = lm($model_league,'Sports')
|
|
|
+ ->select('id','lg_id','name_chinese as league','country_id','area_id')
|
|
|
+ ->get()
|
|
|
+ ->where($source)
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $oddsData = lm($model_odds,'Sports')
|
|
|
+ ->select('id','lg_id','p_code')
|
|
|
+ ->distinct("p_code")//去重
|
|
|
+ ->where($where)
|
|
|
+ ->where($source)
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ //按国家
|
|
|
+ $countryData = [];
|
|
|
+ if(!empty($country) and !empty($leagueData) and($oddsData)){
|
|
|
+ foreach ($country as $k=>$v){
|
|
|
+ if($v['country_id']){
|
|
|
+ $countryData[$k] = $v;
|
|
|
+ foreach ($leagueData as $kk=>$vv){
|
|
|
+ if($v['country_id'] == $vv['country_id']){
|
|
|
+ $countryData[$k]['league_count'][] = $vv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //去除无联赛 国家
|
|
|
+ foreach ($countryData as $k=>$v){
|
|
|
+ if(count($v) == 2){
|
|
|
+ unset($countryData[$k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //按地区
|
|
|
+ $areaData = [];
|
|
|
+ if(!empty($area) and !empty($leagueData) and($oddsData)){
|
|
|
+ foreach ($area as $k=>$v){
|
|
|
+ if($v['area_id']){
|
|
|
+ $areaData[$k] = $v;
|
|
|
+ foreach ($leagueData as $kk=>$vv){
|
|
|
+ if($v['area_id'] == $vv['area_id']){
|
|
|
+ $areaData[$k]['league_count'][] = $vv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //去除无联赛 地区
|
|
|
+ foreach ($areaData as $k=>$v){
|
|
|
+ if(count($v) == 2){
|
|
|
+ unset($areaData[$k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $countryData = array_gj_tt($countryData,$oddsData);
|
|
|
+ $areaData = array_gj_tt($areaData,$oddsData);
|
|
|
+ $data = array_merge($countryData,$areaData);
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取联赛下 赛事赔率
|
|
|
*/
|
|
|
@@ -555,8 +635,8 @@ class GetmatchData {
|
|
|
->where($source)
|
|
|
->where('lg_id',$lg_id)
|
|
|
->first();
|
|
|
- if(!empty($time)){
|
|
|
- if($time == 'other'){
|
|
|
+ if(!empty($time)){//早盘 按时间查询
|
|
|
+ if($time == 'other'){//早盘 一周后
|
|
|
$matchData = lm($model_match,"Sports")
|
|
|
->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
|
|
|
->where($source)
|
|
|
@@ -572,20 +652,38 @@ class GetmatchData {
|
|
|
->get()
|
|
|
->toarray();
|
|
|
}else{
|
|
|
- $matchData = lm($model_match,"Sports")
|
|
|
- ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
|
|
|
- ->where($source)
|
|
|
- ->where($model_match.'.lg_id',$lg_id)
|
|
|
- ->where($where)
|
|
|
- ->where('match_date',$time)
|
|
|
- ->where(function($query)use ($model_match,$search){
|
|
|
- $query->where($model_match.'.home_team','like','%'.$search.'%')
|
|
|
- ->orWhere(function($query)use ($model_match,$search) {
|
|
|
- $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
|
|
|
- });
|
|
|
- })
|
|
|
- ->get()
|
|
|
- ->toarray();
|
|
|
+ if($time == date('Y-m-d')){//早盘今天
|
|
|
+ $matchData = lm($model_match,"Sports")
|
|
|
+ ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
|
|
|
+ ->where($source)
|
|
|
+ ->where($model_match.'.lg_id',$lg_id)
|
|
|
+ ->where('is_morningplate','=',1)
|
|
|
+ ->where('match_date',$time)
|
|
|
+ ->where('match_time','>',date("H:i:s", time()))
|
|
|
+ ->where(function($query)use ($model_match,$search){
|
|
|
+ $query->where($model_match.'.home_team','like','%'.$search.'%')
|
|
|
+ ->orWhere(function($query)use ($model_match,$search) {
|
|
|
+ $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->get()
|
|
|
+ ->toarray();
|
|
|
+ }else{//早盘 今天以后
|
|
|
+ $matchData = lm($model_match,"Sports")
|
|
|
+ ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
|
|
|
+ ->where($source)
|
|
|
+ ->where($model_match.'.lg_id',$lg_id)
|
|
|
+ ->where($where)
|
|
|
+ ->where('match_date',$time)
|
|
|
+ ->where(function($query)use ($model_match,$search){
|
|
|
+ $query->where($model_match.'.home_team','like','%'.$search.'%')
|
|
|
+ ->orWhere(function($query)use ($model_match,$search) {
|
|
|
+ $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->get()
|
|
|
+ ->toarray();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
@@ -685,24 +783,31 @@ class GetmatchData {
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取欧冠 赛事数据
|
|
|
+ * 获取欧冠 各状态赛事数据
|
|
|
*/
|
|
|
public function getUEFAChampions($source){
|
|
|
$model = getModels('gj',1);
|
|
|
+
|
|
|
+ $model_league = $model['model_league'];
|
|
|
+ $leagueData = lm($model_league,'Sports')
|
|
|
+ ->select('name_chinese','lg_id','last_time')
|
|
|
+ ->where($model_league.'.source',$source['source'])
|
|
|
+ ->where($model_league.'.name_chinese','欧洲冠军杯')
|
|
|
+ ->first();
|
|
|
//获取滚球数据
|
|
|
- $StRollBall = $this->getUEFAMatchData($model,'StRollBall',$source);
|
|
|
- //获取滚球数据
|
|
|
- $StToday = $this->getUEFAMatchData($model,'StToday',$source);
|
|
|
- //获取滚球数据
|
|
|
- $StMorningPlate = $this->getUEFAMatchData($model,'StMorningPlate',$source);
|
|
|
- //获取滚球数据
|
|
|
- $StChampion = $this->getUEFAMatchData($model,'StChampion',$source);
|
|
|
+ $StRollBall = $this->getUEFAStRollBall($model,'StRollBall',$source,$leagueData->lg_id);
|
|
|
+ //获取今日数据
|
|
|
+ $StToday = $this->getUEFAStToday($model,'StToday',$source,$leagueData->lg_id);
|
|
|
+ //获取早盘数据
|
|
|
+ $StMorningPlate = $this->getUEFAStMorningPlate($model,'StMorningPlate',$source,$leagueData->lg_id);
|
|
|
+ //获取冠军盘口数据
|
|
|
+ $StChampion = $this->getUEFAStChampion($model,'StChampion',$source,$leagueData->lg_id,$leagueData->last_time);
|
|
|
|
|
|
$data = [
|
|
|
+ 'leagueName'=> $leagueData->name_chinese,
|
|
|
'StRollBall'=>[//滚球数据
|
|
|
'typeName'=>'滚球',
|
|
|
'matchNum'=>count($StRollBall),
|
|
|
@@ -729,43 +834,155 @@ class GetmatchData {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取欧冠 各状态赛事及赔率数据
|
|
|
+ * 获取欧冠 滚球数据
|
|
|
*/
|
|
|
- public function getUEFAMatchData($model,$type_code,$source){
|
|
|
- $model_league = $model['model_league'];
|
|
|
+ public function getUEFAStRollBall($model,$type_code,$source,$lg_id){
|
|
|
$model_match = $model['model_match'];
|
|
|
$model_odds = $model['model_odds'];
|
|
|
+ $model_result = $model['model_result'];
|
|
|
|
|
|
$where = getState($type_code,$model_match);
|
|
|
+ $matchData = lm($model_match,"Sports")
|
|
|
+ ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
|
|
|
+ ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_score','guest_score',$model_result.'.match_time as a_time','match_process')
|
|
|
+ ->where($model_match.'.source',$source['source'])
|
|
|
+ ->where($model_match.'.lg_id',$lg_id)
|
|
|
+ ->where($where)
|
|
|
+ ->get()
|
|
|
+ ->toarray();
|
|
|
|
|
|
- if($type_code != 'StChampion'){
|
|
|
- $matchData = lm($model_match,'Sports')
|
|
|
- ->leftjoin($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
|
|
|
- ->select($model_league.'.name_chinese',$model_match.'.match_id','match_date','match_time','tag','home_team','guest_team')
|
|
|
+ foreach($matchData as $kk => $vv){
|
|
|
+ $oddsData= lm($model_match,"Sports")
|
|
|
+ ->leftjoin($model_odds,$model_odds.'.match_id',$model_match.'.match_id')
|
|
|
+ ->select($model_odds.'.id','p_code','odds_code',$model_odds.'.status','odds','condition','sort')
|
|
|
->where($model_match.'.source',$source['source'])
|
|
|
- ->where($where)
|
|
|
- ->where($model_league.'.name_chinese','欧洲冠军杯')
|
|
|
+ ->where([$model_odds.'.match_id' => $vv['match_id'],$model_odds.'.type'=>0])
|
|
|
+// ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
|
|
|
+ ->where(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','concede_home')
|
|
|
+ ->orWhere(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','concede_guest');
|
|
|
+ })
|
|
|
+ ->orWhere(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','size_home');
|
|
|
+ })
|
|
|
+ ->orWhere(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','size_guest');
|
|
|
+ })
|
|
|
+ ->orWhere(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','capot_home');
|
|
|
+ })
|
|
|
+ ->orWhere(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','capot_dogfall');
|
|
|
+ })
|
|
|
+ ->orWhere(function($query)use ($model_odds){
|
|
|
+ $query->where($model_odds.'.odds_code','capot_guest');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->get()
|
|
|
+ ->toarray();
|
|
|
|
|
|
- ->get()->toArray();
|
|
|
+//根据 排序 获取 最新让球/大小玩法赔率
|
|
|
+ $sortData = array_column($oddsData,'sort');
|
|
|
+ array_multisort($sortData,SORT_DESC,$oddsData);
|
|
|
|
|
|
- foreach($matchData as $kk => $vv) {
|
|
|
- $oddsData = lm($model_match, "Sports")
|
|
|
- ->leftjoin($model_odds, $model_odds . '.match_id', $model_match . '.match_id')
|
|
|
- ->select($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
|
|
|
- ->where($model_match.'.source',$source['source'])
|
|
|
- ->where([$model_odds . '.match_id' => $vv['match_id']])
|
|
|
-// ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
|
|
|
- ->groupBy($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
|
|
|
- ->orderBy($model_odds . '.id','desc')
|
|
|
- ->get()
|
|
|
- ->toarray();
|
|
|
- $matchData[$kk]['oddsData'] = $oddsData;
|
|
|
+ $zu = [];
|
|
|
+ foreach ($oddsData as $key1 =>$item1){
|
|
|
+ $zu[$item1['p_code']][] = $item1;
|
|
|
}
|
|
|
- }else{
|
|
|
- $matchData = [];
|
|
|
+ $c_s = array_slice($zu['concede_size'],0,4);//让球/大小 前四条 放入
|
|
|
+ $capot = $zu['capot'];//独赢
|
|
|
+
|
|
|
+ $matchData[$kk]['oddsData'] = [$c_s,$capot];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return $matchData;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取欧冠 今日数据
|
|
|
+ */
|
|
|
+ public function getUEFAStToday($model,$type_code,$source,$lg_id){
|
|
|
+ $model_match = $model['model_match'];
|
|
|
+ $model_odds = $model['model_odds'];
|
|
|
+
|
|
|
+ $where = getState($type_code);
|
|
|
+ $matchData = lm($model_match,'Sports')
|
|
|
+ ->select('match_id','match_date','match_time','tag','home_team','guest_team')
|
|
|
+ ->where($model_match.'.source',$source['source'])
|
|
|
+ ->where($where)
|
|
|
+ ->where('lg_id',$lg_id)
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ foreach($matchData as $kk => $vv) {
|
|
|
+ $oddsData = lm($model_match, "Sports")
|
|
|
+ ->leftjoin($model_odds, $model_odds . '.match_id', $model_match . '.match_id')
|
|
|
+ ->select($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
|
|
|
+ ->where($model_match.'.source',$source['source'])
|
|
|
+ ->where([$model_odds . '.match_id' => $vv['match_id']])
|
|
|
+// ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
|
|
|
+ ->groupBy($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
|
|
|
+ ->orderBy($model_odds . '.id','desc')
|
|
|
+ ->get()
|
|
|
+ ->toarray();
|
|
|
+ $matchData[$kk]['oddsData'] = $oddsData;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $matchData;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取欧冠 早盘数据
|
|
|
+ */
|
|
|
+ public function getUEFAStMorningPlate($model,$type_code,$source,$lg_id){
|
|
|
+ $model_match = $model['model_match'];
|
|
|
+ $model_odds = $model['model_odds'];
|
|
|
+
|
|
|
+ $where = getState($type_code);
|
|
|
+
|
|
|
+ $matchData = lm($model_match,'Sports')
|
|
|
+ ->select('match_id','match_date','match_time','tag','home_team','guest_team')
|
|
|
+ ->where($model_match.'.source',$source['source'])
|
|
|
+ ->where($where)
|
|
|
+ ->where('lg_id',$lg_id)
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ $data = $this->getOddsData->getOddsZQ($matchData,$model_odds,$source);
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取 欧冠 冠军盘口数据
|
|
|
+ */
|
|
|
+ public function getUEFAStChampion($model,$type_code,$source,$lg_id,$last_time=''){
|
|
|
+ $model_odds = $model['model_odds'];
|
|
|
+
|
|
|
+ $where = getState($type_code);
|
|
|
+ $championData = lm($model_odds, 'Sports')
|
|
|
+ ->select("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
|
|
|
+// ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
|
|
|
+ ->where($source)
|
|
|
+ ->where('lg_id',$lg_id)
|
|
|
+ ->where($where)
|
|
|
+ ->groupBy("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ //按p_code分组
|
|
|
+ $p_code=array();
|
|
|
+ foreach($championData as $k=>$v){
|
|
|
+ $p_code[$v['p_code']][]=$v;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ foreach ($p_code as $k1=>$v1){
|
|
|
+ foreach ($v1 as $k2=>$v2){
|
|
|
+ $data[$v2['p_code']]['last_time'] =$last_time;
|
|
|
+ $data[$v2['p_code']][$v2['odds_code']][] = $v2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
}
|