tx odds grapper wip
This commit is contained in:
1 parent
687e10ca9b
commit
e93b62efdf
15 files changed
+42
-42
No files matched your search
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Odds_Points
|
||||
{
|
||||
public static function grap($odds, $offer)
|
||||
{
|
||||
$block_update = Nuh::$options['b'] ?? 0;
|
||||
|
||||
foreach ($offer as $value) {
|
||||
$odds['home'] = (float) $value->o1;
|
||||
$odds['away'] = (float) $value->o2;
|
||||
$odds['handicap'] = (float) $value->o3;
|
||||
}
|
||||
|
||||
if (fmod((float) $odds['handicap'], 1) != 0.5) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($odds['home'] >= 1 && $odds['away'] >= 1) {
|
||||
|
||||
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
|
||||
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
|
||||
|
||||
$res = OddsPoint::where('event_id', $odds['event_id'])
|
||||
->where('bookmaker_id', $odds['bookmaker_id'])
|
||||
->where('handicap', $odds['handicap'])
|
||||
->first();
|
||||
|
||||
if (! $res) {
|
||||
OddsPoint::create($odds);
|
||||
} elseif (! $block_update) {
|
||||
$res->home = $odds['home'];
|
||||
$res->away = $odds['away'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ActiveSpread::collect($odds, 'odds_points');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user