|
@@ -40,12 +40,22 @@ class St_zq_competition extends Model
|
|
|
$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'];
|
|
$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")
|
|
|
|
|
|
|
+ if(!empty($lg_ids)){
|
|
|
|
|
+ $matchData = lm($model_match,"Sports")
|
|
|
->select($select)
|
|
->select($select)
|
|
|
->whereIn($model_match.'.lg_id',$lg_ids)
|
|
->whereIn($model_match.'.lg_id',$lg_ids)
|
|
|
->where($where)
|
|
->where($where)
|
|
|
->get()
|
|
->get()
|
|
|
->toarray();
|
|
->toarray();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $matchData = lm($model_match,"Sports")
|
|
|
|
|
+ ->select($select)
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->get()
|
|
|
|
|
+ ->toarray();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(empty($matchData)) return $matchData;
|
|
|
|
|
|
|
|
$match_ids = [];
|
|
$match_ids = [];
|
|
|
foreach ($matchData as $k=>$v){
|
|
foreach ($matchData as $k=>$v){
|
|
@@ -65,26 +75,27 @@ class St_zq_competition extends Model
|
|
|
// (select match_id,max(id) id from $result_record where match_id IN ($match_ids_str) group by match_id)b
|
|
// (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 ";
|
|
// where a.match_id = b.match_id and a.id = b.id ";
|
|
|
// }
|
|
// }
|
|
|
- //如果是网球
|
|
|
|
|
- if($game_code == 'wq'){
|
|
|
|
|
- $sql = "select a.match_id,a.home_player_score,a.guest_player_score,a.match_time as a_time,a.match_process,a.result_mark 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 ";
|
|
|
|
|
-}else
|
|
|
|
|
-//如果是棒球
|
|
|
|
|
-if($game_code == 'bq'){
|
|
|
|
|
- $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.result_mark 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 ";
|
|
|
|
|
-}else{
|
|
|
|
|
- //其他球类
|
|
|
|
|
- $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($game_code == 'wq'){
|
|
|
|
|
+ $sql = "select a.match_id,a.home_player_score,a.guest_player_score,a.match_time as a_time,a.match_process,a.result_mark 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 ";
|
|
|
|
|
+ }else
|
|
|
|
|
+ //如果是棒球
|
|
|
|
|
+ if($game_code == 'bq'){
|
|
|
|
|
+ $sql = "select a.match_id,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.result_mark 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 ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //其他球类
|
|
|
|
|
+ $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 ";
|
|
|
|
|
+ }
|
|
|
$match_result_record = S ('DB')->select ($sql);
|
|
$match_result_record = S ('DB')->select ($sql);
|
|
|
|
|
|
|
|
//处理赛事数据,追加比分及进程
|
|
//处理赛事数据,追加比分及进程
|
|
|
|
|
+ /*
|
|
|
if(!empty($matchData)){
|
|
if(!empty($matchData)){
|
|
|
foreach ($matchData as $k=>$v){
|
|
foreach ($matchData as $k=>$v){
|
|
|
if( !empty($match_result_record)){
|
|
if( !empty($match_result_record)){
|
|
@@ -115,10 +126,59 @@ where a.match_id = b.match_id and a.id = b.id ";
|
|
|
$matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
|
|
$matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
|
|
|
$matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
|
|
$matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ if(!empty($matchData)){
|
|
|
|
|
+ foreach ($matchData as $k=>$v){
|
|
|
|
|
+ if( !empty($match_result_record)){
|
|
|
|
|
+ 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?:0;
|
|
|
|
|
+ $matchData[$k]['guest_player_score'] = $vv->guest_player_score?:0;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $matchData[$k]['home_score'] = $vv->home_score?:0;
|
|
|
|
|
+ $matchData[$k]['guest_score'] = $vv->guest_score?:0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $matchData[$k]['a_time'] = $vv->a_time?:C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
|
|
|
|
|
+ $matchData[$k]['match_process'] = $vv->match_process?:C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ //如果是网球
|
|
|
|
|
+ if($model_result == 'st_wq_result'){
|
|
|
|
|
+ $matchData[$k]['home_player_score'] = 0;
|
|
|
|
|
+ $matchData[$k]['guest_player_score'] = 0;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $matchData[$k]['home_score'] = 0;
|
|
|
|
|
+ $matchData[$k]['guest_score'] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
|
|
|
|
|
+ $matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //追加当赛事数量为N ,赛事结果记录< N时的处理
|
|
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
|
|
+ if(count($v) < 10){
|
|
|
|
|
+ //如果是网球
|
|
|
|
|
+ if($model_result == 'st_wq_result'){
|
|
|
|
|
+ $matchData[$k]['home_player_score'] = 0;
|
|
|
|
|
+ $matchData[$k]['guest_player_score'] = 0;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $matchData[$k]['home_score'] = 0;
|
|
|
|
|
+ $matchData[$k]['guest_score'] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $matchData[$k]['a_time'] = C()->get('commonFunction')->getMatchTime($v['match_date'],$v['match_time']);
|
|
|
|
|
+ $matchData[$k]['match_process'] = C()->get('commonFunction')->getMatchProcess( $matchData[$k]['a_time'],$ret['game_code']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return $matchData;
|
|
return $matchData;
|
|
|
}
|
|
}
|
|
|
|
|
|