add alarm level from db
This commit is contained in:
1 parent
4e77862aa7
commit
40f40db63c
28 files changed
+248
-251
No files matched your search
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BettypUserGenerator
|
||||
{
|
||||
public static function run($record)
|
||||
{
|
||||
$user_id = (int) $record->id;
|
||||
|
||||
$multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
|
||||
|
||||
foreach ($multilines as $multiline_setting_id => $sport_id) {
|
||||
|
||||
$is_active = in_array($multiline_setting_id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
|
||||
|
||||
$setting = [];
|
||||
$setting['sport_id'] = $sport_id;
|
||||
$setting['user_id'] = $user_id;
|
||||
$setting['multiline_setting_id'] = $multiline_setting_id;
|
||||
|
||||
DB::table('bettype_users')->updateOrInsert($setting, ['is_active' => $is_active]);
|
||||
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Bettypes for user generated successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
|
||||
class LoadCountryGroups
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
$res = Country::query()->select('name', 'id')->get();
|
||||
$countries = [];
|
||||
foreach ($res as $value) {
|
||||
$countries[$value->id] = $value->name;
|
||||
}
|
||||
|
||||
$res = CompetitionGroup::where('sport_id', auth()->user()->sport_id)->select('country_id', 'name', 'id')->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
if (isset($countries[$value->country_id])) {
|
||||
$arr[$value->id] = $countries[$value->country_id].' '.$value->name;
|
||||
} else {
|
||||
$arr[$value->id] = $value->name;
|
||||
}
|
||||
}
|
||||
asort($arr);
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class MultilineGenerator
|
||||
{
|
||||
public static function run($record)
|
||||
{
|
||||
$client_id = $record->id;
|
||||
|
||||
MultilineClient::where('client_id', $client_id)->update(['disabled' => 1]);
|
||||
|
||||
$bookmaker = [0, 6, 30, 649, 117];
|
||||
|
||||
foreach ($record->sport as $sport_id) {
|
||||
|
||||
$multilines = MultilineSetting::where('sport_id', $sport_id)->get();
|
||||
|
||||
foreach ($multilines as $multiline) {
|
||||
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
|
||||
MultilineClient::updateOrInsert(
|
||||
['client_id' => $client_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline->id, 'position' => $i],
|
||||
['bookmaker_id' => $bookmaker[$i], 'sort' => $i, 'disabled' => 0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Multiline generated successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,68 @@
|
||||
<?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)
|
||||
{
|
||||
/**************************************************
|
||||
* 3) BETTYPES for USER in MONITOR
|
||||
**************************************************/
|
||||
|
||||
$multilines = MultilineSetting::orderBy('sport_id')->pluck('sport_id', 'id');
|
||||
|
||||
foreach ($multilines as $multiline_setting_id => $sport_id) {
|
||||
|
||||
$is_active = in_array($multiline_setting_id, [1, 2, 9, 10, 16, 17, 22, 23]) ? 1 : 0;
|
||||
|
||||
BettypeUser::firstOrCreate(
|
||||
['sport_id' => $sport_id, 'user_id' => $record->id, 'multiline_setting_id' => $multiline_setting_id],
|
||||
['is_active' => $is_active],
|
||||
);
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* 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 ($sports as $sport_id) {
|
||||
foreach ($alarm_levels as $alarm_level) {
|
||||
|
||||
PersonalNotification::firstOrCreate(
|
||||
['sport_id' => $sport_id, '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(
|
||||
['sport_id' => $sport_id, '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();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user