浏览代码

代码整理

彭俊 6 年之前
父节点
当前提交
2ed8ed27e6

+ 34 - 112
app/Http/Controllers/Api/WriteSportsController.php

@@ -186,11 +186,11 @@ class WriteSportsController extends BaseController{
                             $this->odds($vv,$gameName,$l_lg_id,$l_match_id,$ret_odds,$ret_odds_record);
                             break;
                         case 'league_result'://联赛结果
-                            $this->league_result($vv);
+                            $this->league_result($vv,$gameName);
                             break;
                         case 'match_result'://赛事结果
                             throw new \Exception(Response::generate('赛事结果数据-match_result:',Response::AUTH_ERROR));
-                            $this->match_result($vv);
+                            $this->match_result($vv,$gameName);
                             break;
                         case 'match_result_record'://赛事结果记录
                             $s_lg_id = $vv['data']['lg_id'];
@@ -221,10 +221,6 @@ class WriteSportsController extends BaseController{
                             //处理 赛事结果 记录
                             $this->com_result_record($vv,$gameName,$l_lg_id,$l_match_id);
                             break;
-                        case 'odds_record'://赔率记录
-                            throw new \Exception(Response::generate('赔率记录数据-odds_record:',Response::AUTH_ERROR));
-                            $this->odds_record($vv);
-                            break;
                         case 'broadcast'://直播数据
                             $this->broadcast($vv,$game_code);
                             break;
@@ -291,7 +287,9 @@ class WriteSportsController extends BaseController{
         }
     }
 
-    //写入直播 数据
+    /*
+     * 写入直播 数据
+     */
     public function broadcast($opt = [],$game_code=''){
         $data = $opt['data'];
         $set_broadcast = [
@@ -311,7 +309,9 @@ class WriteSportsController extends BaseController{
         if($ret == false) throw new \Exception(Response::generate('',Response::BROADCAST_ERROR));
     }
 
-    //将进行中赛事写入 赛事结果
+    /*
+     * 写入 赛事 初始 结果
+     */
     public function match_result($game_code = ''){
         $model =commonFunction::getModels($game_code,1);
         if($game_code == 'zq')  ZqResultModel::ZQresult($model);
@@ -319,29 +319,17 @@ class WriteSportsController extends BaseController{
         if($game_code == 'wq')  WqResultModel::WQresult($model);
         if($game_code == 'bq')  BqResultModel::BQresult($model);
     }
-    //写入地区数据 弃用
-    public function area($opt = []){
-        $ret = lm('st_area','Sports')->insert($opt);
-        return $ret;
-    }
-
-    //写入国家数据 弃用
-    public function country($opt = []){
-        $ret = lm('st_country','Sports')->insert($opt);
-        return $ret;
-    }
 
-    //写入联赛数据
+    /*
+     * 写入联赛数据
+     */
     public function league($opt = [],$gameName=''){
         $game_code = $opt['game_code'];
         //根据球类代码获取相关model
         $model =commonFunction::getModels($game_code,1);
         $data = $opt['data'];
-//        if(empty($data['belong'])) throw new \Exception(Response::generate(Response::COUNTRY_ERROR)) ;//Render([], '10013', lang('Tips','Sports')->get('country_error'));
-//        //获取联赛所属 国家/地区id
-//        $belong = St_area_countryModel::getID($data['belong']);
-        $set_lg['area_id'] = 0;//$belong['area_id'];
-        $set_lg['country_id'] = 0;// $belong['country_id'];
+        $set_lg['area_id'] = 0;
+        $set_lg['country_id'] = 0;
 
         //查询联赛是否已存在
         $id = $model['model_league']::where('name_chinese','=',$data['name_chinese'])
@@ -385,7 +373,9 @@ class WriteSportsController extends BaseController{
         return $data;
     }
 
-    //写入赛事数据
+    /*
+     * 写入赛事数据
+     */
     public function competition($opt = [],$gameName='',$lg_id=''){
         $game_code = $opt['game_code'];
         //根据球类代码获取相关model
@@ -461,7 +451,9 @@ class WriteSportsController extends BaseController{
         return $data;
     }
 
-    //写入赔率数据
+    /*
+     * 写入赔率/赔率记录数据
+     */
     public function odds($opt=[],$gameName='',$lg_id=0,$match_id=0,$oddsID='',$oddsRecordID=''){
         $game_code = $opt['game_code'];
         //根据球类代码获取相关model
@@ -534,8 +526,10 @@ class WriteSportsController extends BaseController{
         //===end===
     }
 
-    //写入联赛结果
-    public function league_result($opt){
+    /*
+     * 写入联赛结果
+     */
+    public function league_result($opt,$gameName){
         $game_code = $opt['game_code'];
         //根据球类代码获取相关model
         $model = commonFunction::getModels($game_code,1);
@@ -544,7 +538,7 @@ class WriteSportsController extends BaseController{
         //验证结果所属联赛
         $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
             ->value('lg_id');
-        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+        if($lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
 
         $lg_result_id = $model['model_league_result']::where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
             ->value('id');
@@ -560,28 +554,21 @@ class WriteSportsController extends BaseController{
         if(!empty($lg_result_id)){
             $ret = $model['model_league_result']::where(['id'=>$lg_result_id])
                 -> update($set_lg_result);
-            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
         }else{
             $ret = $model['model_league_result']::insert($set_lg_result);
-            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
+            if($ret != true) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
         }
-//        return Response::success();
     }
 
-    //写入赛事结果
+    /*
+     * 写入赛事结果
+     */
     public function com_result($opt=[],$gameName='',$lg_id='',$match_id=''){
         $game_code = $opt['game_code'];
         //根据球类代码获取相关model
         $model = commonFunction::getModels($game_code,1);
         $data = $opt['data'];
-//        //验证结果所属联赛
-//        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
-//            ->value('lg_id');
-//        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
-//        //验证结果所属赛事
-//        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
-//            ->value('match_id');
-//        if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
         //查询结果是否存在
         $match_r_id = $model['model_result']::where(['match_id'=>$match_id])
             ->value('id');
@@ -613,10 +600,10 @@ class WriteSportsController extends BaseController{
         if(!empty($match_r_id)){
             $ret = $model['model_result']::where(['id'=>$match_r_id])
                 -> update($set_match_r);
-            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
         }else{
             $ret = $model['model_result']::insert($set_match_r);
-            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+            if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
         }
 //        return Response::success();
     }
@@ -628,15 +615,6 @@ class WriteSportsController extends BaseController{
         $model = commonFunction::getModels($game_code,1);
         $data = $opt['data'];
 
-        //验证结果所属联赛
-//        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
-//            ->value('lg_id');
-//        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
-//        //验证结果所属赛事
-//        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
-//            ->value('match_id');
-//        if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
-
         $match_r_id = $model['model_result_record']::where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
             ->value('id');
         //根据球类 获取 赛事结果记录字段
@@ -653,64 +631,6 @@ class WriteSportsController extends BaseController{
         }
     }
 
-    //写入赔率记录
-    public function odds_record($opt){
-        $game_code = $opt['game_code'];
-        //根据球类代码获取相关model
-        $model = commonFunction::getModels($game_code,1);
-        $data = $opt['data'];
-
-        $match = $model['model_local_match']::select('match_id','others_match_id')
-            ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
-            ->first();
-        if(count($match) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
-
-        //获取赛事 本地/源ID
-        $others_match_id = $match->others_match_id;
-        $match_id = $match->match_id;
-
-        $lg = $model['model_local_league']::select('lg_id','others_lg_id')
-            ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
-            ->first();
-        if(count($lg) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
-
-        //获取联赛 本地/源ID
-        $others_lg_id = $lg->others_lg_id;
-        $lg_id = $lg->lg_id;
-        //查询 赔率数据是否存在
-        $oddsID = $model['model_odds_record']::where(['odds_only'=>$data['odds_only']])
-            ->value('id');
-
-        $set_odds = [
-            'match_id'=> $match_id,
-            'others_match_id'=> $others_match_id,
-            'odds_code'=> $data['odds_code'],
-            'status'=> $data['status'],
-            'sort'=> $data['sort'],
-            'p_code'=> $data['p_code'],
-            'odds'=> $data['odds'],
-            'condition'=> $data['condition'],
-            'odds_only'=> $data['odds_only'],
-            'source'=> $data['source'],
-            'type'=> $data['type'],
-            'team'=> $data['team'],
-            'lg_id'=> $lg_id,
-            'others_lg_id'=> $others_lg_id,
-            'ctime'=> date('Y-m-d H:i:s'),
-            'utime'=> date('Y-m-d H:i:s'),
-        ];
-        //更新或写入赔率记录
-        if(!empty($oddsID)){
-            $ret = $model['model_odds_record']::where(['id'=>$oddsID])
-                -> update($set_odds);
-            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
-        }else{
-            $ret = $model['model_odds_record']::insert($set_odds);
-            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
-        }
-//        return Response::success();
-    }
-
     /**
      * @param $data
      * @return mixed
@@ -723,7 +643,9 @@ class WriteSportsController extends BaseController{
         return $data;
     }
 
-    //根据球类获取 赛事结果记录字段
+    /*
+     * 根据球类获取 赛事结果记录字段
+     */
     public function get_match_r($game_code,$lg_id,$match_id,$data){
         $set_match_r = [];
         if($game_code == 'zq'){

+ 6 - 4
app/Http/Model/StBqResult.php

@@ -5,16 +5,18 @@ use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 用户账号
+ * Class StBqResult
+ * @package App\Http\Model
+ * 棒球 赛事 结果
  */
 class StBqResult extends Model
 {
     protected $table = 'st_bq_result';
     public $timestamps = false;
 
-    //写赛事结果
+    /*
+     * 写赛事结果
+     */
     public static function BQresult($model){
         //获取赛事表7天内所有赛事
         $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_date','match_time')

+ 6 - 8
app/Http/Model/StLqResult.php

@@ -5,16 +5,18 @@ use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 用户账号
+ * Class StLqResult
+ * @package App\Http\Model
+ * 篮球 赛事 结果
  */
 class StLqResult extends Model
 {
     protected $table = 'st_lq_result';
     public $timestamps = false;
 
-    //写赛事结果
+    /*
+     * 写赛事结果
+     */
     public static function LQresult($model){
         //获取赛事表7天内所有赛事
         $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_date','match_time')
@@ -41,8 +43,6 @@ class StLqResult extends Model
                 }
                 $start_time = ($v['match_date'].' '.$v['match_time']);
 
-//                $time = time()-strtotime($v['match_time']);
-//                $match_time = self::secTime($time);
                 $set_match_r[] = [
                     "match_id"=> $v['id'],
                     "home_team"=>$v['home_team'],
@@ -81,8 +81,6 @@ class StLqResult extends Model
                     }
                     $start_time = ($v['match_date'].' '.$v['match_time']);
 
-//                    $time = time()-strtotime($v['match_time']);
-//                    $match_time = self::secTime($time);
                     $set_match_r[] = [
                         "match_id"=> $v['id'],
                         "home_team"=>$v['home_team'],

+ 6 - 4
app/Http/Model/StWqResult.php

@@ -5,16 +5,18 @@ use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 用户账号
+ * Class StWqResult
+ * @package App\Http\Model
+ * 网球 赛事 结果
  */
 class StWqResult extends Model
 {
     protected $table = 'st_wq_result';
     public $timestamps = false;
 
-    //写赛事结果
+    /*
+     * 写赛事结果
+     */
     public static function WQresult($model){
         //获取赛事表7天内所有赛事
         $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_date','match_time')

+ 6 - 4
app/Http/Model/StZqLocalLeague.php

@@ -4,9 +4,9 @@ namespace App\Http\Model;
 use Illuminate\Database\Eloquent\Model;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 足球 联赛 关联
+ * Class StZqLocalLeague
+ * @package App\Http\Model
+ * 足球联赛 中间表
  */
 class StZqLocalLeague extends Model
 {
@@ -14,7 +14,9 @@ class StZqLocalLeague extends Model
     protected $table = 'st_zq_local_league';
     public $timestamps = false;
 
-    //获取三天内所有的联赛id
+    /*
+     * 获取一段时间内所有联赛数据
+     */
     public static function getLeagueID($models){
         $lg_data = $models['model_local_league']::select('lg_id','others_lg_id','source')
             ->where([['ctime','>',date('Y-m-d H:i:s' , strtotime("-15 day"))]])

+ 6 - 4
app/Http/Model/StZqLocalMatch.php

@@ -4,9 +4,9 @@ namespace App\Http\Model;
 use Illuminate\Database\Eloquent\Model;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 足球 赛事关联
+ * Class StZqLocalMatch
+ * @package App\Http\Model
+ * 足球 赛事 中间表
  */
 class StZqLocalMatch extends Model
 {
@@ -14,7 +14,9 @@ class StZqLocalMatch extends Model
     protected $table = 'st_zq_local_match';
     public $timestamps = false;
 
-    //获取三天内所有的赛事id
+    /*
+     * 获取一段时间内所有赛事
+     */
     public static function getMatchID($models){
         $match_data = $models['model_local_match']::select('match_id','others_match_id','source')
             ->where([['ctime','>',date('Y-m-d H:i:s' , strtotime("-3 day"))]])

+ 6 - 4
app/Http/Model/StZqOdds.php

@@ -4,16 +4,18 @@ namespace App\Http\Model;
 use Illuminate\Database\Eloquent\Model;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 用户账号
+ * Class StZqOdds
+ * @package App\Http\Model
+ * 足球 赔率
  */
 class StZqOdds extends Model
 {
     protected $table = 'st_zq_odds';
     public $timestamps = false;
 
-    //获取三天内所有的赔率
+    /*
+     * 获取一段时间内所有的赔率
+     */
     public static function getOddsID($models){
         $Odds_data = $models['model_odds']::select('id','sole','source')
             ->where([['utime','>',date('Y-m-d H:i:s' , strtotime("-1 day"))]])

+ 6 - 4
app/Http/Model/StZqOddsRecord.php

@@ -4,16 +4,18 @@ namespace App\Http\Model;
 use Illuminate\Database\Eloquent\Model;
 
 /**
- * Class Account
- * @package App\Sports\Model
- * 用户账号
+ * Class StZqOddsRecord
+ * @package App\Http\Model
+ * 足球 赔率 记录
  */
 class StZqOddsRecord extends Model
 {
     protected $table = 'st_zq_odds_record';
     public $timestamps = false;
 
-    //获取三天内所有的赔率记录
+    /*
+     * 获取一段时间内所有的赔率记录
+     */
     public static function getOddsRecordID($models){
         $OddsRecord_data = $models['model_odds_record']::select('id','odds_only','source')
             ->where([['ctime','>',date('Y-m-d H:i:s' , strtotime("-1 day"))]])

+ 7 - 4
app/Http/Model/StZqResult.php

@@ -3,17 +3,20 @@ namespace App\Http\Model;
 
 use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
+
 /**
- * Class Account
- * @package App\Sports\Model
- * 足球结果
+ * Class StZqResult
+ * @package App\Http\Model
+ * 足球 赛事 结果
  */
 class StZqResult extends Model
 {
     protected $table = 'st_zq_result';
     public $timestamps = false;
 
-    //写赛事结果
+    /*
+     * 写赛事结果
+     */
     public static function ZQresult($model){
         //获取赛事表7天内所有赛事
         $matchData = $model['model_match']::select('id','home_team','guest_team','lg_id','status','tag','match_date','match_time')