95 lines
2.9 KiB
PHP
95 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\DbMapper;
|
|
|
|
use App\Console\Commands\DbMapper\Helper\FindElement;
|
|
use App\Console\Commands\DbMapper\Helper\FindGroup;
|
|
use App\Console\Commands\Nuh;
|
|
use App\Models\Event;
|
|
use App\Models\Mapper;
|
|
use App\Models\Sport;
|
|
use App\Utilities\Notice;
|
|
use Carbon\Carbon;
|
|
|
|
class LogifutureNigeriaAll
|
|
{
|
|
/**
|
|
* Provider ID 5
|
|
* LOGIFUTURE NIGERA
|
|
*/
|
|
public static function run()
|
|
{
|
|
$provider_id = 5;
|
|
$debug = Nuh::$options['d'] ?? 0;
|
|
|
|
if ($debug) {
|
|
Notice::note(Nuh::$options['name'], 'g');
|
|
}
|
|
|
|
$sports = Sport::getActiveSports();
|
|
|
|
$found = [];
|
|
|
|
foreach ($sports as $sport_id) {
|
|
|
|
$mappers = Mapper::where('provider_id', $provider_id)->where('sport_id', $sport_id)->where('starttime', '>=', Carbon::now())->get()->toArray();
|
|
|
|
foreach ($mappers as $mapper) {
|
|
|
|
FindElement::run($mapper);
|
|
|
|
FindGroup::run($mapper);
|
|
|
|
if ($debug) {
|
|
Notice::note($mapper, 'p');
|
|
}
|
|
|
|
if (isset($mapper['txodds_home_id']) && isset($mapper['txodds_away_id']) && isset($mapper['competition_group_id'])) {
|
|
|
|
$from = Carbon::createFromDate($mapper['starttime'])->subDay();
|
|
$to = Carbon::createFromDate($mapper['starttime'])->addDay();
|
|
|
|
$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['competition_group_id'])
|
|
->first();
|
|
|
|
if ($event) {
|
|
if (! isset($found[$sport_id])) {
|
|
$found[$sport_id] = 1;
|
|
} else {
|
|
$found[$sport_id]++;
|
|
}
|
|
|
|
$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');
|
|
}
|
|
}
|
|
}
|