mapper wip
This commit is contained in:
1 parent
7b2894682f
commit
93febce6fb
18 files changed
+45151
-63
No files matched your search
@@ -2,25 +2,146 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Magloo\Fixtures;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds;
|
||||
use App\Console\Commands\Grapper\Fixtures\FindFixture;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\OddsDc;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Goldbet
|
||||
{
|
||||
public static function switch()
|
||||
{
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'Fixtures':
|
||||
Fixtures::grap();
|
||||
break;
|
||||
case 'Odds':
|
||||
Odds::grap();
|
||||
break;
|
||||
default:
|
||||
Notice::note('prosses name does not exist', 'r', 1);
|
||||
break;
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$save = Nuh::$options['s'] ?? 0;
|
||||
$read = Nuh::$options['r'] ?? 0;
|
||||
|
||||
$filename = app_path().'/Console/Commands/TestFiles/goldbet.json';
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['provider'], 'g');
|
||||
}
|
||||
|
||||
if ($read) {
|
||||
if ($debug) {
|
||||
Notice::note('data read localy', 'g');
|
||||
}
|
||||
|
||||
$file = file_get_contents($filename);
|
||||
|
||||
$data = json_decode($file, true);
|
||||
} else {
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://gb.nuhodds.com');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Proxy-Auth: jjW2jVVezcMURUBuhzf6VDXXsMhN5JWKEeQ5pYusg7b29G',
|
||||
'Proxy-Target-URL: '.Nuh::$options['base_url'],
|
||||
// 'Proxy-Debug: 1'
|
||||
]);
|
||||
|
||||
$file = curl_exec($ch);
|
||||
}
|
||||
|
||||
if ($save) {
|
||||
file_put_contents($filename, $file);
|
||||
|
||||
Notice::note('file saved localy', 'g');
|
||||
}
|
||||
|
||||
$data = json_decode($file, true);
|
||||
|
||||
// https://api.b365api.com/v1/sbobet/event?token=36152-aeTRNnZxSPUwGe&event_id=10399052
|
||||
// https://api.b365api.com/v1/sbobet/inplay?sport_id=1&token=36152-aeTRNnZxSPUwGe
|
||||
|
||||
foreach ($data as $row) {
|
||||
if ($row['liga'] != 'Fantasy Matches') {
|
||||
|
||||
/**
|
||||
* sportid is same like txoods
|
||||
*/
|
||||
$event = [
|
||||
'event_id' => (int) $row['matchid'],
|
||||
'sport_id' => (int) $row['sport'],
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => (string) Carbon::createFromTimestamp((string) $row['starttime'])->toDateTimeString(),
|
||||
'country' => $row['country'] ?? 0,
|
||||
'country_id' => (int) $row['countryid'] ?? 0,
|
||||
'home' => $row['e1'] ?? '',
|
||||
'home_id' => (int) $row['e2id'],
|
||||
'away' => $row['e2'] ?? '',
|
||||
'away_id' => (int) $row['e2id'],
|
||||
'group' => $row['liga'] ?? '',
|
||||
'group_id' => (int) $row['lid'] ?? 0,
|
||||
];
|
||||
|
||||
FindFixture::find($event);
|
||||
|
||||
if (isset($event['id'])) {
|
||||
|
||||
$base = [];
|
||||
$base['sport_id'] = (int) Nuh::$options['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = (int) $row['match_id'];
|
||||
$base['flag'] = 1;
|
||||
|
||||
if (isset($row['1x2'])) {
|
||||
$odds = [];
|
||||
$odds['h3w'] = $row['1x2']['one'];
|
||||
$odds['d3w'] = $row['1x2']['x'];
|
||||
$odds['a3w'] = $row['1x2']['two'];
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['starttime'] = (string) $row['start_time'];
|
||||
|
||||
Odds3way::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}
|
||||
if (isset($row['ou'])) {
|
||||
$odds = [];
|
||||
$odds['over'] = $row['ou']['over'];
|
||||
$odds['under'] = $row['ou']['under'];
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['total'] = 2.5;
|
||||
|
||||
OddsTotal::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}
|
||||
if (isset($row['dc'])) {
|
||||
$odds = [];
|
||||
$odds['dc1x'] = $row['dc']['dc1x'];
|
||||
$odds['dc12'] = $row['dc']['dc12'];
|
||||
$odds['dcx2'] = $row['dc']['dcx2'];
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['starttime'] = (string) $row['start_time'];
|
||||
|
||||
OddsDc::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}
|
||||
if (isset($row['gg_ng'])) {
|
||||
$odds = [];
|
||||
$odds['gg'] = $row['gg_ng']['gg'];
|
||||
$odds['ng'] = $row['gg_ng']['ng'];
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['starttime'] = (string) $row['start_time'];
|
||||
|
||||
OddsGgng::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user