瀏覽代碼

调整冠军联赛列表数据

彭俊 6 年之前
父節點
當前提交
7f41f91cae
共有 2 個文件被更改,包括 71 次插入10 次删除
  1. 1 10
      app/Http/Controllers/Admin/ZqChampionsLeagueController.php
  2. 70 0
      app/Models/SoccerLeague.php

+ 1 - 10
app/Http/Controllers/Admin/ZqChampionsLeagueController.php

@@ -83,7 +83,7 @@ class ZqChampionsLeagueController extends Controller
         }
 
         $newapp = new \App\Models\SoccerLeague();
-        $data = $newapp->getinfo($list, $page, $where);
+        $data = $newapp->get_league_gj_info($list, $page, $where);
         return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
     }
 
@@ -104,10 +104,6 @@ class ZqChampionsLeagueController extends Controller
             return -1;
         }
 
-        // $areas = $this->getarea();
-        // if (!$areas) {
-        //     return -2;
-        // }
         $data = \App\Models\SoccerLeague::where('id',$id)->first();
         $areaname = \App\Models\StAreaCountry::where('id',$data->area_id)->first();
         $countryname = \App\Models\StAreaCountry::where('id',$data->country_id)->first();
@@ -131,9 +127,7 @@ class ZqChampionsLeagueController extends Controller
 
             return view('sports.soccer_champions_league_form', $data);
         } else {
-            // var_dump(count($allteam));die;
             for($i=0;$i<count($odds_code);$i++){
-                // $tname = 'teammz'.$i;
                 for ($ic=0; $ic < count($allteam); $ic++) { 
                     $team = 'teammz'.$i .$ic;
                     $isteam = $req->$team .',';
@@ -192,7 +186,4 @@ class ZqChampionsLeagueController extends Controller
         }
     }
 
-
-
-
 }

+ 70 - 0
app/Models/SoccerLeague.php

@@ -8,6 +8,8 @@
 
 namespace App\Models;
 use Illuminate\Support\Facades\DB;
+use App\Lib\Biz\Sport\Common as commonFunction;
+
 class SoccerLeague extends BaseModel {
     protected $table = "st_zq_league";
     public $timestamps = false;
@@ -105,5 +107,73 @@ class SoccerLeague extends BaseModel {
         return $data->toArray();
     }
 
+    //测试冠军联赛数据
+    function get_league_gj_info($list = 10, $page, $where = '')
+    {
+        if (is_array ($where) && count ($where) > 0){
+            $data = $this
+                ->join('st_zq_odds','st_zq_odds.lg_id','=','st_zq_league.id')
+                ->select('st_zq_league.id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.status','st_zq_league.utime')
+                ->orderby('st_zq_league.utime','desc')
+                ->where($where)
+                ->distinct('st_zq_league.name_chinese')
+                ->paginate ($list);
+        }else{
+            $data = $this
+                ->join('st_zq_odds','st_zq_odds.lg_id','=','st_zq_league.id')
+                ->select('st_zq_league.id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.status','st_zq_league.utime')
+                ->where('st_zq_odds.type',1)
+                ->distinct('st_zq_league.name_chinese')
+                ->orderby('st_zq_league.utime','desc')
+                ->paginate ($list);
+        }
+        if (!$data) {
+            return -5040000102; //无相关信息
+        }
+        //地区
+        $area = \App\Models\StAreaCountry::where('pid','0')->get();
+
+        //国家
+        $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
+
+        for($i=0;$i<count($data);$i++){
+            //$data[$i]->id = $data[$i]->lg_id;
+
+            if($data[$i]->status == '-1'){
+                $data[$i]->league_status = '未启用';
+            }
+            if($data[$i]->status == '1'){
+                $data[$i]->league_status = '启用';
+            }
+
+            $str = 0;
+            $str1 = 0;
+            if($data[$i]->area_id == '0'){
+                $data[$i]->area = '无';
+            }else{
+                for($b=0;$b<count($area);$b++){
+                    if($area[$b]->id == $data[$i]->area_id){
+                        $str = 1;
+                        $data[$i]->area = $area[$b]->name;
+                    }
+                }
+                if($str == 0){$data[$i]->area = '无';}
+            }
+            if($data[$i]->country_id == 0){
+                $data[$i]->country = '无';
+            }else{
+                for($c=0;$c<count($country);$c++){
+                    if($country[$c]->id == $data[$i]->country_id){
+                        $str1 = 1;
+                        $data[$i]->country = $country[$c]->name;
+                    }
+                }
+                if($str1 == 0){$data[$i]->country = '无';}
+            }
+
+        }
+
+        return $data->toArray();
+    }
 
 }