wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user