renewd grapper wip
This commit is contained in:
1 parent
8f1aeafe46
commit
4afe60a957
55 files changed
+1389
-823
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Utilities\Margin;
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\ActiveHandicap;
|
||||
|
||||
class FilterHandicap
|
||||
{
|
||||
public static function get($_array)
|
||||
public static function get($_spreads)
|
||||
{
|
||||
|
||||
ActiveHandicap::set($_spreads);
|
||||
|
||||
$_points = [];
|
||||
foreach ($_array as $handicap => $value) {
|
||||
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);
|
||||
@@ -18,32 +21,6 @@ class FilterHandicap
|
||||
}
|
||||
}
|
||||
|
||||
$tmp = 10000;
|
||||
$handicap = false;
|
||||
foreach ($_points as $key => $value) {
|
||||
$x = 0;
|
||||
foreach ($value as $k => $v) {
|
||||
if ($x == 0) {
|
||||
$x = $v;
|
||||
} else {
|
||||
$x -= $v;
|
||||
}
|
||||
}
|
||||
$x = abs($x);
|
||||
if ($x < $tmp) {
|
||||
$handicap = $key;
|
||||
$tmp = $x;
|
||||
}
|
||||
}
|
||||
$return = [];
|
||||
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;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $_points;
|
||||
}
|
||||
}
|
||||
@@ -2,50 +2,25 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class FilterHandicapQ1
|
||||
{
|
||||
public static function get($_array)
|
||||
{
|
||||
$_points = [];
|
||||
foreach ($_array as $handicap => $value) {
|
||||
$t = explode('_', $handicap);
|
||||
$handicap = $t[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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tmp = 10000;
|
||||
$handicap = false;
|
||||
foreach ($_points as $key => $value) {
|
||||
$x = 0;
|
||||
foreach ($value as $k => $v) {
|
||||
if ($x == 0) {
|
||||
$x = $v;
|
||||
} else {
|
||||
$x -= $v;
|
||||
}
|
||||
}
|
||||
$x = abs($x);
|
||||
if ($x < $tmp) {
|
||||
$handicap = $key;
|
||||
$tmp = $x;
|
||||
}
|
||||
}
|
||||
$return = [];
|
||||
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;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $_points;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class FilterTotals
|
||||
{
|
||||
public static function get($_array, $sport_id)
|
||||
@@ -17,36 +15,7 @@ class FilterTotals
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sport_id == 1) {
|
||||
$spread = '2.5';
|
||||
} else {
|
||||
$tmp = 10000;
|
||||
$spread = false;
|
||||
foreach ($_totals as $key => $value) {
|
||||
$x = 0;
|
||||
foreach ($value as $v) {
|
||||
if ($x == 0) {
|
||||
$x = $v;
|
||||
} else {
|
||||
$x -= $v;
|
||||
}
|
||||
}
|
||||
$x = abs($x);
|
||||
if ($x < $tmp) {
|
||||
$spread = $key;
|
||||
$tmp = $x;
|
||||
}
|
||||
}
|
||||
}
|
||||
$return = [];
|
||||
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;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $_totals;
|
||||
}
|
||||
}
|
||||
@@ -2,53 +2,25 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class FilterTotalsQ1
|
||||
{
|
||||
public static function get($_array, $sport_id)
|
||||
{
|
||||
$_totals = [];
|
||||
foreach ($_array as $total => $value) {
|
||||
if (fmod(abs($total), 1) == 0.5) {
|
||||
$t = explode('_', $total);
|
||||
$total = $t[1];
|
||||
if ($value[12] > 1 and $value[13] > 1) {
|
||||
$_totals[$total]['over'] = number_format($value[12], 2);
|
||||
$_totals[$total]['under'] = number_format($value[13], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sport_id == 1) {
|
||||
$spread = '2.5';
|
||||
} else {
|
||||
$tmp = 10000;
|
||||
$spread = false;
|
||||
foreach ($_totals as $key => $value) {
|
||||
$x = 0;
|
||||
foreach ($value as $k => $v) {
|
||||
if ($x == 0) {
|
||||
$x = $v;
|
||||
} else {
|
||||
$x -= $v;
|
||||
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);
|
||||
}
|
||||
}
|
||||
$x = abs($x);
|
||||
if ($x < $tmp) {
|
||||
$spread = $key;
|
||||
$tmp = $x;
|
||||
}
|
||||
}
|
||||
}
|
||||
$return = [];
|
||||
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;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $_totals;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\Odds3way;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class Store1x2
|
||||
{
|
||||
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 = 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->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsDc;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreDc
|
||||
{
|
||||
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 = 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'];
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = $odds['checked_at'];
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsGgng;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreGgng
|
||||
{
|
||||
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 = 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'];
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = $odds['checked_at'];
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StorePoints
|
||||
{
|
||||
public static function store($data, $base)
|
||||
{
|
||||
ActiveHandicap::set($data);
|
||||
|
||||
foreach ($data as $handicap => $value) {
|
||||
$odds = $value;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['active_spread'] = $value['active_spread'];
|
||||
$odds['handicap'] = $handicap;
|
||||
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
|
||||
|
||||
$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->home = number_format($odds['home'], 2);
|
||||
$res->away = number_format($odds['away'], 2);
|
||||
$res->handicap = number_format($odds['handicap'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->checked_at = now();
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsPointQ1;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StorePointsQ1
|
||||
{
|
||||
public static function store($data, $base)
|
||||
{
|
||||
ActiveHandicap::set($data);
|
||||
|
||||
foreach ($data as $handicap => $value) {
|
||||
$odds = $value;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['active_spread'] = $value['active_spread'];
|
||||
$odds['handicap'] = $handicap;
|
||||
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
|
||||
|
||||
$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->home = number_format($odds['home'], 2);
|
||||
$res->away = number_format($odds['away'], 2);
|
||||
$res->handicap = number_format($odds['handicap'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->checked_at = now();
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreTotals
|
||||
{
|
||||
public static function store($data, $base)
|
||||
{
|
||||
ActiveHandicap::set($data);
|
||||
|
||||
foreach ($data as $total => $value) {
|
||||
$odds = $value;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['active_spread'] = $value['active_spread'];
|
||||
$odds['total'] = $total;
|
||||
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
|
||||
|
||||
$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->over = number_format($odds['over'], 2);
|
||||
$res->under = number_format($odds['under'], 2);
|
||||
$res->total = number_format($odds['total'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->checked_at = now();
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsTotalQ1;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreTotalsQ1
|
||||
{
|
||||
public static function store($data, $base)
|
||||
{
|
||||
ActiveHandicap::set($data);
|
||||
|
||||
foreach ($data as $total => $value) {
|
||||
$odds = $value;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['active_spread'] = $value['active_spread'];
|
||||
$odds['total'] = $total;
|
||||
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
|
||||
|
||||
$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->over = number_format($odds['over'], 2);
|
||||
$res->under = number_format($odds['under'], 2);
|
||||
$res->total = number_format($odds['total'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->checked_at = now();
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsTq;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreTq
|
||||
{
|
||||
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);
|
||||
|
||||
$res = OddsTq::where('event_id', $base['event_id'])->where('bookmaker_id', $base['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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user