This commit is contained in:
salam committed 2025-12-05 07:00:25 +01:00
1 parent 7abcc5c56c
commit 90bba45c0a
26 files changed
+3448 -32353

No files matched your search

+246 -161
View File
@@ -2,12 +2,20 @@
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\Helper;
use App\Console\Commands\Grapper\TxOdds\Odds\_3Way;
use App\Console\Commands\Grapper\TxOdds\Odds\_Dc;
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\Models\Odds2way;
use App\Models\Odds3way;
use App\Models\OddsDc;
use App\Models\OddsGgng;
use App\Models\OddsQualify;
use App\Models\OddsTotal;
use App\Utilities\Notice;
@@ -15,6 +23,8 @@ use Carbon\Carbon;
class Odds
{
public static $event = [];
public static function grap()
{
@@ -102,17 +112,17 @@ class Odds
/*************************************************
* URL
*************************************************/
$url = 'https://xml2.txodds.com/feed/odds/xml.php?'.config('nuh.txodds_token_soccer').'&all_odds=2&spid='.NuhBash::$options['sport_id'].'&json=2';
$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('time', '>', Carbon::now()->toDateTimeString())->pluck('txid');
$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('time', '>', Carbon::now()->toDateTimeString())->where('time', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('txid');
$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;
}
@@ -125,11 +135,84 @@ class Odds
*************************************************/
foreach ($_calls as $url) {
$json_obj = Curl::load($url);
$data = Xml::load($url);
foreach ($data as $row) {
$event = [];
$event['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'],
]);
Event::updateOrCreate($event, ['starttime' => $event['starttime']]);
foreach ($row->bookmaker as $book) {
$bkmid = $book['bid'];
foreach ($book->offer as $offer) {
$bettypeid = (int) $offer['od'];
Notice::note($bettypeid, 'b');
switch ($bettypeid) {
case 0:
_3Way::grap($bkmid, $offer);
break;
case 5242880:
_Dc::grap($bkmid, $offer);
break;
default:
Notice::note($offer, 'r', 1);
break;
}
}
}
}
foreach ($json_obj['match'] as $match) {
$e = [];
self::$event = [];
foreach ($match as $key => $v) {
@@ -140,197 +223,199 @@ class Odds
switch ($key) {
case '@attributes':
$e['id'] = (int) $v['id'];
self::$event['id'] = (int) $v['id'];
break;
case 'time':
$starttime = Carbon::createFromDate($v)->toDateTimeString();
self::$event['starttime'] = Carbon::createFromDate($v)->toDateTimeString();
break;
case 'group':
$e['sport_id'] = (int) $v['@attributes']['spid'];
$e['country_id'] = (int) $v['@attributes']['cnid'];
$e['group_id'] = (int) $v['@attributes']['id'];
$e['competition_group_id'] = (int) $v['@attributes']['cgid'];
self::$event['sport_id'] = (int) $v['@attributes']['spid'];
self::$event['country_id'] = (int) $v['@attributes']['cnid'];
self::$event['group_id'] = (int) $v['@attributes']['id'];
self::$event['competition_group_id'] = (int) $v['@attributes']['cgid'];
break;
case 'hteam':
$e['home_id'] = $v['@attributes']['id'];
self::$event['home_id'] = $v['@attributes']['id'];
break;
case 'ateam':
$e['away_id'] = $v['@attributes']['id'];
$event = Event::firstOrCreate($e, ['starttime' => $starttime]);
self::$event['away_id'] = $v['@attributes']['id'];
break;
case 'bookmaker':
foreach ($v as $books) {
Event::updateOrCreate(self::$event, ['starttime' => self::$event['starttime']]);
foreach ($books as $bookkey => $book) {
Notice::note(count($v), 'r');
$bkmid = false;
if (count($v) <= 2) {
$bkmid = (int) $v['@attributes']['bid'];
Notice::note($v, 'p');
} else {
foreach ($v as $books) {
switch ($bookkey) {
case '@attributes':
if (isset($book['bid'])) {
$bkmid = (int) $book['bid'];
}
Notice::note($books, 'b');
case 'offer':
if ($bkmid) {
foreach ($book as $type => $od) {
$bkmid = (int) $books['@attributes']['bid'];
switch ($type) {
case '@attributes':
$bettypeid = (int) $od['ot'];
$bmoid = (int) $od['bmoid'];
break;
case 'odds':
switch ($bettypeid) {
case '0':
Odds3way::updateOrCreate(
[
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
],
[
'h3w' => (float) $od['o1'],
'd3w' => (float) $od['o2'],
'a3w' => (float) $od['o3'],
'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
'flag' => 1,
'nuh_check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
// foreach ($books['offer'] as $bk => $book) {
EventBookmaker::updateOrCreate([
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'bmoid' => $bmoid,
], [
'bkm_starttime' => Carbon::createFromDate($od['@attributes']['starting_time'])->toDateTimeString(),
'last_check_at' => Carbon::now()->toDateTimeString(),
]);
// if ($bkmid) {
// foreach ($book as $type => $od) {
break;
// switch ($type) {
// case '@attributes':
// $bettypeid = (int) $od['ot'];
// $bmoid = (int) $od['bmoid'];
// break;
// case 'odds':
// switch ($bettypeid) {
// case '0':
// Odds3way::updateOrCreate(
// [
// 'event_id' => $event->id,
// 'bookmaker_id' => $bkmid,
// 'sport_id' => NuhBash::$options['sport_id'],
// ],
// [
// 'h3w' => (float) $od['o1'],
// 'd3w' => (float) $od['o2'],
// 'a3w' => (float) $od['o3'],
// 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
// 'flag' => 1,
// 'nuh_check' => 0,
// 'source_updated_at' => $od['@attributes']['time'],
// 'last_check_at' => Carbon::now()->toDateTimeString(),
// ]
// );
case '1':
Odds2way::updateOrCreate(
[
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
],
[
'h2w' => (float) $od['o1'],
'a2w' => (float) $od['o3'],
'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
'flag' => 1,
'nuh_check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
// EventBookmaker::updateOrCreate([
// 'event_id' => $event->id,
// 'bookmaker_id' => $bkmid,
// 'bmoid' => $bmoid,
// ], [
// 'bkm_starttime' => Carbon::createFromDate($od['@attributes']['starting_time'])->toDateTimeString(),
// 'last_check_at' => Carbon::now()->toDateTimeString(),
// ]);
case '4':
OddsTotal::updateOrCreate(
[
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'spread' => (float) $od['o3'],
],
[
'over' => (float) $od['o1'],
'under' => (float) $od['o2'],
'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
'flag' => 1,
'nuh_check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
// break;
case '5242880':
OddsDc::updateOrCreate(
[
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
],
[
'dc1x' => (float) $od['o1'],
'dc12' => (float) $od['o2'],
'dc2x' => (float) $od['o3'],
'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
'flag' => 1,
'nuh_check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
// // case '1':
// // Odds2way::updateOrCreate(
// // [
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'sport_id' => NuhBash::$options['sport_id'],
// // ],
// // [
// // 'h2w' => (float) $od['o1'],
// // 'a2w' => (float) $od['o3'],
// // 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
// // 'flag' => 1,
// // 'nuh_check' => 0,
// // 'source_updated_at' => $od['@attributes']['time'],
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]
// // );
// // break;
case '11534337':
OddsGgng::updateOrCreate(
[
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
],
[
'gg' => (float) $od['o1'],
'ng' => (float) $od['o3'],
'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
'flag' => 1,
'nuh_check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
// // case '4':
// // OddsTotal::updateOrCreate(
// // [
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'sport_id' => NuhBash::$options['sport_id'],
// // 'spread' => (float) $od['o3'],
// // ],
// // [
// // 'over' => (float) $od['o1'],
// // 'under' => (float) $od['o2'],
// // 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
// // 'flag' => 1,
// // 'nuh_check' => 0,
// // 'source_updated_at' => $od['@attributes']['time'],
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]
// // );
// // break;
case '11534337':
OddsQualify::updateOrCreate(
[
'event_id' => $event->id,
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
],
[
'htq' => (float) $od['o1'],
'atq' => (float) $od['o2'],
'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
'flag' => 1,
'nuh_check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
}
// // case '5242880':
// // OddsDc::updateOrCreate(
// // [
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'sport_id' => NuhBash::$options['sport_id'],
// // ],
// // [
// // 'dc1x' => (float) $od['o1'],
// // 'dc12' => (float) $od['o2'],
// // 'dc2x' => (float) $od['o3'],
// // 'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
// // 'flag' => 1,
// // 'nuh_check' => 0,
// // 'source_updated_at' => $od['@attributes']['time'],
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]
// // );
// // break;
break;
}
}
break;
}
}
// // case '11534337':
// // OddsGgng::updateOrCreate(
// // [
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'sport_id' => NuhBash::$options['sport_id'],
// // ],
// // [
// // 'gg' => (float) $od['o1'],
// // 'ng' => (float) $od['o3'],
// // 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
// // 'flag' => 1,
// // 'nuh_check' => 0,
// // 'source_updated_at' => $od['@attributes']['time'],
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]
// // );
// // break;
// // case '11534337':
// // OddsQualify::updateOrCreate(
// // [
// // 'event_id' => $event->id,
// // 'bookmaker_id' => $bkmid,
// // 'sport_id' => NuhBash::$options['sport_id'],
// // ],
// // [
// // 'htq' => (float) $od['o1'],
// // 'atq' => (float) $od['o2'],
// // 'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
// // 'flag' => 1,
// // 'nuh_check' => 0,
// // 'source_updated_at' => $od['@attributes']['time'],
// // 'last_check_at' => Carbon::now()->toDateTimeString(),
// // ]
// // );
// // break;
// }
// break;
// }
// }
// break;
// }
// }
}
break;
}
break;
}
}
Notice::note('END', 'r', 1);
}
}
}