Browse Source

新增各球类赛果数据接口

彭俊 6 years ago
parent
commit
b7165f3494

+ 82 - 0
Application/Sports/Controller/ResultMatch.php

@@ -0,0 +1,82 @@
+<?php
+namespace App\Sports\Controller;
+
+use BaseController\Controller;
+use Biz\Match\GetmatchData;
+use Biz\Match\GetOddsData;
+
+/**
+ * 前台赛果数据接口
+ * User: tank
+ * Date: 2019/9/24
+ */
+class ResultMatch extends Controller{
+    public function init() {
+        $this->commonFunction =  C()->get('commonFunction');
+        $this->getTypeData = new GetmatchData();
+        $this->getOddsData = new GetOddsData();
+
+    }
+
+    /**
+     * 获取各球类赛果数据
+     */
+    public function getMatchResult(){
+        
+        //获取球类代码
+        $game_code = $_REQUEST['game_code'];
+        //获取开赛日期
+        $match_date = $_REQUEST['match_date'];
+        try {
+            if(empty($game_code) || empty($match_date)){
+                throw new \Exception(Render([], '10001', lang('Tips','Sports')->get('PARAM_ERROR')));
+            }
+            //获取球类 model
+            $getModels = $this->commonFunction->getModels($game_code);
+            $model_result_express = $getModels['model_result_express'];
+
+            //拼装查询条件
+            $where = [
+                ['match_date','=',$match_date]
+            ];
+
+            //获取赛果数据
+
+            //获取联赛数据
+            $match_result_league= lm($model_result_express,"Sports")
+                ->select('league_id','league_name')
+                ->where($where)
+                ->groupBy('league_id','league_name')
+                ->orderBy('league_id','asc')
+                ->get()
+                ->toArray();
+
+            //获取赛事数据
+            $match_result_match = lm($model_result_express,"Sports")
+                ->select('league_id','league_name','match_date','match_time','home_team','guest_team','score_half','score_full','play_data','c_time','source','match_id')
+                ->where($where)
+                ->get()
+                ->toArray();
+
+            //拼装数据
+            $match_result_data = [];
+            if(!empty($match_result_league) and !empty($match_result_match)){
+                foreach($match_result_league as $k=>$v){
+                    foreach($match_result_match as $kk=>$vv){
+                        if($v['league_id'] == $vv['league_id']){
+                            $v['match_data'][] = $vv;
+                        }
+                    }
+
+                    $match_result_data[$k] = $v;
+                }
+            }
+
+            Render($match_result_data, '1', lang('Tips','Sports')->get('success'));
+        } catch (\Exception $e) {
+            echo $e->getMessage();
+        }
+    }
+
+
+}

+ 14 - 0
Application/Sports/Model/St_bq_result_express.php

@@ -0,0 +1,14 @@
+<?php
+namespace App\Sports\Model;
+
+use \System\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class St_bq_result_express extends Model
+{
+    protected $table = 'st_bq_result_express';
+}

+ 14 - 0
Application/Sports/Model/St_lq_result_express.php

@@ -0,0 +1,14 @@
+<?php
+namespace App\Sports\Model;
+
+use \System\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class St_lq_result_express extends Model
+{
+    protected $table = 'st_lq_result_express';
+}

+ 14 - 0
Application/Sports/Model/St_wq_result_express.php

@@ -0,0 +1,14 @@
+<?php
+namespace App\Sports\Model;
+
+use \System\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class St_wq_result_express extends Model
+{
+    protected $table = 'st_wq_result_express';
+}

+ 14 - 0
Application/Sports/Model/St_zq_result_express.php

@@ -0,0 +1,14 @@
+<?php
+namespace App\Sports\Model;
+
+use \System\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class St_zq_result_express extends Model
+{
+    protected $table = 'st_zq_result_express';
+}

+ 5 - 0
Biz/Common/CommonFunction.php

@@ -611,6 +611,7 @@ class CommonFunction {
                     $model_league_result = 'st_zq_league_result';
                     $model_local_league = 'st_zq_local_league';
                     $model_local_match = 'st_zq_local_match';
+                    $model_result_express = 'st_zq_result_express';
 
                     break;
                 case 'lq':
@@ -623,6 +624,7 @@ class CommonFunction {
                     $model_league_result = 'st_lq_league_result';
                     $model_local_league = 'st_lq_local_league';
                     $model_local_match = 'st_lq_local_match';
+                    $model_result_express = 'st_lq_result_express';
 
                     break;
                 case 'wq':
@@ -635,6 +637,7 @@ class CommonFunction {
                     $model_league_result = 'st_wq_league_result';
                     $model_local_league = 'st_wq_local_league';
                     $model_local_match = 'st_wq_local_match';
+                    $model_result_express = 'st_wq_result_express';
 
                     break;
                 case 'bq':
@@ -647,6 +650,7 @@ class CommonFunction {
                     $model_league_result = 'st_bq_league_result';
                     $model_local_league = 'st_bq_local_league';
                     $model_local_match = 'st_bq_local_match';
+                    $model_result_express = 'st_bq_result_express';
 
                     break;
                 case 'gj':
@@ -706,6 +710,7 @@ class CommonFunction {
             'model_league_result'=>$model_league_result,//联赛结果
             'model_local_league'=>$model_local_league,//本地关联联赛
             'model_local_match'=>$model_local_match,//本地关联赛事
+            'model_result_express' =>$model_result_express,//赛果
         ];
         return $data;
     }