This commit is contained in:
salam committed 2025-12-01 21:50:23 +01:00
1 parent 419148cd18
commit 7abcc5c56c
75 files changed
+32250 -127794

No files matched your search

@@ -1,8 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\DB;
class DbOdds
{
public static function call() {}
}
@@ -1,51 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Grapper\Grapper;
use App\Models\Event;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class Events
{
public static function grap()
{
Notice::note('txodd fixture sport: '.Grapper::$options['sport_id'], 'b');
$debug = Grapper::$options['d'] ?? 0;
$now = Carbon::tomorrow();
for ($i = 0; $i < 60; $i++) {
$from = $now->toDateString();
$to = $now->addDays(1)->toDateString();
$url = Grapper::$domain.'feed/result/xml.php?'.Grapper::$auth."&date=$from,$to";
if ($debug) {
Notice::note($url, 'y');
}
$xml = simplexml_load_file($url, null, LIBXML_NOCDATA);
foreach ($xml->match as $_match) {
Event::updateOrCreate([
'txid' => (int) $_match['id'],
'spid' => Grapper::$options['sport_id'],
'prid' => Grapper::$options['provider_id'],
'cnid' => (int) $_match->group['cnid'], // country_id
'grid' => (int) $_match->group['id'], // group_id
'cgid' => (int) $_match->group['cgid'], // competition_group_id
'hoid' => (int) $_match->hteam['id'],
'awid' => (int) $_match->ateam['id'],
'home' => (string) $_match->hteam,
'away' => (string) $_match->ateam,
'liga' => (string) $_match->group['cname'],
], [
'time' => Carbon::parse($_match->time)->toDateTimeString(),
]);
}
}
}
}
@@ -3,11 +3,11 @@
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxCountry;
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxElement;
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxLiga;
use App\Console\Commands\NuhBash;
use App\Models\CompetitionGroup;
use App\Models\Element;
use App\Models\Event;
use App\Models\Group;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
@@ -17,7 +17,6 @@ class Fixtures
{
$debug = NuhBash::$options['d'] ?? 0;
$print = NuhBash::$options['p'] ?? 0;
$read = NuhBash::$options['r'] ?? 0;
$break = NuhBash::$options['b'] ?? 0;
$total = 0;
@@ -29,38 +28,86 @@ class Fixtures
$to = $date->addDays($i + 1)->toDateString();
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.config('nuh.txodds_token_soccer')."&date=$from,$to&json=2";
$data = Curl::load($url, $debug);
$data = Curl::load($url);
if ($print) {
Notice::note($data, '', 1);
}
$count = 0;
foreach ($data['match'] as $row) {
$e = [];
foreach ($data['match'] as $match) {
foreach ($match as $key => $v) {
switch ($key) {
case '@attributes':
$e['txodds_id'] = (int) $v['id'];
break;
case 'time':
$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'];
Group::firstOrCreate([
'txodds_id' => $v['@attributes']['id'],
'competition_group_id' => $e['competition_group_id'],
], [
'name' => (string) $v['@text'],
'sport_id' => $e['sport_id'],
'country_id' => $e['country_id'],
]);
CompetitionGroup::firstOrCreate([
'txodds_id' => $v['@attributes']['cgid'],
'name' => $v['@attributes']['cname'],
'sport_id' => $e['sport_id'],
'country_id' => $e['country_id'],
]);
break;
case 'hteam':
$e['home_id'] = $v['@attributes']['id'];
Element::firstOrCreate([
'txodds_id' => (int) $v['@attributes']['id'],
'name' => $v['@text'],
'sport_id' => $e['sport_id'],
]);
break;
case 'ateam':
$e['away_id'] = $v['@attributes']['id'];
Element::firstOrCreate([
'txodds_id' => (int) $v['@attributes']['id'],
'name' => $v['@text'],
'sport_id' => $e['sport_id'],
]);
break;
}
}
Event::firstOrCreate($e, ['starttime' => $starttime]);
$count++;
$txodds_id = array_column($row, 'id');
$spid = array_column($row['group'], 'spid');
$country_id = TxCountry::find($row['group']);
$liga_id = TxLiga::find($country_id, $row['group']);
$home_id = TxElement::find($row['hteam'], 1);
$away_id = TxElement::find($row['ateam'], 1);
$event = Event::updateOrCreate([
'starttime' => date('Y-m-d H:i:s', strtotime($row['time'])),
'sport_id' => (int) $spid[0],
'provider_id' => 1,
'txodds_id' => (int) $txodds_id[0],
'country_id' => (int) $country_id,
'liga_id' => (int) $liga_id,
'home_id' => (int) $home_id,
'away_id' => (int) $away_id,
]);
}
Notice::note("$from - $count events processed", 'g');
if ($debug) {
Notice::note("$from - $count events processed", 'g');
}
$total += $count;
if ($break) {
if ($break || $debug) {
break;
}
}
@@ -1,22 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Models\Country;
class TxCountry
{
public static function find($group)
{
$cnid = array_column($group, 'cnid');
$cname = array_column($group, 'cname');
$country = Country::firstOrCreate(
['txid' => $cnid[0]],
['name' => $cname[0]]
);
return $country->id;
}
}
@@ -1,25 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Models\Element;
class TxElement
{
public static function find($element, $sport_id)
{
// dd($element);
$txodds_id = array_column($element, 'id');
$element = Element::firstOrCreate([
'name' => (string) $element['@text'],
'sport_id' => $sport_id,
'txodds_id' => (int) $txodds_id[0],
]);
return $element->id;
}
}
@@ -1,24 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Models\Liga;
class TxLiga
{
public static function find($country_id, $group)
{
$cname = array_column($group, 'cname');
$spid = array_column($group, 'spid');
$cgid = array_column($group, 'cgid');
$liga = Liga::firstOrCreate([
'name' => (string) $cname[0],
'sport_id' => (int) $spid[0],
'country_id' => $country_id,
'txodds_id' => (int) $cgid[0],
]);
return $liga->id;
}
}
+191 -182
View File
@@ -6,6 +6,7 @@ use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\Helper;
use App\Console\Commands\NuhBash;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\Odds3way;
use App\Models\OddsQualify;
use App\Models\OddsTotal;
@@ -17,7 +18,11 @@ class Odds
public static function grap()
{
Notice::note('txodd odd sport: '.NuhBash::$options['sport_id'], 'b');
$debug = NuhBash::$options['d'] ?? 0;
if ($debug) {
Notice::note('txodd odd sport: '.NuhBash::$options['sport_id'], 'b');
}
/*************************************************
* SINGLE SOCCER
@@ -120,207 +125,211 @@ class Odds
*************************************************/
foreach ($_calls as $url) {
$json_obj = Curl::load($url, $debug);
$json_obj = Curl::load($url);
$e = [];
foreach ($json_obj['match'] as $match) {
foreach ($json_obj['match'] as $key => $v) {
$e = [];
Notice::note($key, 'b');
foreach ($match as $key => $v) {
switch ($key) {
case '@attributes':
$e['id'] = (int) $v['id'];
break;
// if ($debug) {
// Notice::note($key, 'b');
// }
case 'time':
$e['time'] = $v;
break;
switch ($key) {
case 'group':
$e['liga'] = $v['@attributes']['cname'];
$e['liid'] = $v['@attributes']['id'];
$e['cgid'] = $v['@attributes']['cgid'];
$e['spid'] = $v['@attributes']['spid'];
$e['mgid'] = $v['@attributes']['mgid'];
$e['cnid'] = $v['@attributes']['cnid'];
break;
case '@attributes':
$e['id'] = (int) $v['id'];
break;
case 'hteam':
$e['hoid'] = $v['@attributes']['id'];
$e['home'] = $v['@text'];
break;
case 'time':
$starttime = Carbon::createFromDate($v)->toDateTimeString();
break;
case 'ateam':
$e['awid'] = $v['@attributes']['id'];
$e['away'] = $v['@text'];
break;
case 'group':
case 'bookmaker':
$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'];
break;
foreach ($v as $books) {
case 'hteam':
$e['home_id'] = $v['@attributes']['id'];
break;
foreach ($books as $bkey => $book) {
case 'ateam':
$e['away_id'] = $v['@attributes']['id'];
switch ($bkey) {
case '@attributes':
$bname = $book['name'];
$bkmid = (int) $book['bid'];
$e['odds'][$bkmid]['name'] = $bname;
break;
case 'offer':
$event = Event::firstOrCreate($e, ['starttime' => $starttime]);
break;
foreach ($book as $offer) {
foreach ($offer as $type => $od) {
case 'bookmaker':
switch ($type) {
case '@attributes':
$bettypeid = (int) $od['ot'];
dd('add to event bookmaker missing');
// 'book_startime' => $od['@attributes']['starting_time'],
$bmoid = $od['bmoid'];
break;
case 'odds':
switch ($bettypeid) {
case '0':
Odds3way::updateOrCreate(
[
'event_id' => $e['id'],
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'bmoid' => $bmoid,
],
[
'start' => $od['@attributes']['starting_time'],
'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,
'check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
foreach ($v as $books) {
case '1':
Odds2way::updateOrCreate(
[
'event_id' => $e['id'],
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'bmoid' => $bmoid,
],
[
'start' => $od['@attributes']['starting_time'],
'h2w' => (float) $od['o1'],
'a2w' => (float) $od['o3'],
'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
'flag' => 1,
'check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
foreach ($books as $bookkey => $book) {
case '4':
OddsTotal::updateOrCreate(
[
'event_id' => $e['id'],
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'bmoid' => $bmoid,
'spread' => (float) $od['o3'],
],
[
'start' => $od['@attributes']['starting_time'],
'over' => (float) $od['o1'],
'under' => (float) $od['o2'],
'margin' => (float) Helper::margin([$od['o1'], $od['o2'], $od['o3']], 1),
'flag' => 1,
'check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
$bkmid = false;
case '5242880':
OddsDc::updateOrCreate(
[
'event_id' => $e['id'],
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'bmoid' => $bmoid,
],
[
'start' => $od['@attributes']['starting_time'],
'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,
'check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
case '11534337':
OddsGgng::updateOrCreate(
[
'event_id' => $e['id'],
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'bmoid' => $bmoid,
],
[
'start' => $od['@attributes']['starting_time'],
'gg' => (float) $od['o1'],
'ng' => (float) $od['o3'],
'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
'flag' => 1,
'check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
case '11534337':
OddsQualify::updateOrCreate(
[
'event_id' => $e['id'],
'bookmaker_id' => $bkmid,
'sport_id' => NuhBash::$options['sport_id'],
'bmoid' => $bmoid,
],
[
'start' => $od['@attributes']['starting_time'],
'htq' => (float) $od['o1'],
'atq' => (float) $od['o2'],
'margin' => (float) Helper::margin([$od['o1'], $od['o3']], 1),
'flag' => 1,
'check' => 0,
'source_updated_at' => $od['@attributes']['time'],
'last_check_at' => Carbon::now()->toDateTimeString(),
]
);
break;
}
break;
}
switch ($bookkey) {
case '@attributes':
if (isset($book['bid'])) {
$bkmid = (int) $book['bid'];
}
}
break;
case 'offer':
if ($bkmid) {
foreach ($book as $type => $od) {
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(),
]
);
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(),
]);
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 '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 '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 '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;
}
}
}
}