diff --git a/app/Actions/AlarmGenerator.php b/app/Actions/AlarmGenerator.php deleted file mode 100644 index 2e553801..00000000 --- a/app/Actions/AlarmGenerator.php +++ /dev/null @@ -1,12 +0,0 @@ - $event->id, + 'sport_id' => $event->sport_id, 'bookmaker_id' => $bookmaker_id, ], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]); diff --git a/app/Console/Commands/Grapper/Fixtures/FindFixture.php b/app/Console/Commands/Grapper/Fixtures/FindFixture.php index b118aa13..64fb2cd0 100644 --- a/app/Console/Commands/Grapper/Fixtures/FindFixture.php +++ b/app/Console/Commands/Grapper/Fixtures/FindFixture.php @@ -52,22 +52,30 @@ class FindFixture case 3: // MAGLOO KENIA $res = EventBookmaker::where('bookmaker_id', 10)->where('event_id', $event_id)->first(); - $match = Event::where('id', $res->event_id)->first(); + if ($res) { + $match = Event::where('id', $res->event_id)->first(); + } break; case 4: // MAGLOO NIGERIA $res = EventBookmaker::where('bookmaker_id', 16)->where('event_id', $event_id)->first(); - $match = Event::where('id', $res->event_id)->first(); + if ($res) { + $match = Event::where('id', $res->event_id)->first(); + } break; case 5: // LOGIFUTUR NIGERA $res = EventBookmaker::where('bookmaker_id', 35)->where('event_id', $event_id)->first(); - $match = Event::where('id', $res->event_id)->first(); + if ($res) { + $match = Event::where('id', $res->event_id)->first(); + } break; case 6: // LOGIFUTUR COLOMBIA $res = EventBookmaker::where('bookmaker_id', 36)->where('event_id', $event_id)->first(); - $match = Event::where('id', $res->event_id)->first(); + if ($res) { + $match = Event::where('id', $res->event_id)->first(); + } break; } } diff --git a/app/Console/Commands/Grapper/Logifuture.php b/app/Console/Commands/Grapper/Logifuture.php index 99ca8c94..cf600802 100644 --- a/app/Console/Commands/Grapper/Logifuture.php +++ b/app/Console/Commands/Grapper/Logifuture.php @@ -59,6 +59,7 @@ class Logifuture EventBookmaker::updateOrCreate([ 'event_id' => $event['id'], + 'sport_id' => $sport_id, 'bookmaker_id' => Nuh::$options['bookmaker_id'], ], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'startime' => $event['starttime']]); diff --git a/app/Console/Commands/Grapper/Magloo/Fixtures.php b/app/Console/Commands/Grapper/Magloo/Fixtures.php index 47f8f244..4e281a75 100644 --- a/app/Console/Commands/Grapper/Magloo/Fixtures.php +++ b/app/Console/Commands/Grapper/Magloo/Fixtures.php @@ -106,8 +106,9 @@ class Fixtures EventBookmaker::updateOrCreate([ 'event_id' => $event['id'], + 'sport_id' => $sport_id, 'bookmaker_id' => Nuh::$options['bookmaker_id'], - ], ['in_feed' => 1, 'bmoid' => $event['event_id']]); + ], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]); } } } diff --git a/app/Console/Commands/Grapper/Magloo/Odds.php b/app/Console/Commands/Grapper/Magloo/Odds.php index 650b07db..b0fa011d 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds.php +++ b/app/Console/Commands/Grapper/Magloo/Odds.php @@ -57,8 +57,6 @@ class Odds $betradar_id = (int) preg_replace('/\D/', '', $match['p']); - $bmoid = preg_replace('/\D/', '', $match['i']); - $starttime = Carbon::parse($match['dt'])->toDateTimeString(); $event_id = Event::where('betradar_id', $betradar_id)->value('id'); @@ -77,6 +75,7 @@ class Odds EventBookmaker::updateOrCreate([ 'event_id' => $event_id, + 'sport_id' => $sport_id, 'bookmaker_id' => Nuh::$options['bookmaker_id'], ], ['starttime' => $starttime, 'in_feed' => 1, 'bmoid' => $base['bmoid']]); diff --git a/app/Console/Commands/Grapper/Magloo/Odds/FilterTotals.php b/app/Console/Commands/Grapper/Magloo/Odds/FilterTotals.php index c3f9ca17..713fdd1f 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/FilterTotals.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/FilterTotals.php @@ -8,10 +8,19 @@ class FilterTotals { $_totals = []; foreach ($_array as $total => $value) { - if (fmod(abs($total), 1) == 0.5) { - if ($value[12] > 1 and $value[13] > 1) { - $_totals[$total]['over'] = number_format($value[12], 2); - $_totals[$total]['under'] = number_format($value[13], 2); + if ($sport_id == 1) { + if ($total == 2.5) { + if ($value[12] > 1 and $value[13] > 1) { + $_totals[$total]['over'] = number_format($value[12], 2); + $_totals[$total]['under'] = number_format($value[13], 2); + } + } + } else { + if (fmod(abs($total), 1) == 0.5) { + if ($value[12] > 1 and $value[13] > 1) { + $_totals[$total]['over'] = number_format($value[12], 2); + $_totals[$total]['under'] = number_format($value[13], 2); + } } } } diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStore1x2.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStore1x2.php index 051196ed..36ab0870 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStore1x2.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStore1x2.php @@ -14,6 +14,7 @@ class MaglooStore1x2 $odds['d3w'] = number_format($value['static'][2], 2) ?? 1; $odds['a3w'] = number_format($value['static'][3], 2) ?? 1; $odds['margin'] = (float) Margin::calculate($odds, 1); + $odds['flags'] = 1; $odds = array_merge($odds, $base); $res = Odds3way::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first(); @@ -23,6 +24,7 @@ class MaglooStore1x2 $res->h3w = $odds['h3w']; $res->a3w = $odds['d3w']; $res->d3w = $odds['a3w']; + $res->flags = 1; if ($res->isDirty()) { $res->oddchange_at = now(); } diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreDc.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreDc.php index f78e0a61..0799ccd3 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreDc.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreDc.php @@ -14,6 +14,7 @@ class MaglooStoreDc $odds['dc12'] = number_format($value['static'][10], 2) ?? 1; $odds['dcx2'] = number_format($value['static'][11], 2) ?? 1; $odds['margin'] = (float) Margin::calculate($odds, 1); + $odds['flags'] = 1; $odds = array_merge($odds, $base); $res = OddsDc::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first(); @@ -24,6 +25,7 @@ class MaglooStoreDc $res->dc1x = $odds['dc1x']; $res->dc12 = $odds['dc12']; $res->dcx2 = $odds['dcx2']; + $res->flags = 1; if ($res->isDirty()) { $res->oddchange_at = now(); } diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreGgng.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreGgng.php index c217cb9c..6c8f1fb8 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreGgng.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreGgng.php @@ -13,6 +13,7 @@ class MaglooStoreGgng $odds['gg'] = number_format($value['static'][74], 2) ?? 1; $odds['ng'] = number_format($value['static'][76], 2) ?? 1; $odds['margin'] = (float) Margin::calculate($odds, 1); + $odds['flags'] = 1; $odds = array_merge($odds, $base); $res = OddsGgng::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first(); @@ -22,6 +23,7 @@ class MaglooStoreGgng } else { $res->gg = $odds['gg']; $res->ng = $odds['ng']; + $res->flags = 1; if ($res->isDirty()) { $res->oddchange_at = now(); } diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePoints.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePoints.php index 5e750091..6449285c 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePoints.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePoints.php @@ -17,6 +17,7 @@ class MaglooStorePoints $odds['active_spread'] = $value['active_spread']; $odds['handicap'] = $handicap; $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); + $odds['flags'] = 1; $odds = array_merge($odds, $base); @@ -28,6 +29,7 @@ class MaglooStorePoints if (! $res) { OddsPoint::create($odds); } else { + $res->flags = 1; $res->home = number_format($odds['home'], 2); $res->away = number_format($odds['away'], 2); $res->handicap = number_format($odds['handicap'], 2); diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePointsQ1.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePointsQ1.php index d98fca30..f834f56d 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePointsQ1.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStorePointsQ1.php @@ -17,6 +17,7 @@ class MaglooStorePointsQ1 $odds['active_spread'] = $value['active_spread']; $odds['handicap'] = $handicap; $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); + $odds['flags'] = 1; $odds = array_merge($odds, $base); @@ -28,6 +29,7 @@ class MaglooStorePointsQ1 if (! $res) { OddsPointQ1::create($odds); } else { + $res->flags = 1; $res->home = number_format($odds['home'], 2); $res->away = number_format($odds['away'], 2); $res->handicap = number_format($odds['handicap'], 2); diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotals.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotals.php index c0f2576a..4b54f6c2 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotals.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotals.php @@ -17,6 +17,7 @@ class MaglooStoreTotals $odds['active_spread'] = $value['active_spread']; $odds['total'] = $total; $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); + $odds['flags'] = 1; $odds = array_merge($odds, $base); @@ -28,6 +29,7 @@ class MaglooStoreTotals if (! $res) { OddsTotal::create($odds); } else { + $res->flags = 1; $res->over = number_format($odds['over'], 2); $res->under = number_format($odds['under'], 2); $res->total = number_format($odds['total'], 2); diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotalsQ1.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotalsQ1.php index db0920bb..a8d2b02b 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotalsQ1.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTotalsQ1.php @@ -17,6 +17,7 @@ class MaglooStoreTotalsQ1 $odds['active_spread'] = $value['active_spread']; $odds['total'] = $total; $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); + $odds['flags'] = 1; $odds = array_merge($odds, $base); @@ -28,6 +29,7 @@ class MaglooStoreTotalsQ1 if (! $res) { OddsTotalQ1::create($odds); } else { + $res->flags = 1; $res->over = number_format($odds['over'], 2); $res->under = number_format($odds['under'], 2); $res->total = number_format($odds['total'], 2); diff --git a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTq.php b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTq.php index 2f0e049c..b0f439b2 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTq.php +++ b/app/Console/Commands/Grapper/Magloo/Odds/MaglooStoreTq.php @@ -14,12 +14,14 @@ class MaglooStoreTq $odds['atq'] = number_format($value['static'][5], 2) ?? 1; $odds['margin'] = (float) Margin::calculate($odds, 1); $odds = array_merge($odds, $base); + $odds['flags'] = 1; $res = OddsTq::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first(); if (! $res) { OddsTq::create($odds); } else { + $res->flags = 1; $res->htq = $odds['htq']; $res->atq = $odds['atq']; if ($res->isDirty()) { diff --git a/app/Console/Commands/Grapper/TxOdds/Odds.php b/app/Console/Commands/Grapper/TxOdds/Odds.php index 9ed3f1a6..04e6d312 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds.php @@ -319,6 +319,7 @@ class Odds case 'starting_time': EventBookmaker::updateOrInsert([ 'event_id' => $event_id, + 'sport_id' => $sport_id, 'bookmaker_id' => $bookmaker_id, ], ['starttime' => $attributeValue]); break; @@ -333,6 +334,7 @@ class Odds case 'starting_time': EventBookmaker::updateOrInsert([ 'event_id' => $event_id, + 'sport_id' => $sport_id, 'bookmaker_id' => $bookmaker_id, ], ['starttime' => $attributeValue]); break; @@ -347,6 +349,7 @@ class Odds case 'starting_time': EventBookmaker::updateOrInsert([ 'event_id' => $event_id, + 'sport_id' => $sport_id, 'bookmaker_id' => $bookmaker_id, ], ['starttime' => $attributeValue]); break; diff --git a/app/Console/Commands/Services/Services.php b/app/Console/Commands/Services/Services.php index 6691c309..d2dc76b5 100644 --- a/app/Console/Commands/Services/Services.php +++ b/app/Console/Commands/Services/Services.php @@ -3,6 +3,7 @@ namespace App\Console\Commands\Services; use App\Console\Commands\Nuh; +use App\Console\Commands\Services\Tasks\AlarmGenerator; use App\Console\Commands\Services\Tasks\CallTxoddsMarkets; use App\Console\Commands\Services\Tasks\DBMapper; use App\Console\Commands\Services\Tasks\GenerateDefaultSetting; @@ -21,6 +22,9 @@ class Services case 'Generate Default Setting': GenerateDefaultSetting::run(); break; + case 'Alarm Generator': + AlarmGenerator::run(); + break; } } diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmBookmakerFilter.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmBookmakerFilter.php new file mode 100644 index 00000000..a53b5f80 --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmBookmakerFilter.php @@ -0,0 +1,30 @@ +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; + } +} diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmFilterClient.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmFilterClient.php new file mode 100644 index 00000000..2b6dc839 --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmFilterClient.php @@ -0,0 +1,16 @@ + $value) { + + if (isset($odds[$bookmaker_id])) { + $data = $odds[$bookmaker_id]; + if ($data['margin'] <= $value['margin_threshold']) { + $data['bookmaker_id'] = $bookmaker_id; + + return $data; + } + } + } + + return []; + } +} diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmLoadOdds.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmLoadOdds.php new file mode 100644 index 00000000..df5ce009 --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmLoadOdds.php @@ -0,0 +1,29 @@ +where('flags', 1)->where('event_id', $event_id)->get(); + + $odds = explode(',', $oddnames); + + $arr = []; + foreach ($res as $value) { + 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 ($odds as $odd) { + $arr[(int) $value->bookmaker_id][$odd] = (float) $value->$odd; + } + } + + return $arr; + } +} diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmMap.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmMap.php new file mode 100644 index 00000000..a36abc8f --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmMap.php @@ -0,0 +1,28 @@ + ['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]; + } +} diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmMultilineSetting.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmMultilineSetting.php new file mode 100644 index 00000000..e7a38016 --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmMultilineSetting.php @@ -0,0 +1,24 @@ +get(); + + $arr = []; + foreach ($res as $value) { + $arr[$value->id] = [ + 'table' => $value->table, + 'oddnames' => $value->oddnames, + ]; + } + + return $arr; + } +} diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmSettings.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmSettings.php new file mode 100644 index 00000000..b4e34ab9 --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmSettings.php @@ -0,0 +1,25 @@ +where('client_bookmaker_id', $client_bookmaker_id) + ->where('disabled', 0) + ->select('multiline_setting_id', 'level_id', 'alarm_threshold') + ->get(); + + $arr = []; + foreach ($res as $value) { + $arr[$value->multiline_setting_id][$value->level_id] = $value->alarm_threshold; + } + + return $arr; + } +} diff --git a/app/Console/Commands/Services/Tasks/Alarm/AlarmStore.php b/app/Console/Commands/Services/Tasks/Alarm/AlarmStore.php new file mode 100644 index 00000000..6e0fc03e --- /dev/null +++ b/app/Console/Commands/Services/Tasks/Alarm/AlarmStore.php @@ -0,0 +1,42 @@ + $oddname) { + $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; + } else { + // Rset Alarm + $update_array[$fieldname] = 0; + } + } + + EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $client_bookmaker_id)->update($update_array); + } +} diff --git a/app/Console/Commands/Services/Tasks/AlarmGenerator.php b/app/Console/Commands/Services/Tasks/AlarmGenerator.php new file mode 100644 index 00000000..179de036 --- /dev/null +++ b/app/Console/Commands/Services/Tasks/AlarmGenerator.php @@ -0,0 +1,57 @@ +bookmaker as $client_bookmaker_id) { + + $alarm_threshold = AlarmSettings::get($client_bookmaker_id); + + $filter = AlarmBookmakerFilter::get($client_bookmaker_id); + + $res = EventBookmaker::where('bookmaker_id', $client_bookmaker_id)->where('sport_id', Nuh::$options['sport_id'])->get(); + + foreach ($res as $event) { + + foreach ($multilines as $multiline_id => $multiline) { + + $odds = AlarmLoadOdds::get($event->event_id, $multiline['table'], $multiline['oddnames']); + + $compare_odds = AlarmFilterCompare::get($odds, $filter); + + $client_odds = AlarmFilterClient::get($odds, $client_bookmaker_id); + + AlarmStore::get($event->event_id, $multiline['table'], $client_bookmaker_id, $alarm_threshold[$multiline_id], $compare_odds, $client_odds); + } + } + } + } + } +} diff --git a/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php b/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php index 2b5a0398..254947f1 100644 --- a/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php +++ b/app/Console/Commands/Services/Tasks/GenerateDefaultSetting.php @@ -3,6 +3,7 @@ namespace App\Console\Commands\Services\Tasks; use App\Console\Commands\Nuh; +use App\Models\AlarmSetting; use App\Models\BettypeUser; use App\Models\Bookmaker; use App\Models\Client; @@ -24,11 +25,45 @@ class GenerateDefaultSetting } /************************************************** - * MULTILINE SLOTS + * 1) ALARM BOOKMAKER **************************************************/ if ($debug) { - Notice::note('1) MULTILINE SLOTS', 'p'); + Notice::note('1) ALARM BOOKMAKER', 'p'); + } + + $alarm_thresholds = [1 => 0.01, 2 => 0.2, 3 => 0.3]; + + $clients = Client::get(); + + foreach ($clients as $client) { + + foreach ($client->sport as $sport_id) { + + foreach ($client->bookmaker as $client_bookmaker_id) { + + $multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id'); + + foreach ($multilines as $multiline_id) { + + foreach ($alarm_thresholds as $level_id => $alarm_threshold) { + + AlarmSetting::firstOrCreate( + ['client_bookmaker_id' => $client_bookmaker_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'level_id' => $level_id], + ['name' => "LEVEL $level_id", 'alarm_threshold' => $alarm_threshold] + ); + } + } + } + } + } + + /************************************************** + * 2) MULTILINE SLOTS + **************************************************/ + + if ($debug) { + Notice::note('2) MULTILINE SLOTS', 'p'); } $bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126]; @@ -58,11 +93,11 @@ class GenerateDefaultSetting } /************************************************** - * BETTYPES for USER in MONITOR + * 3) BETTYPES for USER in MONITOR **************************************************/ if ($debug) { - Notice::note('2) GENERATOR BETTYPES IM COMPARATORE FOR USERS', 'p'); + Notice::note('3) GENERATOR BETTYPES IM COMPARATORE FOR USERS', 'p'); } $users = User::get(); @@ -83,11 +118,11 @@ class GenerateDefaultSetting } /************************************************** - * COMPARING BOOKMAKER + * 4) COMPARING BOOKMAKER **************************************************/ if ($debug) { - Notice::note('3) COMPARING BOOKMAKER', 'p'); + Notice::note('4) COMPARING BOOKMAKER', 'p'); } $res = Client::get(); @@ -104,13 +139,12 @@ class GenerateDefaultSetting $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' => 110, 'sorting' => $i] + ['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => $margin_threshold, 'sorting' => $i] ); $i++; - } } } diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 78d8a2b7..caa00496 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -184,6 +184,11 @@ class EventsTable User::where('id', self::$user->id)->update(['sport_id' => (int) $state]); $livewire->dispatch('refreshBettypeMenu'); + $livewire->dispatch('reload_bookmaker_multiline'); + $livewire->dispatch('reload_alarm_bookmaker'); + $livewire->dispatch('refresh_comparing_bookmaker'); + $livewire->dispatch('reload_data_left'); + $livewire->dispatch('reload_data_right'); $set('country_id', null); $set('competition_group_id', null); diff --git a/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php b/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php index 039b752c..780578c9 100644 --- a/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php +++ b/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php @@ -76,6 +76,7 @@ class SupervisorsTable 'Txodds Markets' => 'Txodds Markets', 'DB Mapper' => 'DB Mapper', 'Generate Default Setting' => 'Generate Default Setting', + 'Alarm Generator' => 'Alarm Generator', ]; case 9: case 10: diff --git a/app/Filament/Tables/Columns/ColumnOdds.php b/app/Filament/Tables/Columns/ColumnOdds.php index ddb9c931..7220755b 100644 --- a/app/Filament/Tables/Columns/ColumnOdds.php +++ b/app/Filament/Tables/Columns/ColumnOdds.php @@ -316,6 +316,7 @@ class ColumnOdds extends Column public function setCompare($record) { $this->compare = null; + $this->data->filter(function ($model) { if ($model->bookmaker_id != auth()->user()->bookmaker_id) { diff --git a/app/Livewire/AlarmBookmaker.php b/app/Livewire/AlarmBookmaker.php new file mode 100644 index 00000000..07984949 --- /dev/null +++ b/app/Livewire/AlarmBookmaker.php @@ -0,0 +1,111 @@ + '$refresh', + ]; + + public static $default_filter; + + public static function load_filter($sport_id) + { + self::$default_filter = MultilineSetting::where('sport_id', $sport_id) + ->orderBy('id')->pluck('id')->first(); + } + + public function table(Table $table): Table + { + self::load_filter(auth()->user()->sport_id); + + return $table + ->query(AlarmSetting::query() + ->where('client_bookmaker_id', auth()->user()->bookmaker_id) + ->where('sport_id', auth()->user()->sport_id)) + ->paginated(false) + ->columns([ + IconColumn::make('sport.icon') + ->label('') + ->width('1rem') + ->icon(function ($record): string { + return $record->sport->icon; + }) + ->color(fn ($record): string => match ($record->level_id) { + 1 => 'success', + 2 => 'warning', + 3 => 'danger', + }), + TextColumn::make('sport.name'), + TextColumn::make('multiline_setting.name')->label('Bettype'), + TextColumn::make('name') + ->color(fn ($record): string => match ($record->level_id) { + 1 => 'success', + 2 => 'warning', + 3 => 'danger', + }), + TextInputColumn::make('alarm_threshold') + ->tooltip('Between 0.01 - 2.00') + ->width('2rem') + ->prefix('Threshold:') + ->rules(['required', 'decimal:2', 'between:0,2']), + ToggleColumn::make('disabled') + ->label('Status') + ->offColor('success') + ->onColor('danger'), + ]) + ->defaultSort('level_id') + ->deferFilters(false) + ->filters([ + Filter::make('multiline_setting_id') + ->schema([ + Radio::make('multiline_setting_id') + ->inline() + ->columnSpan(6) + ->default(self::$default_filter) + ->columnSpanFull() + ->hiddenLabel() + ->options(fn () => MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('name')->pluck('name', 'id')), + ]) + ->query(function (Builder $query, array $data): Builder { + return $query + ->when( + $data['multiline_setting_id'], + fn (Builder $query, $multiline_setting_id): Builder => $query->where('multiline_setting_id', $multiline_setting_id), + ); + }) + ->columns(6)->columnSpan(6), + ], layout: FiltersLayout::AboveContent) + ->hiddenFilterIndicators(); + } + + public function render(): View + { + return view('livewire.alarm-bookmaker'); + } +} diff --git a/app/Livewire/ComparingBookmakerMenu.php b/app/Livewire/ComparingBookmakerMenu.php index 555c6736..38c22913 100644 --- a/app/Livewire/ComparingBookmakerMenu.php +++ b/app/Livewire/ComparingBookmakerMenu.php @@ -34,7 +34,7 @@ class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas public $user; protected $listeners = [ - 'refresh' => '$refresh', + 'refresh_comparing_bookmaker' => '$refresh', ]; public function table(Table $table): Table diff --git a/app/Livewire/Mapper/StoreMapped.php b/app/Livewire/Mapper/StoreMapped.php index 8de9ab8c..44255c0c 100644 --- a/app/Livewire/Mapper/StoreMapped.php +++ b/app/Livewire/Mapper/StoreMapped.php @@ -83,6 +83,7 @@ class StoreMapped // MAGLOO KENIA EventBookmaker::updateOrCreate([ 'event_id' => $arguments['id'], + 'sport_id' => $event->sport_id, 'bookmaker_id' => 16, ], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]); break; @@ -90,6 +91,7 @@ class StoreMapped // MAGLOO NIGERIA EventBookmaker::updateOrCreate([ 'event_id' => $arguments['id'], + 'sport_id' => $event->sport_id, 'bookmaker_id' => 10, ], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]); break; @@ -97,6 +99,7 @@ class StoreMapped // LOGIFUTUR NIGERA EventBookmaker::updateOrCreate([ 'event_id' => $arguments['id'], + 'sport_id' => $event->sport_id, 'bookmaker_id' => 35, ], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]); break; @@ -104,6 +107,7 @@ class StoreMapped // LOGIFUTUR COLOMBIA EventBookmaker::updateOrCreate([ 'event_id' => $arguments['id'], + 'sport_id' => $event->sport_id, 'bookmaker_id' => 36, ], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]); break; diff --git a/app/Livewire/MultilineBookmaker.php b/app/Livewire/MultilineBookmaker.php index 3e012ca6..d70cf583 100644 --- a/app/Livewire/MultilineBookmaker.php +++ b/app/Livewire/MultilineBookmaker.php @@ -31,25 +31,19 @@ class MultilineBookmaker extends Component implements HasActions, HasSchemas, Ha use InteractsWithSchemas; use InteractsWithTable; - public static $default_filter; + protected $listeners = [ + 'reload_bookmaker_multiline' => '$refresh', + ]; public $user; - public static function load_filter($sport_id) - { - self::$default_filter = MultilineSetting::where('sport_id', $sport_id) - ->orderBy('id')->pluck('id')->first(); - } - public function table(Table $table): Table { $this->user = User::getUser(); - self::load_filter($this->user->sport_id); - return $table - ->query(MultilineClient::query()->where('client_bookmaker_id', auth()->user()->bookmaker_id)->where('sport_id', $this->user->sport_id)) + ->query(MultilineClient::query()->where('client_bookmaker_id', $this->user->bookmaker_id)->where('sport_id', $this->user->sport_id)) ->paginated(false) ->columns([ IconColumn::make('sport.icon') @@ -88,7 +82,7 @@ class MultilineBookmaker extends Component implements HasActions, HasSchemas, Ha ->schema([ Radio::make('multiline_setting_id') ->inline() - ->default(self::$default_filter) + ->default(1) ->columnSpan(6) ->columnSpanFull() ->hiddenLabel() diff --git a/app/Models/AlarmSetting.php b/app/Models/AlarmSetting.php index aefde3b2..8389a79e 100644 --- a/app/Models/AlarmSetting.php +++ b/app/Models/AlarmSetting.php @@ -6,5 +6,23 @@ use Illuminate\Database\Eloquent\Model; class AlarmSetting extends Model { - // + protected $fillable = [ + 'client_bookmaker_id', + 'sport_id', + 'disabled', + 'multiline_setting_id', + 'name', + 'level_id', + 'alarm_threshold', + ]; + + public function multiline_setting() + { + return $this->belongsTo(MultilineSetting::class); + } + + public function sport() + { + return $this->belongsTo(Sport::class); + } } diff --git a/app/Models/EventBookmaker.php b/app/Models/EventBookmaker.php index 0e11ed28..725af6e6 100644 --- a/app/Models/EventBookmaker.php +++ b/app/Models/EventBookmaker.php @@ -8,6 +8,7 @@ class EventBookmaker extends Model { protected $fillable = [ 'event_id', + 'sport_id', 'bookmaker_id', 'starttime', 'bmoid', @@ -15,20 +16,51 @@ class EventBookmaker extends Model 'is_swopped', 'send_status', 'has_to_qualify', - 'alarm_2w', - 'alarm_2ws1', - 'alarm_3w', - 'alarm_3wht', - 'alarm_dc', - 'alarm_dbn', - 'alarm_ggng', - 'alarm_po', - 'alarm_poht', - 'alarm_poq1', - 'alarm_to', - 'alarm_toht', - 'alarm_toq1', - 'alarm_tq', + + 'alarm_2w_h2w', + 'alarm_2w_a2w', + + 'alarm_2ws1_h2w', + 'alarm_2ws1_a2w', + + 'alarm_3w_h3w', + 'alarm_3w_d3w', + 'alarm_3w_a3w', + + 'alarm_3wht_h3w', + 'alarm_3wht_d3w', + 'alarm_3wht_a3w', + + 'alarm_dc_dc1x', + 'alarm_dc_dc12', + 'alarm_dc_dcx2', + + 'alarm_dbn_dnb1', + 'alarm_dbn_dnb2', + + 'alarm_ggng_gg', + 'alarm_ggng_ng', + + 'alarm_po_home', + 'alarm_po_away', + + 'alarm_poht_home', + 'alarm_poht_away', + + 'alarm_poq1_home', + 'alarm_poq1_away', + + 'alarm_to_over', + 'alarm_to_under', + + 'alarm_toht_over', + 'alarm_toht_under', + + 'alarm_toq1_over', + 'alarm_toq1_under', + + 'alarm_tq_htq', + 'alarm_tq_atq', ]; public function event() diff --git a/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php b/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php index 69b5b478..decc0ff6 100644 --- a/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php +++ b/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php @@ -15,32 +15,58 @@ return new class extends Migration $table->id(); $table->foreignId('event_id')->index()->constrained()->cascadeOnDelete()->references('id')->on('events'); $table->integer('bookmaker_id')->index()->references('id')->on('bookmakers'); + $table->integer('sport_id')->index()->references('id')->on('sports'); $table->timestamp('starttime')->nullable(); $table->string('bmoid')->nullable(); $table->boolean('is_swopped')->default(0); $table->boolean('in_feed')->default(0); $table->boolean('send_status')->default(0); $table->boolean('has_to_qualify')->index()->default(0); - /** - * favorit client is lower then favorit from method - * 0.01 - * 0.3 - * 0.5 - */ - $table->integer('alarm_2w')->nullable()->default(0); - $table->integer('alarm_2ws1')->nullable()->default(0); - $table->integer('alarm_3w')->nullable()->default(0); - $table->integer('alarm_3wht')->nullable()->default(0); - $table->integer('alarm_dc')->nullable()->default(0); - $table->integer('alarm_dbn')->nullable()->default(0); - $table->integer('alarm_ggng')->nullable()->default(0); - $table->integer('alarm_po')->nullable()->default(0); - $table->integer('alarm_poht')->nullable()->default(0); - $table->integer('alarm_poq1')->nullable()->default(0); - $table->integer('alarm_to')->nullable()->default(0); - $table->integer('alarm_toht')->nullable()->default(0); - $table->integer('alarm_toq1')->nullable()->default(0); - $table->integer('alarm_tq')->nullable()->default(0); + + $table->integer('alarm_2w_h2w')->nullable()->default(0); + $table->integer('alarm_2w_a2w')->nullable()->default(0); + + $table->integer('alarm_2ws1_h2w')->nullable()->default(0); + $table->integer('alarm_2ws1_a2w')->nullable()->default(0); + + $table->integer('alarm_3w_h3w')->nullable()->default(0); + $table->integer('alarm_3w_d3w')->nullable()->default(0); + $table->integer('alarm_3w_a3w')->nullable()->default(0); + + $table->integer('alarm_3wht_h3w')->nullable()->default(0); + $table->integer('alarm_3wht_d3w')->nullable()->default(0); + $table->integer('alarm_3wht_a3w')->nullable()->default(0); + + $table->integer('alarm_dc_dc1x')->nullable()->default(0); + $table->integer('alarm_dc_dc12')->nullable()->default(0); + $table->integer('alarm_dc_dcx2')->nullable()->default(0); + + $table->integer('alarm_dbn_dnb1')->nullable()->default(0); + $table->integer('alarm_dbn_dnb2')->nullable()->default(0); + + $table->integer('alarm_ggng_gg')->nullable()->default(0); + $table->integer('alarm_ggng_ng')->nullable()->default(0); + + $table->integer('alarm_po_home')->nullable()->default(0); + $table->integer('alarm_po_away')->nullable()->default(0); + + $table->integer('alarm_poht_home')->nullable()->default(0); + $table->integer('alarm_poht_away')->nullable()->default(0); + + $table->integer('alarm_poq1_home')->nullable()->default(0); + $table->integer('alarm_poq1_away')->nullable()->default(0); + + $table->integer('alarm_to_over')->nullable()->default(0); + $table->integer('alarm_to_under')->nullable()->default(0); + + $table->integer('alarm_toht_over')->nullable()->default(0); + $table->integer('alarm_toht_under')->nullable()->default(0); + + $table->integer('alarm_toq1_over')->nullable()->default(0); + $table->integer('alarm_toq1_under')->nullable()->default(0); + + $table->integer('alarm_tq_htq')->nullable()->default(0); + $table->integer('alarm_tq_atq')->nullable()->default(0); $table->timestamps(); }); diff --git a/database/migrations/2025_12_14_090814_create_multiline_clients_table.php b/database/migrations/2025_12_14_090814_create_multiline_clients_table.php index 5cd78783..d6002474 100644 --- a/database/migrations/2025_12_14_090814_create_multiline_clients_table.php +++ b/database/migrations/2025_12_14_090814_create_multiline_clients_table.php @@ -17,8 +17,9 @@ return new class extends Migration $table->integer('sport_id')->index()->references('id')->on('sports'); $table->boolean('disabled')->default(0); $table->integer('multiline_setting_id')->default(1)->references('id')->on('multiline_settings'); - $table->integer('level_id')->default(0); - $table->decimal('alarm_threshold', 3, 2)->default(0); + $table->integer('bookmaker_id')->index()->references('id')->on('bookmakers'); + $table->integer('position')->default(0); + $table->integer('sort')->default(0); $table->timestamps(); }); } diff --git a/database/migrations/2025_12_14_090816_create_multiline_settings_table.php b/database/migrations/2025_12_14_090816_create_multiline_settings_table.php index e3d929f8..22fbd3c0 100644 --- a/database/migrations/2025_12_14_090816_create_multiline_settings_table.php +++ b/database/migrations/2025_12_14_090816_create_multiline_settings_table.php @@ -17,6 +17,7 @@ return new class extends Migration $table->string('name'); $table->string('short'); $table->string('table'); + $table->string('oddnames'); $table->string('matchpart'); $table->integer('rows')->default(4); $table->integer('has_3_columns')->default(0); diff --git a/database/migrations/2026_01_26_121301_create_alarm_settings_table.php b/database/migrations/2026_01_26_121301_create_alarm_settings_table.php index 1101b4c5..b4b3b4f2 100644 --- a/database/migrations/2026_01_26_121301_create_alarm_settings_table.php +++ b/database/migrations/2026_01_26_121301_create_alarm_settings_table.php @@ -17,9 +17,9 @@ return new class extends Migration $table->integer('sport_id')->index()->references('id')->on('sports'); $table->boolean('disabled')->default(0); $table->integer('multiline_setting_id')->default(1)->references('id')->on('multiline_settings'); - $table->integer('bookmaker_id')->index()->references('id')->on('bookmakers'); - $table->integer('position')->default(0); - $table->integer('sort')->default(0); + $table->string('name')->nullable(); + $table->integer('level_id')->default(0); + $table->decimal('alarm_threshold', 3, 2)->default(0); $table->timestamps(); }); } diff --git a/database/seeders/MultilineSettingSeeder.php b/database/seeders/MultilineSettingSeeder.php index 89b95173..de1de224 100644 --- a/database/seeders/MultilineSettingSeeder.php +++ b/database/seeders/MultilineSettingSeeder.php @@ -12,36 +12,33 @@ class MultilineSettingSeeder extends Seeder /** * Clients */ - $sql = "INSERT INTO `multiline_settings` (`sport_id`, `name`, `short`, `table`, `rows`, `has_3_columns`, `created_at`, `updated_at`) + $sql = "INSERT INTO `multiline_settings` (`id`, `sport_id`, `name`, `short`, `table`, `oddnames`, `matchpart`, `rows`, `has_3_columns`, `created_at`, `updated_at`) VALUES - (1, '1X2', '1X2', 'odds_3ways', 4, 1, '2025-12-14 09:25:48', '2025-12-14 09:25:48'), - (1, 'TOTALS', 'OU', 'odds_totals', 4, 1, '2025-12-14 09:32:38', '2025-12-14 09:32:38'), - (1, '1X2 HALF TIME', '1X2 HT', 'odds_3ways_ht', 4, 1, '2025-12-14 09:25:48', '2025-12-14 09:25:48'), - (1, 'TOTALS HALF TIME', 'OU HT', 'odds_totals_ht', 4, 1, '2025-12-14 09:32:38', '2025-12-14 09:32:38'), - (1, 'GOAL NO GOAL', 'GGNG', 'odds_ggng', 4, 0, '2025-12-14 09:31:56', '2025-12-14 09:31:56'), - (1, 'DOUBLE CHANCE', 'DC', 'odds_dc', 4, 1, '2025-12-14 09:31:22', '2025-12-14 09:32:55'), - (1, 'TO QUALIFY', 'TQ', 'odds_tq', 4, 0, '2025-12-14 09:32:19', '2025-12-14 09:32:19'), - (1, 'DRAW NO BET', 'DNB', 'odds_dnb', 4, 0, '2025-12-14 09:31:42', '2025-12-14 09:31:42'), - - (2, '1X2', '1X2', 'odds_3ways', 4, 1, '2025-12-14 09:41:34', '2025-12-14 09:41:34'), - (2, 'MONEY LINE', 'ML', 'odds_2ways', 4, 0, '2025-12-14 09:41:21', '2025-12-14 09:41:21'), - (2, 'POINTS', 'HC', 'odds_points', 4, 1, '2025-12-14 09:41:56', '2025-12-14 09:41:56'), - (2, 'TOTALS', 'OU', 'odds_totals', 4, 1, '2025-12-14 09:42:13', '2025-12-14 09:42:13'), - (2, 'POINTS FIRST QUARTER', 'HC Q1', 'odds_points_q1', 4, 1, '2025-12-14 09:41:56', '2025-12-14 09:41:56'), - (2, 'TOTALS FIRST QUARTER', 'OU Q1', 'odds_totals_q1', 4, 1, '2025-12-14 09:42:13', '2025-12-14 09:42:13'), - - (3, 'MONEY LINE', 'ML', 'odds_2ways', 4, 0, '2025-12-14 09:37:32', '2025-12-14 09:37:32'), - (3, 'POINTS', 'HC', 'odds_points', 4, 1, '2025-12-14 09:38:05', '2025-12-14 09:38:05'), - (3, 'TOTALS', 'OU', 'odds_totals', 4, 1, '2025-12-14 09:38:44', '2025-12-14 09:38:44'), - (3, 'POINTS FIRST QUARTER', 'HC Q1', 'odds_points_q1', 4, 1, '2025-12-14 09:38:26', '2025-12-14 09:39:54'), - (3, 'TOTALS FIRST QUARTER', 'OU Q1', 'odds_totals_q1', 4, 1, '2025-12-14 09:39:12', '2025-12-14 09:39:59'), - (3, 'POINTS HALF TIME', 'HC HT', 'odds_points_ht', 4, 1, '2025-12-14 09:38:26', '2025-12-14 09:39:54'), - (3, 'TOTALS HALF TIME', 'OU HT', 'odds_totals_ht', 4, 1, '2025-12-14 09:39:12', '2025-12-14 09:39:59'), - - (5, 'MONEY LINE', 'ML', 'odds_2ways', 4, 0, '2025-12-14 09:43:52', '2025-12-14 09:43:52'), - (5, 'MONEY LINE SET 1', 'ML S1', 'odds_2ways_s1', 4, 0, '2025-12-14 09:44:13', '2025-12-14 09:44:13'), - (5, 'TOTALS', 'OU', 'odds_totals', 4, 1, '2025-12-14 09:44:26', '2025-12-14 09:44:26'), - (5, 'POINTS', 'HC', 'odds_points', 4, 1, '2025-12-14 09:44:26', '2025-12-14 09:44:26'); + (1, 1, '1X2', '1X2', 'odds_3ways', 'h3w,d3w,a3w', '', 4, 1, '2025-12-14 09:25:48', '2025-12-14 09:25:48'), + (2, 1, 'TOTALS', 'OU', 'odds_totals', 'over,under', '', 4, 1, '2025-12-14 09:32:38', '2025-12-14 09:32:38'), + (3, 1, '1X2 HALF TIME', '1X2 HT', 'odds_3ways_ht', 'h3w,d3w,a3w', '', 4, 1, '2025-12-14 09:25:48', '2025-12-14 09:25:48'), + (4, 1, 'TOTALS HALF TIME', 'OU HT', 'odds_totals_ht', 'over,under', '', 4, 1, '2025-12-14 09:32:38', '2025-12-14 09:32:38'), + (5, 1, 'GOAL NO GOAL', 'GGNG', 'odds_ggng', 'gg,ng', '', 4, 0, '2025-12-14 09:31:56', '2025-12-14 09:31:56'), + (6, 1, 'DOUBLE CHANCE', 'DC', 'odds_dc', 'dc1x,dc12,dcx2', '', 4, 1, '2025-12-14 09:31:22', '2025-12-14 09:32:55'), + (7, 1, 'TO QUALIFY', 'TQ', 'odds_tq', 'htq,atq', '', 4, 0, '2025-12-14 09:32:19', '2025-12-14 09:32:19'), + (8, 1, 'DRAW NO BET', 'DNB', 'odds_dnb', 'dnb1,dnb2', '', 4, 0, '2025-12-14 09:31:42', '2025-12-14 09:31:42'), + (9, 2, '1X2', '1X2', 'odds_3ways', 'h3w,d3w,a3w', '', 4, 1, '2025-12-14 09:41:34', '2025-12-14 09:41:34'), + (10, 2, 'MONEY LINE', 'ML', 'odds_2ways', 'h2w,a2w', '', 4, 0, '2025-12-14 09:41:21', '2025-12-14 09:41:21'), + (11, 2, 'POINTS', 'HC', 'odds_points', 'home,away', '', 4, 1, '2025-12-14 09:41:56', '2025-12-14 09:41:56'), + (12, 2, 'TOTALS', 'OU', 'odds_totals', 'over,under', '', 4, 1, '2025-12-14 09:42:13', '2025-12-14 09:42:13'), + (13, 2, 'POINTS FIRST QUARTER', 'HC Q1', 'odds_points_q1', 'home,away', '', 4, 1, '2025-12-14 09:41:56', '2025-12-14 09:41:56'), + (14, 2, 'TOTALS FIRST QUARTER', 'OU Q1', 'odds_totals_q1', 'over,under', '', 4, 1, '2025-12-14 09:42:13', '2025-12-14 09:42:13'), + (15, 3, 'MONEY LINE', 'ML', 'odds_2ways', 'h2w,a2w', '', 4, 0, '2025-12-14 09:37:32', '2025-12-14 09:37:32'), + (16, 3, 'POINTS', 'HC', 'odds_points', 'home,away', '', 4, 1, '2025-12-14 09:38:05', '2025-12-14 09:38:05'), + (17, 3, 'TOTALS', 'OU', 'odds_totals', 'over,under', '', 4, 1, '2025-12-14 09:38:44', '2025-12-14 09:38:44'), + (18, 3, 'POINTS FIRST QUARTER', 'HC Q1', 'odds_points_q1', 'home,away', '', 4, 1, '2025-12-14 09:38:26', '2025-12-14 09:39:54'), + (19, 3, 'TOTALS FIRST QUARTER', 'OU Q1', 'odds_totals_q1', 'over,under', '', 4, 1, '2025-12-14 09:39:12', '2025-12-14 09:39:59'), + (20, 3, 'POINTS HALF TIME', 'HC HT', 'odds_points_ht', 'home,away', '', 4, 1, '2025-12-14 09:38:26', '2025-12-14 09:39:54'), + (21, 3, 'TOTALS HALF TIME', 'OU HT', 'odds_totals_ht', 'over,under', '', 4, 1, '2025-12-14 09:39:12', '2025-12-14 09:39:59'), + (22, 5, 'MONEY LINE', 'ML', 'odds_2ways', 'h2w,a2w', '', 4, 0, '2025-12-14 09:43:52', '2025-12-14 09:43:52'), + (23, 5, 'MONEY LINE SET 1', 'ML S1', 'odds_2ways_s1', 'h2w,a2w', '', 4, 0, '2025-12-14 09:44:13', '2025-12-14 09:44:13'), + (24, 5, 'TOTALS', 'OU', 'odds_totals', 'over,under', '', 4, 1, '2025-12-14 09:44:26', '2025-12-14 09:44:26'), + (25, 5, 'POINTS', 'HC', 'odds_points', 'home,away', '', 4, 1, '2025-12-14 09:44:26', '2025-12-14 09:44:26'); "; DB::unprepared($sql); diff --git a/database/seeders/SupervisorSeeder.php b/database/seeders/SupervisorSeeder.php index df18a622..44fecd5f 100644 --- a/database/seeders/SupervisorSeeder.php +++ b/database/seeders/SupervisorSeeder.php @@ -66,8 +66,9 @@ class SupervisorSeeder extends Seeder (50, '', 8, 5, 131073, 30, 0, NULL, NULL, 30, 0, 0, 0, 0, 10, 10, '2026-01-14 17:41:16', '2026-01-14 17:41:25'), (51, '', 9, 1, NULL, 30, 0, NULL, NULL, 30, 0, 0, 0, 0, 10, 10, '2026-01-16 12:05:14', '2026-01-16 12:05:14'), (52, '', 10, 0, NULL, 30, 0, NULL, NULL, 30, 0, 0, 0, 0, 10, 10, '2026-01-16 12:05:14', '2026-01-16 12:05:14'), - (53, 'Generate Default Setting', 7, 0, NULL, 30, 0, NULL, NULL, 30, 0, 0, 0, 0, 10, 10, '2026-01-16 12:05:14', '2026-01-16 12:05:14'); -"; + (53, 'Generate Default Setting', 7, 0, NULL, 30, 0, NULL, NULL, 30, 0, 0, 0, 0, 10, 10, '2026-01-16 12:05:14', '2026-01-16 12:05:14'), + (54, 'Alarm Generator', 7, 1, NULL, 30, 0, NULL, NULL, 30, 0, 0, 0, 0, 10, 10, '2026-01-16 12:05:14', '2026-01-16 12:05:14');"; + DB::unprepared($sql); } } diff --git a/resources/views/filament/tables/columns/multiline/multiline-client.blade.php b/resources/views/filament/tables/columns/multiline/multiline-client.blade.php index b35eedd3..8b0e20d5 100644 --- a/resources/views/filament/tables/columns/multiline/multiline-client.blade.php +++ b/resources/views/filament/tables/columns/multiline/multiline-client.blade.php @@ -9,95 +9,135 @@ ]) @switch ($getBettype()) + @case ('odds_tq') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->htq, + 'alarm' => $record->event_bookmaker->alarm_tq_htq, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->atq, + 'alarm' => $record->event_bookmaker->alarm_tq_htq, + 'd' => 2, + ]) + @break; @case ('odds_2ways') - - @case ('odds_2ways_s1') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->h2w, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_2w_h2w, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->a2w, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_2w_a2w, 'd' => 2, ]) @break; - @case ('odds_3ways') - @case ('odds_3ways_ht') + @case ('odds_2ways_s1') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->h2w, + 'alarm' => $record->event_bookmaker->alarm_2ws1_h2w, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->a2w, + 'alarm' => $record->event_bookmaker->alarm_2ws1_h2w, + 'd' => 2, + ]) + @break; + + @case ('odds_3ways') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->h3w, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_3w_h3w, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->d3w, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_3w_d3w, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->a3w, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_3w_a3w, 'd' => 2, ]) @break; + + @case ('odds_3ways_ht') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->h3w, + 'alarm' => $record->event_bookmaker->alarm_3wht_h3w, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->d3w, + 'alarm' => $record->event_bookmaker->alarm_3wht_d3w, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->a3w, + 'alarm' => $record->event_bookmaker->alarm_3wht_a3w, + 'd' => 2, + ]) + @break; + @case ('odds_dc') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->dc1x, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_dc_dc1x, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->dc12, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_dc_dc12, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->dcx2, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_dc_dcx2, 'd' => 2, ]) @break; + @case ('odds_dnb') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->dnb1, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_dbn_dnb1, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->dnb2, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_dbn_dnb2, 'd' => 2, ]) @break; + @case ('odds_ggng') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->gg, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_ggng_gg, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->ng, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_ggng_ng, 'd' => 2, ]) @break; + @case ('odds_points') - - @case ('odds_points_ht') - - @case ('odds_points_q1') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->home, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_po_home, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->away, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_po_away, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ @@ -106,19 +146,52 @@ 'd' => 1, ]) @break; + + @case ('odds_points_ht') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->home, + 'alarm' => $record->event_bookmaker->alarm_poht_home, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->away, + 'alarm' => $record->event_bookmaker->alarm_poht_away, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->handicap, + 'alarm' => 0, + 'd' => 1, + ]) + @break; + + @case ('odds_points_q1') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->home, + 'alarm' => $record->event_bookmaker->alarm_poq1_home, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->away, + 'alarm' => $record->event_bookmaker->alarm_poq1_away, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->handicap, + 'alarm' => 0, + 'd' => 1, + ]) + @break; + @case ('odds_totals') - - @case ('odds_totals_ht') - - @case ('odds_totals_q1') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->over, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_to_over, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $client->under, - 'alarm' => 0, + 'alarm' => $record->event_bookmaker->alarm_to_under, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ @@ -127,6 +200,43 @@ 'd' => 1, ]) @break; + + @case ('odds_totals_ht') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->over, + 'alarm' => $record->event_bookmaker->alarm_toht_over, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->under, + 'alarm' => $record->event_bookmaker->alarm_toht_under, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->total, + 'alarm' => 0, + 'd' => 1, + ]) + @break; + + @case ('odds_totals_q1') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->over, + 'alarm' => $record->event_bookmaker->alarm_toq1_over, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->under, + 'alarm' => $record->event_bookmaker->alarm_toq1_under, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $client->total, + 'alarm' => 0, + 'd' => 1, + ]) + @break; + @endswitch diff --git a/resources/views/filament/tables/columns/multiline/multiline-compare.blade.php b/resources/views/filament/tables/columns/multiline/multiline-compare.blade.php index ffbc79c0..685de503 100644 --- a/resources/views/filament/tables/columns/multiline/multiline-compare.blade.php +++ b/resources/views/filament/tables/columns/multiline/multiline-compare.blade.php @@ -9,7 +9,19 @@ ]) @switch ($getBettype()) + @case ('odds_tq') + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $compare->htq, + 'alarm' => 0, + 'd' => 2, + ]) + @include('filament.tables.columns.multiline.odd-compare', [ + 'odd' => $compare->atq, + 'alarm' => 0, + 'd' => 2, + ]) + @break; @case ('odds_2ways') @@ -64,11 +76,12 @@ @case ('odds_dnb') @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $compare->dnb1, - + 'alarm' => 0, 'd' => 2, ]) @include('filament.tables.columns.multiline.odd-compare', [ 'odd' => $compare->dnb2, + 'alarm' => 0, 'd' => 2, ]) @break; diff --git a/resources/views/livewire/alarm-bookmaker.blade.php b/resources/views/livewire/alarm-bookmaker.blade.php new file mode 100644 index 00000000..c3fedc4a --- /dev/null +++ b/resources/views/livewire/alarm-bookmaker.blade.php @@ -0,0 +1,3 @@ +
+ {{ $this->table }} +
diff --git a/resources/views/livewire/top-menu-items.blade.php b/resources/views/livewire/top-menu-items.blade.php index b6e510ac..fdb4efd6 100644 --- a/resources/views/livewire/top-menu-items.blade.php +++ b/resources/views/livewire/top-menu-items.blade.php @@ -185,7 +185,7 @@ Alarm Settings - Alarm Settings Content + @livewire('alarm-bookmaker') {{-- Calculation --}} diff --git a/textfiles/alarm_model.js b/textfiles/alarm_model.js new file mode 100644 index 00000000..b600641f --- /dev/null +++ b/textfiles/alarm_model.js @@ -0,0 +1,204 @@ +define([ + 'dojo/_base/array', + 'dojo/dom-class', + 'nuhjs/comparatore/main/columset/nuh_columnsets', + 'dojo/domReady!' +], function (arrayUtil, domClass, nuh_columnsets) { + return { + alarm_label_red: function () { + let bg = 1 == LOCALSCOPE.alarm_level_active ? ' bg-black' : '' + let label = + ' (' + + LOCALSCOPE.alarms.a + + ') Red ' + + LOCALSCOPE.alarm_a + + '' + if (dijit.byId('alarm_color_1')) + dijit.byId('alarm_color_1').set('label', label) + }, + alarm_label_orange: function () { + if (LOCALSCOPE.alarm_b < LOCALSCOPE.alarm_a) { + let bg = 2 == LOCALSCOPE.alarm_level_active ? ' bg-black' : '' + let label = + ' (' + + LOCALSCOPE.alarms.b + + ') Orange ' + + LOCALSCOPE.alarm_b + + '' + if (dijit.byId('alarm_color_2')) + dijit.byId('alarm_color_2').set('label', label) + } + }, + alarm_label_yellow: function () { + if (LOCALSCOPE.alarm_c < LOCALSCOPE.alarm_b) { + let bg = 3 == LOCALSCOPE.alarm_level_active ? ' bg-black' : '' + let label = + ' (' + + LOCALSCOPE.alarms.c + + ') Yellow ' + + LOCALSCOPE.alarm_c + + '' + if (dijit.byId('alarm_color_3')) + dijit.byId('alarm_color_3').set('label', label) + } + }, + alarm_label_green: function () { + if (LOCALSCOPE.alarm_d < LOCALSCOPE.alarm_c) { + let bg = 4 == LOCALSCOPE.alarm_level_active ? ' bg-black' : '' + let label = + ' (' + + LOCALSCOPE.alarms.d + + ') Green ' + + LOCALSCOPE.alarm_d + + '' + if (dijit.byId('alarm_color_4')) + dijit.byId('alarm_color_4').set('label', label) + } + }, + alarm_label_top: function () { + let color, num, str + switch (LOCALSCOPE.alarm_level_active) { + case 1: + str = 'Red ' + color = 'nuhrot' + num = LOCALSCOPE.alarms.a + break + case 2: + str = 'Orange ' + color = 'nuhorange' + num = LOCALSCOPE.alarms.b + break + case 3: + str = 'Yellow ' + color = 'nuhgelb' + num = LOCALSCOPE.alarms.c + break + case 4: + str = 'Green ' + color = 'nuhgreen' + num = LOCALSCOPE.alarms.d + break + } + + let label = + '' + + str + + LOCALSCOPE.alarm_market_active.toUpperCase() + + ' (' + + num + + ')' + if (LOCALSCOPE.filter_switch == 'alarm') { + domClass.add('popup_alarm', 'set-active') + } else { + domClass.remove('popup_alarm', 'set-active') + } + // topmenu + dijit.byId('popup_alarm').set('label', label) + //in Managment Menu force alarms + if (LOCALSCOPE.hasfeed == 1) { + dijit + .byId('force_alarms_menu') + .set( + 'label', + ' Force ' + label + ) + } + }, + market_label: function (item) { + if (dijit.byId('market_' + item.market) != undefined) { + let activebg = + LOCALSCOPE.alarm_market_active == item.market ? ' bg-black' : '' + let label = + 'Market' + + item.market.toUpperCase() + + '' + dijit.byId('market_' + item.market).set('label', label) + } + }, + compare_odds: function ( + id, + disabled, + smart, + market_odd, + client_odd, + market_all, + client_all + ) { + if ( + disabled || + market_odd == undefined || + market_odd == 0 || + client_odd == undefined || + client_odd == 0 + ) { + return false + } + + // if ( + // (LOCALSCOPE.alarm_proportional_or_direct == 0 || smart) && + // market_all > 0 && + // client_all > 0 + // ) { + // market_odd = (market_odd * market_all) / (client_all - 3) + // } + + // if (LOCALSCOPE.alarm_proportional_or_direct == 0) { + // // proportional + // p = 1 / market_odd - 1 / client_odd + // } else { + // // direct + // p = client_odd - market_odd + // } + + p = client_odd - market_odd + if (p >= LOCALSCOPE.alarm_a) { + LOCALSCOPE.alarms.a++ + if (LOCALSCOPE.alarm_level_active == 1) return 1 + } else if (p < LOCALSCOPE.alarm_a && p >= LOCALSCOPE.alarm_b) { + LOCALSCOPE.alarms.b++ + if (LOCALSCOPE.alarm_level_active == 2) return 1 + } else if (p < LOCALSCOPE.alarm_b && p >= LOCALSCOPE.alarm_c) { + LOCALSCOPE.alarms.c++ + if (LOCALSCOPE.alarm_level_active == 3) return 1 + } else if (p < LOCALSCOPE.alarm_c && p >= LOCALSCOPE.alarm_d) { + LOCALSCOPE.alarms.d++ + if (LOCALSCOPE.alarm_level_active == 4) return 1 + } + return 0 + }, + go_to_set: function () { + if (LOCALSCOPE.sportid >= 100) { + return + } + var set = 1 + arrayUtil.forEach(LOCALSCOPE.columnsets.data, function (item, i) { + if (item.market == LOCALSCOPE.alarm_market_active) { + if (i >= 2) { + set = 2 + } + } + }) + if (set == 1) { + dijit.byId('gridset1').set('class', 'set-active') + dijit.byId('gridset2').set('class', 'set-light') + matches_grid.set('columnSets', nuh_columnsets.init(1)) + } else { + dijit.byId('gridset1').set('class', 'set-light') + dijit.byId('gridset2').set('class', 'set-active') + matches_grid.set('columnSets', nuh_columnsets.init(2)) + } + } + } +})