|
|
@@ -333,29 +333,35 @@ class StZqResult extends Model
|
|
|
/**
|
|
|
* 获取自动赛事结果
|
|
|
* 只更新已结束+未手动修改的赛事结果
|
|
|
+ * $match_id 本地赛事id 为0时 则用于后台手动刷新赛果
|
|
|
*/
|
|
|
- public static function ZQresult_v2($model){
|
|
|
- //获取两天内的结束赛事
|
|
|
- $matchData = $model['model_match']
|
|
|
- ->join('st_zq_result','st_zq_result.match_id','=','st_zq_competition.id')
|
|
|
- ->select('st_zq_competition.id','is_correct')
|
|
|
- ->where([['st_zq_competition.match_date','>',date('Y-m-d', strtotime("-2 day"))],['st_zq_competition.status','=',2]])
|
|
|
- ->get()
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- //没有数据,无需操作
|
|
|
- if(empty($matchData)) return Response::success();
|
|
|
- //获取需更新结果的赛事ID
|
|
|
- $match_ids = [];
|
|
|
- foreach($matchData as $k =>$v){
|
|
|
- //未手动修改比分
|
|
|
- if($v['is_correct'] == 0){
|
|
|
- $match_ids[] = $v['id'];
|
|
|
+ public static function ZQresult_v2($model,$match_id = 0){
|
|
|
+ //如果有赛事id 则只更新当前赛事结果
|
|
|
+ if($match_id > 0){
|
|
|
+ $match_ids_str = $match_id;
|
|
|
+ }else{
|
|
|
+ //获取两天内的结束赛事
|
|
|
+ $matchData = $model['model_match']
|
|
|
+ ->join('st_zq_result','st_zq_result.match_id','=','st_zq_competition.id')
|
|
|
+ ->select('st_zq_competition.id','is_correct')
|
|
|
+ ->where([['st_zq_competition.match_date','>',date('Y-m-d', strtotime("-2 day"))],['st_zq_competition.status','=',2],['st_zq_result.is_correct','=',-1]])
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ //没有数据,无需操作
|
|
|
+ if(empty($matchData)) return Response::success();
|
|
|
+ //获取需更新结果的赛事ID
|
|
|
+ $match_ids = [];
|
|
|
+ foreach($matchData as $k =>$v){
|
|
|
+ //未手动修改比分
|
|
|
+ if($v['is_correct'] == 0){
|
|
|
+ $match_ids[] = $v['id'];
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if(empty($match_ids)) return Response::success();
|
|
|
+ if(empty($match_ids)) return Response::success();
|
|
|
|
|
|
- $match_ids_str = implode(",", $match_ids);
|
|
|
+ $match_ids_str = implode(",", $match_ids);
|
|
|
+ }
|
|
|
|
|
|
//上半场
|
|
|
$sql_h = "select a.match_id,a.home_team,a.guest_team,a.home_score,a.guest_score,a.match_time as a_time,a.match_process,a.all_goal,a.first_score,a.last_score,a.match_score,a.match_winer from st_zq_result_record a,
|
|
|
@@ -432,10 +438,10 @@ class StZqResult extends Model
|
|
|
"is_correct"=> -1,//自动比分
|
|
|
];
|
|
|
|
|
|
- $ret = $model['model_result']::where(['match_id' => $v['match_id']])
|
|
|
+ $ret = $model['model_result']::where(['match_id' => $v['match_id'],'is_correct'=>-1])
|
|
|
->update($set_match_r);
|
|
|
|
|
|
- if($ret < 1) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));
|
|
|
+ // if($ret < 1) throw new \Exception( Response::generate('',Response::ADD_MATCH_R_ERROR));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -469,6 +475,7 @@ class StZqResult extends Model
|
|
|
'match_time'=>0,//比赛进行时间
|
|
|
"ctime"=>date('Y-m-d H:i:s'),
|
|
|
"update_time"=>date('Y-m-d H:i:s'),
|
|
|
+ "is_correct" => -1,
|
|
|
"start_time"=>date('Y-m-d H:i:s',strtotime($start_time)),
|
|
|
];
|
|
|
|