133 lines
4.6 KiB
PHP
133 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper;
|
|
|
|
use App\Console\Commands\Grapper\Logifuture\Auth;
|
|
use App\Console\Commands\Grapper\Logifuture\BaseUrl;
|
|
use App\Console\Commands\Grapper\Logifuture\Basketball;
|
|
use App\Console\Commands\Grapper\Logifuture\Icehockey;
|
|
use App\Console\Commands\Grapper\Logifuture\MapEvent;
|
|
use App\Console\Commands\Grapper\Logifuture\Soccer;
|
|
use App\Console\Commands\Grapper\Logifuture\Tennis;
|
|
use App\Console\Commands\Nuh;
|
|
use App\Mapper\FindFixture;
|
|
use App\Mapper\LoadElements;
|
|
use App\Mapper\LoadGroups;
|
|
use App\Models\EventBookmaker;
|
|
use App\Models\Sport;
|
|
use App\Utilities\Notice;
|
|
|
|
class Logifuture
|
|
{
|
|
public static function switch()
|
|
{
|
|
$debug = Nuh::$options['d'] ?? 0;
|
|
|
|
$_elements = LoadElements::load(Nuh::$options['provider_id'], true);
|
|
|
|
$_groups = LoadGroups::load(Nuh::$options['provider_id'], true);
|
|
|
|
$sportmap = Sport::map('logi', 1, [1, 2, 3, 5]);
|
|
|
|
$event_id_collector = [];
|
|
|
|
if ($debug) {
|
|
Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['sport']['name'], 'g');
|
|
}
|
|
|
|
switch (Nuh::$options['provider_id']) {
|
|
case 5:
|
|
Nuh::$options['bookmaker_id'] = 35;
|
|
break;
|
|
case 6:
|
|
Nuh::$options['bookmaker_id'] = 36;
|
|
break;
|
|
}
|
|
|
|
// https://external-api.bet9ja.com/external/v1/matches?sport_id=1
|
|
// https://external-api.bet9ja.com/external
|
|
|
|
$data = Auth::exe();
|
|
|
|
$header = [];
|
|
$header[] = 'Authorization: Bearer '.$data['token'];
|
|
$header[] = 'accept: application/json';
|
|
$header[] = 'content-type: application/json';
|
|
|
|
foreach ($sportmap as $client_sport_id => $sport_id) {
|
|
$post_fields = [
|
|
'url' => BaseUrl::get().'/v1/matches?sportId='.$client_sport_id,
|
|
'header' => json_encode($header),
|
|
];
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
if (config('env.app_env') == 'local') {
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
|
|
curl_setopt($ch, CURLOPT_URL, 'https://proxydb1.nuhodds.com/logifuture.php');
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
|
|
]);
|
|
} else {
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
}
|
|
|
|
$file = curl_exec($ch);
|
|
|
|
$matches = json_decode($file, 1);
|
|
|
|
if (! isset($matches['error'])) {
|
|
|
|
foreach ($matches as $match) {
|
|
|
|
if (strpos($match['sportCategory'], 'Simulated Reality') === false) {
|
|
|
|
$event = MapEvent::filter($sport_id, $match);
|
|
|
|
FindFixture::search($event, $_groups[$sport_id], $_elements[$sport_id], true);
|
|
|
|
if ($event['id']) {
|
|
|
|
$event_id_collector[] = $event['id'];
|
|
|
|
EventBookmaker::updateOrCreate([
|
|
'event_id' => $event['id'],
|
|
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
|
], ['in_feed' => 1, 'bmoid' => $event['event_id']]);
|
|
|
|
$_spreads = [];
|
|
switch ($sport_id) {
|
|
case 1:
|
|
Soccer::get($event, $match);
|
|
break;
|
|
case 2:
|
|
Icehockey::get($event, $_spreads, $match);
|
|
break;
|
|
case 3:
|
|
Basketball::get($event, $_spreads, $match);
|
|
break;
|
|
case 5:
|
|
Tennis::get($event, $_spreads, $match);
|
|
break;
|
|
|
|
default:
|
|
Notice::note('SPORT NOT IMPLEMENTED', 'r', 1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
if ($event_id_collector) {
|
|
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
|
|
}
|
|
}
|
|
}
|