This commit is contained in:
salam committed 2026-01-27 15:08:59 +01:00
1 parent f5fc937311
commit d81af0b02b
30 files changed
+381 -267

No files matched your search

+158 -122
View File
@@ -16,6 +16,7 @@ use App\Models\Sport;
use App\Utilities\Margin;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Bet365
{
@@ -31,7 +32,7 @@ class Bet365
$sportmap = Sport::map('bapi', 1, [1, 2, 3, 5]);
$flags = [];
$events_collector = [];
/**
* Bet365
@@ -92,88 +93,29 @@ class Bet365
* 1X2
*/
if (isset($offer['full_time_result'])) {
$odds = [];
$odds['h3w'] = number_format($offer['full_time_result']['odds'][0]['odds'], 2) ?? 1;
$odds['d3w'] = number_format($offer['full_time_result']['odds'][1]['odds'], 2) ?? 1;
$odds['a3w'] = number_format($offer['full_time_result']['odds'][2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds = array_merge($odds, $base);
$data = $offer['full_time_result']['odds'] ?? [];
$flags['odds_3ways'][] = $event->id;
if ($data) {
$res = Odds3way::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
$odds = [];
$odds['h3w'] = number_format($data[0]['odds'], 2) ?? 1;
$odds['d3w'] = number_format($data[1]['odds'], 2) ?? 1;
$odds['a3w'] = number_format($data[2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if (! $res) {
Odds3way::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->a3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
$odds = array_merge($odds, $base);
/**
* DC
*/
if (isset($offer['double_chance'])) {
$odds = [];
$odds['dc1x'] = number_format($offer['double_chance']['odds'][0]['odds'], 2) ?? 1;
$odds['dc12'] = number_format($offer['double_chance']['odds'][1]['odds'], 2) ?? 1;
$odds['dcx2'] = number_format($offer['double_chance']['odds'][2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$events_collector['odds_3ways'][] = $event->id;
$odds = array_merge($odds, $base);
$flags['odds_dc'][] = $event->id;
$res = OddsDc::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
if (! $res) {
OddsDc::create($odds);
} else {
$res->dc1x = $odds['dc1x'];
$res->dc12 = $odds['dc12'];
$res->dcx2 = $odds['dcx2'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
/**
* OU
*/
if (isset($offer['goals_over_under'])) {
$odds = [];
$odds['over'] = number_format($offer['goals_over_under']['odds'][0]['odds'], 2) ?? 1;
$odds['under'] = number_format($offer['goals_over_under']['odds'][1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
$odds = array_merge($odds, $base);
$flags['odds_totals'][] = $event->id;
if ($offer['goals_over_under']['odds'][1]['name'] == '2.5') {
$odds['total'] = 2.5;
$res = OddsTotal::where('event_id', $event->id)
->where('bookmaker_id', $bookmaker_id)
->where('total', $odds['total'])
->first();
$res = Odds3way::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
if (! $res) {
OddsTotal::create($odds);
Odds3way::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
$res->difference = abs(1 / $odds['over'] - 1 / $odds['under']);
$res->h3w = $odds['h3w'];
$res->a3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
@@ -181,29 +123,111 @@ class Bet365
}
}
/**
* DC
*/
if (isset($offer['double_chance'])) {
$data = $offer['double_chance']['odds'] ?? [];
if ($data) {
$odds = [];
$odds['dc1x'] = number_format($data[0]['odds'], 2) ?? 1;
$odds['dc12'] = number_format($data[1]['odds'], 2) ?? 1;
$odds['dcx2'] = number_format($data[2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds = array_merge($odds, $base);
$events_collector['odds_dc'][] = $event->id;
$res = OddsDc::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
if (! $res) {
OddsDc::create($odds);
} else {
$res->dc1x = $odds['dc1x'];
$res->dc12 = $odds['dc12'];
$res->dcx2 = $odds['dcx2'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
}
/**
* OU
*/
if (isset($offer['goals_over_under'])) {
$data = $offer['goals_over_under']['odds'] ?? [];
if ($data) {
$odds = [];
$odds['over'] = number_format($data[0]['odds'], 2) ?? 1;
$odds['under'] = number_format($data[1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if ($base['sport_id'] == 1) {
$odds['active_spread'] = 1;
}
$odds = array_merge($odds, $base);
$events_collector['odds_totals'][] = $event->id;
if ($offer['goals_over_under']['odds'][1]['name'] == '2.5') {
$odds['total'] = 2.5;
$res = OddsTotal::where('event_id', $event->id)
->where('bookmaker_id', $bookmaker_id)
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotal::create($odds);
} else {
$res->over = $odds['over'];
$res->under = $odds['under'];
$res->difference = abs(1 / $odds['over'] - 1 / $odds['under']);
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
}
}
/**
* GG NG
*/
if (isset($offer['both_teams_to_score'])) {
$odds = [];
$odds['gg'] = number_format($offer['both_teams_to_score']['odds'][0]['odds'], 2) ?? 1;
$odds['ng'] = number_format($offer['both_teams_to_score']['odds'][1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds = array_merge($odds, $base);
$data = $offer['both_teams_to_score']['odds'] ?? [];
$flags['odds_ggng'][] = $event->id;
if ($data) {
$res = OddsGgng::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
$odds = [];
$odds['gg'] = number_format($data[0]['odds'], 2) ?? 1;
$odds['ng'] = number_format($data[1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if (! $res) {
OddsGgng::create($odds);
} else {
$res->gg = $odds['gg'];
$res->ng = $odds['ng'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
$odds = array_merge($odds, $base);
$events_collector['odds_ggng'][] = $event->id;
$res = OddsGgng::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
if (! $res) {
OddsGgng::create($odds);
} else {
$res->gg = $odds['gg'];
$res->ng = $odds['ng'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
}
@@ -211,25 +235,31 @@ class Bet365
* DNB
*/
if (isset($offer['draw_no_bet'])) {
$odds = [];
$odds['dnb1'] = number_format($offer['draw_no_bet']['odds'][0]['odds'], 2) ?? 1;
$odds['dnb2'] = number_format($offer['draw_no_bet']['odds'][1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$res = OddsDnb::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
$data = $offer['draw_no_bet']['odds'] ?? [];
$odds = array_merge($odds, $base);
if ($data) {
$flags['odds_dnb'][] = $event->id;
$odds = [];
$odds['dnb1'] = number_format($data[0]['odds'], 2) ?? 1;
$odds['dnb2'] = number_format($data[1]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if (! $res) {
OddsDnb::create($odds);
} else {
$res->dnb1 = $odds['dnb1'];
$res->dnb2 = $odds['dnb2'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
$res = OddsDnb::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
$odds = array_merge($odds, $base);
$events_collector['odds_dnb'][] = $event->id;
if (! $res) {
OddsDnb::create($odds);
} else {
$res->dnb1 = $odds['dnb1'];
$res->dnb2 = $odds['dnb2'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
}
@@ -237,34 +267,40 @@ class Bet365
* 1X2 HT
*/
if (isset($offer['half_time_result'])) {
$odds = [];
$odds['h3w'] = number_format($offer['half_time_result']['odds'][0]['odds'], 2) ?? 1;
$odds['d3w'] = number_format($offer['half_time_result']['odds'][1]['odds'], 2) ?? 1;
$odds['a3w'] = number_format($offer['half_time_result']['odds'][2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds = array_merge($odds, $base);
$data = $offer['half_time_result']['odds'] ?? [];
$flags['odds_3ways_ht'][] = $event->id;
if ($data) {
$res = Odds3wayHt::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
$odds = [];
$odds['h3w'] = number_format($data[0]['odds'], 2) ?? 1;
$odds['d3w'] = number_format($data[1]['odds'], 2) ?? 1;
$odds['a3w'] = number_format($data[2]['odds'], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
if (! $res) {
Odds3wayHt::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->d3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
$odds = array_merge($odds, $base);
$events_collector['odds_3ways_ht'][] = $event->id;
$res = Odds3wayHt::where('event_id', $event->id)->where('bookmaker_id', $bookmaker_id)->first();
if (! $res) {
Odds3wayHt::create($odds);
} else {
$res->h3w = $odds['h3w'];
$res->d3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
}
}
}
}
foreach ($flags as $table => $event_ids) {
foreach ($events_collector as $table => $event_ids) {
DB::table($table)->where('bookmaker_id', $bookmaker_id)->whereNotIn('event_id', $event_ids)->update(['flags' => 0]);
}
}
+5 -12
View File
@@ -14,6 +14,7 @@ use App\Console\Commands\Nuh;
use App\Models\EventBookmaker;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Facades\DB;
class Logifuture
{
@@ -35,8 +36,6 @@ class Logifuture
Authentication::authenticate();
$flags = [];
foreach ($sportmap as $logifuture_sport_id => $sport_id) {
$matches = LogifutureData::load($logifuture_sport_id);
@@ -65,8 +64,6 @@ class Logifuture
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'startime' => $event['starttime']]);
$flags[$sport_id][] = $event['id'];
switch ($sport_id) {
case 1:
Soccer::get($event, $match);
@@ -94,15 +91,11 @@ class Logifuture
}
if ($event_id_collector) {
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
}
$tables = [];
$tables[1] = ['odds_3ways', 'odds_totals', 'odds_ggng', 'odds_dc', 'odds_tq'];
$tables[2] = ['odds_2ways', 'odds_2ways_s1', 'odds_3ways', 'odds_totals', 'odds_points', 'odds_points_q1', 'odds_totals_q1'];
$tables[3] = ['odds_totals', 'odds_points', 'odds_points_q1', 'odds_totals_q1'];
$tables[5] = ['odds_2ways', 'odds_2ways_s1', 'odds_totals', 'odds_points'];
foreach ($tables as $sport_id => $table) {
DB::table($table)->where('bookmaker_id', $bookmaker_id)->whereNotIn('event_id', $flags[$sport_id])->update(['flags' => 0]);
$tables = ['odds_2ways', 'odds_2ways_s1', 'odds_3ways', 'odds_totals', 'odds_points', 'odds_ggng', 'odds_dc', 'odds_tq', 'odds_points_q1', 'odds_totals_q1'];
foreach ($tables as $table) {
DB::table($table)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->whereNotIn('event_id', $event_id_collector)->update(['flags' => 0]);
}
}
}
}
+2 -1
View File
@@ -21,6 +21,7 @@ use App\Models\EventBookmaker;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Odds
{
@@ -149,7 +150,7 @@ class Odds
$tables = ['odds_3ways', 'odds_dc', 'odds_ggng', 'odds_points', 'odds_points_q1', 'odds_totals', 'odds_totals_q1', 'odds_tq'];
foreach ($tables as $table) {
DB::table($table)->where('bookmaker_id', $bookmaker_id)->whereNotIn('event_id', $event_id_collector)->update(['flags' => 0]);
DB::table($table)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->whereNotIn('event_id', $event_id_collector)->update(['flags' => 0]);
}
}
}