mapper MaglooNigeriaAll add

This commit is contained in:
salam committed 2026-02-27 15:42:50 +01:00
1 parent 8459e10c73
commit f1eaa51e38
2 files changed
+62 -41

No files matched your search

@@ -15,7 +15,7 @@ use Carbon\Carbon;
class MaglooKeniaAll class MaglooKeniaAll
{ {
/** /**
* Provider ID 2 * Provider Id 3
*/ */
public static function run() public static function run()
{ {
@@ -2,82 +2,103 @@
namespace App\Console\Commands\DbMapper; namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroup; use App\Console\Commands\DbMapper\Helper\FindCompetitionGroupById;
use App\Console\Commands\DbMapper\Helper\FindElement; use App\Console\Commands\DbMapper\Helper\FindElementById;
use App\Console\Commands\DbMapper\Store\StoreElement; use App\Console\Commands\DbMapper\Store\StoreElement;
use App\Console\Commands\DbMapper\Store\StoreGroup; use App\Console\Commands\DbMapper\Store\StoreGroup;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\Event; use App\Models\Event;
use App\Models\Mapper; use App\Models\Mapper;
use App\Models\Sport;
use App\Utilities\Notice; use App\Utilities\Notice;
use Carbon\Carbon; use Carbon\Carbon;
class MaglooNigeriaAll class MaglooNigeriaAll
{ {
/** /**
* Provider ID 2 * Provider Id 4
*/ */
public static function run() public static function run()
{ {
$debug = Nuh::$options['d'] ?? 0; $debug = Nuh::$options['d'] ?? 0;
$provider_id = 4;
if ($debug) { if ($debug) {
Notice::note(Nuh::$options['name'], 'g'); Notice::note(Nuh::$options['name'], 'g');
} }
$sports = Sport::map('magl'); $sports = [1, 3];
$mappers = Mapper::where('provider_id', 2)->where('sport_id', 5)->where('starttime', '>=', Carbon::now())->get()->toArray(); $found = [];
foreach ($mappers as $mapper) { foreach ($sports as $sport_id) {
FindElement::run($mapper); $mappers = Mapper::where('provider_id', $provider_id)->where('sport_id', $sport_id)->where('starttime', '>=', Carbon::now())->get()->toArray();
FindCompetitionGroup::run($mapper); foreach ($mappers as $mapper) {
if ($debug) { FindElementById::run($mapper);
Notice::note($mapper, 'b');
}
if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) { FindCompetitionGroupById::run($mapper);
$from = Carbon::createFromDate($mapper['starttime'])->subDay(); if ($debug) {
$to = Carbon::createFromDate($mapper['starttime'])->addDay(); Notice::note($mapper, 'p');
}
$event = Event::where('starttime', '>', $from) if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) {
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->first();
if ($event) { $from = Carbon::createFromDate($mapper['starttime'])->subDay();
StoreElement::store($mapper); $to = Carbon::createFromDate($mapper['starttime'])->addDay();
StoreGroup::store($mapper); $event = Event::where('starttime', '>', $from)
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->first();
$arr = []; if ($event) {
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete(); if ($debug) {
} Notice::note($event, 'g');
}
if ($debug) { if (! isset($found[$sport_id])) {
Notice::note($event->toArray(), 'g'); $found[$sport_id] = 1;
} else {
$found[$sport_id]++;
}
StoreElement::store($mapper);
StoreGroup::store($mapper);
$arr = [];
if ($mapper['bet365_id']) {
$arr['bet365_id'] = $mapper['bet365_id'];
}
if ($mapper['betradar_id']) {
$arr['betradar_id'] = $mapper['betradar_id'];
}
if ($mapper['betsapi_id']) {
$arr['betsapi_id'] = $mapper['betsapi_id'];
}
if ($arr) {
Event::where('id', $event->id)->update($arr);
Mapper::where('id', $mapper['id'])->delete();
}
if ($debug) {
Notice::note($event->toArray(), 'g');
}
} }
} }
} }
} }
if ($debug) {
Notice::note($found, 'g');
}
} }
} }