grapper betsapi bet365 wip
This commit is contained in:
1 parent
e90a6c71f6
commit
b1a724061f
19 files changed
+93
-51
No files matched your search
@@ -5,7 +5,10 @@ namespace App\Console\Commands\Grapper\Betsapi;
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Utilities\Notice;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\OddsDc;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Bet365
|
||||
{
|
||||
@@ -18,29 +21,59 @@ class Bet365
|
||||
*/
|
||||
$bookmaker_id = 126;
|
||||
|
||||
$res = Event::where('bet365_id', '>', 0)->pluck('id', 'bet365_id');
|
||||
$events = Event::where('bet365_id', '>', 0)->where('events.starttime', '>', Carbon::now())->get();
|
||||
|
||||
foreach ($res as $bet365_id => $txodds_id) {
|
||||
foreach ($events as $event) {
|
||||
|
||||
/**
|
||||
* BET365 ODDS (per event)
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$bet365_id;
|
||||
$url = 'https://api.b365api.com/v4/bet365/prematch?token='.config('env.betsapi_token').'&FI='.$event->bet365_id;
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
dd($data);
|
||||
$offer = $data['results'][0]['main']['sp'];
|
||||
|
||||
$betsapi_id = $data['results'][0]['id'] ?? 0;
|
||||
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
|
||||
/**
|
||||
* 1X2
|
||||
*/
|
||||
$odds = [];
|
||||
$odds['h3w'] = $offer['full_time_result']['odds'][0]['odds'];
|
||||
$odds['d3w'] = $offer['full_time_result']['odds'][1]['odds'];
|
||||
$odds['a3w'] = $offer['full_time_result']['odds'][2]['odds'];
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
|
||||
$odds['sport_id'] = $event->sport_id;
|
||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
||||
$odds['bmoid'] = $event->bet365_id;
|
||||
$odds['flag'] = 1;
|
||||
$odds['last_check_at'] = Carbon::now();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
|
||||
}
|
||||
Odds3way::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $odds);
|
||||
|
||||
/**
|
||||
* DC
|
||||
*/
|
||||
$odds = [];
|
||||
$odds['dc1x'] = $offer['full_time_result']['odds'][0]['odds'];
|
||||
$odds['dc12'] = $offer['full_time_result']['odds'][1]['odds'];
|
||||
$odds['dcx2'] = $offer['full_time_result']['odds'][2]['odds'];
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['dc1x'], $odds['dc12'], $odds['dcx2']], 1);
|
||||
$odds['sport_id'] = $event->sport_id;
|
||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
||||
$odds['bmoid'] = $event->bet365_id;
|
||||
$odds['flag'] = 1;
|
||||
$odds['last_check_at'] = Carbon::now();
|
||||
|
||||
OddsDc::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $odds);
|
||||
|
||||
dd($odds);
|
||||
|
||||
if ($betsapi_id) {
|
||||
Event::where('id', (int) $txodds_id)->update(['betsapi_id' => $betsapi_id, 'bet365_id' => $bet365_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,9 @@ class Betfair
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
/**
|
||||
* Bet365
|
||||
* Betfair
|
||||
*/
|
||||
exit;
|
||||
$bookmaker_id = 126;
|
||||
|
||||
$res = Event::where('bet365_id', '>', 0)->pluck('id', 'bet365_id');
|
||||
|
||||
@@ -32,6 +32,7 @@ class Willhill
|
||||
|
||||
$res = Odds3way::join('events', 'odds_3ways.event_id', 'events.id')
|
||||
->where('odds_3ways.bookmaker_id', $bookmaker_id)
|
||||
->where('events.starttime', '>', Carbon::now())
|
||||
->where('events.betsapi_id', 0)
|
||||
->where('events.sport_id', $sport_id)
|
||||
->where('odds_3ways.bmoid', '>', 0)->pluck('odds_3ways.event_id', 'odds_3ways.bmoid');
|
||||
|
||||
Reference in new issue
Block a user