Ken 1 месяц назад
Родитель
Сommit
e4f88c2eb8

+ 2 - 2
app/Http/Controllers/Api/Test.php

@@ -14,8 +14,8 @@ class Test extends Controller
     public function index()
     {
 
-
-//        return $this->success($list);
+        $res = FixtureService::odds('164327');
+        return $this->success($res);
     }
 
     function football($api, $params = [])

+ 5 - 0
app/Services/ApiFootball/Client.php

@@ -73,6 +73,11 @@ public static function oddsLive($params = [])
         return static::get('odds/live', $params);
     }
 
+    public static function odds($params = [])
+    {
+        return static::get('odds', $params);
+    }
+
     public static function fixturesRounds($params = [])
     {
         return static::get('fixtures/rounds', $params);

+ 14 - 0
app/Services/FixtureService.php

@@ -5,10 +5,24 @@
 use App\Models\Sport;
 use App\Services\ApiFootball\Client;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Cache;
 
 class FixtureService extends BaseService
 {
 
+    static function odds($id)
+    {
+        $key = "odds_{$id}";
+        $odds = Cache::get($key, null);
+        if ($odds) return json_decode($odds, true);
+        $res = Client::odds(['fixture'=>$id]);
+        return $res;
+//        $res['']
+//        $sport = Sport::where('data_id', $id)->first();
+//        return $sport->odds;
+
+
+    }
 
     /**
      * 将进行中的赛事 更新赔率