瀏覽代碼

调整写赛事逻辑

彭俊 6 年之前
父節點
當前提交
fff238dd5c
共有 1 個文件被更改,包括 22 次插入2 次删除
  1. 22 2
      app/Http/Controllers/Api/WriteSportsController.php

+ 22 - 2
app/Http/Controllers/Api/WriteSportsController.php

@@ -240,7 +240,7 @@ class WriteSportsController extends BaseController{
             $models = commonFunction::getModels($game_code, 1);
             //获取 赛事 数据
             $matchData = $getData['data'];
-            //获取 当前请求 所有 uuid /match_id
+            //获取 当前请求 所有 uuid
             $identity = [];
             $s_match_ids = [];
             foreach($matchData as $k=>$v){
@@ -256,6 +256,25 @@ class WriteSportsController extends BaseController{
             $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id','others_lg_id')->get()->toArray();
             //二维数组去重
             $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
+            //如果获取不到本地联赛数据,则返回联赛不存在
+            if(empty($l_lg_data)) throw new \Exception(Response::generate($gameName.'本次请求的所有赛事都没有联赛数据;',Response::LEAGUE_ERROR));
+            
+            //获取到本次请求,所有本地有联赛的赛事
+            $mathData_before = $matchData;//接收原赛事
+            $matchData = [];//获取新赛事
+            foreach($l_lg_data as $k=>$v){
+                foreach($mathData_before as $kk=>$vv){
+                    if($v['identity'] == $vv['uuid']){
+                        $matchData[] = $vv;
+                    }
+                }
+            }
+            //获取当前请求有关联联赛的赛事 match_id
+            $s_match_ids = [];
+            foreach($matchData as $k=>$v){
+                $s_match_ids[] = $v['match_id'];
+            }
+            /*
             //循环对比 请求uuid->本地identity
             foreach($l_lg_data as $k=>$v){
                 foreach($identity as $kk=> $uuid){
@@ -266,7 +285,7 @@ class WriteSportsController extends BaseController{
             }
             sort($identity);
             //去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常
-            // if(!empty($identity))  throw new \Exception(Response::generate($gameName.'联赛:uuid-'.$identity[0].';',Response::LEAGUE_ERROR));
+            if(!empty($identity))  throw new \Exception(Response::generate($gameName.'联赛:uuid-'.$identity[0].';',Response::LEAGUE_ERROR));
             //如果有剩余联赛,则表示该赛事找不到联赛,将其删除
             if(!empty($identity)){
                 foreach($matchData as $k=>$v){
@@ -279,6 +298,7 @@ class WriteSportsController extends BaseController{
                 sort($matchData);
             }
             //====end====
+            */
 
             //====获取 本地 已存在 赛事====
             $s_match_ids = array_unique($s_match_ids);