renewd grapper wip
This commit is contained in:
1 parent
8f1aeafe46
commit
4afe60a957
55 files changed
+1389
-823
No files matched your search
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Betsapi\Bet365;
|
||||
use App\Console\Commands\Grapper\Betsapi\Betfair;
|
||||
use App\Console\Commands\Grapper\Betsapi\Bwin;
|
||||
use App\Console\Commands\Grapper\Betsapi\Fixtures;
|
||||
use App\Console\Commands\Grapper\Betsapi\Odds;
|
||||
@@ -36,9 +35,6 @@ class Betsapi
|
||||
case 'Bet365':
|
||||
Bet365::grap();
|
||||
break;
|
||||
case 'Betfair':
|
||||
Betfair::grap();
|
||||
break;
|
||||
default:
|
||||
Notice::note('prosses name does not exist', 'r', 1);
|
||||
break;
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Models\OddsDc;
|
||||
use App\Models\OddsDnb;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -28,236 +29,243 @@ class Bet365
|
||||
|
||||
$single = Nuh::$options['id'] ?? 0;
|
||||
|
||||
$sportmap = Sport::map('bapi', 1, [1, 2, 3, 5]);
|
||||
|
||||
$sportmap = [3];
|
||||
|
||||
/**
|
||||
* Bet365
|
||||
*/
|
||||
$bookmaker_id = 126;
|
||||
|
||||
if ($single) {
|
||||
$events = Event::where('id', Nuh::$options['id'])->where('bet365_id', '>', 0)->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
} elseif ($today) {
|
||||
$events = Event::where('bet365_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDay()->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
} elseif ($week) {
|
||||
$events = Event::where('bet365_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
} else {
|
||||
// all
|
||||
$events = Event::where('bet365_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
}
|
||||
if ($events ?? null && $debug) {
|
||||
Notice::note('No events', 'r');
|
||||
}
|
||||
foreach ($events as $key => $event) {
|
||||
foreach ($sportmap as $sport_id) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note([
|
||||
'id' => $event->id,
|
||||
'bet365_id' => $event->bet365_id,
|
||||
'starttime' => $event->starttime,
|
||||
'count' => count($events).'/'.$key + 1,
|
||||
], 'b');
|
||||
if ($single) {
|
||||
$events = Event::where('id', Nuh::$options['id'])->where('bet365_id', '>', 0)->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
} elseif ($today) {
|
||||
$events = Event::where('sport_id', $sport_id)->where('bet365_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDay()->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
} elseif ($week) {
|
||||
$events = Event::where('sport_id', $sport_id)->where('bet365_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
} else {
|
||||
// all
|
||||
$events = Event::where('sport_id', $sport_id)->where('bet365_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'starttime')->get();
|
||||
}
|
||||
/**
|
||||
* BET365 ODDS (per event)
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$event->bet365_id;
|
||||
if ($events ?? null && $debug) {
|
||||
Notice::note('No events', 'r');
|
||||
}
|
||||
foreach ($events as $key => $event) {
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
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;
|
||||
$base['flag'] = 1;
|
||||
|
||||
/**
|
||||
* 1X2
|
||||
*/
|
||||
if (isset($offer['full_time_result'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
$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();
|
||||
}
|
||||
if ($debug) {
|
||||
Notice::note([
|
||||
'id' => $event->id,
|
||||
'bet365_id' => $event->bet365_id,
|
||||
'starttime' => $event->starttime,
|
||||
'count' => count($events).'/'.$key + 1,
|
||||
], 'b');
|
||||
}
|
||||
|
||||
/**
|
||||
* DC
|
||||
* BET365 ODDS (per event)
|
||||
*/
|
||||
if (isset($offer['double_chance'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$event->bet365_id;
|
||||
|
||||
$odds = array_merge($odds, $base);
|
||||
$data = Curl::load($url);
|
||||
|
||||
$res = OddsDc::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
if (isset($data['results'][0]['main'])) {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]);
|
||||
|
||||
/**
|
||||
* OU
|
||||
*/
|
||||
if (isset($offer['goals_over_under'])) {
|
||||
$offer = $data['results'][0]['main']['sp'];
|
||||
|
||||
$odds = [];
|
||||
$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;
|
||||
}
|
||||
$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;
|
||||
$base['flag'] = 1;
|
||||
|
||||
$odds = array_merge($odds, $base);
|
||||
/**
|
||||
* 1X2
|
||||
*/
|
||||
if (isset($offer['full_time_result'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
if ($offer['goals_over_under']['odds'][1]['name'] == '2.5') {
|
||||
$odds['total'] = 2.5;
|
||||
$res = OddsTotal::where('event_id', $event->id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('total', $odds['total'])
|
||||
->first();
|
||||
$odds = array_merge($odds, $base);
|
||||
|
||||
$res = Odds3way::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
|
||||
if (! $res) {
|
||||
OddsTotal::create($odds);
|
||||
Odds3way::create($odds);
|
||||
} else {
|
||||
$res->over = $odds['over'];
|
||||
$res->under = $odds['under'];
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DC
|
||||
*/
|
||||
if (isset($offer['double_chance'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* OU
|
||||
*/
|
||||
if (isset($offer['goals_over_under'])) {
|
||||
|
||||
$odds = [];
|
||||
$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') {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GG NG
|
||||
*/
|
||||
if (isset($offer['both_teams_to_score'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DNB
|
||||
*/
|
||||
if (isset($offer['draw_no_bet'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
$res = OddsDnb::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
|
||||
$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'] = 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);
|
||||
|
||||
$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->difference = abs(1 / $odds['over'] - 1 / $odds['under']);
|
||||
$res->checked_at = now();
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GG NG
|
||||
*/
|
||||
if (isset($offer['both_teams_to_score'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DNB
|
||||
*/
|
||||
if (isset($offer['draw_no_bet'])) {
|
||||
$odds = [];
|
||||
$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);
|
||||
|
||||
$res = OddsDnb::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
|
||||
$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'] = 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);
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Betfair
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
/**
|
||||
* Betfair
|
||||
*/
|
||||
exit;
|
||||
$bookmaker_id = 126;
|
||||
|
||||
$res = Event::where('bet365_id', '>', 0)->pluck('id', 'bet365_id');
|
||||
|
||||
foreach ($res as $bet365_id => $txodds_id) {
|
||||
|
||||
/**
|
||||
* BETFAIR SP (per page)
|
||||
* https://api.b365api.com/v1/bwin/prematch?token=36152-aeTRNnZxSPUwGe
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$bet365_id;
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
dd($data);
|
||||
|
||||
$betsapi_id = $data['results'][0]['id'] ?? 0;
|
||||
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
|
||||
}
|
||||
|
||||
if ($betsapi_id) {
|
||||
Event::where('id', (int) $txodds_id)->update(['betsapi_id' => $betsapi_id, 'bet365_id' => $bet365_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\Supervisor;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Odds
|
||||
{
|
||||
@@ -12,5 +19,121 @@ class Odds
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$today = Nuh::$options['t'] ?? 0;
|
||||
|
||||
$week = Nuh::$options['w'] ?? 0;
|
||||
|
||||
$single = Nuh::$options['id'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('BETSAPI ODDS '.Nuh::$options['sport'], 'b');
|
||||
}
|
||||
|
||||
$sources = [126 => 'bet365', 83 => 'pinnaclesports'];
|
||||
|
||||
if ($single) {
|
||||
$events = Event::where('id', Nuh::$options['id'])->where('betsapi_id', '>', 0)->select('id', 'sport_id', 'bet365_id', 'betsapi_id', 'starttime')->get();
|
||||
} elseif ($today) {
|
||||
$events = Event::where('sport_id', Nuh::$options['sport_id'])->where('betsapi_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDay()->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'betsapi_id', 'starttime')->get();
|
||||
} elseif ($week) {
|
||||
$events = Event::where('sport_id', Nuh::$options['sport_id'])->where('betsapi_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'betsapi_id', 'starttime')->get();
|
||||
} else {
|
||||
// all
|
||||
$events = Event::where('sport_id', Nuh::$options['sport_id'])->where('betsapi_id', '>', 0)->where('starttime', '>', Carbon::now()->toDateTimeString())->select('id', 'sport_id', 'bet365_id', 'betsapi_id', 'starttime')->get();
|
||||
}
|
||||
|
||||
foreach ($events as $key => $event) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note([
|
||||
'id' => $event->id,
|
||||
'betsapi_id' => $event->betsapi_id,
|
||||
'starttime' => $event->starttime,
|
||||
'count' => count($events).'/'.$key + 1,
|
||||
], 'b');
|
||||
}
|
||||
|
||||
$since_time = Nuh::$options['lastcall'] - 600;
|
||||
|
||||
$since_time = 0;
|
||||
|
||||
foreach ($sources as $bookmaker_id => $source) {
|
||||
|
||||
$url = 'https://api.b365api.com/v2/event/odds?token='.config('env.betsapi_token').'&source'.$source.'&since_time='.$since_time.'&event_id='.$event->betsapi_id;
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$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->betsapi_id;
|
||||
$base['flag'] = 1;
|
||||
|
||||
foreach ($data['results']['odds'] as $key => $value) {
|
||||
switch ($key) {
|
||||
case '1_1':
|
||||
|
||||
$odds = [];
|
||||
$odds['h3w'] = number_format($value[0]['home_od'], 2) ?? 1;
|
||||
$odds['d3w'] = number_format($value[0]['draw_od'], 2) ?? 1;
|
||||
$odds['a3w'] = number_format($value[0]['away_od'], 2) ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
$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();
|
||||
}
|
||||
break;
|
||||
case '1_3':
|
||||
|
||||
dd($value);
|
||||
|
||||
$odds = [];
|
||||
$odds['h3w'] = number_format($value[0]['home_od'], 2) ?? 1;
|
||||
$odds['d3w'] = number_format($value[0]['draw_od'], 2) ?? 1;
|
||||
$odds['a3w'] = number_format($value[0]['away_od'], 2) ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
$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();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Supervisor::where('id', Nuh::$options['supervisor_id'])->update(['lastcall' => time()]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ class Willhill
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$sports = [1, 2, 3, 5];
|
||||
|
||||
/**
|
||||
* williamhill
|
||||
*/
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
6 Unibet
|
||||
13 Sportingbet
|
||||
42 William Hill
|
||||
110 BetFair
|
||||
117 SNAI
|
||||
314 Matchbook
|
||||
649 1XBet
|
||||
824 BetPlay
|
||||
@@ -41,7 +41,8 @@ class FindFixture
|
||||
// DEFAULT BETRADAR
|
||||
if ($betradar_id) {
|
||||
$match = Event::where('betradar_id', $betradar_id)->first();
|
||||
} else {
|
||||
}
|
||||
if (! isset($match) or ! $match) {
|
||||
switch ($event['provider_id']) {
|
||||
case 2:
|
||||
// BETSAPI
|
||||
@@ -66,7 +67,7 @@ class FindFixture
|
||||
}
|
||||
}
|
||||
|
||||
if ($match ?? null) {
|
||||
if ($match) {
|
||||
|
||||
$update_array = [];
|
||||
|
||||
|
||||
@@ -60,21 +60,20 @@ class Logifuture
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'startime' => $event['startime']]);
|
||||
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'startime' => $event['starttime']]);
|
||||
|
||||
$_spreads = [];
|
||||
switch ($sport_id) {
|
||||
case 1:
|
||||
Soccer::get($event, $match);
|
||||
break;
|
||||
case 2:
|
||||
Icehockey::get($event, $_spreads, $match);
|
||||
Icehockey::get($event, $match);
|
||||
break;
|
||||
case 3:
|
||||
Basketball::get($event, $_spreads, $match);
|
||||
Basketball::get($event, $match);
|
||||
break;
|
||||
case 5:
|
||||
Tennis::get($event, $_spreads, $match);
|
||||
Tennis::get($event, $match);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,13 +50,20 @@ class Odds
|
||||
Notice::note("Deleted: $info");
|
||||
}
|
||||
|
||||
$txodds_markets_columns = [
|
||||
1 => 'soccer',
|
||||
2 => 'ice_hockey',
|
||||
3 => 'basketball',
|
||||
5 => 'tennis',
|
||||
];
|
||||
$res = TxoddsMarket::where($txodds_markets_columns[Nuh::$options['sport_id']], 1)->pluck('market_id', 'id')->toArray();
|
||||
switch (Nuh::$options['sport_id']) {
|
||||
case 1:
|
||||
$res = TxoddsMarket::where('soccer', 1)->pluck('market_id', 'id')->toArray();
|
||||
break;
|
||||
case 2:
|
||||
$res = TxoddsMarket::where('ice_hockey', 1)->pluck('market_id', 'id')->toArray();
|
||||
break;
|
||||
case 3:
|
||||
$res = TxoddsMarket::where('basketball', 1)->pluck('market_id', 'id')->toArray();
|
||||
break;
|
||||
case 5:
|
||||
$res = TxoddsMarket::where('tennis', 1)->pluck('market_id', 'id')->toArray();
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* use_lastcall
|
||||
@@ -65,6 +72,7 @@ class Odds
|
||||
|
||||
/*************************************************
|
||||
* URL
|
||||
* https://xml2.txodds.com/feed/odds/xml.php?36152-aeTRNnZxSPUwGe&all_odds=2&peid=14190947
|
||||
*************************************************/
|
||||
if (Nuh::$options['sport_id'] == 1) {
|
||||
$url = 'https://xml2.txodds.com/feed/odds/xml.php?'.config('env.txodds_betaid1').'&all_odds=2';
|
||||
@@ -256,6 +264,8 @@ class Odds
|
||||
|
||||
foreach ($row->bookmaker as $book) {
|
||||
|
||||
ActiveSpread::start();
|
||||
|
||||
$bookmaker_id = (int) $book['bid'];
|
||||
|
||||
$odds = [];
|
||||
@@ -372,8 +382,8 @@ class Odds
|
||||
break;
|
||||
}
|
||||
}
|
||||
ActiveSpread::set($event_id, $bookmaker_id);
|
||||
}
|
||||
ActiveSpread::set();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,54 +8,49 @@ class ActiveSpread
|
||||
{
|
||||
public static $collector = [];
|
||||
|
||||
public static $event_id = 0;
|
||||
|
||||
public static $provider_id = 0;
|
||||
|
||||
public static function collect($odds, $bettype)
|
||||
public static function start()
|
||||
{
|
||||
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'];
|
||||
self::$collector = [];
|
||||
}
|
||||
|
||||
public static function collect($odds, $table)
|
||||
{
|
||||
|
||||
if (! isset(self::$collector[$table]['difference'])) {
|
||||
self::$collector[$table]['difference'] = $odds['difference'];
|
||||
if (isset($odds['handicap'])) {
|
||||
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['handicap'];
|
||||
self::$collector[$table]['active_spread'] = $odds['handicap'];
|
||||
} else {
|
||||
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['total'];
|
||||
self::$collector[$table]['active_spread'] = $odds['total'];
|
||||
}
|
||||
} elseif ($odds['difference'] < self::$collector[$bettype][$odds['bookmaker_id']]['difference']) {
|
||||
self::$collector[$bettype][$odds['bookmaker_id']]['difference'] = $odds['difference'];
|
||||
} elseif ($odds['difference'] < self::$collector[$table]['difference']) {
|
||||
self::$collector[$table]['difference'] = $odds['difference'];
|
||||
if (isset($odds['handicap'])) {
|
||||
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['handicap'];
|
||||
self::$collector[$table]['active_spread'] = $odds['handicap'];
|
||||
} else {
|
||||
self::$collector[$bettype][$odds['bookmaker_id']]['active_spread'] = $odds['total'];
|
||||
self::$collector[$table]['active_spread'] = $odds['total'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function set()
|
||||
public static function set($event_id, $bookmaker_id)
|
||||
{
|
||||
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 (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', self::$event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('handicap', $values['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
} else {
|
||||
DB::table($table)
|
||||
->where('event_id', self::$event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('total', $values['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
}
|
||||
|
||||
DB::table($table)->where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->update(['active_spread' => 0]);
|
||||
|
||||
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
|
||||
DB::table($table)
|
||||
->where('event_id', $event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('handicap', (float) $value['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
} else {
|
||||
DB::table($table)
|
||||
->where('event_id', $event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('total', (float) $value['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ class _PointsQ1
|
||||
$res->save();
|
||||
}
|
||||
|
||||
ActiveSpread::collect($odds, 'odds_points_q1');
|
||||
ActiveSpread::collect($odds, 'odds_totals_q1');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user