grapper wip
This commit is contained in:
1 parent
562c65f331
commit
4184acdb8a
60 files changed
+28840
-398
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ class FilterHandicap
|
||||
foreach ($_array as $handicap => $value) {
|
||||
if (fmod(abs($handicap), 1) == 0.5) {
|
||||
if ($value[1714] > 1 and $value[1715] > 1) {
|
||||
$_points[$handicap]['home'] = $value[1714];
|
||||
$_points[$handicap]['away'] = $value[1715];
|
||||
$_points[$handicap]['home'] = number_format($value[1714], 2);
|
||||
$_points[$handicap]['away'] = number_format($value[1715], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ class FilterHandicap
|
||||
if ($handicap) {
|
||||
$return['home'] = $_points[$handicap]['home'];
|
||||
$return['away'] = $_points[$handicap]['away'];
|
||||
$return['difference'] = abs(1 / $return['home'] - 1 / $return['away']);
|
||||
$return['margin'] = (float) Margin::calculate($return, 1);
|
||||
$return['handicap'] = $handicap;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ class FilterHandicapQ1
|
||||
$handicap = $t[1];
|
||||
if (fmod(abs($handicap), 1) == 0.5) {
|
||||
if ($value[1714] > 1 and $value[1715] > 1) {
|
||||
$_points[$handicap]['home'] = $value[1714];
|
||||
$_points[$handicap]['away'] = $value[1715];
|
||||
$_points[$handicap]['home'] = number_format($value[1714], 2);
|
||||
$_points[$handicap]['away'] = number_format($value[1715], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ class FilterHandicapQ1
|
||||
if ($handicap) {
|
||||
$return['home'] = $_points[$handicap]['home'];
|
||||
$return['away'] = $_points[$handicap]['away'];
|
||||
$return['difference'] = abs(1 / $return['home'] - 1 / $return['away']);
|
||||
$return['margin'] = (float) Margin::calculate($return, 1);
|
||||
$return['handicap'] = $handicap;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ class FilterTotals
|
||||
foreach ($_array as $total => $value) {
|
||||
if (fmod(abs($total), 1) == 0.5) {
|
||||
if ($value[12] > 1 and $value[13] > 1) {
|
||||
$_totals[$total]['over'] = $value[12];
|
||||
$_totals[$total]['under'] = $value[13];
|
||||
$_totals[$total]['over'] = number_format($value[12], 2);
|
||||
$_totals[$total]['under'] = number_format($value[13], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ class FilterTotals
|
||||
if (isset($_totals[$spread])) {
|
||||
$return['over'] = $_totals[$spread]['over'];
|
||||
$return['under'] = $_totals[$spread]['under'];
|
||||
$return['difference'] = abs(1 / $return['over'] - 1 / $return['under']);
|
||||
$return['margin'] = (float) Margin::calculate($return, 1);
|
||||
$return['total'] = $spread;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ class FilterTotalsQ1
|
||||
$t = explode('_', $total);
|
||||
$total = $t[1];
|
||||
if ($value[12] > 1 and $value[13] > 1) {
|
||||
$_totals[$total]['over'] = $value[12];
|
||||
$_totals[$total]['under'] = $value[13];
|
||||
$_totals[$total]['over'] = number_format($value[12], 2);
|
||||
$_totals[$total]['under'] = number_format($value[13], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ class FilterTotalsQ1
|
||||
if (isset($_totals[$spread])) {
|
||||
$return['over'] = $_totals[$spread]['over'];
|
||||
$return['under'] = $_totals[$spread]['under'];
|
||||
$return['difference'] = abs(1 / $return['over'] - 1 / $return['under']);
|
||||
$return['margin'] = (float) Margin::calculate($return, 1);
|
||||
$return['total'] = $spread;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user