ActiveSpread
This commit is contained in:
1 parent
2df0e142b2
commit
7c0fd2b7a0
1 file changed
+43
-10
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools;
|
namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
class ActiveSpread
|
class ActiveSpread
|
||||||
{
|
{
|
||||||
@@ -40,17 +41,49 @@ class ActiveSpread
|
|||||||
DB::table($table)->where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->update(['active_spread' => 0]);
|
DB::table($table)->where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->update(['active_spread' => 0]);
|
||||||
|
|
||||||
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
|
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
|
||||||
DB::table($table)
|
$max_tries = 5;
|
||||||
->where('event_id', $event_id)
|
$tries = 0;
|
||||||
->where('bookmaker_id', $bookmaker_id)
|
do {
|
||||||
->where('handicap', (float) $value['active_spread'])
|
$retry = false;
|
||||||
->update(['active_spread' => 1]);
|
try {
|
||||||
|
$query = DB::table($table)
|
||||||
|
->where('event_id', $event_id)
|
||||||
|
->where('bookmaker_id', $bookmaker_id)
|
||||||
|
->where('handicap', (float) $value['active_spread'])
|
||||||
|
->update(['active_spread' => 1]);
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
} catch (PDOException $exc) {
|
||||||
|
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
|
||||||
|
$retry = true;
|
||||||
|
sleep(1);
|
||||||
|
} else {
|
||||||
|
throw $exc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while ($retry);
|
||||||
} else {
|
} else {
|
||||||
DB::table($table)
|
$max_tries = 5;
|
||||||
->where('event_id', $event_id)
|
$tries = 0;
|
||||||
->where('bookmaker_id', $bookmaker_id)
|
do {
|
||||||
->where('total', (float) $value['active_spread'])
|
$retry = false;
|
||||||
->update(['active_spread' => 1]);
|
try {
|
||||||
|
$query = DB::table($table)
|
||||||
|
->where('event_id', $event_id)
|
||||||
|
->where('bookmaker_id', $bookmaker_id)
|
||||||
|
->where('total', (float) $value['active_spread'])
|
||||||
|
->update(['active_spread' => 1]);
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
} catch (PDOException $exc) {
|
||||||
|
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
|
||||||
|
$retry = true;
|
||||||
|
sleep(1);
|
||||||
|
} else {
|
||||||
|
throw $exc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while ($retry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user