wip del err

This commit is contained in:
salam committed 2026-10-04 15:22:39 +02:00
1 parent 812736ca9a
commit 9bcd4432c6
1210 files changed
-220941

No files matched your search

@@ -1,132 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo;
use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\Fixtures\FindFixture;
use App\Console\Commands\Nuh;
use App\Models\EventBookmaker;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Fixtures
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$proxy = Nuh::$options['p'] ?? 0;
FindFixture::start();
$sportmap = Sport::map('magl', false, [1, 3]);
// dd($sportmap);
if ($proxy) {
Notice::note('PROXY USED', 'r');
}
if ($debug) {
Notice::note(Nuh::$options['provider'].' '.Nuh::$options['name'], 'g');
}
foreach ($sportmap as $sport_id => $magloo_sport_id) {
$event_id_collector = [];
/**
* Tornaments
*/
$url = Nuh::$options['base_url'].'/en/'.$magloo_sport_id.'/prematch/sport';
$data = Curl::load($url);
if (is_array($data) or \count($data)) {
$ligas = [];
foreach ($data as $value) {
$tmp = [];
if ($value['i'] == $magloo_sport_id) {
$tmp['sport'] = $value['n'];
$tmp['sport_id'] = $sport_id;
foreach ($value['C'] as $key => $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) {
// 19 => array:6 [
// "sport" => "Basketball"
// "sport_id" => 3
// "country_id" => 146
// "country" => "Israel"
// "group_id" => 525
// "group" => "Super League"
// ]
if ($liga['group'] && strpos($liga['group'], 'Simulated') === false) {
$sport_id = $liga['sport_id'];
$url = Nuh::$options['base_url'].'/en/'.$magloo_sport_id.'/prematch/tournament/'.$liga['group_id'].'/event';
$data = Curl::load($url);
if (! count($data)) {
return;
}
foreach ($data as $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['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::find($event);
if (isset($event['id'])) {
$event_id_collector[] = $event['id'];
DB::transaction(function () use ($event, $sport_id) {
EventBookmaker::updateOrCreate([
'event_id' => $event['id'],
'sport_id' => $sport_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]);
}, 5);
}
}
}
}
if ($event_id_collector) {
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
}
}
}
}
}
@@ -1,156 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo;
use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\Magloo\Odds\FilterHandicap;
use App\Console\Commands\Grapper\Magloo\Odds\FilterHandicapQ1;
use App\Console\Commands\Grapper\Magloo\Odds\FilterTotals;
use App\Console\Commands\Grapper\Magloo\Odds\FilterTotalsQ1;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStore1x2;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStoreDc;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStoreGgng;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStorePoints;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStorePointsQ1;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStoreTotals;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStoreTotalsQ1;
use App\Console\Commands\Grapper\Magloo\Odds\MaglooStoreTq;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Odds
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$proxy = Nuh::$options['p'] ?? 0;
$event_id_collector = [];
$sportmap = Sport::map('magl', 1, [1, 3]);
if ($proxy) {
Notice::note('PROXY USED', 'r');
}
if ($debug) {
Notice::note(Nuh::$options['provider'].' '.Nuh::$options['name'], 'g');
}
foreach ($sportmap as $magloo_sport_id => $sport_id) {
$url = Nuh::$options['base_url'].'/1/prematch/sport/'.$magloo_sport_id.'/odds';
$data = Curl::load($url, ['timeout' => 30]);
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['event_id'] = $event_id;
$base['bookmaker_id'] = Nuh::$options['bookmaker_id'];
$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,
'sport_id' => $sport_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['starttime' => $starttime, 'in_feed' => 1, 'bmoid' => $base['bmoid']]);
// if ($event_id == 14190947) {
// dd($match['M']);
// }
foreach ($match['M'] as $magloo_bettype_id => $value) {
switch ($magloo_bettype_id) {
case 1:
// 1x2
MaglooStore1x2::store($value, $base);
break;
case 2:
// to qalify
MaglooStoreTq::store($value, $base);
break;
case 10:
// double chance
MaglooStoreDc::store($value, $base);
break;
case 27:
// ggng
MaglooStoreGgng::store($value, $base);
break;
case 16:
case 2000:
// points
$odds = FilterHandicap::get($value);
MaglooStorePoints::store($odds, $base);
break;
case 2025:
// points qt
$odds = FilterHandicapQ1::get($value);
MaglooStorePointsQ1::store($odds, $base);
break;
case 17:
case 2002:
// totals
$odds = FilterTotals::get($value, $sport_id);
MaglooStoreTotals::store($odds, $base);
break;
case 2012:
// totals qt
$odds = FilterTotalsQ1::get($value, $sport_id);
MaglooStoreTotalsQ1::store($odds, $base);
break;
}
}
}
}
}
EventBookmaker::whereNotIn('event_id', $event_id_collector)
->where('bookmaker_id', Nuh::$options['bookmaker_id'])
->update(['in_feed' => 0]);
$tables = ['odds_3ways', 'odds_dc', 'odds_ggng', 'odds_points', 'odds_points_q1', 'odds_totals', 'odds_totals_q1', 'odds_tq'];
foreach ($tables as $table) {
DB::table($table)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->whereNotIn('event_id', $event_id_collector)->update(['flags' => 0]);
}
}
}
@@ -1,35 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
class ActiveHandicap
{
public static function set(&$_spreads)
{
$tmp = 10000;
$hcap = false;
foreach ($_spreads 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;
}
}
foreach ($_spreads as $key => $value) {
if ($key == $hcap) {
$_spreads[$key]['active_spread'] = 1;
} else {
$_spreads[$key]['active_spread'] = 0;
}
}
}
}
@@ -1,26 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Console\Commands\Grapper\Logifuture\Tools\ActiveHandicap;
class FilterHandicap
{
public static function get($_spreads)
{
ActiveHandicap::set($_spreads);
$_points = [];
foreach ($_spreads as $handicap => $value) {
if (fmod(abs($handicap), 1) == 0.5) {
if ($value[1714] > 1 and $value[1715] > 1) {
$_points[$handicap]['home'] = number_format($value[1714], 2);
$_points[$handicap]['away'] = number_format($value[1715], 2);
}
}
}
return $_points;
}
}
@@ -1,26 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
class FilterHandicapQ1
{
public static function get($_array)
{
$_points = [];
foreach ($_array as $key => $value) {
$t = explode('_', $key);
$matchpart = $t[0];
$handicap = (float) $t[1];
if ($matchpart == 1) {
if (fmod(abs($handicap), 1) == 0.5) {
if ($value[1714] > 1 and $value[1715] > 1) {
$_points[$handicap]['home'] = number_format($value[1714], 2);
$_points[$handicap]['away'] = number_format($value[1715], 2);
}
}
}
}
return $_points;
}
}
@@ -1,30 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
class FilterTotals
{
public static function get($_array, $sport_id)
{
$_totals = [];
foreach ($_array as $total => $value) {
if ($sport_id == 1) {
if ($total == 2.5) {
if ($value[12] > 1 and $value[13] > 1) {
$_totals[$total]['over'] = number_format($value[12], 2);
$_totals[$total]['under'] = number_format($value[13], 2);
}
}
} else {
if (fmod(abs($total), 1) == 0.5) {
if ($value[12] > 1 and $value[13] > 1) {
$_totals[$total]['over'] = number_format($value[12], 2);
$_totals[$total]['under'] = number_format($value[13], 2);
}
}
}
}
return $_totals;
}
}
@@ -1,26 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
class FilterTotalsQ1
{
public static function get($_array, $sport_id)
{
$_totals = [];
foreach ($_array as $key => $value) {
$t = explode('_', $key);
$matchpart = $t[0];
$total = (float) $t[1];
if ($matchpart == 1) {
if (fmod(abs($total), 1) == 0.5) {
if ($value[12] > 1 and $value[13] > 1) {
$_totals[$total]['over'] = number_format($value[12], 2);
$_totals[$total]['under'] = number_format($value[13], 2);
}
}
}
}
return $_totals;
}
}
@@ -1,37 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\Odds3way;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStore1x2
{
public static function store($value, $base)
{
$odds = [];
$odds['h3w'] = number_format($value['static'][1], 2) ?? 1;
$odds['d3w'] = number_format($value['static'][2], 2) ?? 1;
$odds['a3w'] = number_format($value['static'][3], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = Odds3way::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
if (! $res) {
Odds3way::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->d3w = $odds['d3w'];
$res->a3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,39 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsDc;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreDc
{
public static function store($value, $base)
{
$odds = [];
$odds['dc1x'] = number_format($value['static'][9], 2) ?? 1;
$odds['dc12'] = number_format($value['static'][10], 2) ?? 1;
$odds['dcx2'] = number_format($value['static'][11], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsDc::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
if (! $res) {
OddsDc::create($odds);
} else {
$res->dc1x = $odds['dc1x'];
$res->dc12 = $odds['dc12'];
$res->dcx2 = $odds['dcx2'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,36 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsGgng;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreGgng
{
public static function store($value, $base)
{
$odds = [];
$odds['gg'] = number_format($value['static'][74], 2) ?? 1;
$odds['ng'] = number_format($value['static'][76], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsGgng::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
if (! $res) {
OddsGgng::create($odds);
} else {
$res->gg = $odds['gg'];
$res->ng = $odds['ng'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,48 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsPoint;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStorePoints
{
public static function store($data, $base)
{
ActiveHandicap::set($data);
foreach ($data as $handicap => $value) {
$odds = $value;
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$odds['active_spread'] = $value['active_spread'];
$odds['handicap'] = $handicap;
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsPoint::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPoint::create($odds);
} else {
$res->flags = 1;
$res->home = number_format($odds['home'], 2);
$res->away = number_format($odds['away'], 2);
$res->handicap = number_format($odds['handicap'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -1,48 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsPointQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStorePointsQ1
{
public static function store($data, $base)
{
ActiveHandicap::set($data);
foreach ($data as $handicap => $value) {
$odds = $value;
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$odds['active_spread'] = $value['active_spread'];
$odds['handicap'] = $handicap;
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsPointQ1::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPointQ1::create($odds);
} else {
$res->flags = 1;
$res->home = number_format($odds['home'], 2);
$res->away = number_format($odds['away'], 2);
$res->handicap = number_format($odds['handicap'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -1,48 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTotal;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTotals
{
public static function store($data, $base)
{
ActiveHandicap::set($data);
foreach ($data as $total => $value) {
$odds = $value;
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$odds['active_spread'] = $value['active_spread'];
$odds['total'] = $total;
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsTotal::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotal::create($odds);
} else {
$res->flags = 1;
$res->over = number_format($odds['over'], 2);
$res->under = number_format($odds['under'], 2);
$res->total = number_format($odds['total'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -1,48 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTotalQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTotalsQ1
{
public static function store($data, $base)
{
ActiveHandicap::set($data);
foreach ($data as $total => $value) {
$odds = $value;
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$odds['active_spread'] = $value['active_spread'];
$odds['total'] = $total;
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsTotalQ1::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotalQ1::create($odds);
} else {
$res->flags = 1;
$res->over = number_format($odds['over'], 2);
$res->under = number_format($odds['under'], 2);
$res->total = number_format($odds['total'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -1,36 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTq;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTq
{
public static function store($value, $base)
{
$odds = [];
$odds['htq'] = number_format($value['static'][4], 2) ?? 1;
$odds['atq'] = number_format($value['static'][5], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds = array_merge($odds, $base);
$odds['flags'] = 1;
$res = OddsTq::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
if (! $res) {
OddsTq::create($odds);
} else {
$res->flags = 1;
$res->htq = $odds['htq'];
$res->atq = $odds['atq'];
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}