vali преди 6 години
родител
ревизия
a9cc43bc5f
променени са 3 файла, в които са добавени 59 реда и са изтрити 0 реда
  1. 46 0
      app/Http/Model/St_team.php
  2. 4 0
      app/Http/Response/Response.php
  3. 9 0
      app/Logic/DataLogic.php

+ 46 - 0
app/Http/Model/St_team.php

@@ -0,0 +1,46 @@
+<?php
+namespace App\Http\Model;
+
+use Illuminate\Database\Eloquent\Model;
+use App\Http\Response\Response;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 数据源球队model
+ */
+class St_team extends Model
+{
+
+    protected $table = 'st_team';
+    public $timestamps = false;
+
+    /**
+     * 写入数据源球队数据
+     * $game_code 球类代码
+     * $team 球队名称
+     */
+    public static function setTeam($game_code,$teamNameArr=[]){
+        if(!empty($game_code) and !empty($teamNameArr)){
+            //拼装数据
+            foreach($teamNameArr as $k => $teamName){
+                $set_arr[] = [
+                    'game_type' => $game_code,
+                    'team_name_cn' => $teamName,
+                    'status' => 1,
+                    'update_time' => date('Y-m-d H:i:s')
+                ];
+            }
+
+            //循环写入/更新
+            foreach($set_arr as $k =>$set){
+                $ret = self::updateOrInsert(
+                    ['game_type' => $game_code, 'team_name_cn' => $set['team_name_cn']],
+                    ['status' => $set['status'],'update_time' => $set['update_time']]
+                );
+
+                if(empty($ret)) return Response::generate('',Response::SET_TEAM_ERR);
+            }
+        }
+    }
+}

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

@@ -49,6 +49,8 @@ class Response
     const L_MATCH_ID_ERR = 10038;
     //删除历史直播数据
     const DEL_PAST_BROADCAST_ERR = 10039;
+    //球队数据处理失败
+    const SET_TEAM_ERR = 10040;
 
 
     private static $errorMsgs = [
@@ -93,6 +95,8 @@ class Response
         self::L_MATCH_ID_ERR=>'未获取到赔率所属本地赛事id',
         //===删除历史直播数据失败===
         self::DEL_PAST_BROADCAST_ERR=>'删除历史直播数据失败',
+        //===球队数据处理失败===
+        self::SET_TEAM_ERR =>'球队数据处理失败'
 
     ];
 

+ 9 - 0
app/Logic/DataLogic.php

@@ -27,6 +27,7 @@ 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;
+use App\Http\Model\St_team as StTeamModel;
 
 class DataLogic
 {
@@ -350,6 +351,14 @@ class DataLogic
                             ];
                             $ret = $models['model_local_match']::insertGetId($set_local);
                             if ($ret < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::LOCAL_MATCH_ERROR));//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
+
+                            //追加写球队名称
+                            $team = [
+                                'team_h' => $data['home_team'],
+                                'team_g' => $data['guest_team'],
+                            ];
+                            StTeamModel::setTeam($game_code, $team);
+
                         }
                     }
                 }