set alatm for total and point only when same hcap or total
This commit is contained in:
1 parent
bfecd7b536
commit
a6ef8e74cc
3 files changed
+39
-13
No files matched your search
@@ -17,6 +17,11 @@ class AlarmLoadOdds
|
||||
$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 {
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Models\EventBookmaker;
|
||||
|
||||
class AlarmStore
|
||||
{
|
||||
public static function get($event_id, $oddnames, $client_bookmaker_id, $alarm_threshold, $compare_odds, $client_odds)
|
||||
public static function get($table, $event_id, $oddnames, $client_bookmaker_id, $alarm_threshold, $compare_odds, $client_odds)
|
||||
{
|
||||
if (! $compare_odds) {
|
||||
return;
|
||||
@@ -18,24 +18,26 @@ class AlarmStore
|
||||
|
||||
$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 ($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;
|
||||
if (in_array($table, ['odds_totals', 'odds_totals_ht', 'odds_totals_q1'])) {
|
||||
if ($client_odds['total'] = (float) $compare_odds['total']) {
|
||||
self::setAlarm($update_array, $fieldname, $threshold, $alarm_threshold);
|
||||
}
|
||||
} elseif (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
|
||||
if ($client_odds['handicap'] = (float) $compare_odds['handicap']) {
|
||||
self::setAlarm($update_array, $fieldname, $threshold, $alarm_threshold);
|
||||
}
|
||||
} else {
|
||||
// Reset Alarm
|
||||
$update_array[$fieldname] = 0;
|
||||
self::setAlarm($update_array, $fieldname, $threshold, $alarm_threshold);
|
||||
}
|
||||
} else {
|
||||
$update_array[$fieldname] = 0;
|
||||
@@ -44,4 +46,21 @@ class AlarmStore
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,11 +66,13 @@ class GenerateAlarms
|
||||
|
||||
$odds = AlarmLoadOdds::get($event->event_id, $table, $oddnames[$table]);
|
||||
|
||||
// check if margin is > 1
|
||||
$compare_odds = AlarmFilterCompare::get($odds, $filter);
|
||||
|
||||
// check if client has odds
|
||||
$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);
|
||||
AlarmStore::get($table, $event->event_id, $oddnames[$table], $client_bookmaker_id, $alarm_threshold[$multiline_id], $compare_odds, $client_odds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user