82 lines
2.7 KiB
PHP
82 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Services\Tasks;
|
|
|
|
use App\Console\Commands\Nuh;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmBookmakerFilter;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmFilterClient;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmFilterCompare;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmLoadOdds;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmMultilineSetting;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmSettings;
|
|
use App\Console\Commands\Services\Tasks\Alarm\AlarmStore;
|
|
use App\Models\Client;
|
|
use App\Models\EventBookmaker;
|
|
use App\Models\OddsTable;
|
|
use App\Utilities\Notice;
|
|
|
|
class GenerateAlarms
|
|
{
|
|
public static function run()
|
|
{
|
|
|
|
$debug = Nuh::$options['d'] ?? 0;
|
|
|
|
if ($debug) {
|
|
Notice::note('GENERATE ALARMS', 'b');
|
|
}
|
|
|
|
$oddnames = OddsTable::oddnames();
|
|
|
|
$clients = Client::get();
|
|
|
|
foreach ($clients as $client) {
|
|
if ($debug) {
|
|
Notice::note($client->name, 'b');
|
|
}
|
|
|
|
foreach ($client->sport as $sport_id) {
|
|
|
|
if ($debug) {
|
|
Notice::note('Sport: '.$sport_id, 'b');
|
|
}
|
|
|
|
$multilines = AlarmMultilineSetting::get($sport_id);
|
|
|
|
foreach ($client->bookmaker as $client_bookmaker_id) {
|
|
|
|
$alarm_threshold = AlarmSettings::get($client_bookmaker_id, $sport_id);
|
|
|
|
$filter = AlarmBookmakerFilter::get($client_bookmaker_id, $sport_id);
|
|
|
|
$res = EventBookmaker::with('event')->where('bookmaker_id', $client_bookmaker_id)->where('sport_id', $sport_id)->get();
|
|
|
|
if ($debug) {
|
|
Notice::note('Event: '.\count($res), 'b');
|
|
}
|
|
// $res = EventBookmaker::where('event_id', 14597944)->where('bookmaker_id', $client_bookmaker_id)->where('sport_id', $sport_id)->get();
|
|
|
|
foreach ($res as $event) {
|
|
|
|
if ($event->event->starttime > now()) {
|
|
|
|
foreach ($multilines as $multiline_id => $multiline) {
|
|
|
|
$table = $multiline['table'];
|
|
|
|
$odds = AlarmLoadOdds::get($event->event_id, $table, $oddnames[$table]);
|
|
|
|
$compare_odds = AlarmFilterCompare::get($odds, $filter);
|
|
|
|
$client_odds = AlarmFilterClient::get($odds, $client_bookmaker_id);
|
|
|
|
AlarmStore::get($event->event_id, $oddnames[$table], $client_bookmaker_id, $alarm_threshold[$multiline_id], $compare_odds, $client_odds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|