彭俊 6 gadi atpakaļ
vecāks
revīzija
35bcfcfe8e
1 mainītis faili ar 43 papildinājumiem un 14 dzēšanām
  1. 43 14
      app/Http/Controllers/Api/WriteSportsController.php

+ 43 - 14
app/Http/Controllers/Api/WriteSportsController.php

@@ -59,16 +59,14 @@ class WriteSportsController extends BaseController
     //写赛事结果记录
     public function setMatchResult(Req $data)
     {
-        $ret = $this->setMatchResult_v1($data);
+        $ret = $this->setMatchResult_v2($data);
         return $ret;
     }
 
     //写赛事赔率
     public function setOdds(Req $data)
     {
-        // $ret = $this->setOdds_v1($data);
         $ret = $this->setOdds_v3($data);
-
         return $ret;
     }
 
@@ -841,9 +839,9 @@ class WriteSportsController extends BaseController
                     }
                 }
             }
-            sort($s_match_ids);
+            sort($match_uuids);
             //去除本地和请求里都存在的赛事,如果还有剩余赛事id,则返回异常
-            if (!empty($s_match_ids)) throw new \Exception(Response::generate($gameName . '赛事-match_id' . $s_match_ids[0] . ';', Response::MATCH_ERROR));
+            if (!empty($match_uuids)) throw new \Exception(Response::generate($gameName . '赛事-match_id' . $match_uuids[0] . ';', Response::MATCH_ERROR));
             //====end====
 
             //处理 赛事 结果记录 数据
@@ -1347,14 +1345,15 @@ class WriteSportsController extends BaseController
             $tag = $getData['tag'] ?: 99;
             //获取赔率是否是串场
             $is_stringscene = $getData['is_stringscene'];
-
+             //获取数据源赛事uuid
+             $match_identity = $getData['match_identity'];
             //获取球类名称
             $gameName = gameModel::getGameName($game_code);
             //验证本次请求所属联赛/赛事是否存在 返回本地联赛/赛事ID
             $models = commonFunction::getModels($game_code, 1);
 
             $lg_id = $this->leagueVerify($models, $uuid, $source, $gameName);
-            $match_id = $this->matchVerify($models, $s_match_id, $source, $gameName);
+            $match_id = $this->matchVerify_v2($models, $match_identity, $source, $gameName);
 
             //更新赛事 tag 值
             //如果未获取到本地赛事id,则返回异常
@@ -1927,20 +1926,43 @@ class WriteSportsController extends BaseController
             //获取 数据源 
             $source = $data['source'];
 
-            //获取所有数据源赛事 match_id
+
+            //获取 当前请求 所有 uuid /match_id
             $others_match_ids = [];
+            $match_uuids = [];
             foreach ($data['data'] as $k => $v) {
                 $others_match_ids[] = $v['match_id'];
+                //追加获取赛事uuid
+                $match_uuids[] = $v['match_identity'];
             }
+
             //根据球类代码 获取model
             $model = commonFunction::getModels($game_code, 1);
             //获取所有赛事 match_id
             $local_match = $model['model_local_match']::SELECT('others_match_id', 'match_id')
                 ->where(['source' => $source])
-                ->whereIn('others_match_id', $others_match_ids)
+                ->whereIn('identity',$match_uuids)
                 ->get()->toArray();
             if (empty($local_match)) throw new \Exception(Response::generate('', Response::MATCHID_NULL));
 
+            //设置各球类 判断结束时间
+            if($game_code == 'zq'){
+                //足球 60分钟
+                $handle_time = 60*60;
+            }
+            if($game_code == 'lq'){
+                //篮球 40分钟
+                $handle_time = 60*40;
+            }
+            if($game_code == 'wq'){
+                //网球 2小时
+                $handle_time = 60*60*2;
+            }
+            if($game_code == 'bq'){
+                //棒球 2小时
+                $handle_time = 60*60*2;
+            }
+
             //取值 更新字段
             foreach ($local_match as $k => $v) {
                 foreach($data['data'] as $kk =>$vv){
@@ -1963,12 +1985,17 @@ class WriteSportsController extends BaseController
                             ->update($set_status);
                         if ($ret < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $v['others_match_id'], Response::UPSTATUS_ERROR));
                     
-                        //===如果赛事已结束===
-                        if($vv['status'] == 2){
+                        //获取赛事开始时间
+                        $game_start_time = $model['model_result']::where(['match_id' => $v['match_id']])->first()->start_time;
+                        //开赛时间 时间戳
+                        $game_start_time_unx = strtotime($game_start_time);
+
+                       
+                        //===如果赛事已结束 并且 开赛时间< 当前时间-各球类处理时间 ===
+                        if($vv['status'] == 2 and $game_start_time_unx < (time() - $handle_time)){
                             // 新增 更新 赛事结果
                             $this->match_result($game_code, $v['match_id']);
-                            //获取赛事开始时间
-                            $game_start_time = $model['model_result']::where(['match_id' => $v['match_id']])->first()->start_time;
+                            
                             // 写入结算通知表 用于自动结算
                             $Comendnotice = new \App\Models\Comendnotice();
                             $ret_add = $Comendnotice->addcomendnotice($v['match_id'], $game_code, 0, $game_start_time);
@@ -2718,6 +2745,8 @@ class WriteSportsController extends BaseController
             $source = $getData['source'];
             //获取数据源赛事id
             $others_match_id = $getData['match_id'];
+            //获取数据源赛事uuid
+            $match_identity = $getData['match_identity'];
             //获取球类名称
             $gameName = gameModel::getGameName($game_code);
             //获取 model
@@ -2727,7 +2756,7 @@ class WriteSportsController extends BaseController
 
              //获取赛事 match_id
              $match_id = $models['model_local_match']::SELECT('others_match_id', 'match_id')
-             ->where(['source' => $source,'others_match_id'=>$others_match_id])
+             ->where(['source' => $source,'identity' => $match_identity])
              ->first()->match_id;
 
              if(!empty($match_id)){