141 lines
4.3 KiB
PHP
141 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\Logifuture;
|
|
|
|
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, $match)
|
|
{
|
|
$ml = [];
|
|
$mls1 = [];
|
|
$n_totals = [];
|
|
$n_points = [];
|
|
$c_totals = [];
|
|
$c_points = [];
|
|
|
|
foreach ($match['odds'] as $name => $value) {
|
|
switch ($name) {
|
|
case 'T_12_1':
|
|
$ml['h2w'] = number_format($value, 2);
|
|
break;
|
|
case 'T_12_2':
|
|
$ml['a2w'] = number_format($value, 2);
|
|
break;
|
|
|
|
case 'T_121P_1':
|
|
$mls1['h2w'] = number_format($value, 2);
|
|
break;
|
|
case 'T_121P_2':
|
|
$mls1['a2w'] = number_format($value, 2);
|
|
break;
|
|
}
|
|
|
|
if (strpos($name, '@') !== false) {
|
|
$pos = strpos($name, '@');
|
|
$market = substr($name, 0, $pos);
|
|
|
|
switch ($market) {
|
|
// NIGERIA
|
|
case 'T_OUG':
|
|
$n_totals[$name] = $value;
|
|
$c_totals[$name] = $value;
|
|
break;
|
|
case 'T_GH':
|
|
$n_points[$name] = $value;
|
|
break;
|
|
|
|
// COLOMBIA
|
|
case 'T_HNDGAMES':
|
|
$c_points[$name] = $value;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
$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) {
|
|
FilterHandicap::filter($_spreads['total'], 'T_OUG@', $c_totals, ['over', 'under', 'total']);
|
|
}
|
|
if ($c_points) {
|
|
FilterHandicap::filter($_spreads['point'], 'T_HNDGAMES@', $c_points, ['hth1', 'hth2', 'hcap']);
|
|
}
|
|
|
|
// NIGERIA
|
|
if ($n_totals) {
|
|
FilterHandicap::filter($_spreads['total'], 'T_OUG@', $n_totals, ['over', 'under', 'total']);
|
|
}
|
|
if ($n_points) {
|
|
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);
|
|
}
|
|
}
|
|
}
|