This commit is contained in:
salam committed 2026-10-04 15:25:03 +02:00
1 parent 9bcd4432c6
commit 6f92f9e1d5
1209 files changed
+220940

No files matched your search

@@ -0,0 +1,29 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
use App\Models\ComparingBookmaker;
class AlarmBookmakerFilter
{
public static function get($client_bookmaker_id, $sport_id)
{
$res = ComparingBookmaker::where('sport_id', $sport_id)
->where('client_bookmaker_id', $client_bookmaker_id)
->where('is_active', 1)
->orderBy('sorting', 'asc')
->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'sorting')
->get();
$arr = [];
foreach ($res as $value) {
$arr[$value->bookmaker_id] = [
'sorting' => $value->sorting,
'time_lastcheck' => $value->time_lastcheck,
'margin_threshold' => $value->margin_threshold,
];
}
return $arr;
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
class AlarmFilterClient
{
public static function get($odds, $client_bookmaker_id)
{
if (isset($odds[$client_bookmaker_id])) {
return $odds[$client_bookmaker_id];
}
return [];
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
class AlarmFilterCompare
{
public static function get($odds, $filter)
{
foreach ($filter as $bookmaker_id => $value) {
if (isset($odds[$bookmaker_id])) {
$data = $odds[$bookmaker_id];
if ($data['margin'] <= $value['margin_threshold']) {
$data['bookmaker_id'] = $bookmaker_id;
return $data;
}
}
}
return [];
}
}
@@ -0,0 +1,100 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
use Illuminate\Support\Facades\DB;
class AlarmLoadOdds
{
public static function get($event_id, $table, $oddnames)
{
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1', 'odds_totals', 'odds_totals_ht', 'odds_totals_q1'])) {
$res = DB::table($table)->where('active_spread', 1)->where('flags', 1)->where('event_id', $event_id)->get();
} else {
$res = DB::table($table)->where('flags', 1)->where('event_id', $event_id)->get();
}
$arr = [];
foreach ($res as $value) {
if (in_array($table, ['odds_totals', 'odds_totals_ht', 'odds_totals_q1'])) {
$arr[(int) $value->bookmaker_id]['total'] = (float) $value->total;
} elseif (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
$arr[(int) $value->bookmaker_id]['handicap'] = (float) $value->handicap;
}
if ($table == 'odds_dc') {
$arr[(int) $value->bookmaker_id]['margin'] = (float) $value->margin * 2;
} else {
$arr[(int) $value->bookmaker_id]['margin'] = (float) $value->margin;
}
foreach ($oddnames as $odd) {
switch ($odd) {
case 'h3w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->h3w;
break;
case 'd3w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->d3w;
break;
case 'a3w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->a3w;
break;
case 'h2w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->h2w;
break;
case 'a2w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->a2w;
break;
case 'dnb1':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dnb1;
break;
case 'dnb2':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dnb2;
break;
case 'gg':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->gg;
break;
case 'ng':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->ng;
break;
case 'dc1x':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dc1x;
break;
case 'dc12':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dc12;
break;
case 'dcx2':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dcx2;
break;
case 'home':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->home;
break;
case 'away':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->away;
break;
case 'over':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->over;
break;
case 'under':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->under;
break;
case 'htq':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->htq;
break;
case 'atq':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->atq;
break;
}
}
}
return $arr;
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
class AlarmMap
{
public static function get($table)
{
$map = [
'odds_2ways' => ['alarm_2w_h2w' => 'h3w', 'alarm_2w_a2w' => 'a2w'],
'odds_2ways_s1' => ['alarm_2ws1_h2w' => 'h3w', 'alarm_2ws1_a2w' => 'a2w'],
'odds_3ways' => ['alarm_3w_h3w' => 'h3w', 'alarm_3w_d3w' => 'd3w', 'alarm_3w_a3w' => 'a3w'],
'odds_3ways_ht' => ['alarm_3wht_h3w' => 'h3w', 'alarm_3wht_d3w' => 'd3w', 'alarm_3wht_a3w' => 'a3w'],
'odds_dc' => ['alarm_dc_dc1x' => 'dc1x', 'alarm_dc_dc12' => 'dc12', 'alarm_dc_dcx2' => 'dcx2'],
'odds_dnb' => ['alarm_dbn_dnb1' => 'dnb1', 'alarm_dbn_dnb2' => 'dnb2'],
'odds_ggng' => ['alarm_ggng_gg' => 'gg', 'alarm_ggng_ng' => 'ng'],
'odds_points' => ['alarm_po_home' => 'home', 'alarm_po_away' => 'away'],
'odds_points_ht' => ['alarm_poht_home' => 'home', 'alarm_poht_away' => 'away'],
'odds_points_q1' => ['alarm_poq1_home' => 'home', 'alarm_poq1_away' => 'away'],
'odds_totals' => ['alarm_to_over' => 'over', 'alarm_to_under' => 'under'],
'odds_totals_ht' => ['alarm_toht_over' => 'over', 'alarm_toht_under' => 'under'],
'odds_totals_q1' => ['alarm_toq1_over' => 'over', 'alarm_toq1_under' => 'under'],
'odds_tq' => ['alarm_tq_htq' => 'htq', 'alarm_tq_atq' => 'atq'],
];
return $map[$table];
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
use App\Models\MultilineSetting;
class AlarmMultilineSetting
{
public static function get($sport_id)
{
$res = MultilineSetting::where('sport_id', $sport_id)->get();
$arr = [];
foreach ($res as $value) {
$arr[$value->id] = [
'table' => $value->table,
'oddnames' => $value->oddnames,
];
}
return $arr;
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
use App\Models\AlarmSetting;
class AlarmSettings
{
public static function get($client_bookmaker_id, $sport_id)
{
$res = AlarmSetting::where('sport_id', $sport_id)
->where('client_bookmaker_id', $client_bookmaker_id)
->where('disabled', 0)
->select('multiline_setting_id', 'alarm_level_id', 'alarm_threshold')
->get();
$arr = [];
foreach ($res as $value) {
$arr[$value->multiline_setting_id][$value->alarm_level_id] = $value->alarm_threshold;
}
return $arr;
}
}
@@ -0,0 +1,70 @@
<?php
namespace App\Console\Commands\Services\Tasks\Alarm;
use App\Models\EventBookmaker;
class AlarmStore
{
public static function get($table, $event_id, $oddnames, $client_bookmaker_id, $alarm_threshold, $compare_odds, $client_odds)
{
if (! $compare_odds) {
return;
}
if (! $client_odds) {
return;
}
$favorit = min($client_odds);
// if ($table == 'odds_points') {
// dd($compare_odds);
// }
$update_array = [];
foreach ($oddnames as $fieldname => $oddname) {
if ($client_odds[$oddname] == $favorit) {
$threshold = $client_odds[$oddname] - $compare_odds[$oddname];
if (in_array($table, ['odds_totals', 'odds_totals_ht', 'odds_totals_q1'])) {
if ((float) $client_odds['total'] == (float) $compare_odds['total']) {
self::setAlarm($update_array, $fieldname, $threshold, $alarm_threshold);
} else {
$update_array[$fieldname] = 0;
}
} elseif (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
if ((float) $client_odds['handicap'] == (float) $compare_odds['handicap']) {
self::setAlarm($update_array, $fieldname, $threshold, $alarm_threshold);
} else {
$update_array[$fieldname] = 0;
}
} else {
self::setAlarm($update_array, $fieldname, $threshold, $alarm_threshold);
}
} else {
$update_array[$fieldname] = 0;
}
}
EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $client_bookmaker_id)->update($update_array);
}
public static function setAlarm(&$update_array, $fieldname, $threshold, $alarm_threshold)
{
if ($threshold > $alarm_threshold[3]) {
// ROT
$update_array[$fieldname] = 3;
} elseif ($threshold > $alarm_threshold[2]) {
// ORANGE
$update_array[$fieldname] = 2;
} elseif ($threshold > $alarm_threshold[1]) {
// GRÜNE
$update_array[$fieldname] = 1;
} else {
// Reset Alarm
$update_array[$fieldname] = 0;
}
}
}