137 lines
4.5 KiB
PHP
137 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\Logifuture;
|
|
|
|
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
|
|
use App\Models\OddsTotal;
|
|
use App\Utilities\Margin;
|
|
|
|
class Basketball
|
|
{
|
|
public static function get(&$event, &$_spreads, $match)
|
|
{
|
|
$n_totals = [];
|
|
$n_totals_qt = [];
|
|
$n_points = [];
|
|
$n_points_qt = [];
|
|
|
|
$c_totals = [];
|
|
$c_totals_qt = [];
|
|
$c_points = [];
|
|
$c_points_qt = [];
|
|
|
|
foreach ($match['odds'] as $name => $value) {
|
|
/*
|
|
case 'B_1X2_1':
|
|
$event['h3w'] = $value;
|
|
break;
|
|
case 'B_1X2_X':
|
|
$event['d3w'] = $value;
|
|
break;
|
|
case 'B_1X2_2':
|
|
$event['a3w'] = $value;
|
|
break;
|
|
|
|
case 'B_12_1':
|
|
$_bai_2way['h2w'] = $value;
|
|
break;
|
|
case 'B_12_2':
|
|
$_bai_2way['a2w'] = $value;
|
|
break;
|
|
*/
|
|
|
|
if (strpos($name, '@') !== false) {
|
|
$pos = strpos($name, '@');
|
|
$market = substr($name, 0, $pos);
|
|
|
|
switch ($market) {
|
|
// NIGERIA
|
|
case 'B_OUN':
|
|
$n_totals[$name] = number_format($value, 2);
|
|
break;
|
|
case 'B_1QOU':
|
|
$n_totals_qt[$name] = number_format($value, 2);
|
|
break;
|
|
case 'B_H':
|
|
$n_points[$name] = number_format($value, 2);
|
|
break;
|
|
case 'B_1QH':
|
|
$n_points_qt[$name] = number_format($value, 2);
|
|
break;
|
|
|
|
// COLOMBIA
|
|
case 'B_OUHND':
|
|
$c_totals[$name] = number_format($value, 2);
|
|
break;
|
|
case 'B_OUHND1P':
|
|
$c_totals_qt[$name] = number_format($value, 2);
|
|
break;
|
|
case 'B_12HND':
|
|
$c_points[$name] = number_format($value, 2);
|
|
break;
|
|
case 'B_12HND1P':
|
|
$c_points_qt[$name] = number_format($value, 2);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
dd($n_totals);
|
|
|
|
// COLUMBIA
|
|
if ($c_totals) {
|
|
PrinzipalHandicap::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']);
|
|
}
|
|
if ($c_points) {
|
|
PrinzipalHandicap::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']);
|
|
}
|
|
|
|
// NIGERIA
|
|
if ($n_totals) {
|
|
PrinzipalHandicap::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']);
|
|
}
|
|
if ($n_points) {
|
|
PrinzipalHandicap::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']);
|
|
}
|
|
|
|
dd($n_totals);
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|