grapper wip

This commit is contained in:
salam committed 2026-01-18 14:35:30 +01:00
1 parent 562c65f331
commit 4184acdb8a
60 files changed
+28840 -398

No files matched your search

+165 -45
View File
@@ -12,6 +12,7 @@ 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;
@@ -63,17 +64,20 @@ class Odds
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;
$base['checked_at'] = now();
$event_id_collector[] = $event_id;
EventBookmaker::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $base['bmoid']]);
], ['starttime' => $starttime, 'in_feed' => 1, 'bmoid' => $base['bmoid']]);
// if ($event_id == 13913478) {
// dd($match['M']);
@@ -84,59 +88,104 @@ class Odds
case 1:
// 1x2
$odds = [];
$odds['h3w'] = $value['static'][1] ?? 1;
$odds['d3w'] = $value['static'][2] ?? 1;
$odds['a3w'] = $value['static'][3] ?? 1;
$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['starttime'] = $starttime;
$odds = array_merge($odds, $base);
Odds3way::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$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();
}
break;
case 2:
// to qalify
$odds = [];
$odds['htq'] = $value['static'][4] ?? 1;
$odds['atq'] = $value['static'][5] ?? 1;
$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);
OddsTq::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$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();
}
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['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);
OddsDc::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$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();
}
break;
case 27:
// ggng
$odds = [];
$odds['gg'] = $value['static'][74] ?? 1;
$odds['ng'] = $value['static'][76] ?? 1;
$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);
OddsDc::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$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();
}
break;
@@ -144,43 +193,114 @@ class Odds
case 2000:
// points
$odds = FilterHandicap::get($value);
$odds['starttime'] = $starttime;
OddsPoint::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$odds = array_merge($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);
OddsPointQ1::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$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();
}
break;
case 17:
case 2002:
// totals
$odds = FilterTotals::get($value, $sport_id);
$odds = array_merge($odds, $base);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
OddsTotal::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$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();
}
break;
case 2012:
// totals qt
$odds = FilterTotalsQ1::get($value, $sport_id);
OddsTotalQ1::updateOrCreate([
'event_id' => $event_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], $base + $odds);
$odds = array_merge($odds, $base);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
$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;
}
}