renewd grapper wip
This commit is contained in:
1 parent
8f1aeafe46
commit
4afe60a957
55 files changed
+1389
-823
No files matched your search
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\Margin;
|
||||
use App\Console\Commands\Grapper\Logifuture\Odds\StorePoints;
|
||||
use App\Console\Commands\Grapper\Logifuture\Odds\StoreTotals;
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\FilterHandicap;
|
||||
use App\Console\Commands\Nuh;
|
||||
|
||||
class Basketball
|
||||
{
|
||||
public static function get(&$event, &$_spreads, $match)
|
||||
public static function get(&$event, $match)
|
||||
{
|
||||
$n_totals = [];
|
||||
$n_totals_qt = [];
|
||||
@@ -76,61 +77,48 @@ class Basketball
|
||||
}
|
||||
}
|
||||
|
||||
dd($n_totals);
|
||||
|
||||
$_spreads = [];
|
||||
// COLUMBIA
|
||||
if ($c_totals) {
|
||||
PrinzipalHandicap::filter($_spreads['total'], 'B_OUHND@', $c_totals, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total'], 'B_OUHND@', $c_totals, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($c_totals_qt) {
|
||||
PrinzipalHandicap::filter($_spreads['total_qt'], 'B_OUHND1P@', $c_totals_qt, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total_qt'], 'B_OUHND1P@', $c_totals_qt, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($c_points) {
|
||||
PrinzipalHandicap::filter($_spreads['point'], 'B_12HND@', $c_points, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point'], 'B_12HND@', $c_points, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
if ($c_points_qt) {
|
||||
PrinzipalHandicap::filter($_spreads['point_qt'], 'B_12HND1P@', $c_points_qt, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point_qt'], 'B_12HND1P@', $c_points_qt, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
|
||||
// NIGERIA
|
||||
if ($n_totals) {
|
||||
PrinzipalHandicap::filter($_spreads['total'], 'B_OUN@', $n_totals, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total'], 'B_OUN@', $n_totals, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($n_totals_qt) {
|
||||
PrinzipalHandicap::filter($_spreads['total_qt'], 'B_1QOU@', $n_totals_qt, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total_qt'], 'B_1QOU@', $n_totals_qt, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($n_points) {
|
||||
PrinzipalHandicap::filter($_spreads['point'], 'B_H@', $n_points, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point'], 'B_H@', $n_points, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
if ($n_points_qt) {
|
||||
PrinzipalHandicap::filter($_spreads['point_qt'], 'B_1QH@', $n_points_qt, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point_qt'], 'B_1QH@', $n_points_qt, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
|
||||
dd($n_totals);
|
||||
$base = [];
|
||||
$base['event_id'] = $event['id'];
|
||||
$base['bookmaker_id'] = $event['bookmaker_id'];
|
||||
$base['sport_id'] = $event['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = $event['event_id'];
|
||||
$base['flags'] = 1;
|
||||
|
||||
if (\count($n_totals) == 2) {
|
||||
|
||||
$_total['margin'] = (float) Margin::calculate($n_totals, 1);
|
||||
|
||||
$_total = array_merge($_total, $base);
|
||||
|
||||
$res = OddsTotal::where('event_id', $event['id'])
|
||||
->where('bookmaker_id', $event['bookmaker_id'])
|
||||
->where('total', $event['total'])
|
||||
->first();
|
||||
|
||||
if (! $res) {
|
||||
OddsTotal::create($_total);
|
||||
} else {
|
||||
$res->over = number_format($_total['over'], 2);
|
||||
$res->under = number_format($_total['under'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->margin = $_total['margin'];
|
||||
$res->save();
|
||||
}
|
||||
if (isset($_spreads['total'])) {
|
||||
StoreTotals::store($_spreads['total'], $base);
|
||||
}
|
||||
if (isset($_spreads['point'])) {
|
||||
StorePoints::store($_spreads['point'], $base);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,24 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
|
||||
use App\Console\Commands\Grapper\Logifuture\Odds\StorePoints;
|
||||
use App\Console\Commands\Grapper\Logifuture\Odds\StorePointsQ1;
|
||||
use App\Console\Commands\Grapper\Logifuture\Odds\StoreTotals;
|
||||
use App\Console\Commands\Grapper\Logifuture\Odds\StoreTotalsQ1;
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\FilterHandicap;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds2way;
|
||||
use App\Models\Odds2wayS1;
|
||||
use App\Models\Odds3way;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class Icehockey
|
||||
{
|
||||
public static function get(&$event, &$_spreads, $match)
|
||||
public static function get(&$event, $match)
|
||||
{
|
||||
$ml = [];
|
||||
$mls1 = [];
|
||||
$_3way = [];
|
||||
$n_totals = [];
|
||||
$n_points = [];
|
||||
$c_totals = [];
|
||||
@@ -16,22 +28,27 @@ class Icehockey
|
||||
foreach ($match['odds'] as $name => $value) {
|
||||
switch ($name) {
|
||||
case 'IH_1X2_1':
|
||||
$event['h3w'] = number_format($value, 2);
|
||||
$_3way['h3w'] = number_format($value, 2);
|
||||
break;
|
||||
case 'IH_1X2_X':
|
||||
$event['d3w'] = number_format($value, 2);
|
||||
$_3way['d3w'] = number_format($value, 2);
|
||||
break;
|
||||
case 'IH_1X2_2':
|
||||
$event['a3w'] = number_format($value, 2);
|
||||
$_3way['a3w'] = number_format($value, 2);
|
||||
break;
|
||||
|
||||
case 'IH_12_1':
|
||||
case 'IH_12OTAP_1':
|
||||
$event['h2w'] = number_format($value, 2);
|
||||
$ml['h2w'] = number_format($value, 2);
|
||||
break;
|
||||
case 'IH_12_2':
|
||||
$ml['a2w'] = number_format($value, 2);
|
||||
break;
|
||||
|
||||
case 'IH_12OTAP_1':
|
||||
$mls1['h2w'] = number_format($value, 2);
|
||||
break;
|
||||
case 'IH_12OTAP_2':
|
||||
$event['a2w'] = number_format($value, 2);
|
||||
$mls1['a2w'] = number_format($value, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -59,20 +76,111 @@ class Icehockey
|
||||
}
|
||||
}
|
||||
|
||||
$base = [];
|
||||
$base['event_id'] = $event['id'];
|
||||
$base['bookmaker_id'] = $event['bookmaker_id'];
|
||||
$base['sport_id'] = $event['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = $event['event_id'];
|
||||
$base['flags'] = 1;
|
||||
|
||||
// 1x2
|
||||
if (\count($_3way) == 3) {
|
||||
|
||||
$_3way['margin'] = (float) Margin::calculate($_3way, 1);
|
||||
|
||||
$_3way = array_merge($_3way, $base);
|
||||
|
||||
$res = Odds3way::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
Odds3way::create($_3way);
|
||||
} else {
|
||||
$res->h3w = number_format($_3way['h3w'], 2);
|
||||
$res->d3w = number_format($_3way['d3w'], 2);
|
||||
$res->a3w = number_format($_3way['a3w'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->margin = $_3way['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ML
|
||||
if (\count($ml) == 2) {
|
||||
|
||||
$ml['margin'] = (float) Margin::calculate($ml, 1);
|
||||
|
||||
$ml = array_merge($ml, $base);
|
||||
|
||||
$res = Odds2way::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
Odds2way::create($ml);
|
||||
} else {
|
||||
$res->h2w = number_format($ml['h2w'], 2);
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->margin = $ml['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (\count($mls1) == 2) {
|
||||
|
||||
$mls1['margin'] = (float) Margin::calculate($mls1, 1);
|
||||
|
||||
$mls1 = array_merge($mls1, $base);
|
||||
|
||||
$res = Odds2wayS1::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
Odds2wayS1::create($ml);
|
||||
} else {
|
||||
$res->h2w = number_format($ml['h2w'], 2);
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->margin = $mls1['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
// COLUMBIA
|
||||
if ($c_totals) {
|
||||
PrinzipalHandicap::filter($_spreads['total'], 'IH_OUHND@', $c_totals, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total'], 'IH_OUHND@', $c_totals, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($c_points) {
|
||||
PrinzipalHandicap::filter($_spreads['point'], 'IH_12HND@', $c_points, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point'], 'IH_12HND@', $c_points, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
|
||||
// NIGERIA
|
||||
if ($n_totals) {
|
||||
PrinzipalHandicap::filter($_spreads['total'], 'IH_TF@', $n_totals, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total'], 'IH_TF@', $n_totals, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($n_points) {
|
||||
PrinzipalHandicap::filter($_spreads['point'], 'IH_HR1@', $n_points, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point'], 'IH_HR1@', $n_points, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
|
||||
if (isset($_spreads['total'])) {
|
||||
StoreTotals::store($_spreads['total'], $base);
|
||||
}
|
||||
if (isset($_spreads['total_qt'])) {
|
||||
StoreTotalsQ1::store($_spreads['total_qt'], $base);
|
||||
}
|
||||
if (isset($_spreads['point'])) {
|
||||
StorePoints::store($_spreads['point'], $base);
|
||||
}
|
||||
if (isset($_spreads['point_qt'])) {
|
||||
StorePointsQ1::store($_spreads['point_qt'], $base);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class Soccer
|
||||
$base['sport_id'] = $event['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = $event['event_id'];
|
||||
$base['flag'] = 1;
|
||||
$base['flags'] = 1;
|
||||
|
||||
// 1x2
|
||||
if (\count($_3way) == 3) {
|
||||
@@ -89,13 +89,12 @@ class Soccer
|
||||
Odds3way::create($_3way);
|
||||
} else {
|
||||
$res->h3w = number_format($_3way['h3w'], 2);
|
||||
$res->a3w = number_format($_3way['d3w'], 2);
|
||||
$res->d3w = number_format($_3way['a3w'], 2);
|
||||
$res->d3w = number_format($_3way['d3w'], 2);
|
||||
$res->a3w = number_format($_3way['a3w'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->flag = 1;
|
||||
$res->margin = $_3way['margin'];
|
||||
$res->save();
|
||||
}
|
||||
@@ -111,7 +110,7 @@ class Soccer
|
||||
|
||||
$res = OddsTotal::where('event_id', $event['id'])
|
||||
->where('bookmaker_id', $event['bookmaker_id'])
|
||||
->where('total', $event['total'])
|
||||
->where('total', $_total['total'])
|
||||
->first();
|
||||
|
||||
if (! $res) {
|
||||
@@ -179,12 +178,12 @@ class Soccer
|
||||
|
||||
$_tq['margin'] = (float) Margin::calculate($_tq, 1);
|
||||
|
||||
$_tq = array_merge($_dc, $base);
|
||||
$_tq = array_merge($_tq, $base);
|
||||
|
||||
$res = OddsTq::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
OddsTq::create($_dc);
|
||||
OddsTq::create($_tq);
|
||||
} else {
|
||||
$res->htq = number_format($_tq['htq'], 2);
|
||||
$res->atq = number_format($_tq['atq'], 2);
|
||||
|
||||
@@ -2,12 +2,20 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\FilterHandicap;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds\StorePoints;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds\StoreTotals;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds2way;
|
||||
use App\Models\Odds2wayS1;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class Tennis
|
||||
{
|
||||
public static function get(&$event, &$_spreads, $match)
|
||||
public static function get(&$event, $match)
|
||||
{
|
||||
$ml = [];
|
||||
$mls1 = [];
|
||||
$n_totals = [];
|
||||
$n_points = [];
|
||||
$c_totals = [];
|
||||
@@ -16,17 +24,17 @@ class Tennis
|
||||
foreach ($match['odds'] as $name => $value) {
|
||||
switch ($name) {
|
||||
case 'T_12_1':
|
||||
$event['h2w'] = number_format($value, 2);
|
||||
$ml['h2w'] = number_format($value, 2);
|
||||
break;
|
||||
case 'T_12_2':
|
||||
$event['a2w'] = number_format($value, 2);
|
||||
$ml['a2w'] = number_format($value, 2);
|
||||
break;
|
||||
|
||||
case 'T_121P_1':
|
||||
$_spreads['mlset1']['h2w'] = number_format($value, 2);
|
||||
$mls1['h2w'] = number_format($value, 2);
|
||||
break;
|
||||
case 'T_121P_2':
|
||||
$_spreads['mlset1']['a2w'] = number_format($value, 2);
|
||||
$mls1['a2w'] = number_format($value, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -38,15 +46,13 @@ class Tennis
|
||||
// NIGERIA
|
||||
case 'T_OUG':
|
||||
$n_totals[$name] = $value;
|
||||
$c_totals[$name] = $value;
|
||||
break;
|
||||
case 'T_GH':
|
||||
$n_points[$name] = $value;
|
||||
break;
|
||||
|
||||
// COLOMBIA
|
||||
case 'T_OUG':
|
||||
$c_totals[$name] = $value;
|
||||
break;
|
||||
case 'T_HNDGAMES':
|
||||
$c_points[$name] = $value;
|
||||
break;
|
||||
@@ -54,20 +60,81 @@ class Tennis
|
||||
}
|
||||
}
|
||||
|
||||
$base = [];
|
||||
$base['event_id'] = $event['id'];
|
||||
$base['bookmaker_id'] = $event['bookmaker_id'];
|
||||
$base['sport_id'] = $event['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = $event['event_id'];
|
||||
$base['flags'] = 1;
|
||||
|
||||
// ML
|
||||
if (\count($ml) == 2) {
|
||||
|
||||
$ml['margin'] = (float) Margin::calculate($ml, 1);
|
||||
|
||||
$ml = array_merge($ml, $base);
|
||||
|
||||
$res = Odds2way::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
Odds2way::create($ml);
|
||||
} else {
|
||||
$res->h2w = number_format($ml['h2w'], 2);
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->margin = $ml['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (\count($mls1) == 2) {
|
||||
|
||||
$mls1['margin'] = (float) Margin::calculate($mls1, 1);
|
||||
|
||||
$mls1 = array_merge($mls1, $base);
|
||||
|
||||
$res = Odds2wayS1::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
Odds2wayS1::create($ml);
|
||||
} else {
|
||||
$res->h2w = number_format($ml['h2w'], 2);
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = now();
|
||||
$res->margin = $mls1['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
|
||||
$_spreads = [];
|
||||
// COLUMBIA
|
||||
if ($c_totals) {
|
||||
PrinzipalHandicap::filter($_spreads['total'], 'T_OUG@', $c_totals, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total'], 'T_OUG@', $c_totals, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($c_points) {
|
||||
PrinzipalHandicap::filter($_spreads['point'], 'T_HNDGAMES@', $c_points, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point'], 'T_HNDGAMES@', $c_points, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
|
||||
// NIGERIA
|
||||
if ($n_totals) {
|
||||
PrinzipalHandicap::filter($_spreads['total'], 'T_OUG@', $n_totals, ['over', 'under', 'total']);
|
||||
FilterHandicap::filter($_spreads['total'], 'T_OUG@', $n_totals, ['over', 'under', 'total']);
|
||||
}
|
||||
if ($n_points) {
|
||||
PrinzipalHandicap::filter($_spreads['point'], 'T_GH@', $n_points, ['hth1', 'hth2', 'hcap']);
|
||||
FilterHandicap::filter($_spreads['point'], 'T_GH@', $n_points, ['hth1', 'hth2', 'hcap']);
|
||||
}
|
||||
|
||||
if (isset($_spreads['total'])) {
|
||||
StoreTotals::store($_spreads['total'], $base);
|
||||
}
|
||||
if (isset($_spreads['point'])) {
|
||||
StorePoints::store($_spreads['point'], $base);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
class FilterHandicap
|
||||
{
|
||||
public static function filter(&$_spreads, $filter, $data, $oddnames)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$key = str_replace($filter, '', $key);
|
||||
|
||||
if (strpos($key, '_O') !== false) {
|
||||
$hcap = str_replace('_O', '', $key);
|
||||
$_spreads[$hcap]['ele1'] = $value;
|
||||
} elseif (strpos($key, '_1H') !== false) {
|
||||
$hcap = str_replace('_1H', '', $key);
|
||||
$_spreads[$hcap]['ele1'] = $value;
|
||||
} elseif (strpos($key, '_1') !== false) {
|
||||
$hcap = str_replace('_1', '', $key);
|
||||
$_spreads[$hcap]['ele1'] = $value;
|
||||
} elseif (strpos($key, '_U') !== false) {
|
||||
$hcap = str_replace('_U', '', $key);
|
||||
$_spreads[$hcap]['ele2'] = $value;
|
||||
} elseif (strpos($key, '_2H') !== false) {
|
||||
$hcap = str_replace('_2H', '', $key);
|
||||
$_spreads[$hcap]['ele2'] = $value;
|
||||
} elseif (strpos($key, '_2') !== false) {
|
||||
$hcap = str_replace('_2', '', $key);
|
||||
$_spreads[$hcap]['ele2'] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,25 @@ use App\Utilities\Notice;
|
||||
|
||||
class LogifutureData
|
||||
{
|
||||
public static $testfiles = '/Console/Commands/TestFiles/';
|
||||
|
||||
public static function load($logifuture_sport_id)
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$save = Nuh::$options['s'] ?? 0;
|
||||
$read = Nuh::$options['r'] ?? 0;
|
||||
|
||||
$filename = app_path().self::$testfiles.str_replace(' ', '_', strtolower(Nuh::$options['sport'].'_'.Nuh::$options['provider'])).'.json';
|
||||
|
||||
if ($read) {
|
||||
if ($debug) {
|
||||
Notice::note('data read localy', 'g');
|
||||
}
|
||||
|
||||
$file = file_get_contents($filename);
|
||||
|
||||
return json_decode($file, true);
|
||||
}
|
||||
|
||||
$url = Nuh::$options['base_url'].'/v1/matches?sportId='.$logifuture_sport_id;
|
||||
|
||||
@@ -59,6 +75,13 @@ class LogifutureData
|
||||
|
||||
$file = curl_exec($ch);
|
||||
|
||||
if ($save) {
|
||||
|
||||
file_put_contents($filename, $file);
|
||||
|
||||
Notice::note('file saved localy', 'g');
|
||||
}
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
echo curl_error($ch);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ class MapEvent
|
||||
{
|
||||
public static function filter($sport_id, $match)
|
||||
{
|
||||
|
||||
$event = [];
|
||||
$event['event_id'] = (int) $match['id'];
|
||||
$event['bookmaker_id'] = Nuh::$options['bookmaker_id'];
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
class PrinzipalHandicap
|
||||
{
|
||||
public static function filter(&$_spreads, $filter, $data, $oddnames)
|
||||
{
|
||||
$_tmp = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$key = str_replace($filter, '', $key);
|
||||
|
||||
if (strpos($key, '_O') !== false) {
|
||||
$hcap = str_replace('_O', '', $key);
|
||||
$_tmp[$hcap]['ele1'] = $value;
|
||||
} elseif (strpos($key, '_1H') !== false) {
|
||||
$hcap = str_replace('_1H', '', $key);
|
||||
$_tmp[$hcap]['ele1'] = $value;
|
||||
} elseif (strpos($key, '_1') !== false) {
|
||||
$hcap = str_replace('_1', '', $key);
|
||||
$_tmp[$hcap]['ele1'] = $value;
|
||||
} elseif (strpos($key, '_U') !== false) {
|
||||
$hcap = str_replace('_U', '', $key);
|
||||
$_tmp[$hcap]['ele2'] = $value;
|
||||
} elseif (strpos($key, '_2H') !== false) {
|
||||
$hcap = str_replace('_2H', '', $key);
|
||||
$_tmp[$hcap]['ele2'] = $value;
|
||||
} elseif (strpos($key, '_2') !== false) {
|
||||
$hcap = str_replace('_2', '', $key);
|
||||
$_tmp[$hcap]['ele2'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$tmp = 10000;
|
||||
$hcap = false;
|
||||
foreach ($_tmp 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;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hcap) {
|
||||
$_spreads[$oddnames[0]] = $_tmp[$hcap]['ele1'];
|
||||
$_spreads[$oddnames[1]] = $_tmp[$hcap]['ele2'];
|
||||
$_spreads[$oddnames[2]] = $hcap;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Odds;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\ActiveHandicap;
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StorePoints
|
||||
{
|
||||
public static function store(&$_spreads, $base)
|
||||
{
|
||||
ActiveHandicap::set($_spreads);
|
||||
|
||||
foreach ($_spreads as $handicap => $value) {
|
||||
// code...
|
||||
$odds = [];
|
||||
$odds['home'] = $value['ele1'];
|
||||
$odds['away'] = $value['ele2'];
|
||||
$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,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Odds;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\ActiveHandicap;
|
||||
use App\Models\OddsPointQ1;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StorePointsQ1
|
||||
{
|
||||
public static function store(&$_spreads, $base)
|
||||
{
|
||||
ActiveHandicap::set($_spreads);
|
||||
|
||||
foreach ($_spreads as $handicap => $value) {
|
||||
// code...
|
||||
$odds = [];
|
||||
$odds['home'] = $value['ele1'];
|
||||
$odds['away'] = $value['ele2'];
|
||||
$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,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Odds;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\ActiveHandicap;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreTotals
|
||||
{
|
||||
public static function store(&$_spreads, $base)
|
||||
{
|
||||
ActiveHandicap::set($_spreads);
|
||||
|
||||
foreach ($_spreads as $total => $value) {
|
||||
// code...
|
||||
$odds = [];
|
||||
$odds['over'] = $value['ele1'];
|
||||
$odds['under'] = $value['ele2'];
|
||||
$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,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Odds;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\Tools\ActiveHandicap;
|
||||
use App\Models\OddsTotalQ1;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class StoreTotalsQ1
|
||||
{
|
||||
public static function store(&$_spreads, $base)
|
||||
{
|
||||
ActiveHandicap::set($_spreads);
|
||||
|
||||
foreach ($_spreads as $total => $value) {
|
||||
// code...
|
||||
$odds = [];
|
||||
$odds['over'] = $value['ele1'];
|
||||
$odds['under'] = $value['ele2'];
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user