264 lines
9.9 KiB
PHP
264 lines
9.9 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds;
|
|
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\_3Way;
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\_Dc;
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\_Dnb;
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\_Ggng;
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\_Totals;
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\_Tq;
|
|
use App\Console\Commands\NuhBash;
|
|
use App\Console\Commands\Xml;
|
|
use App\Models\CompetitionGroup;
|
|
use App\Models\Element;
|
|
use App\Models\Event;
|
|
use App\Models\EventBookmaker;
|
|
use App\Models\Group;
|
|
use App\Utilities\Notice;
|
|
use Carbon\Carbon;
|
|
|
|
class Odds
|
|
{
|
|
public static function grap()
|
|
{
|
|
|
|
$debug = NuhBash::$options['d'] ?? 0;
|
|
|
|
if ($debug) {
|
|
Notice::note('txodd odd sport: '.NuhBash::$options['sport_id'], 'b');
|
|
}
|
|
|
|
/*************************************************
|
|
* SINGLE SOCCER
|
|
* https://xml2.txodds.com/feed/odds/xml.php?ident=betaid1&passwd=Dy59vpRC&peid=3118930
|
|
|
|
* SINGLE OTHER
|
|
*************************************************
|
|
* https://xml2.txodds.com/feed/odds/xml.php?ident=betaid2&passwd=Dy59vpRC&peid=3118930
|
|
|
|
*************************************************
|
|
* https://xml2.txodds.com/feed/odds_types.php
|
|
|
|
* BETTYPE IDS
|
|
0 3-WAY
|
|
1 2-WAY
|
|
3 POINTS
|
|
4 TOTALS
|
|
5 Asian
|
|
65536 3-WAY HALF TIME
|
|
131072 3 WAY QUARTER TIME
|
|
65539 POINTS HALF TIME
|
|
131075 POINTS QUARTER TIME
|
|
262147 POINTS OVER TIME
|
|
65540 TOTALS HALF TIME
|
|
131076 TOTALS QUARTER TIME
|
|
262148 TOTALS OVER TIME
|
|
11534337 GG/NG (both teams to score)
|
|
5242880 DOUBLE CHANCE
|
|
7340033 TO PROGRESS (to_qualify)
|
|
6291457 DRAW NO BET
|
|
|
|
Not used:
|
|
|
|
65537 2-WAY HALF TIME
|
|
327680 3-WAY 2ND HALF
|
|
327681 2-WAY 2ND HALF
|
|
327683 POINT 2ND HALF
|
|
327684 TOTALS 2ND HALF
|
|
1048577 GOAL / NO GOAL
|
|
|
|
2097153 ODD / EVEN
|
|
4194304 TOTAL GOALS
|
|
8388608 1X2 EURO HANDCIAP
|
|
9437188 TOTAL CORNERS
|
|
9502724 TOTAL CORNERS 1ST HALF
|
|
20971520 3-WAY CORNERS
|
|
28311555 HANDICAP SETS
|
|
28311556 TOTAL SETS
|
|
|
|
*************************************************/
|
|
|
|
$debug = NuhBash::$options['d'] ?? 0;
|
|
|
|
switch (NuhBash::$options['sport_id']) {
|
|
case 1:
|
|
$markets = '0,4,11534337,5242880,7340033,6291457';
|
|
break;
|
|
case 2:
|
|
// needs check
|
|
$markets = '0,1,3,4,262148,131072,131076';
|
|
break;
|
|
case 3:
|
|
// needs check
|
|
$markets = '0,1,3,4,262147,262148,65539,65540,131075,131076';
|
|
break;
|
|
case 5:
|
|
$markets = '1,3,4';
|
|
break;
|
|
case 8:
|
|
$markets = '0,3,4';
|
|
break;
|
|
default:
|
|
Notice::note('sport not defined', 'r', 1);
|
|
break;
|
|
}
|
|
|
|
/*************************************************
|
|
* URL
|
|
*************************************************/
|
|
$url = 'https://xml2.txodds.com/feed/odds/xml.php?'.NuhBash::$AUTHTOKEN.'&all_odds=2&spid='.NuhBash::$options['sport_id'];
|
|
$_calls = [];
|
|
if (NuhBash::$options['event_id']) {
|
|
$_calls[] = $url."&ot=$markets&peid=".NuhBash::$options['event_id'];
|
|
} elseif (NuhBash::$options['a']) {
|
|
$res = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('txodds_id');
|
|
foreach ($res as $id) {
|
|
$_calls[] = $url."&ot=$markets&peid=".$id;
|
|
}
|
|
} elseif (NuhBash::$options['w']) {
|
|
$res = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('txodds_id');
|
|
foreach ($res as $id) {
|
|
$_calls[] = $url."&ot=$markets&peid=".$id;
|
|
}
|
|
} else {
|
|
$_calls[] = $url.'&last='.NuhBash::$options['lastcall'];
|
|
}
|
|
|
|
/*************************************************
|
|
* CALL
|
|
*************************************************/
|
|
foreach ($_calls as $url) {
|
|
|
|
$data = Xml::load($url);
|
|
|
|
foreach ($data as $row) {
|
|
|
|
$event = [];
|
|
$event['txodds_id'] = (int) $row['id'];
|
|
$event['starttime'] = Carbon::createFromDate((string) $row->time)->toDateTimeString();
|
|
$group_name = (string) $row->group;
|
|
$event['group_id'] = (int) $row->group['id'];
|
|
$event['sport_id'] = (int) $row->group['spid'];
|
|
$event['country_id'] = (int) $row->group['cnid'];
|
|
$event['competition_group_id'] = (int) $row->group['cgid'];
|
|
$competition_group_name = (string) $row->group['cname'];
|
|
$home = (string) $row->hteam;
|
|
$event['home_id'] = (int) $row->hteam['id'];
|
|
$away = (string) $row->ateam;
|
|
$event['away_id'] = (int) $row->ateam['id'];
|
|
|
|
Group::updateOrCreate([
|
|
'txodds_id' => $event['group_id'],
|
|
'competition_group_id' => $event['competition_group_id'],
|
|
'sport_id' => $event['sport_id'],
|
|
'country_id' => $event['country_id'],
|
|
], [
|
|
'name' => $group_name,
|
|
]);
|
|
|
|
CompetitionGroup::updateOrCreate([
|
|
'txodds_id' => $event['competition_group_id'],
|
|
'sport_id' => $event['sport_id'],
|
|
'country_id' => $event['country_id'],
|
|
], [
|
|
'name' => $competition_group_name,
|
|
]);
|
|
|
|
Element::firstOrCreate([
|
|
'txodds_id' => $event['home_id'],
|
|
'name' => $home,
|
|
'sport_id' => $event['sport_id'],
|
|
]);
|
|
|
|
Element::firstOrCreate([
|
|
'txodds_id' => $event['away_id'],
|
|
'name' => $away,
|
|
'sport_id' => $event['sport_id'],
|
|
]);
|
|
|
|
NuhBash::$_event = Event::firstOrCreate($event, ['starttime' => $event['starttime']]);
|
|
|
|
foreach ($row->bookmaker as $book) {
|
|
|
|
NuhBash::$bookmaker_id = (int) $book['bid'];
|
|
|
|
NuhBash::$bookmaker_id = (int) $book['bid'];
|
|
|
|
$odds = [];
|
|
$odds['sport_id'] = (int) $event['sport_id'];
|
|
$odds['provider_id'] = 2;
|
|
|
|
NuhBash::$_event_bookmaker = [];
|
|
|
|
foreach ($book->offer as $offer) {
|
|
|
|
$bettypeid = 0;
|
|
|
|
foreach ($offer->attributes() as $attributeName => $attributeValue) {
|
|
switch ($attributeName) {
|
|
case 'id':
|
|
$odds['offer_id'] = (int) $attributeValue;
|
|
break;
|
|
case 'ot':
|
|
$bettypeid = (int) $attributeValue;
|
|
break;
|
|
case 'bmoid':
|
|
$odds['bmoid'] = (string) $attributeValue;
|
|
break;
|
|
case 'last_updated':
|
|
$odds['source_updated_at'] = Carbon::createFromDate((string) $attributeValue)->toDateTimeString();
|
|
break;
|
|
}
|
|
}
|
|
|
|
switch ($bettypeid) {
|
|
case 0:
|
|
_3Way::grap($odds, $offer);
|
|
break;
|
|
case 4:
|
|
_Totals::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('ERROR Bettype ID not set: '.$bettypeid, 'r');
|
|
break;
|
|
}
|
|
}
|
|
|
|
foreach (NuhBash::$_event_bookmaker as $value) {
|
|
|
|
EventBookmaker::updateOrCreate([
|
|
'event_id' => NuhBash::$_event->id,
|
|
'bookmaker_id' => NuhBash::$bookmaker_id,
|
|
'bookmaker_id' => NuhBash::$bookmaker_id,
|
|
], [
|
|
'bmoid' => $value['bmoid'],
|
|
'provider_id' => 2,
|
|
'bkm_starttime' => Carbon::createFromDate($value['starttime'])->toDateTimeString(),
|
|
'last_check_at' => Carbon::now()->toDateTimeString(),
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($debug) {
|
|
Notice::note('END '.NuhBash::$_event->id, 'g');
|
|
Notice::note('END', 'g');
|
|
}
|
|
}
|
|
}
|
|
}
|