Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. DB::beginTransaction();
  2.             $round = $this->lottery->getCurrentRound(Input::get('type'));
  3.             $amount_to_spend = $amount - $amount%($threshold*1e8);//переводим порог в инт
  4.             $this->currentUser->addToBalance(-$amount_to_spend);
  5.             $this->currentUser->paymentHistory()->save(new PaymentHistory(['amount_btc' => -1 * $amount_to_spend, 'order_id'=>0,'comment' => 'Лотерея #' . $round->id, 'status' => 'confirmed']));
  6.             $bet=$round->placeBet($this->currentUser->id, $amount_to_spend);
  7.             $round->calcBetData($bet);
  8.             $redis = L4Redis::connection();
  9.             $redis->publish('lottery.bet', json_encode([
  10.                 'bank' => $round->bank_int() + $bet->amount,
  11.                 'round' => [
  12.                     'id' => $round->id,
  13.                     'bets'=>$round->bets->toArray()
  14.                 ],
  15.                 'html' => View::make('lottery.bet',compact('bet'))->render(),
  16.             ]));
  17.             if($lottery_type == 'blitz' && $round->bets->count() === 9){//последняя ставка для блица
  18.                 $round = Round::findOrFail($round->id);
  19.                 $round->roundPay();//расчитываемся по прошедшему раунду
  20.                 $round->lottery->launchNewRound();//запускаем новый раунд
  21.             }
  22.             DB::commit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement