grapper wip

This commit is contained in:
salam committed 2026-01-18 14:35:30 +01:00
1 parent 562c65f331
commit 4184acdb8a
60 files changed
+28840 -398

No files matched your search

+127 -45
View File
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Curl;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\Odds3way;
use App\Models\Odds3wayHt;
use App\Models\OddsDc;
@@ -64,9 +65,16 @@ class Bet365
if (isset($data['results'][0]['main'])) {
EventBookmaker::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]);
$offer = $data['results'][0]['main']['sp'];
$base = [];
$base['event_id'] = $event->id;
$base['bookmaker_id'] = $bookmaker_id;
$base['sport_id'] = $event->sport_id;
$base['provider_id'] = Nuh::$options['provider_id'];
$base['bmoid'] = $event->bet365_id;
@@ -77,15 +85,28 @@ class Bet365
*/
if (isset($offer['full_time_result'])) {
$odds = [];
$odds['h3w'] = $offer['full_time_result']['odds'][0]['odds'] ?? 1;
$odds['d3w'] = $offer['full_time_result']['odds'][1]['odds'] ?? 1;
$odds['a3w'] = $offer['full_time_result']['odds'][2]['odds'] ?? 1;
$odds['h3w'] = number_format($offer['full_time_result']['odds'][0]['odds'], 2) ?? 1;
$odds['d3w'] = number_format($offer['full_time_result']['odds'][1]['odds'], 2) ?? 1;
$odds['a3w'] = number_format($offer['full_time_result']['odds'][2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
Odds3way::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bookmaker_id,
], $base + $odds);
$odds = array_merge($odds, $base);
$res = Odds3way::where('event_id', $event->id)->where('bookmaker_id', $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 = now();
$res->margin = $odds['margin'];
$res->save();
}
}
/**
@@ -93,15 +114,28 @@ class Bet365
*/
if (isset($offer['double_chance'])) {
$odds = [];
$odds['dc1x'] = $offer['double_chance']['odds'][0]['odds'] ?? 1;
$odds['dc12'] = $offer['double_chance']['odds'][1]['odds'] ?? 1;
$odds['dcx2'] = $offer['double_chance']['odds'][2]['odds'] ?? 1;
$odds['dc1x'] = number_format($offer['double_chance']['odds'][0]['odds'], 2) ?? 1;
$odds['dc12'] = number_format($offer['double_chance']['odds'][1]['odds'], 2) ?? 1;
$odds['dcx2'] = number_format($offer['double_chance']['odds'][2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
OddsDc::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bookmaker_id,
], $base + $odds);
$odds = array_merge($odds, $base);
$res = OddsDc::where('event_id', $event->id)->where('bookmaker_id', $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 = now();
$res->margin = $odds['margin'];
$res->save();
}
}
/**
@@ -110,19 +144,35 @@ class Bet365
if (isset($offer['goals_over_under'])) {
$odds = [];
$odds['over'] = $offer['goals_over_under']['odds'][0]['odds'] ?? 1;
$odds['under'] = $offer['goals_over_under']['odds'][1]['odds'] ?? 1;
$odds['over'] = number_format($offer['goals_over_under']['odds'][0]['odds'], 2) ?? 1;
$odds['under'] = number_format($offer['goals_over_under']['odds'][1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
$odds = array_merge($odds, $base);
if ($offer['goals_over_under']['odds'][1]['name'] == '2.5') {
OddsTotal::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bookmaker_id,
'total' => 2.5,
], $base + $odds);
$odds['total'] = 2.5;
$res = OddsTotal::where('event_id', $event->id)
->where('bookmaker_id', $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 = abs(1 / $odds['over'] - 1 / $odds['under']);
$res->checked_at = now();
$res->margin = $odds['margin'];
$res->save();
}
}
}
@@ -131,14 +181,26 @@ class Bet365
*/
if (isset($offer['both_teams_to_score'])) {
$odds = [];
$odds['gg'] = $offer['both_teams_to_score']['odds'][0]['odds'] ?? 1;
$odds['ng'] = $offer['both_teams_to_score']['odds'][1]['odds'] ?? 1;
$odds['gg'] = number_format($offer['both_teams_to_score']['odds'][0]['odds'], 2) ?? 1;
$odds['ng'] = number_format($offer['both_teams_to_score']['odds'][1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
OddsGgng::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bookmaker_id,
], $base + $odds);
$odds = array_merge($odds, $base);
$res = OddsGgng::where('event_id', $event->id)->where('bookmaker_id', $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 = now();
$res->margin = $odds['margin'];
$res->save();
}
}
/**
@@ -146,35 +208,55 @@ class Bet365
*/
if (isset($offer['draw_no_bet'])) {
$odds = [];
$odds['dnb1'] = $offer['draw_no_bet']['odds'][0]['odds'] ?? 1;
$odds['dnb2'] = $offer['draw_no_bet']['odds'][1]['odds'] ?? 1;
$odds['dnb1'] = number_format($offer['draw_no_bet']['odds'][0]['odds'], 2) ?? 1;
$odds['dnb2'] = number_format($offer['draw_no_bet']['odds'][1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
OddsDnb::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bookmaker_id,
], $base + $odds);
}
$res = OddsDnb::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
/**
* HALFTIME
*/
$offer = $data['results'][0]['half']['sp'] ?? '';
$odds = array_merge($odds, $base);
if (! $res) {
OddsDnb::create($odds);
} else {
$res->dnb1 = $odds['dnb1'];
$res->dnb2 = $odds['dnb2'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = now();
$res->margin = $odds['margin'];
$res->save();
}
}
/**
* 1X2 HT
*/
if (isset($offer['half_time_result'])) {
$odds = [];
$odds['h3w'] = $offer['half_time_result']['odds'][0]['odds'] ?? 1;
$odds['d3w'] = $offer['half_time_result']['odds'][1]['odds'] ?? 1;
$odds['a3w'] = $offer['half_time_result']['odds'][2]['odds'] ?? 1;
$odds['h3w'] = number_format($offer['half_time_result']['odds'][0]['odds'], 2) ?? 1;
$odds['d3w'] = number_format($offer['half_time_result']['odds'][1]['odds'], 2) ?? 1;
$odds['a3w'] = number_format($offer['half_time_result']['odds'][2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
Odds3wayHt::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bookmaker_id,
], $base + $odds);
$odds = array_merge($odds, $base);
$res = Odds3wayHt::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
if (! $res) {
Odds3wayHt::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->d3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = now();
$res->margin = $odds['margin'];
$res->save();
}
}
}
}
+2 -2
View File
@@ -25,7 +25,7 @@ class Logifuture
{
$debug = Nuh::$options['d'] ?? 0;
$sportmap = Sport::map('logi', 1, [1, 2, 3, 5]);
$sportmap = Sport::map('logi', 1, [Nuh::$options['sport_id']]);
$event_id_collector = [];
@@ -60,7 +60,7 @@ class Logifuture
EventBookmaker::updateOrCreate([
'event_id' => $event['id'],
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id']]);
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'startime' => $event['startime']]);
$_spreads = [];
switch ($sport_id) {
@@ -3,6 +3,8 @@
namespace App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
use App\Models\OddsTotal;
use App\Utilities\Margin;
class Basketball
{
@@ -45,35 +47,37 @@ class Basketball
switch ($market) {
// NIGERIA
case 'B_OUN':
$n_totals[$name] = $value;
$n_totals[$name] = number_format($value, 2);
break;
case 'B_1QOU':
$n_totals_qt[$name] = $value;
$n_totals_qt[$name] = number_format($value, 2);
break;
case 'B_H':
$n_points[$name] = $value;
$n_points[$name] = number_format($value, 2);
break;
case 'B_1QH':
$n_points_qt[$name] = $value;
$n_points_qt[$name] = number_format($value, 2);
break;
// COLOMBIA
case 'B_OUHND':
$c_totals[$name] = $value;
$c_totals[$name] = number_format($value, 2);
break;
case 'B_OUHND1P':
$c_totals_qt[$name] = $value;
$c_totals_qt[$name] = number_format($value, 2);
break;
case 'B_12HND':
$c_points[$name] = $value;
$c_points[$name] = number_format($value, 2);
break;
case 'B_12HND1P':
$c_points_qt[$name] = $value;
$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']);
@@ -101,5 +105,32 @@ class Basketball
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();
}
}
}
}
@@ -2,6 +2,8 @@
namespace App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
class Icehockey
{
public static function get(&$event, &$_spreads, $match)
@@ -14,22 +16,22 @@ class Icehockey
foreach ($match['odds'] as $name => $value) {
switch ($name) {
case 'IH_1X2_1':
$event['h3w'] = (float) $value;
$event['h3w'] = number_format($value, 2);
break;
case 'IH_1X2_X':
$event['d3w'] = (float) $value;
$event['d3w'] = number_format($value, 2);
break;
case 'IH_1X2_2':
$event['a3w'] = (float) $value;
$event['a3w'] = number_format($value, 2);
break;
case 'IH_12_1':
case 'IH_12OTAP_1':
$event['h2w'] = (float) $value;
$event['h2w'] = number_format($value, 2);
break;
case 'IH_12_2':
case 'IH_12OTAP_2':
$event['a2w'] = (float) $value;
$event['a2w'] = number_format($value, 2);
break;
}
@@ -59,18 +61,18 @@ class Icehockey
// COLUMBIA
if ($c_totals) {
Filter::prinz($_spreads['total'], 'IH_OUHND@', $c_totals, ['over', 'under', 'total']);
PrinzipalHandicap::filter($_spreads['total'], 'IH_OUHND@', $c_totals, ['over', 'under', 'total']);
}
if ($c_points) {
Filter::prinz($_spreads['point'], 'IH_12HND@', $c_points, ['hth1', 'hth2', 'hcap']);
PrinzipalHandicap::filter($_spreads['point'], 'IH_12HND@', $c_points, ['hth1', 'hth2', 'hcap']);
}
// NIGERIA
if ($n_totals) {
Filter::prinz($_spreads['total'], 'IH_TF@', $n_totals, ['over', 'under', 'total']);
PrinzipalHandicap::filter($_spreads['total'], 'IH_TF@', $n_totals, ['over', 'under', 'total']);
}
if ($n_points) {
Filter::prinz($_spreads['point'], 'IH_HR1@', $n_points, ['hth1', 'hth2', 'hcap']);
PrinzipalHandicap::filter($_spreads['point'], 'IH_HR1@', $n_points, ['hth1', 'hth2', 'hcap']);
}
}
}
@@ -23,52 +23,54 @@ class Soccer
foreach ($match['odds'] as $name => $value) {
switch ($name) {
case 'S_1X2_1':
$_3way['h3w'] = (float) $value;
$_3way['h3w'] = number_format($value, 2);
break;
case 'S_1X2_X':
$_3way['d3w'] = (float) $value;
$_3way['d3w'] = number_format($value, 2);
break;
case 'S_1X2_2':
$_3way['a3w'] = (float) $value;
$_3way['a3w'] = number_format($value, 2);
break;
case 'S_OU@2.5_O':
$_total['over'] = (float) $value;
$_total['over'] = number_format($value, 2);
break;
case 'S_OU@2.5_U':
$_total['under'] = (float) $value;
$_total['under'] = number_format($value, 2);
break;
case 'S_GGNG_Y':
$_ggng['gg'] = (float) $value;
$_ggng['gg'] = number_format($value, 2);
break;
case 'S_GGNG_N':
$_ggng['ng'] = (float) $value;
$_ggng['ng'] = number_format($value, 2);
break;
// case 'S_DNB_1':
// break;
// case 'S_DNB_2':
// break;
case 'S_DC_12':
$_dc['dc12'] = (float) $value;
$_dc['dc12'] = number_format($value, 2);
break;
case 'S_DC_1X':
$_dc['dc1x'] = (float) $value;
$_dc['dc1x'] = number_format($value, 2);
break;
case 'S_DC_X2':
$_dc['dcx2'] = (float) $value;
$_dc['dcx2'] = number_format($value, 2);
break;
case 'S_12QUALIFY_1':
$_tq['htq'] = (float) $value;
$_tq['htq'] = number_format($value, 2);
break;
case 'S_12QUALIFY_2':
$_tq['atq'] = (float) $value;
$_tq['atq'] = number_format($value, 2);
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'];
@@ -78,60 +80,121 @@ class Soccer
if (\count($_3way) == 3) {
$_3way['margin'] = (float) Margin::calculate($_3way, 1);
$_3way['starttime'] = $event['starttime'];
Odds3way::updateOrCreate([
'event_id' => $event['id'],
'bookmaker_id' => $event['bookmaker_id'],
], $base + $_3way);
$_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->a3w = number_format($_3way['d3w'], 2);
$res->d3w = 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();
}
}
// OU
if (\count($_total) == 2) {
$_total['margin'] = (float) Margin::calculate($_total, 1);
$_total['total'] = 2.5;
$_total['starttime'] = $event['starttime'];
$_total['active_spread'] = 1;
OddsTotal::updateOrCreate([
'event_id' => $event['id'],
'bookmaker_id' => $event['bookmaker_id'],
], $base + $_total);
$_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();
}
}
// GG NG
if (\count($_ggng) == 2) {
$_ggng['margin'] = (float) Margin::calculate($_ggng, 1);
$_ggng['starttime'] = $event['starttime'];
OddsGgng::updateOrCreate([
'event_id' => $event['id'],
'bookmaker_id' => $event['bookmaker_id'],
], $base + $_ggng);
$_ggng = array_merge($_ggng, $base);
$res = OddsGgng::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
if (! $res) {
OddsGgng::create($_ggng);
} else {
$res->gg = number_format($_ggng['gg'], 2);
$res->ng = number_format($_ggng['ng'], 2);
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = now();
$res->margin = $_ggng['margin'];
$res->save();
}
}
// DC
if (\count($_dc) == 3) {
$_dc['margin'] = (float) Margin::calculate($_dc, 1);
$_dc['starttime'] = $event['starttime'];
OddsDc::updateOrCreate([
'event_id' => $event['id'],
'bookmaker_id' => $event['bookmaker_id'],
], $base + $_dc);
$_dc = array_merge($_dc, $base);
$res = OddsDc::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
if (! $res) {
OddsDc::create($_dc);
} else {
$res->dc1x = number_format($_dc['dc1x'], 2);
$res->dc12 = number_format($_dc['dc12'], 2);
$res->dcx2 = number_format($_dc['dcx2'], 2);
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = now();
$res->margin = $_dc['margin'];
$res->save();
}
}
// TQ
if (\count($_tq) == 2) {
$_tq['margin'] = (float) Margin::calculate($_tq, 1);
$_tq['starttime'] = $event['starttime'];
OddsTq::updateOrCreate([
'event_id' => $event['id'],
'bookmaker_id' => $event['bookmaker_id'],
], $base + $_tq);
$_tq = array_merge($_dc, $base);
$res = OddsTq::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
if (! $res) {
OddsTq::create($_dc);
} else {
$res->htq = number_format($_tq['htq'], 2);
$res->atq = number_format($_tq['atq'], 2);
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = now();
$res->margin = $_tq['margin'];
$res->save();
}
}
}
}
@@ -2,6 +2,8 @@
namespace App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Grapper\Logifuture\Tools\PrinzipalHandicap;
class Tennis
{
public static function get(&$event, &$_spreads, $match)
@@ -14,17 +16,17 @@ class Tennis
foreach ($match['odds'] as $name => $value) {
switch ($name) {
case 'T_12_1':
$event['h2w'] = (float) $value;
$event['h2w'] = number_format($value, 2);
break;
case 'T_12_2':
$event['a2w'] = (float) $value;
$event['a2w'] = number_format($value, 2);
break;
case 'T_121P_1':
$_spreads['mlset1']['h2w'] = (float) $value;
$_spreads['mlset1']['h2w'] = number_format($value, 2);
break;
case 'T_121P_2':
$_spreads['mlset1']['a2w'] = (float) $value;
$_spreads['mlset1']['a2w'] = number_format($value, 2);
break;
}
@@ -54,18 +56,18 @@ class Tennis
// COLUMBIA
if ($c_totals) {
Filter::prinz($_spreads['total'], 'T_OUG@', $c_totals, ['over', 'under', 'total']);
PrinzipalHandicap::filter($_spreads['total'], 'T_OUG@', $c_totals, ['over', 'under', 'total']);
}
if ($c_points) {
Filter::prinz($_spreads['point'], 'T_HNDGAMES@', $c_points, ['hth1', 'hth2', 'hcap']);
PrinzipalHandicap::filter($_spreads['point'], 'T_HNDGAMES@', $c_points, ['hth1', 'hth2', 'hcap']);
}
// NIGERIA
if ($n_totals) {
Filter::prinz($_spreads['total'], 'T_OUG@', $n_totals, ['over', 'under', 'total']);
PrinzipalHandicap::filter($_spreads['total'], 'T_OUG@', $n_totals, ['over', 'under', 'total']);
}
if ($n_points) {
Filter::prinz($_spreads['point'], 'T_GH@', $n_points, ['hth1', 'hth2', 'hcap']);
PrinzipalHandicap::filter($_spreads['point'], 'T_GH@', $n_points, ['hth1', 'hth2', 'hcap']);
}
}
}
+165 -45
View File
@@ -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;
}
+60 -61
View File
@@ -254,8 +254,6 @@ class Odds
];
ElementGroup::updateOrCreate(['element_id' => (int) $row->ateam['id'], 'group_id' => (int) $row->group['id']], $element_group);
Nuh::$collector = [];
foreach ($row->bookmaker as $book) {
$bookmaker_id = (int) $book['bid'];
@@ -265,6 +263,7 @@ class Odds
$odds['bookmaker_id'] = $bookmaker_id;
$odds['sport_id'] = $sport_id;
$odds['provider_id'] = Nuh::$options['provider_id'];
$odds['checked_at'] = now();
foreach ($book->offer as $offer) {
@@ -302,71 +301,71 @@ class Odds
_3Way::grap($odds, $offer);
break;
// case 1:
// foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
// switch ($attributeName) {
// case 'starting_time':
// EventBookmaker::updateOrInsert([
// 'event_id' => Nuh::$id,
// 'bookmaker_id' => Nuh::$bookmaker_id,
// ], ['starttime' => $attributeValue]);
// break;
// }
// }
case 1:
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'starting_time':
EventBookmaker::updateOrInsert([
'event_id' => $event_id,
'bookmaker_id' => $bookmaker_id,
], ['starttime' => $attributeValue]);
break;
}
}
// _2Way::grap($odds, $offer);
// break;
// case 3:
// foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
// switch ($attributeName) {
// case 'starting_time':
// EventBookmaker::updateOrInsert([
// 'event_id' => Nuh::$id,
// 'bookmaker_id' => Nuh::$bookmaker_id,
// ], ['starttime' => $attributeValue]);
// break;
// }
// }
_2Way::grap($odds, $offer);
break;
case 3:
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'starting_time':
EventBookmaker::updateOrInsert([
'event_id' => $event_id,
'bookmaker_id' => $bookmaker_id,
], ['starttime' => $attributeValue]);
break;
}
}
// _Points::grap($odds, $offer);
// break;
// case 4:
// _Totals::grap($odds, $offer);
// break;
_Points::grap($odds, $offer);
break;
case 4:
_Totals::grap($odds, $offer);
break;
// case 131073:
// _2WayS1::grap($odds, $offer);
// break;
case 131073:
_2WayS1::grap($odds, $offer);
break;
// case 65536:
// _3WayHt::grap($odds, $offer);
// break;
// case 65540:
// _TotalsHt::grap($odds, $offer);
// break;
// case 65539:
// _PointsHt::grap($odds, $offer);
// break;
case 65536:
_3WayHt::grap($odds, $offer);
break;
case 65540:
_TotalsHt::grap($odds, $offer);
break;
case 65539:
_PointsHt::grap($odds, $offer);
break;
// case 131075:
// _PointsQ1::grap($odds, $offer);
// break;
// case 131076:
// _TotalsQ1::grap($odds, $offer);
// break;
case 131075:
_PointsQ1::grap($odds, $offer);
break;
case 131076:
_TotalsQ1::grap($odds, $offer);
break;
// case 5242880:
// _Dc::grap($odds, $offer);
// break;
// case 6291457:
// _Dnb::grap($odds, $offer);
// break;
// case 11534337:
// _Ggng::grap($odds, $offer);
// break;
// case 7340033:
// _Tq::grap($odds, $offer);
// break;
case 5242880:
_Dc::grap($odds, $offer);
break;
case 6291457:
_Dnb::grap($odds, $offer);
break;
case 11534337:
_Ggng::grap($odds, $offer);
break;
case 7340033:
_Tq::grap($odds, $offer);
break;
default:
Notice::note('switch bettype ID not found: '.$bettypeid, 'r');
@@ -2,47 +2,56 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools;
use App\Console\Commands\Nuh;
use Illuminate\Support\Facades\DB;
class ActiveSpread
{
public static $collector = [];
public static $event_id = 0;
public static $provider_id = 0;
public static function collect($odds, $bettype)
{
if (! isset(Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference'])) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference'] = $odds['difference'];
if ($odds['event_id'] != self::$event_id) {
self::$event_id = $odds['event_id'];
self::$provider_id = $odds['provider_id'];
self::$collector = [];
}
if (! isset(self::$collector[$bettype][$odds['bookmaker_id']]['difference'])) {
self::$collector[$bettype][$odds['bookmaker_id']]['difference'] = $odds['difference'];
if (isset($odds['handicap'])) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['handicap'];
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['handicap'];
} else {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['total'];
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['total'];
}
} elseif ($odds['difference'] < Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference']) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference'] = $odds['difference'];
} elseif ($odds['difference'] < self::$collector[$bettype][$odds['bookmaker_id']]['difference']) {
self::$collector[$bettype][$odds['bookmaker_id']]['difference'] = $odds['difference'];
if (isset($odds['handicap'])) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['handicap'];
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['handicap'];
} else {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['total'];
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['total'];
}
}
}
public static function set()
{
foreach (Nuh::$collector as $table => $value) {
DB::table($table)->where('event_id', Nuh::$id)->where('provider_id', Nuh::$options['provider_id'])->update(['active_spread' => 0]);
foreach (self::$collector as $table => $value) {
DB::table($table)->where('event_id', self::$event_id)->where('provider_id', self::$provider_id)->update(['active_spread' => 0]);
}
foreach (Nuh::$collector as $table => $bookmaker) {
foreach (self::$collector as $table => $bookmaker) {
foreach ($bookmaker as $bookmaker_id => $values) {
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
DB::table($table)
->where('event_id', Nuh::$id)
->where('event_id', self::$event_id)
->where('bookmaker_id', $bookmaker_id)
->where('handicap', $values['active_spread'])
->update(['active_spread' => 1]);
} else {
DB::table($table)
->where('event_id', Nuh::$id)
->where('event_id', self::$event_id)
->where('bookmaker_id', $bookmaker_id)
->where('total', $values['active_spread'])
->update(['active_spread' => 1]);
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\Odds2way;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _2Way
{
@@ -14,14 +14,20 @@ class _2Way
$odds['a2w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h2w'], $odds['a2w']], 1);
$odds['updated_at'] = now();
DB::table('odds_2ways')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = Odds2way::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['h2w', 'a2w', 'margin', 'flags', 'updated_at']
);
if (! $res) {
Odds2way::create($odds);
} else {
$res->h2w = $odds['h2w'];
$res->a2w = $odds['a2w'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
}
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\Odds2wayS1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _2WayS1
{
@@ -14,14 +14,20 @@ class _2WayS1
$odds['a2w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h2w'], $odds['a2w']], 1);
$odds['updated_at'] = now();
DB::table('odds_2ways_s1')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = Odds2wayS1::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['h2w', 'a2w', 'margin', 'flags', 'updated_at']
);
if (! $res) {
Odds2wayS1::create($odds);
} else {
$res->h2w = $odds['h2w'];
$res->a2w = $odds['a2w'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
}
}
@@ -13,18 +13,23 @@ class _3Way
$odds['h3w'] = (float) $value->o1;
$odds['d3w'] = (float) $value->o2;
$odds['a3w'] = (float) $value->o3;
$odds['a3w'] = (float) 1.1;
}
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
$res = Odds3way::updateOrCreate(
['event_id' => $odds['event_id'], 'bookmaker_id' => $odds['bookmaker_id']],
$odds,
);
if ($res->wasChanged('h3w', 'd3w', 'h3w')) {
$res = Odds3way::updateOrCreate(
['event_id' => $odds['event_id'], 'bookmaker_id' => $odds['bookmaker_id']],
['oddchange_at' => now()],
);
$res = Odds3way::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['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();
}
}
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\Odds3wayHt;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _3WayHt
{
@@ -15,14 +15,21 @@ class _3WayHt
$odds['a3w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
$odds['updated_at'] = now();
DB::table('odds_3ways_ht')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = Odds3wayHt::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['h3w', 'd3w', 'a3w', 'margin', 'flags', 'updated_at']
);
if (! $res) {
Odds3wayHt::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->d3w = $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();
}
}
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\OddsDc;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Dc
{
@@ -15,14 +15,21 @@ class _Dc
$odds['dcx2'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['dc1x'], $odds['dc12'], $odds['dcx2']], 1);
$odds['updated_at'] = now();
DB::table('odds_dc')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = OddsDc::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['dc1x', 'dc12', 'dcx2', 'margin', 'flags', 'updated_at']
);
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();
}
}
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\OddsDnb;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Dnb
{
@@ -14,14 +14,20 @@ class _Dnb
$odds['dnb2'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['dnb1'], $odds['dnb2']], 1);
$odds['updated_at'] = now();
DB::table('odds_dnb')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = OddsDnb::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['dnb1', 'dnb2', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsDnb::create($odds);
} else {
$res->dnb1 = $odds['dnb1'];
$res->dnb2 = $odds['dnb2'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
}
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\OddsGgng;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Ggng
{
@@ -14,14 +14,20 @@ class _Ggng
$odds['ng'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['gg'], $odds['ng']], 1);
$odds['updated_at'] = now();
DB::table('odds_ggng')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = OddsGgng::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['gg', 'ng', 'margin', 'flags', 'updated_at']
);
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();
}
}
}
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Models\OddsPoint;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Points
{
@@ -20,18 +20,27 @@ class _Points
return;
}
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['updated_at'] = now();
DB::table('odds_points')->upsert(
$odds,
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
['event_id', 'bookmaker_id', 'handicap'],
$res = OddsPoint::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
['home', 'away', 'difference', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsPoint::create($odds);
} else {
$res->home = $odds['home'];
$res->away = $odds['away'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
ActiveSpread::collect($odds, 'odds_points');
}
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Models\OddsPointHt;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _PointsHt
{
@@ -20,18 +20,27 @@ class _PointsHt
return;
}
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['updated_at'] = now();
DB::table('odds_points_ht')->upsert(
$odds,
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
['event_id', 'bookmaker_id', 'handicap'],
$res = OddsPointHt::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
['home', 'away', 'difference', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsPointHt::create($odds);
} else {
$res->home = $odds['home'];
$res->away = $odds['away'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
ActiveSpread::collect($odds, 'odds_points_ht');
}
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Models\OddsPointQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _PointsQ1
{
@@ -20,18 +20,27 @@ class _PointsQ1
return;
}
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['updated_at'] = now();
DB::table('odds_points_q1')->upsert(
$odds,
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
['event_id', 'bookmaker_id', 'handicap'],
$res = OddsPointQ1::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
['home', 'away', 'difference', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsPointQ1::create($odds);
} else {
$res->home = $odds['home'];
$res->away = $odds['away'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
ActiveSpread::collect($odds, 'odds_points_q1');
}
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Models\OddsTotal;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Totals
{
@@ -26,18 +26,27 @@ class _Totals
}
}
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['updated_at'] = now();
DB::table('odds_totals')->upsert(
$odds,
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
['event_id', 'bookmaker_id', 'total'],
$res = OddsTotal::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('total', $odds['total'])
->first();
['over', 'under', 'difference', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsTotal::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
ActiveSpread::collect($odds, 'odds_totals');
}
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Models\OddsTotalHt;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _TotalsHt
{
@@ -26,18 +26,27 @@ class _TotalsHt
}
}
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['updated_at'] = now();
DB::table('odds_totals_ht')->upsert(
$odds,
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
['event_id', 'bookmaker_id', 'total'],
$res = OddsTotalHt::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('total', $odds['total'])
->first();
['over', 'under', 'difference', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsTotalHt::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
ActiveSpread::collect($odds, 'odds_totals_ht');
}
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Models\OddsTotalQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _TotalsQ1
{
@@ -26,18 +26,27 @@ class _TotalsQ1
}
}
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['updated_at'] = now();
DB::table('odds_totals_q1')->upsert(
$odds,
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
['event_id', 'bookmaker_id', 'total'],
$res = OddsTotalQ1::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('total', $odds['total'])
->first();
['over', 'under', 'difference', 'margin', 'flags', 'updated_at']
);
if (! $res) {
OddsTotalQ1::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
if ($res->isDirty()) {
$res->oddchange_at = now();
}
$res->checked_at = $odds['checked_at'];
$res->margin = $odds['margin'];
$res->save();
}
ActiveSpread::collect($odds, 'odds_totals_q1');
}
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Models\OddsTq;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Tq
{
@@ -14,14 +14,20 @@ class _Tq
$odds['atq'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['htq'], $odds['atq']], 1);
$odds['updated_at'] = now();
DB::table('odds_tq')->upsert(
$odds,
['event_id', 'bookmaker_id'],
$res = OddsTq::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
['htq', 'atq', 'margin', 'flags', 'updated_at']
);
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();
}
}
}