From 91ec9d11ccbe0b337d76473ff1683fcfc2bfbd02 Mon Sep 17 00:00:00 2001 From: salam Date: Wed, 7 Jan 2026 13:24:56 +0100 Subject: [PATCH] grapper logifuture wip --- app/Console/Commands/Grapper/Logifuture.php | 82 ++++++- .../Grapper/Logifuture/ActiveEvent.php | 40 ++++ .../Grapper/Logifuture/Basketball.php | 103 +++++++++ .../Commands/Grapper/Logifuture/Fixtures.php | 108 --------- .../Commands/Grapper/Logifuture/Icehockey.php | 76 +++++++ .../Commands/Grapper/Logifuture/Odds.php | 205 ------------------ .../Grapper/Logifuture/PrinzipalHandicap.php | 58 +++++ .../Commands/Grapper/Logifuture/Soccer.php | 59 +++++ .../Commands/Grapper/Logifuture/Tennis.php | 71 ++++++ .../Resources/Events/Tables/EventsTable.php | 2 +- 10 files changed, 480 insertions(+), 324 deletions(-) create mode 100644 app/Console/Commands/Grapper/Logifuture/ActiveEvent.php create mode 100644 app/Console/Commands/Grapper/Logifuture/Basketball.php delete mode 100644 app/Console/Commands/Grapper/Logifuture/Fixtures.php create mode 100644 app/Console/Commands/Grapper/Logifuture/Icehockey.php delete mode 100644 app/Console/Commands/Grapper/Logifuture/Odds.php create mode 100644 app/Console/Commands/Grapper/Logifuture/PrinzipalHandicap.php create mode 100644 app/Console/Commands/Grapper/Logifuture/Soccer.php create mode 100644 app/Console/Commands/Grapper/Logifuture/Tennis.php diff --git a/app/Console/Commands/Grapper/Logifuture.php b/app/Console/Commands/Grapper/Logifuture.php index f8977910..181699cf 100644 --- a/app/Console/Commands/Grapper/Logifuture.php +++ b/app/Console/Commands/Grapper/Logifuture.php @@ -2,6 +2,7 @@ namespace App\Console\Commands\Grapper; +use App\Console\Commands\Grapper\Logifuture\ActiveEvent; use App\Console\Commands\Grapper\Logifuture\Auth; use App\Console\Commands\Grapper\Logifuture\BaseUrl; use App\Console\Commands\Nuh; @@ -52,19 +53,80 @@ class Logifuture ]); $file = curl_exec($ch); + $matches = json_decode($file, 1); - dd($file); + if (! isset($matches['error'])) { - $data = json_decode($file, true); + foreach ($matches as $match) { - dd($data); + if (strpos($match['sportCategory'], 'Simulated Reality') === false) { + + $event = ActiveEvent::filter($sportid, $match); + + dd($event); + + $_spreads = []; + switch ($sportid) { + case 1: + Soccer::get($event, $match); + break; + case 2: + Icehockey::get($event, $_spreads, $match); + break; + case 3: + Basket::get($event, $_spreads, $match); + break; + case 5: + Tennis::get($event, $_spreads, $match); + break; + + default: + Notice::note('SPORT NOT IMPLEMENTED', 'r', 1); + break; + } + + Parser::$_matches_array = []; + Parser::$_matches_array[] = $event; + + $matchid = Parser::processData(1); + + if ($matchid) { + + $event['matchid'] = $matchid; + + if (isset($_spreads['point'])) { + $tmp = $event + $_spreads['point']; + DB_Parser::addPointOdds('bai_points', $matchid, $tmp); + } + + if (isset($_spreads['point_qt'])) { + $tmp = $event + $_spreads['point_qt']; + DB_Parser::addPointOdds('bai_points_qt', $matchid, $tmp); + } + + if (isset($_spreads['total'])) { + $tmp = $event + $_spreads['total']; + DB_Parser::addTotalOdds('bai_totals', $matchid, $tmp); + } + + if (isset($_spreads['total_qt'])) { + $tmp = $event + $_spreads['total_qt']; + DB_Parser::addTotalOdds('bai_totals_qt', $matchid, $tmp); + } + + if (isset($_spreads['mlset1'])) { + $tmp = $event + $_spreads['mlset1']; + DB_Parser::addTotalOdds('bai_2way_set1', $matchid, $tmp); + } + + if (Database::$debug) { + Notice::note($event, 'y'); + } + } + } + } + Parser::flagStatus($sportid); + } } } } - -$header = []; -$header[] = 'Authorization: Bearer '.$data['token']; -$header[] = 'accept: application/json'; -$header[] = 'content-type: application/json'; - -return $header; diff --git a/app/Console/Commands/Grapper/Logifuture/ActiveEvent.php b/app/Console/Commands/Grapper/Logifuture/ActiveEvent.php new file mode 100644 index 00000000..09de9497 --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/ActiveEvent.php @@ -0,0 +1,40 @@ +setTimezone(new DateTimeZone('Europe/Vienna')); + $event['starttime'] = $date->getTimestamp(); + + $event['groupname'] = addslashes($match['tournamentName']); + $event['groupid'] = (int) $match['tournamentId']; + $event['country'] = addslashes($match['sportCategory']); + $str = str_replace('||', '|', $match['description']); + $str = trim(str_replace('|', ' ', $str)); + $event['event'] = addslashes($str); + if (Nuh::$options['bookmaker_id'] == 36) { + $teams = explode(' v ', $str); + } else { + $teams = explode(' - ', $str); + } + $event['home'] = addslashes($teams[0]); + $event['away'] = addslashes($teams[1]); + + return $event; + } +} diff --git a/app/Console/Commands/Grapper/Logifuture/Basketball.php b/app/Console/Commands/Grapper/Logifuture/Basketball.php new file mode 100644 index 00000000..b8ddb6e9 --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/Basketball.php @@ -0,0 +1,103 @@ + $value) { + /* + case 'B_1X2_1': + $event['h3w'] = $value; + break; + case 'B_1X2_X': + $event['d3w'] = $value; + break; + case 'B_1X2_2': + $event['a3w'] = $value; + break; + + case 'B_12_1': + $_bai_2way['h2w'] = $value; + break; + case 'B_12_2': + $_bai_2way['a2w'] = $value; + break; + */ + + if (strpos($name, '@') !== false) { + $pos = strpos($name, '@'); + $market = substr($name, 0, $pos); + + switch ($market) { + // NIGERIA + case 'B_OUN': + $n_totals[$name] = $value; + break; + case 'B_1QOU': + $n_totals_qt[$name] = $value; + break; + case 'B_H': + $n_points[$name] = $value; + break; + case 'B_1QH': + $n_points_qt[$name] = $value; + break; + + // COLOMBIA + case 'B_OUHND': + $c_totals[$name] = $value; + break; + case 'B_OUHND1P': + $c_totals_qt[$name] = $value; + break; + case 'B_12HND': + $c_points[$name] = $value; + break; + case 'B_12HND1P': + $c_points_qt[$name] = $value; + break; + } + } + } + + // COLUMBIA + if ($c_totals) { + PrinzipalHandicap::filter($_spreads['total'], 'B_OUHND@', $c_totals, ['over', 'under', 'total']); + } + if ($c_totals_qt) { + PrinzipalHandicap::filter($_spreads['total_qt'], 'B_OUHND1P@', $c_totals_qt, ['over', 'under', 'total']); + } + if ($c_points) { + PrinzipalHandicap::filter($_spreads['point'], 'B_12HND@', $c_points, ['hth1', 'hth2', 'hcap']); + } + if ($c_points_qt) { + PrinzipalHandicap::filter($_spreads['point_qt'], 'B_12HND1P@', $c_points_qt, ['hth1', 'hth2', 'hcap']); + } + + // NIGERIA + if ($n_totals) { + PrinzipalHandicap::filter($_spreads['total'], 'B_OUN@', $n_totals, ['over', 'under', 'total']); + } + if ($n_totals_qt) { + PrinzipalHandicap::filter($_spreads['total_qt'], 'B_1QOU@', $n_totals_qt, ['over', 'under', 'total']); + } + if ($n_points) { + PrinzipalHandicap::filter($_spreads['point'], 'B_H@', $n_points, ['hth1', 'hth2', 'hcap']); + } + if ($n_points_qt) { + PrinzipalHandicap::filter($_spreads['point_qt'], 'B_1QH@', $n_points_qt, ['hth1', 'hth2', 'hcap']); + } + } +} diff --git a/app/Console/Commands/Grapper/Logifuture/Fixtures.php b/app/Console/Commands/Grapper/Logifuture/Fixtures.php deleted file mode 100644 index 50af3e7b..00000000 --- a/app/Console/Commands/Grapper/Logifuture/Fixtures.php +++ /dev/null @@ -1,108 +0,0 @@ - $val1) { - $tmp['country_id'] = $val1['i']; - $tmp['country'] = $val1['n']; - foreach ($val1['T'] as $key => $val2) { - $tmp['group_id'] = $val2['i']; - $tmp['group'] = $val2['n']; - $ligas[] = $tmp; - } - } - } - } - - foreach ($ligas as $liga) { - if ($liga['group'] && strpos($liga['group'], 'Simulated') === false) { - - $sport_id = $liga['sport_id']; - - $url = $base_url.'/tournament/'.$liga['group_id'].'/event'; - - $data = Curl::load($url); - - foreach ($data as $magloo) { - - // print_r($magloo); - - $event = []; - $event['event_id'] = (int) $magloo['i']; - $event['betradar_id'] = (int) preg_replace('/\D/', '', $magloo['p']); - $event['sport_id'] = $sport_id; - $event['provider_id'] = Nuh::$options['provider_id']; - $event['starttime'] = strtotime($magloo['dt']); - $event['country_id'] = $liga['country_id']; - $event['country'] = $liga['country']; - $event['group_id'] = $liga['group_id']; - $event['group'] = $liga['group']; - $event['starttime'] = Carbon::parse($magloo['dt'])->toDateTimeString(); - $teams = explode(' v ', str_replace('|', ' ', $magloo['n'])); - $event['home_id'] = $magloo['htId']; - $event['home'] = addslashes($teams[0]); - $event['away_id'] = $magloo['atId']; - $event['away'] = addslashes($teams[1]); - - FindFixture::search($event, self::$groups[$sport_id], self::$elements[$sport_id]); - } - } - } - } -} diff --git a/app/Console/Commands/Grapper/Logifuture/Icehockey.php b/app/Console/Commands/Grapper/Logifuture/Icehockey.php new file mode 100644 index 00000000..f1db5641 --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/Icehockey.php @@ -0,0 +1,76 @@ + $value) { + switch ($name) { + case 'IH_1X2_1': + $event['h3w'] = (float) $value; + break; + case 'IH_1X2_X': + $event['d3w'] = (float) $value; + break; + case 'IH_1X2_2': + $event['a3w'] = (float) $value; + break; + + case 'IH_12_1': + case 'IH_12OTAP_1': + $event['h2w'] = (float) $value; + break; + case 'IH_12_2': + case 'IH_12OTAP_2': + $event['a2w'] = (float) $value; + break; + } + + if (strpos($name, '@') !== false) { + $pos = strpos($name, '@'); + $market = substr($name, 0, $pos); + + switch ($market) { + // NIGERIA + case 'IH_TF': + $n_totals[$name] = $value; + break; + case 'IH_HR1': + $n_points[$name] = $value; + break; + + // COLOMBIA + case 'IH_OUHND': + $c_totals[$name] = $value; + break; + case 'IH_12HND': + $c_points[$name] = $value; + break; + } + } + } + + // COLUMBIA + if ($c_totals) { + Filter::prinz($_spreads['total'], 'IH_OUHND@', $c_totals, ['over', 'under', 'total']); + } + if ($c_points) { + Filter::prinz($_spreads['point'], 'IH_12HND@', $c_points, ['hth1', 'hth2', 'hcap']); + } + + // NIGERIA + if ($n_totals) { + Filter::prinz($_spreads['total'], 'IH_TF@', $n_totals, ['over', 'under', 'total']); + } + if ($n_points) { + Filter::prinz($_spreads['point'], 'IH_HR1@', $n_points, ['hth1', 'hth2', 'hcap']); + } + } +} diff --git a/app/Console/Commands/Grapper/Logifuture/Odds.php b/app/Console/Commands/Grapper/Logifuture/Odds.php deleted file mode 100644 index 8a838317..00000000 --- a/app/Console/Commands/Grapper/Logifuture/Odds.php +++ /dev/null @@ -1,205 +0,0 @@ - $sport_id) { - $url = $base_url.$magloo_sport_id.'/odds'; - - $data = Curl::load($url); - if (! is_array($data) or \count($data) == 0) { - Notice::note('no data in feed', 'r', 1); - - return; - } - - foreach ($data as $match) { - - $betradar_id = (int) preg_replace('/\D/', '', $match['p']); - - $starttime = Carbon::parse($match['dt'])->toDateTimeString(); - - $event_id = Event::where('betradar_id', $betradar_id)->value('id'); - - if ($event_id) { - $base = []; - $base['sport_id'] = $sport_id; - $base['provider_id'] = Nuh::$options['provider_id']; - $base['bmoid'] = preg_replace('/\D/', '', $match['i']); - $base['flag'] = 1; - - $event_id_collector[] = $event_id; - - EventBookmaker::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], ['in_feed' => 1, 'bmoid' => $base['bmoid']]); - - foreach ($match['M'] as $magloo_bettype_id => $value) { - switch ($magloo_bettype_id) { - case 1: - // 1x2 - $odds = []; - $odds['h3w'] = $value['static'][1] ?? 1; - $odds['d3w'] = $value['static'][2] ?? 1; - $odds['a3w'] = $value['static'][3] ?? 1; - $odds['margin'] = (float) Margin::calculate($odds, 1); - $odds['starttime'] = $starttime; - - Odds3way::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - - break; - case 2: - // to qalify - $odds = []; - $odds['htq'] = $value['static'][4] ?? 1; - $odds['atq'] = $value['static'][5] ?? 1; - $odds['margin'] = (float) Margin::calculate($odds, 1); - - OddsTq::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - - break; - - case 10: - // double chance - $odds = []; - $odds['dc1x'] = $value['static'][9] ?? 1; - $odds['dc12'] = $value['static'][10] ?? 1; - $odds['dcx2'] = $value['static'][11] ?? 1; - $odds['margin'] = (float) Margin::calculate($odds, 1); - - OddsDc::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - - break; - - case 10: - // ggng - $odds = []; - $odds['gg'] = $value['static'][74] ?? 1; - $odds['ng'] = $value['static'][76] ?? 1; - $odds['margin'] = (float) Margin::calculate($odds, 1); - - OddsDc::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - - break; - - case 16: - // points - $odds = FilterHandicap::get($value); - $odds['starttime'] = $starttime; - - OddsHandicap::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - break; - - case 2000: - // points qt - $odds = FilterHandicap::get($value); - OddsHandicap::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - break; - - case 2025: - // points qt - $odds = FilterHandicapQ1::get($value); - OddsHandicapQ1::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - break; - case 17: - case 2002: - // totals - $odds = FilterTotals::get($value, $sport_id); - OddsTotal::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - break; - case 2012: - // totals qt - $odds = FilterTotalsQ1::get($value, $sport_id); - OddsTotalQ1::updateOrCreate([ - 'event_id' => $event_id, - 'bookmaker_id' => $bookmaker_id, - ], $base + $odds); - break; - } - } - } - } - } - - EventBookmaker::whereNotIn('event_id', $event_id_collector) - ->where('bookmaker_id', $bookmaker_id) - ->update(['in_feed' => 0]); - - } -} diff --git a/app/Console/Commands/Grapper/Logifuture/PrinzipalHandicap.php b/app/Console/Commands/Grapper/Logifuture/PrinzipalHandicap.php new file mode 100644 index 00000000..da1408eb --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/PrinzipalHandicap.php @@ -0,0 +1,58 @@ + $value) { + $key = str_replace($filter, '', $key); + + if (strpos($key, '_O') !== false) { + $hcap = str_replace('_O', '', $key); + $_tmp[$hcap]['ele1'] = $value; + } elseif (strpos($key, '_1H') !== false) { + $hcap = str_replace('_1H', '', $key); + $_tmp[$hcap]['ele1'] = $value; + } elseif (strpos($key, '_1') !== false) { + $hcap = str_replace('_1', '', $key); + $_tmp[$hcap]['ele1'] = $value; + } elseif (strpos($key, '_U') !== false) { + $hcap = str_replace('_U', '', $key); + $_tmp[$hcap]['ele2'] = $value; + } elseif (strpos($key, '_2H') !== false) { + $hcap = str_replace('_2H', '', $key); + $_tmp[$hcap]['ele2'] = $value; + } elseif (strpos($key, '_2') !== false) { + $hcap = str_replace('_2', '', $key); + $_tmp[$hcap]['ele2'] = $value; + } + } + + $tmp = 10000; + $hcap = false; + foreach ($_tmp as $key => $value) { + $x = 0; + foreach ($value as $k => $v) { + if ($x == 0) { + $x = $v; + } else { + $x -= $v; + } + } + $x = abs($x); + if ($x < $tmp) { + $hcap = $key; + $tmp = $x; + } + } + + if ($hcap) { + $_spreads[$oddnames[0]] = $_tmp[$hcap]['ele1']; + $_spreads[$oddnames[1]] = $_tmp[$hcap]['ele2']; + $_spreads[$oddnames[2]] = $hcap; + } + } +} diff --git a/app/Console/Commands/Grapper/Logifuture/Soccer.php b/app/Console/Commands/Grapper/Logifuture/Soccer.php new file mode 100644 index 00000000..d8248028 --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/Soccer.php @@ -0,0 +1,59 @@ + $value) { + switch ($name) { + case 'S_1X2_1': + $event['h3w'] = (float) $value; + break; + case 'S_1X2_X': + $event['d3w'] = (float) $value; + break; + case 'S_1X2_2': + $event['a3w'] = (float) $value; + break; + + case 'S_OU@2.5_O': + $event['total'] = 2.5; + $event['over'] = (float) $value; + break; + case 'S_OU@2.5_U': + $event['total'] = 2.5; + $event['under'] = (float) $value; + break; + + case 'S_GGNG_Y': + $event['gg'] = (float) $value; + break; + case 'S_GGNG_N': + $event['ng'] = (float) $value; + break; + // case 'S_DNB_1': + // break; + // case 'S_DNB_2': + // break; + // case 'S_DC_12': + // $event['dc12'] = (float) $value; + // break; + // case 'S_DC_1X': + // $event['dc1x'] = (float) $value; + // break; + // case 'S_DC_X2': + // $event['dcx2'] = (float) $value; + // break; + + case 'S_12QUALIFY_1': + $event['one'] = (float) $value; + break; + case 'S_12QUALIFY_2': + $event['two'] = (float) $value; + break; + } + } + } +} diff --git a/app/Console/Commands/Grapper/Logifuture/Tennis.php b/app/Console/Commands/Grapper/Logifuture/Tennis.php new file mode 100644 index 00000000..5ae191a8 --- /dev/null +++ b/app/Console/Commands/Grapper/Logifuture/Tennis.php @@ -0,0 +1,71 @@ + $value) { + switch ($name) { + case 'T_12_1': + $event['h2w'] = (float) $value; + break; + case 'T_12_2': + $event['a2w'] = (float) $value; + break; + + case 'T_121P_1': + $_spreads['mlset1']['h2w'] = (float) $value; + break; + case 'T_121P_2': + $_spreads['mlset1']['a2w'] = (float) $value; + break; + } + + if (strpos($name, '@') !== false) { + $pos = strpos($name, '@'); + $market = substr($name, 0, $pos); + + switch ($market) { + // NIGERIA + case 'T_OUG': + $n_totals[$name] = $value; + break; + case 'T_GH': + $n_points[$name] = $value; + break; + + // COLOMBIA + case 'T_OUG': + $c_totals[$name] = $value; + break; + case 'T_HNDGAMES': + $c_points[$name] = $value; + break; + } + } + } + + // COLUMBIA + if ($c_totals) { + Filter::prinz($_spreads['total'], 'T_OUG@', $c_totals, ['over', 'under', 'total']); + } + if ($c_points) { + Filter::prinz($_spreads['point'], 'T_HNDGAMES@', $c_points, ['hth1', 'hth2', 'hcap']); + } + + // NIGERIA + if ($n_totals) { + Filter::prinz($_spreads['total'], 'T_OUG@', $n_totals, ['over', 'under', 'total']); + } + if ($n_points) { + Filter::prinz($_spreads['point'], 'T_GH@', $n_points, ['hth1', 'hth2', 'hcap']); + } + } +} diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index b003e88e..a8f018d5 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -123,7 +123,7 @@ class EventsTable self::load_multiline_bookmaker(); return $table - // ->poll('10s') + ->poll('10s') ->striped() ->deferLoading() ->columns([