vali 6 rokov pred
rodič
commit
8d92383db3

+ 33 - 0
app/Http/Model/St_set_sports_record.php

@@ -0,0 +1,33 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * Class St_country
+ * @package App\Sports\Model
+ * 国家 地区 关系
+ */
+class St_set_sports_record extends Model
+{
+
+    protected $table = 'st_set_sports_record';
+    public $timestamps = false;
+
+
+   //写 请求 数据 日志记录
+   public static function setSportsRecord($title,$obt){
+        $set = 0;
+        if(!empty($title) and !empty($obt)){
+           $setData = [
+            'title'=>$title,
+            'data'=>$obt,
+            'add_time'=>date('Y-m-d H:i:s'),
+           ];
+           $set = self::insertGetId($setData);
+        }
+
+        return $set;
+
+   }
+}

+ 13 - 0
app/Http/Response/Response.php

@@ -39,6 +39,12 @@ class Response
     const LG__UUID_NULL = 10033;
     //更新赛事tag
     const UPMATCHTAG_ERROR = 10034;
+    //未获取到数据源lg_id
+    const S_LG_ID_NULL = 10035;
+    //未获取到本地lg_id
+    const L_LG_ID_NULL = 10036;
+    //请求数据写日志记录失败
+    const SPORTS_RECORD_ERR = 10037;
 
 
     private static $errorMsgs = [
@@ -73,6 +79,13 @@ class Response
         self::TOKEN_ERR => '用户token异常,请重新获取',
         //===联赛uuid 为空====
         self::LG__UUID_NULL=> '联赛uuid为空',
+        //===未获取到数据源lg_id===
+        self::S_LG_ID_NULL =>'未获取到数据源lg_id',
+        //===未获取到本地lg_id===
+        self::L_LG_ID_NULL => '未获取到本地lg_id',
+        //===写请求数据日志记录失败===
+        self::SPORTS_RECORD_ERR=>'写请求数据日志记录失败',
+
     ];
 
     public static function getMsg($code)

+ 19 - 9
app/Logic/DataLogic.php

@@ -26,6 +26,7 @@ use App\Http\Model\StZqOdds as OddsModel;
 use App\Http\Model\StZqOddsRecord as OddsRecordModel;
 use App\Http\Model\StZqResult as ZqResultModel;
 use App\Http\Model\St_area_country as StAreaCountryModel;
+use App\Http\Model\St_set_sports_record  as St_set_sports_recordModel;
 
 class DataLogic
 {
@@ -183,7 +184,7 @@ class DataLogic
             sort($identity);
 
             //获取 本地 已存在 联赛
-            $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id')->get()->toArray();
+            $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');
             //循环对比 请求uuid->本地identity
@@ -208,12 +209,16 @@ class DataLogic
             $l_match_data = commonFunction::uniquArrV2($l_match_data,'others_match_id');
 
             //循环对比 请求match_id->本地others_match_id
-            foreach($l_match_data as $k=>$v){
-                foreach($s_match_ids as $kk=> $s_match_id){
-                    if($v['others_match_id'] == $s_match_id){
-                        unset($s_match_ids[$kk]);
+            //如果本地有 赛事,则取出本地不存在赛事
+            if(!empty($l_match_data)){
+                foreach($l_match_data as $k=>$v){
+                    foreach($s_match_ids as $kk=> $s_match_id){
+                        if($v['others_match_id'] == $s_match_id){
+                            unset($s_match_ids[$kk]);
+                        }
                     }
                 }
+                sort($s_match_ids);
             }
 
             //剩余 赛事 数据 写入
@@ -224,12 +229,17 @@ class DataLogic
                             $data = $v;
                             $half_match_id = 0;
                             //获取 本地 联赛 ID
+                            //验证本赛事是否有数据源lg_id
+                            if(empty($data['lg_id'])) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::S_LG_ID_NULL));
                             $lg_id = commonFunction::searcharray($data['lg_id'],'others_lg_id',$l_lg_data,'lg_id');
+                            //验证 本赛事是否获取到本地lg_id
+                            if(empty($lg_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::L_LG_ID_NULL));
                             //如果有上半场赛事id 获取上半场赛事是否存在
-                            if(!empty($data['half_match_id'])){
-                                $half_match_id = $models['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$source])
-                                    ->value('match_id');
-                                if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'上半场赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
+                            if(!empty($l_match_data) and $data['half_match_id'] > 0){
+                                $half_match_id = -1;
+                                // $half_match_id = $models['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$source])
+                                //     ->value('match_id');
+                                // if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'上半场赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
                             }
                             //如果赛事没有开始日期,则为冠军盘口赛事
                             if(empty($data['match_date'])){