wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\OddsTable;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AlarmStatistic
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$res = OddsTable::select('name', 'fieldnames')->get();
|
||||
$fields = [];
|
||||
foreach ($res as $value) {
|
||||
$fields[$value->name] = explode(',', $value->fieldnames);
|
||||
}
|
||||
|
||||
$events = Event::with('event_bookmaker')
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('starttime', '>=', Carbon::now())
|
||||
->whereHas('event_bookmaker', function ($query) {
|
||||
$query->where('bookmaker_id', auth()->user()->bookmaker_id);
|
||||
})
|
||||
->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($events as $event) {
|
||||
$row = $event->event_bookmaker;
|
||||
// $row = get_object_vars($event->toArray());
|
||||
foreach ($fields as $table => $names) {
|
||||
foreach ($names as $name) {
|
||||
$val = (int) $row[$name];
|
||||
if ($val) {
|
||||
if (isset($arr[$table][$val])) {
|
||||
$arr[$table][$val]++;
|
||||
} else {
|
||||
$arr[$table][$val] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadSofaScoreCategory
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$league_ids = StatisticFixtures::where('sport_id', 1)
|
||||
->groupBy('league_id')
|
||||
->pluck('league_id')->toArray();
|
||||
|
||||
$res = SofaScoreTournament::with('sofascore_category')->whereIn('tournament_id', $league_ids)->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
$arr[$value->sofa_score_category_id] = $value->sofascore_category->name;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadStatisticFixturesLeaguesOptions
|
||||
{
|
||||
public static function load(?int $sofascore_category_id = 0)
|
||||
{
|
||||
$res = StatisticFixtures::with('league')
|
||||
->whereHas('league', function ($query) use ($sofascore_category_id) {
|
||||
$query->where('sofa_score_category_id', $sofascore_category_id);
|
||||
})
|
||||
->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
$arr[$value->league_id] = $value->league->name;
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\StatisticFixtures;
|
||||
|
||||
class LoadStatisticFixturesMatchOptions
|
||||
{
|
||||
public static function load($league_id = 0)
|
||||
{
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
$team_map = SofaScoreRosa::pluck('ss_team_name', 'ss_team_id')->toArray();
|
||||
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->id] = $val->starttime->format('Y-m-d H:i').' - '.$team_map[$val->home_id].' vs '.$team_map[$val->away_id];
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\AlarmLevel;
|
||||
use App\Models\AlarmSetting;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\ComparingBookmaker;
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\MultilineSetting;
|
||||
use App\Models\Sport;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class SettingGeneratorClient
|
||||
{
|
||||
public static function run($record)
|
||||
{
|
||||
/**************************************************
|
||||
* 1) ALARM SETTING (client_bookmaker_id)
|
||||
**************************************************/
|
||||
$alarm_levels = AlarmLevel::get();
|
||||
|
||||
foreach ($record->sport as $sport_id) {
|
||||
|
||||
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||
|
||||
$multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
|
||||
|
||||
foreach ($multilines as $multiline_id) {
|
||||
|
||||
foreach ($alarm_levels as $alarm_level) {
|
||||
|
||||
AlarmSetting::firstOrCreate(
|
||||
['client_bookmaker_id' => $client_bookmaker_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'alarm_level_id' => $alarm_level->id],
|
||||
['alarm_threshold' => $alarm_level->default_threshold]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* 2) MULTILINE SLOTS (client_bookmaker_id)
|
||||
**************************************************/
|
||||
|
||||
$bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126];
|
||||
|
||||
foreach ($record->sport as $sport_id) {
|
||||
|
||||
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||
|
||||
$multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
|
||||
|
||||
foreach ($multilines as $multiline_id) {
|
||||
|
||||
foreach ($bookmaker_slots as $slot => $bookmaker_id) {
|
||||
|
||||
MultilineClient::firstOrCreate(
|
||||
['client_bookmaker_id' => $client_bookmaker_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'position' => $slot],
|
||||
['bookmaker_id' => $bookmaker_id, 'sort' => $slot, 'disabled' => 0]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**************************************************
|
||||
* 4) COMPARING BOOKMAKER (client_bookmaker_id)
|
||||
**************************************************/
|
||||
|
||||
$bookmakers_soccer = Bookmaker::where('in_soccer', 1)->orderBy('name')->pluck('id')->toArray();
|
||||
|
||||
ComparingBookmaker::where('method_id', 1)->where('sport_id', 1)->whereNotIn('bookmaker_id', $bookmakers_soccer)->delete();
|
||||
|
||||
foreach ($record as $client) {
|
||||
|
||||
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||
|
||||
$i = 1;
|
||||
foreach ($bookmakers_soccer as $bookmaker_id) {
|
||||
$margin_threshold = $bookmaker_id == 110 ? 103 : 115;
|
||||
ComparingBookmaker::updateOrCreate(
|
||||
['method_id' => 1, 'sport_id' => 1, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
|
||||
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => $margin_threshold, 'sorting' => $i]
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sports = Sport::getActiveSports();
|
||||
if (($key = array_search(1, $sports)) !== false) {
|
||||
unset($sports[$key]);
|
||||
}
|
||||
|
||||
$bookmakers_other = Bookmaker::where('in_other', 1)->orderBy('name')->pluck('id')->toArray();
|
||||
|
||||
ComparingBookmaker::where('method_id', 1)->whereIn('sport_id', $sports)->whereNotIn('bookmaker_id', $bookmakers_other)->delete();
|
||||
|
||||
foreach ($record as $client) {
|
||||
|
||||
foreach ($record->bookmaker as $client_bookmaker_id) {
|
||||
|
||||
foreach ($sports as $sport_id) {
|
||||
$i = 1;
|
||||
foreach ($bookmakers_other as $bookmaker_id) {
|
||||
|
||||
ComparingBookmaker::updateOrCreate(
|
||||
['method_id' => 1, 'sport_id' => $sport_id, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
|
||||
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Settings generated successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\AlarmLevel;
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\Client;
|
||||
use App\Models\MultilineSetting;
|
||||
use App\Models\PersonalNotification;
|
||||
use App\Models\Sport;
|
||||
use App\Models\User;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class SettingGeneratorUser
|
||||
{
|
||||
public static function run($record)
|
||||
{
|
||||
|
||||
User::where('id', $record->id)->update(['all_only_none' => 1]);
|
||||
|
||||
/**************************************************
|
||||
* 3) BETTYPES for USER in MONITOR
|
||||
**************************************************/
|
||||
|
||||
$multilines = MultilineSetting::orderBy('sport_id')->get();
|
||||
|
||||
foreach ($multilines as $multiline) {
|
||||
|
||||
$is_active = in_array($multiline->id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
|
||||
|
||||
BettypeUser::updateOrCreate(
|
||||
['sport_id' => $multiline->sport_id, 'user_id' => $record->id, 'multiline_setting_id' => $multiline->id],
|
||||
['is_active' => $multiline->is_active, 'sorting' => $multiline->sorting],
|
||||
);
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* 5) ALARM NOTIFICATION SETTINGS FOR USERS
|
||||
**************************************************/
|
||||
|
||||
if (in_array($record->id, [1, 2])) {
|
||||
$sports = Sport::where('is_active', 1)->pluck('id')->toArray();
|
||||
} else {
|
||||
$sports = Client::find($record->client_id)->value('sport');
|
||||
}
|
||||
$alarm_levels = AlarmLevel::get();
|
||||
|
||||
foreach ($alarm_levels as $alarm_level) {
|
||||
|
||||
PersonalNotification::firstOrCreate(
|
||||
['user_id' => $record->id, 'bookmaker_id' => $record->bookmaker_id, 'alarm_level_id' => $alarm_level->id],
|
||||
['notify_by_system' => 0, 'notify_by_email' => 0]
|
||||
);
|
||||
|
||||
if ($record->partner_bookmaker_id) {
|
||||
PersonalNotification::firstOrCreate(
|
||||
['user_id' => $record->id, 'bookmaker_id' => $record->partner_bookmaker_id, 'alarm_level_id' => $alarm_level->id],
|
||||
['notify_by_system' => 0, 'notify_by_email' => 0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Settings for user generated successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Supervisor;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class SupervisorMaker
|
||||
{
|
||||
public static $base = '';
|
||||
|
||||
public static $path = '';
|
||||
|
||||
public static function run($supervisor)
|
||||
{
|
||||
$supervisors = Supervisor::all();
|
||||
|
||||
$path = base_path().'/supervisor/nuh';
|
||||
|
||||
if (! is_dir($path)) {
|
||||
mkdir($path, 0777);
|
||||
}
|
||||
|
||||
$file = new Filesystem;
|
||||
$file->cleanDirectory($path);
|
||||
|
||||
foreach ($supervisors as $supervisor) {
|
||||
|
||||
$parts = [];
|
||||
$parts[] = 'p'.$supervisor->id;
|
||||
if (isset($supervisor->sport->name)) {
|
||||
$parts[] = self::fix_string($supervisor->sport->name);
|
||||
} else {
|
||||
$parts[] = 'all';
|
||||
}
|
||||
$parts[] = self::fix_string($supervisor->provider->name);
|
||||
if ($supervisor->name) {
|
||||
$parts[] = self::fix_string($supervisor->name);
|
||||
}
|
||||
|
||||
if ($supervisor->days_to) {
|
||||
$parts[] = 'day'.$supervisor->days_from;
|
||||
$parts[] = 'day'.$supervisor->days_to;
|
||||
}
|
||||
|
||||
$process = strtolower(implode('_', $parts));
|
||||
|
||||
$content = '[program:'.$process.']'.PHP_EOL;
|
||||
if ($supervisor->commandline_options != '') {
|
||||
$content .= 'command=/usr/bin/php '.base_path().'/artisan nuh '.$supervisor->id.' '.$supervisor->commandline_options.PHP_EOL;
|
||||
} else {
|
||||
$content .= 'command=/usr/bin/php '.base_path().'/artisan nuh '.$supervisor->id.PHP_EOL;
|
||||
}
|
||||
$content .= 'autostart=true'.PHP_EOL;
|
||||
$content .= 'autorestart=true'.PHP_EOL;
|
||||
|
||||
$file = $path.'/'.$process.'.ini';
|
||||
if ($supervisor->is_active && $supervisor->is_supervisor) {
|
||||
file_put_contents($file, $content);
|
||||
chmod($file, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
if (config('env.app_env') == 'production') {
|
||||
$exec = base_path().'/supervisor/super_update.sh';
|
||||
exec($exec, $out, $rcode);
|
||||
}
|
||||
|
||||
Notice::note('SUPERVISOR '.\count($supervisors).' PROCESSES UPDATED', 'b', 1);
|
||||
}
|
||||
|
||||
public static function fix_string($string)
|
||||
{
|
||||
$string = preg_replace("'\W'", '_', $string);
|
||||
|
||||
return strtolower($string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Supervisor;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class SupervisorStatus
|
||||
{
|
||||
public static function set($status = 0)
|
||||
{
|
||||
Supervisor::query()->update(['is_active' => $status]);
|
||||
|
||||
if ($status) {
|
||||
|
||||
Notification::make()
|
||||
->title('All supervisors started successfully')
|
||||
->success()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('All supervisors stopped successfully')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user