wip del err

This commit is contained in:
salam committed 2026-10-04 15:22:39 +02:00
1 parent 812736ca9a
commit 9bcd4432c6
1210 files changed
-220941

No files matched your search

@@ -1,30 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Nuh;
use App\Console\Commands\Xml;
use App\Models\Country;
use App\Utilities\Notice;
class Countries
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$url = 'https://xml2.txodds.com/feed/countries.php';
$data = Xml::load($url);
$count = 0;
foreach ($data as $row) {
Country::updateOrCreate(
['id' => (int) $row->id],
['name' => (string) $row->name, 'cc' => (string) $row->cc]
);
$count++;
}
Notice::note("$count countries processed", 'g');
}
}
@@ -1,142 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Nuh;
use App\Console\Commands\Xml;
use App\Models\CompetitionGroup;
use App\Models\Element;
use App\Models\ElementGroup;
use App\Models\Event;
use App\Models\Group;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Fixtures
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$today = Nuh::$options['t'] ?? 0;
$week = Nuh::$options['w'] ?? 0;
if ($debug) {
Notice::note('TXODDS FIXTURES', 'b');
}
$count = 0;
$total_soccer = 0;
$total_others = 0;
$sports = Sport::where('is_active', 1)->pluck('id')->toArray();
/**
* Grap
*/
$kontos = ['soccer' => config('env.txodds_betaid1'), 'other' => config('env.txodds_betaid2')];
foreach ($kontos as $authentication) {
// code...
if ($today) {
Nuh::$options['days_from'] = 0;
if (now()->between(today(), today()->addHour())) {
Nuh::$options['days_to'] = 2;
} else {
Nuh::$options['days_to'] = 1;
}
} elseif ($week) {
Nuh::$options['days_from'] = 0;
Nuh::$options['days_to'] = 6;
}
for ($i = Nuh::$options['days_from']; $i < Nuh::$options['days_to']; $i++) {
$url = "https://xml2.txodds.com/feed/result/xml.php?$authentication&days=$i,1";
$data = Xml::load($url);
foreach ($data as $row) {
$sport_id = (int) $row->group['spid'];
if (in_array($sport_id, $sports)) {
$event = [
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => Carbon::createFromDate((string) $row->time)->toDateTimeString(),
'sport_id' => (int) $sport_id,
'home_id' => (int) $row->hteam['id'],
'away_id' => (int) $row->ateam['id'],
'country_id' => (int) $row->group['cnid'],
'group_id' => (int) $row->group['id'],
'competition_group_id' => (int) $row->group['cgid'],
];
DB::transaction(function () use ($event, $row) {
Event::updateOrCreate(['id' => (int) $row['id']], $event);
}, 5);
$group = [
'competition_group_id' => (string) $row->group['cgid'],
'sport_id' => (int) $sport_id,
'country_id' => (int) $row->group['cnid'],
'name' => (string) $row->group['cname'],
'fullname' => (string) $row->group,
];
Group::updateOrCreate(['id' => (int) $row->group['id']], $group);
$compgroup = [
'sport_id' => (int) $sport_id,
'country_id' => $event['country_id'],
'name' => (string) $row->group['cname'],
];
CompetitionGroup::updateOrCreate(['id' => (int) $row->group['cgid']], $compgroup);
$element = [
'name' => (string) $row->hteam,
'sport_id' => (int) $sport_id,
'country_id' => (int) $row->group['cnid'],
];
Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element);
$element_group = [
'competition_group_id' => (int) $row->group['cgid'],
];
ElementGroup::updateOrCreate(['element_id' => (int) $row->hteam['id'], 'group_id' => (int) $row->group['id']], $element_group);
$element = [
'name' => (string) $row->ateam,
'sport_id' => (int) $sport_id,
'country_id' => (int) $row->group['cnid'],
];
Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element);
$element_group = [
'competition_group_id' => (int) $row->group['cgid'],
];
ElementGroup::updateOrCreate(['element_id' => (int) $row->ateam['id'], 'group_id' => (int) $row->group['id']], $element_group);
if ($sport_id == 1) {
$total_soccer++;
} else {
$total_others++;
}
}
}
}
if ($debug) {
Notice::note(now()->toDateString()." - $count events processed", 'g');
}
}
if ($debug) {
Notice::note("Total Soccer - $total_soccer\nTotal Others - $total_others", 'g');
}
}
}
@@ -1,72 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Nuh;
use App\Console\Commands\Xml;
use App\Models\Group;
use App\Models\MajorGroup;
use App\Models\Sport;
use App\Utilities\Notice;
class Groups
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$kontos = ['soccer' => config('env.txodds_betaid1'), 'other' => config('env.txodds_betaid2')];
$sport_map = Sport::getActiveSports();
Group::whereNotIn('sport_id', $sport_map)->delete();
$years = [date('y'), date('y') + 1];
foreach ($kontos as $konto => $authentication) {
$url = 'https://xml2.txodds.com/feed/groups.php?' . $authentication . '&sid=' . implode(',', $years);
// https://xml2.txodds.com/feed/groups.php?ident=betaid1&passwd=Dy59vpRC&sid=25
// <group>
// <id>181996</id>
// <mgroup id="1002">FBARG</mgroup>
// <name>Supercopa Entre Rios</name>
// <sid>26</sid>
// <fullname>FBARG Supercopa Entre Rios-26</fullname>
// <date1>2025-12-13 00:00:00</date1>
// <date2>2026-04-30 00:00:00</date2>
// </group>
$data = Xml::load($url);
$count = 0;
foreach ($data as $row) {
$mgroup = $row->mgroup;
$sport_id = MajorGroup::where('name', $mgroup)->value('sport_id');
if (in_array($sport_id, $sport_map)) {
Group::updateOrCreate(
['id' => (int) $row->id],
[
'name' => (string) $row->name,
'fullname' => (string) $row->fullname,
'mgroup' => (string) $row->mgroup,
'sid' => (int) $row->sid,
'sport_id' => (int) $sport_id,
'date1' => (string) $row->date1,
'date2' => (string) $row->date2,
]
);
$count++;
}
}
Notice::note("$count groups $konto processed", 'g');
}
}
}
@@ -1,42 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Nuh;
use App\Console\Commands\Xml;
use App\Models\MajorGroup;
use App\Models\Sport;
use App\Utilities\Notice;
class MajorGroups
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$sports = Sport::getActiveSports();
foreach ($sports as $name => $sport_id) {
$url = 'https://xml2.txodds.com/feed/mgroups.php?spid='.$sport_id.'&active=1';
$data = Xml::load($url);
$count = 0;
foreach ($data as $row) {
MajorGroup::updateOrCreate(
['id' => (int) $row->id],
[
'name' => (string) $row->name,
'sport_id' => $sport_id,
'country_id' => $row->countryid,
]
);
$count++;
}
Notice::note("$count major groups $name processed", 'g');
}
}
}
@@ -1,429 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_2Way;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_2WayS1;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_3Way;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_3WayHt;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_Dc;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_Dnb;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_Ggng;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_Points;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_PointsHt;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_PointsQ1;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_Totals;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_TotalsHt;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_TotalsQ1;
use App\Console\Commands\Grapper\TxOdds\Odds\Odds_Tq;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Console\Commands\Xml;
use App\Models\CompetitionGroup;
use App\Models\Element;
use App\Models\ElementGroup;
use App\Models\Event;
use App\Models\EventBookmaker;
use App\Models\Group;
use App\Models\Supervisor;
use App\Models\TxoddsMarket;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Odds
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note('TXODD ODD sport: '.Nuh::$options['sport_id'], 'b');
}
/**
* Delete
*/
// $info = Event::where('starttime', '<', Carbon::now()->subMinutes(10))->delete();
// if ($debug) {
// Notice::note("Deleted: $info");
// }
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;
}
/*************************************************
* markets
*************************************************/
$markets = '&ot='.implode(',', $res);
/*************************************************
* 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';
} else {
$url = 'https://xml2.txodds.com/feed/odds/xml.php?'.config('env.txodds_betaid2').'&all_odds=2';
}
$_calls = [];
$sport = '&spid='.Nuh::$options['sport_id'];
if (Nuh::$options['provider_id'] == 8) {
/*************************************************
* TXODDS MARKET LASTCALL
*************************************************/
if ($debug) {
Notice::note('TXOdds MARKET Lastcall', 'p');
}
$market = '&ot='.Nuh::$options['txodds_market_id'];
$lastcall = Nuh::$options['lastcall'] > time() - 600 ? '&last='.Nuh::$options['lastcall'] : '&last='.time() - 600;
$_calls[] = $url.$sport.$market.$lastcall;
} elseif (Nuh::$options['id']) {
/*************************************************
* BY ID
*************************************************/
if ($debug) {
Notice::note("BY ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
$id = '&peid='.Nuh::$options['id'];
$_calls[] = $url.$markets.$id;
} elseif (Nuh::$options['gid']) {
/*************************************************
* BY GROUP ID
*************************************************/
if ($debug) {
Notice::note("GROUP_ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
$from_to = '&days='.Nuh::$options['days_from'].','.Nuh::$options['days_to'];
$events = Event::where('starttime', '>', Carbon::now())->where('group_id', Nuh::$options['gid'])->pluck('id');
foreach ($events as $event_id) {
$_calls[] = $url.$markets.$from_to.'&peid='.$event_id;
}
} elseif (Nuh::$options['g']) {
/*************************************************
* ALL BY GROUP ID for last changes
*************************************************/
if ($debug) {
Notice::note("GROUP_ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
$from_to = '&days='.Nuh::$options['days_from'].','.Nuh::$options['days_to'];
$groupids = Event::where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group_id');
foreach ($groupids as $groupid) {
$_calls[] = $url.$markets.$from_to.'&pgid='.$groupid;
}
} elseif (Nuh::$options['t']) {
/*************************************************
* TODAY by ID
*************************************************/
if ($debug) {
Notice::note("TODAY \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>=', Carbon::now())->where('starttime', '<', Carbon::now()->addDays(1))->pluck('id');
foreach ($res as $id) {
$_calls[] = $url.$sport.$markets.'&peid='.$id;
}
} elseif (Nuh::$options['w']) {
/*************************************************
* ONE WEEK FROM NOW
*************************************************/
if ($debug) {
Notice::note("ONE WEEK FROM NOW \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>=', Carbon::now())->where('starttime', '<', Carbon::now()->addDays(7))->pluck('id');
foreach ($res as $id) {
$_calls[] = $url.$sport.$markets.'&peid='.$id;
}
} elseif (Nuh::$options['a']) {
/*************************************************
* ALL BY ID (reload)
*************************************************/
if ($debug) {
Notice::note("ALL \nsport_id: ".Nuh::$options['sport_id'], 'p');
}
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>=', Carbon::now())->pluck('id');
foreach ($res as $id) {
$_calls[] = $url.$sport.$markets.'&peid='.$id;
}
} else {
Notice::note('BASH PARAMETER MISSING [--t, --w, --g, --a, --id=]', 'r', 1);
}
/*************************************************
* CALL
*************************************************/
$counter = 0;
foreach ($_calls as $url) {
$counter++;
$data = Xml::load($url);
if (Nuh::$options['provider_id'] == 8) {
Supervisor::where('id', Nuh::$options['supervisor_id'])->update(['lastcall' => (int) $data['timestamp']]);
}
if ($debug) {
Notice::note('counter: '.count($_calls).'/'.$counter, 'g');
}
foreach ($data as $row) {
$event_id = (int) $row['id'];
$sport_id = (int) $row->group['spid'];
$event = [
'has_markets' => 1,
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => Carbon::parse($row->time)->toDateTimeString(),
'sport_id' => $sport_id,
'home_id' => (int) $row->hteam['id'],
'away_id' => (int) $row->ateam['id'],
'country_id' => (int) $row->group['cnid'],
'group_id' => (int) $row->group['id'],
'competition_group_id' => (int) $row->group['cgid'],
];
$res = DB::transaction(function () use ($row, $event) {
return Event::updateOrCreate(['id' => (int) $row['id']], $event);
}, 5);
$event_id = $res->id;
$group = [
'competition_group_id' => (string) $row->group['cgid'],
'sport_id' => $sport_id,
'country_id' => (int) $row->group['cnid'],
'name' => (string) $row->group['cname'],
'fullname' => (string) $row->group,
];
Group::updateOrCreate(['id' => (int) $row->group['id']], $group);
$compgroup = [
'sport_id' => $sport_id,
'country_id' => $event['country_id'],
'name' => (string) $row->group['cname'],
];
CompetitionGroup::updateOrCreate(['id' => (int) $row->group['cgid']], $compgroup);
$element = [
'name' => (string) $row->hteam,
'sport_id' => $sport_id,
'country_id' => (int) $row->group['cnid'],
];
Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element);
$element_group = [
'competition_group_id' => (int) $row->group['cgid'],
];
ElementGroup::updateOrCreate(['element_id' => (int) $row->hteam['id'], 'group_id' => (int) $row->group['id']], $element_group);
$element = [
'name' => (string) $row->ateam,
'sport_id' => $sport_id,
'country_id' => (int) $row->group['cnid'],
];
Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element);
$element_group = [
'competition_group_id' => (int) $row->group['cgid'],
];
ElementGroup::updateOrCreate(['element_id' => (int) $row->ateam['id'], 'group_id' => (int) $row->group['id']], $element_group);
if ($event_id && Event::where('id', $event_id)->exists()) {
// inconsistency with CONSTRAINT when getting only market updates
foreach ($row->bookmaker as $book) {
ActiveSpread::start();
$bookmaker_id = (int) $book['bid'];
$odds = [];
$odds['event_id'] = $event_id;
$odds['bookmaker_id'] = $bookmaker_id;
$odds['sport_id'] = $sport_id;
$odds['provider_id'] = Nuh::$options['provider_id'];
$odds['flags'] = 1;
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 'flags':
$odds['flags'] = (string) $attributeValue;
break;
}
}
switch ($bettypeid) {
case 0:
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'starting_time':
DB::transaction(function () use ($odds, $sport_id, $event_id, $bookmaker_id, $attributeValue) {
EventBookmaker::updateOrCreate([
'event_id' => $event_id,
'sport_id' => $sport_id,
'bookmaker_id' => $bookmaker_id,
], ['in_feed' => 1, 'bmoid' => $odds['bmoid'], 'starttime' => Carbon::parse($attributeValue)->toDateTimeString()]);
}, 5);
break;
}
}
Odds_3Way::grap($odds, $offer);
break;
case 1:
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'starting_time':
DB::transaction(function () use ($odds, $sport_id, $event_id, $bookmaker_id, $attributeValue) {
EventBookmaker::updateOrCreate([
'event_id' => $event_id,
'sport_id' => $sport_id,
'bookmaker_id' => $bookmaker_id,
], ['in_feed' => 1, 'bmoid' => $odds['bmoid'], 'starttime' => Carbon::parse($attributeValue)->toDateTimeString()]);
}, 5);
break;
}
}
Odds_2Way::grap($odds, $offer);
break;
case 3:
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'starting_time':
DB::transaction(function () use ($odds, $sport_id, $event_id, $bookmaker_id, $attributeValue) {
EventBookmaker::updateOrCreate([
'event_id' => $event_id,
'sport_id' => $sport_id,
'bookmaker_id' => $bookmaker_id,
], ['in_feed' => 1, 'bmoid' => $odds['bmoid'], 'starttime' => Carbon::parse($attributeValue)->toDateTimeString()]);
}, 5);
break;
}
}
Odds_Points::grap($odds, $offer);
break;
case 4:
Odds_Totals::grap($odds, $offer);
break;
case 131073:
Odds_2WayS1::grap($odds, $offer);
break;
case 65536:
Odds_3WayHt::grap($odds, $offer);
break;
case 65540:
Odds_TotalsHt::grap($odds, $offer);
break;
case 65539:
Odds_PointsHt::grap($odds, $offer);
break;
case 131075:
Odds_PointsQ1::grap($odds, $offer);
break;
case 131076:
Odds_TotalsQ1::grap($odds, $offer);
break;
case 5242880:
Odds_Dc::grap($odds, $offer);
break;
case 6291457:
Odds_Dnb::grap($odds, $offer);
break;
case 11534337:
Odds_Ggng::grap($odds, $offer);
break;
case 7340033:
Odds_Tq::grap($odds, $offer);
break;
default:
Notice::note('switch bettype ID not found: '.$bettypeid, 'r');
break;
}
}
ActiveSpread::set($event_id, $bookmaker_id);
}
}
}
}
if ($debug) {
Notice::note('DONE - EVENTS: '.$counter, 'g');
}
}
}
@@ -1,38 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\Odds2way;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_2Way
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['h2w'] = (float) $value->o1;
$odds['a2w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h2w'], $odds['a2w']], 1);
$res = Odds2way::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
Odds2way::create($odds);
} elseif (! $block_update) {
$res->h2w = $odds['h2w'];
$res->a2w = $odds['a2w'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,38 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\Odds2wayS1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_2WayS1
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['h2w'] = (float) $value->o1;
$odds['a2w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h2w'], $odds['a2w']], 1);
$res = Odds2wayS1::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
Odds2wayS1::create($odds);
} elseif (! $block_update) {
$res->h2w = $odds['h2w'];
$res->a2w = $odds['a2w'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,40 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\Odds3way;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_3Way
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['h3w'] = (float) $value->o1;
$odds['d3w'] = (float) $value->o2;
$odds['a3w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
$res = Odds3way::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
Odds3way::create($odds);
} elseif (! $block_update) {
$res->h3w = $odds['h3w'];
$res->d3w = $odds['d3w'];
$res->a3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,40 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\Odds3wayHt;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_3WayHt
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['h3w'] = (float) $value->o1;
$odds['d3w'] = (float) $value->o2;
$odds['a3w'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
$res = Odds3wayHt::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
Odds3wayHt::create($odds);
} elseif (! $block_update) {
$res->h3w = $odds['h3w'];
$res->d3w = $odds['d3w'];
$res->a3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,40 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\OddsDc;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Dc
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['dc1x'] = (float) $value->o1;
$odds['dc12'] = (float) $value->o2;
$odds['dcx2'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['dc1x'], $odds['dc12'], $odds['dcx2']], 1);
$res = OddsDc::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
OddsDc::create($odds);
} elseif (! $block_update) {
$res->dc1x = $odds['dc1x'];
$res->dc12 = $odds['dc12'];
$res->dcx2 = $odds['dcx2'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,38 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\OddsDnb;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Dnb
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['dnb1'] = (float) $value->o1;
$odds['dnb2'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['dnb1'], $odds['dnb2']], 1);
$res = OddsDnb::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
OddsDnb::create($odds);
} elseif (! $block_update) {
$res->dnb1 = $odds['dnb1'];
$res->dnb2 = $odds['dnb2'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,38 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\OddsGgng;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Ggng
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['gg'] = (float) $value->o1;
$odds['ng'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['gg'], $odds['ng']], 1);
$res = OddsGgng::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
OddsGgng::create($odds);
} elseif (! $block_update) {
$res->gg = $odds['gg'];
$res->ng = $odds['ng'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,55 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Models\OddsPoint;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Points
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['home'] = (float) $value->o1;
$odds['away'] = (float) $value->o2;
$odds['handicap'] = (float) $value->o3;
}
if (fmod((float) $odds['handicap'], 1) != 0.5) {
return;
}
if ($odds['home'] >= 1 && $odds['away'] >= 1) {
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$res = OddsPoint::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPoint::create($odds);
} elseif (! $block_update) {
$res->home = $odds['home'];
$res->away = $odds['away'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
ActiveSpread::collect($odds, 'odds_points');
}
}
@@ -1,54 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Models\OddsPointHt;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_PointsHt
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['home'] = (float) $value->o1;
$odds['away'] = (float) $value->o2;
$odds['handicap'] = (float) $value->o3;
}
if (fmod((float) $odds['handicap'], 1) != 0.5) {
return;
}
if ($odds['home'] >= 1 && $odds['away'] >= 1) {
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$res = OddsPointHt::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPointHt::create($odds);
} elseif (! $block_update) {
$res->home = $odds['home'];
$res->away = $odds['away'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
ActiveSpread::collect($odds, 'odds_points_ht');
}
}
@@ -1,54 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Models\OddsPointQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_PointsQ1
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['home'] = (float) $value->o1;
$odds['away'] = (float) $value->o2;
$odds['handicap'] = (float) $value->o3;
}
if (fmod((float) $odds['handicap'], 1) != 0.5) {
return;
}
if ($odds['home'] >= 1 && $odds['away'] >= 1) {
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
$res = OddsPointQ1::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPointQ1::create($odds);
} elseif (! $block_update) {
$res->home = $odds['home'];
$res->away = $odds['away'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
ActiveSpread::collect($odds, 'odds_points_q1');
}
}
@@ -1,60 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Models\OddsTotal;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Totals
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['over'] = (float) $value->o1;
$odds['under'] = (float) $value->o2;
$odds['total'] = (float) $value->o3;
}
if ($odds['sport_id'] == 1) {
if ((float) $odds['total'] != 2.5) {
return;
}
} else {
if (fmod((float) $odds['total'], 1) != 0.5) {
return;
}
}
if ($odds['over'] >= 1 && $odds['under'] >= 1) {
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$res = OddsTotal::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotal::create($odds);
} elseif (! $block_update) {
$res->over = $odds['over'];
$res->under = $odds['under'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
ActiveSpread::collect($odds, 'odds_totals');
}
}
@@ -1,61 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Models\OddsTotalHt;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_TotalsHt
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['over'] = (float) $value->o1;
$odds['under'] = (float) $value->o2;
$odds['total'] = (float) $value->o3;
}
if ($odds['sport_id'] == 1) {
if ((float) $odds['total'] != 2.5) {
return;
}
} else {
if (fmod((float) $odds['total'], 1) != 0.5) {
return;
}
}
if ($odds['over'] >= 1 && $odds['under'] >= 1) {
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$res = OddsTotalHt::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotalHt::create($odds);
} elseif (! $block_update) {
$res->over = $odds['over'];
$res->under = $odds['under'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
ActiveSpread::collect($odds, 'odds_totals_ht');
}
}
@@ -1,60 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Models\OddsTotalQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_TotalsQ1
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['over'] = (float) $value->o1;
$odds['under'] = (float) $value->o2;
$odds['total'] = (float) $value->o3;
}
if ($odds['sport_id'] == 1) {
if ((float) $odds['total'] != 2.5) {
return;
}
} else {
if (fmod((float) $odds['total'], 1) != 0.5) {
return;
}
}
if ($odds['over'] >= 1 && $odds['under'] >= 1) {
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$res = OddsTotalQ1::where('event_id', $odds['event_id'])
->where('bookmaker_id', $odds['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotalQ1::create($odds);
} elseif (! $block_update) {
$res->over = $odds['over'];
$res->under = $odds['under'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
ActiveSpread::collect($odds, 'odds_totals_q1');
}
}
@@ -1,38 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\OddsTq;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Tq
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['htq'] = (float) $value->o1;
$odds['atq'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['htq'], $odds['atq']], 1);
$res = OddsTq::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
OddsTq::create($odds);
} elseif (! $block_update) {
$res->htq = $odds['htq'];
$res->atq = $odds['atq'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
@@ -1,68 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools;
use Illuminate\Support\Facades\DB;
class ActiveSpread
{
public static $collector = [];
public static function start()
{
self::$collector = [];
}
public static function collect($odds, $table)
{
if (! isset(self::$collector[$table])) {
self::$collector[$table]['difference'] = $odds['difference'];
if (isset($odds['handicap'])) {
self::$collector[$table]['active_spread'] = $odds['handicap'];
} else {
self::$collector[$table]['active_spread'] = $odds['total'];
}
} elseif ($odds['difference'] < self::$collector[$table]['difference']) {
self::$collector[$table]['difference'] = $odds['difference'];
if (isset($odds['handicap'])) {
self::$collector[$table]['active_spread'] = $odds['handicap'];
} else {
self::$collector[$table]['active_spread'] = $odds['total'];
}
}
}
public static function set($event_id, $bookmaker_id)
{
foreach (self::$collector as $table => $value) {
DB::transaction(function () use ($table, $event_id, $bookmaker_id) {
DB::table($table)->where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->update(['active_spread' => 0]);
}, 5);
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
DB::transaction(function () use ($table, $event_id, $bookmaker_id, $value) {
DB::table($table)
->where('event_id', $event_id)
->where('bookmaker_id', $bookmaker_id)
->where('handicap', (float) $value['active_spread'])
->update(['active_spread' => 1]);
}, 5);
} else {
DB::transaction(function () use ($table, $event_id, $bookmaker_id, $value) {
DB::table($table)
->where('event_id', $event_id)
->where('bookmaker_id', $bookmaker_id)
->where('total', (float) $value['active_spread'])
->update(['active_spread' => 1]);
}, 5);
}
}
}
}
@@ -1,97 +0,0 @@
/*************************************************
* https://xml2.txodds.com/feed/odds_types.php
* BETTYPE IDS
0 3-WAY
1 2-WAY
3 POINTS
4 TOTALS
131073 MONEY LINE - Q1
65536 3-WAY HALF TIME
65540 TOTALS HALF TIME
65539 POINTS HALF TIME
131075 POINTS QUARTER TIME
131076 TOTALS QUARTER TIME
5242880 DOUBLE CHANCE
6291457 DRAW NO BET
11534337 GG/NG (both teams to score)
7340033 TO PROGRESS (to qualify)
Not used:
5 Asian
131072 3 WAY QUARTER TIME
262148 TOTALS OVER TIME
262147 POINTS OVER TIME
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
*************************************************/
switch (Nuh::$options['sport_id']) {
case 1:
/**
* 0 3-WAY
* 4 TOTALS
* 65536 3-WAY HALF TIME
* 65540 TOTALS HALF TIME
* 11534337 GG/NG (both teams to score)
* 5242880 DOUBLE CHANCE
* 7340033 TO PROGRESS (to qualify)
* 6291457 DRAW NO BET
*/
$markets = '0,4,65536,65540,11534337,5242880,7340033,6291457';
break;
case 2:
/**
* 0 3-WAY
* 1 2-WAY
* 3 POINTS
* 4 TOTALS
* 131075 POINTS QUARTER TIME
* 131076 TOTALS QUARTER TIME
*/
$markets = '0,1,3,4,131076,131075';
break;
case 3:
/**
* 1 2-WAY
* 3 POINTS
* 4 TOTALS
* 65539 POINTS HALF TIME
* 65540 TOTALS HALF TIME
* 131075 POINTS QUARTER TIME
* 131076 TOTALS QUARTER TIME
*/
$markets = '1,3,4,65539,65540,131075,131076';
break;
case 5:
/**
* 1 2-WAY
* 131073 MONEY LINE - Q1
* 3 POINTS
* 4 TOTALS
*/
$markets = '1,3,4,131073';
break;
default:
Notice::note('sport not defined', 'r', 1);
break;
}