|
|
@@ -5,6 +5,8 @@ use Illuminate\Database\Eloquent\Model;
|
|
|
use App\Http\Response\Response;
|
|
|
use Fideloper\Proxy\TrustedProxyServiceProvider;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use App\Lib\Biz\Sport\Common as commonFunction;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -337,19 +339,18 @@ class StZqResult extends Model
|
|
|
* $match_id 本地赛事id 为0时 则用于后台手动刷新赛果
|
|
|
*/
|
|
|
public static function ZQresult_v2($model,$match_id = 0){
|
|
|
-
|
|
|
//如果有赛事id 则只更新当前赛事结果
|
|
|
if($match_id > 0){
|
|
|
$match_ids_str = $match_id;
|
|
|
+ $match_ids = [$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]])
|
|
|
+ ->select('st_zq_competition.id','is_correct','manual_result')
|
|
|
+ ->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
|
|
|
@@ -364,6 +365,14 @@ class StZqResult extends Model
|
|
|
|
|
|
$match_ids_str = implode(",", $match_ids);
|
|
|
}
|
|
|
+
|
|
|
+ //如果有赛事id 获取结果中的手动数据
|
|
|
+ if(!empty($match_ids_str)){
|
|
|
+ $manual_result_data = self::select('match_id','manual_result')
|
|
|
+ ->whereIn('match_id',$match_ids)
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+ }
|
|
|
|
|
|
//上半场
|
|
|
$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,
|
|
|
@@ -421,6 +430,72 @@ class StZqResult extends Model
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //===追加拼接手动结果数据===
|
|
|
+ $resultData = commonFunction::filter_by_value($manual_result_data,'match_id',$v['match_id']);
|
|
|
+ //手动结果数据 json
|
|
|
+ $manual_result_json = $resultData['manual_result'];
|
|
|
+ //手动结果数据 arr
|
|
|
+ $manual_result_arr = json_decode($manual_result_json,true);
|
|
|
+
|
|
|
+ //拼接手动数据
|
|
|
+ foreach($manual_result_arr as $kk=>$vv){
|
|
|
+ //上半场角球
|
|
|
+ if($kk == 'half_corner'){
|
|
|
+ //赋值 上半场角球
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['home'] = 0;
|
|
|
+ $vv['guest'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全场角球
|
|
|
+ if($kk == 'all_corner'){
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['home'] = 0;
|
|
|
+ $vv['guest'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上半场比分
|
|
|
+ if($kk == 'half'){
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['home'] = $v['u_home_score']?:0;
|
|
|
+ $vv['guest'] = $v['u_guest_score']?:0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全场比分
|
|
|
+ if($kk == 'all'){
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['home'] = $v['home_score']?:0;
|
|
|
+ $vv['guest'] = $v['guest_score']?:0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上半场罚牌
|
|
|
+ if($kk == 'half_penalty'){
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['home'] = 0;
|
|
|
+ $vv['guest'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //全场罚牌
|
|
|
+ if($kk == 'all_penalty'){
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['home'] = 0;
|
|
|
+ $vv['guest'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //首进球时间
|
|
|
+ if($kk == 'first_score'){
|
|
|
+ if(empty($vv['home']) || empty($vv['guest'])){
|
|
|
+ $vv['time'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $manual_result_arr[$kk] =$vv;
|
|
|
+ }
|
|
|
+ //转回json
|
|
|
+ $manual_result_json = json_encode($manual_result_arr);
|
|
|
+ //===end===
|
|
|
+
|
|
|
$set_match_r = [
|
|
|
"match_id"=> $v['match_id'],
|
|
|
"update_time"=>date('Y-m-d H:i:s'),
|
|
|
@@ -438,6 +513,7 @@ class StZqResult extends Model
|
|
|
"u_home_score"=> $v['u_home_score']?:0,//上半场主队进球数
|
|
|
"u_guest_score"=> $v['u_guest_score']?:0,//上半场客队进球数
|
|
|
"is_correct"=> -1,//自动比分
|
|
|
+ "manual_result"=> $manual_result_json,//手动结果
|
|
|
];
|
|
|
|
|
|
$ret = $model['model_result']::where(['match_id' => $v['match_id'],'is_correct'=>-1])
|