renewd grapper wip

This commit is contained in:
salam committed 2026-01-19 18:36:07 +01:00
1 parent 8f1aeafe46
commit 4afe60a957
55 files changed
+1389 -823

No files matched your search

+22 -185
View File
@@ -7,19 +7,18 @@ 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\Store1x2;
use App\Console\Commands\Grapper\Magloo\Odds\StoreDc;
use App\Console\Commands\Grapper\Magloo\Odds\StoreGgng;
use App\Console\Commands\Grapper\Magloo\Odds\StorePoints;
use App\Console\Commands\Grapper\Magloo\Odds\StorePointsQ1;
use App\Console\Commands\Grapper\Magloo\Odds\StoreTotals;
use App\Console\Commands\Grapper\Magloo\Odds\StoreTotalsQ1;
use App\Console\Commands\Grapper\Magloo\Odds\StoreTq;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\Odds3way;
use App\Models\OddsDc;
use App\Models\OddsGgng;
use App\Models\OddsPoint;
use App\Models\OddsPointQ1;
use App\Models\OddsTotal;
use App\Models\OddsTotalQ1;
use App\Models\OddsTq;
use App\Models\Sport;
use App\Utilities\Margin;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
@@ -58,9 +57,11 @@ class Odds
$betradar_id = (int) preg_replace('/\D/', '', $match['p']);
$bmoid = preg_replace('/\D/', '', $match['i']);
$starttime = Carbon::parse($match['dt'])->toDateTimeString();
$event_id = Event::where('betradar_id', $betradar_id)->value('id');
$event_id = Event::where('betradar_id', $betradar_id)->orWhere('magnig_id', $bmoid)->orWhere('magken_id', $bmoid)->value('id');
if ($event_id) {
$base = [];
@@ -79,114 +80,30 @@ class Odds
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['starttime' => $starttime, 'in_feed' => 1, 'bmoid' => $base['bmoid']]);
// if ($event_id == 13913478) {
// dd($match['M']);
// }
if ($event_id == 14190947) {
// dd($match['M']);
}
foreach ($match['M'] as $magloo_bettype_id => $value) {
switch ($magloo_bettype_id) {
case 1:
// 1x2
$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 = array_merge($odds, $base);
$res = Odds3way::where('event_id', $event_id)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->first();
if (! $res) {
Odds3way::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->a3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
Store1x2::store($value, $base);
break;
case 2:
// to qalify
$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);
$res = OddsTq::where('event_id', $event_id)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->first();
if (! $res) {
OddsTq::create($odds);
} else {
$res->htq = $odds['htq'];
$res->atq = $odds['atq'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
StoreTq::store($value, $base);
break;
case 10:
// double chance
$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 = array_merge($odds, $base);
$res = OddsDc::where('event_id', $event_id)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->first();
if (! $res) {
OddsDc::create($odds);
} else {
$res->dc1x = $odds['dc1x'];
$res->dc12 = $odds['dc12'];
$res->dcx2 = $odds['dcx2'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
StoreDc::store($value, $base);
break;
case 27:
// ggng
$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 = array_merge($odds, $base);
$res = OddsGgng::where('event_id', $event_id)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->first();
if (! $res) {
OddsGgng::create($odds);
} else {
$res->gg = $odds['gg'];
$res->ng = $odds['ng'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
StoreGgng::store($value, $base);
break;
case 16:
@@ -194,52 +111,15 @@ class Odds
// points
$odds = FilterHandicap::get($value);
$odds = array_merge($odds, $base);
StorePoints::store($odds, $base);
$res = OddsPoint::where('event_id', $event_id)
->where('bookmaker_id', Nuh::$options['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPoint::create($odds);
} else {
$res->home = $odds['home'];
$res->away = $odds['away'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->difference = $odds['difference'];
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
break;
case 2025:
// points qt
$odds = FilterHandicapQ1::get($value);
$odds = array_merge($odds, $base);
$res = OddsPointQ1::where('event_id', $event_id)
->where('bookmaker_id', Nuh::$options['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPointQ1::create($odds);
} else {
$res->home = $odds['home'];
$res->away = $odds['away'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->difference = $odds['difference'];
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
StorePointsQ1::store($odds, $base);
break;
@@ -247,60 +127,17 @@ class Odds
case 2002:
// totals
$odds = FilterTotals::get($value, $sport_id);
$odds = array_merge($odds, $base);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
$res = OddsTotal::where('event_id', $event_id)
->where('bookmaker_id', Nuh::$options['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotal::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->difference = $odds['difference'];
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
StoreTotals::store($odds, $base);
break;
case 2012:
// totals qt
$odds = FilterTotalsQ1::get($value, $sport_id);
$odds = array_merge($odds, $base);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
StoreTotalsQ1::store($odds, $base);
$res = OddsTotalQ1::where('event_id', $event_id)
->where('bookmaker_id', Nuh::$options['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotalQ1::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->difference = $odds['difference'];
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
break;
}
}