/** * Get data for candle chart. * * @param Request $request */ public function getChart(Request $request) { $zoom = (int) $request->input('zoom'); $interval = $request->input('pointInterval') / 1000; list($market, $base) = explode('/', $request->input('pair')); $base_wallet = Wallet::where('short', $base)->first(); $market_wallet = Wallet::where('short', $market)->first(); $data = []; $old_data = Cache::tags('charts')->remember($base . $market . $zoom . $interval, 1, function () use($base_wallet, $market_wallet, $zoom, $interval) { $old_data = []; OrdersChart::selectRaw(' date*1000 as date, volume, open, high, low, close ')->where(function (\Illuminate\Database\Eloquent\Builder $query) use($base_wallet, $market_wallet) { $query->where('wallet_id', $base_wallet->id)->where('want_wallet_id', $market_wallet->id); })->where(DB::raw('from_unixtime(date)'), '>=', DB::raw('DATE_SUB(NOW(), INTERVAL ' . $zoom . ' HOUR)'))->where('interval', $interval)->orderBy('date', 'asc')->chunk(1000, function ($orders) use(&$old_data) { foreach ($orders as $key => $order) { $old_data[] = [(int) $order->date, (double) $order->open, (double) $order->high, (double) $order->low, (double) $order->close, (int) $order->volume]; } }); return $old_data; }); $data = array_merge($data, $old_data); usort($data, function ($a, $b) { return $a[0] - $b[0]; }); return response()->json($old_data)->setCallback($request->input('callback')); }
public function index(Request $request) { //get info for this payment $payTypeInfo = Pay::find(Pay::PAY_TYPE_MOBIO); //calc promo period $promoUntilDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $payTypeInfo->pay_promo_period, date('Y'))); //get incoming params $message = isset($request->message) ? $request->message : null; $item = isset($request->item) ? $request->item : null; $fromnum = isset($request->fromnum) ? $request->fromnum : null; $extid = isset($request->extid) ? $request->extid : null; $servID = isset($request->servID) ? $request->servID : null; //check if ping is comming from allowed ips $mobio_remote_address = explode(',', $payTypeInfo->pay_allowed_ip); if (in_array($request->ip(), $mobio_remote_address)) { $sms_reply = trans('payment_mobio.There is error, please contact us.'); $item = trim($item); if (!empty($item)) { try { $pay_type = mb_strtolower(mb_substr($item, 0, 1)); //make ad vip if ($pay_type == 'a') { $ad_id = mb_substr($item, 1); $adInfo = Ad::find($ad_id); if (!empty($adInfo)) { //update ad $adInfo->ad_promo = 1; $adInfo->ad_promo_until = $promoUntilDate; $adInfo->save(); //add money to wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_mobio.Payment via Mobio SMS')]; Wallet::create($wallet_data); //subtract money from wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => -$payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate])]; Wallet::create($wallet_data); $sms_reply = trans('payment_mobio.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate]); Cache::flush(); } } //add money to wallet if ($pay_type == 'w') { $user_id = mb_substr($item, 1); $userInfo = User::find($user_id); if (!empty($userInfo)) { //save money to wallet $wallet_data = ['user_id' => $userInfo->user_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_mobio.Add Money to Wallet via Mobio SMS')]; Wallet::create($wallet_data); $sms_reply = trans('payment_mobio.You have added :money to your wallet.', ['money' => number_format($payTypeInfo->pay_sum, 2) . config('dc.site_price_sign')]); Cache::flush(); } } } catch (\Exception $e) { } } file_get_contents("http://mobio.bg/paynotify/pnsendsms.php?servID={$servID}&tonum={$fromnum}&extid={$extid}&message=" . urlencode($sms_reply)); } }
public function index(Request $request) { $sms_reply = trans('payment_fortumo.There is error, please contact us.'); //get info for this payment $payTypeInfo = Pay::find(Pay::PAY_TYPE_FORTUMO); //calc promo period $promoUntilDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $payTypeInfo->pay_promo_period, date('Y'))); //get incoming params $message = isset($request->message) ? $request->message : null; $status = isset($request->status) ? $request->status : null; $billing_type = isset($request->billing_type) ? $request->billing_type : null; //check if ping is comming from allowed ips $fortumo_remote_address = explode(',', $payTypeInfo->pay_allowed_ip); if (in_array($request->ip(), $fortumo_remote_address) && $this->check_signature($request->all(), $payTypeInfo->pay_secret)) { $message = trim($message); if (!empty($message) && (preg_match("/OK/i", $status) || preg_match("/MO/i", $billing_type) && preg_match("/pending/i", $status))) { try { $pay_type = mb_strtolower(mb_substr($message, 0, 1)); //make ad vip if ($pay_type == 'a') { $ad_id = mb_substr($message, 1); $adInfo = Ad::find($ad_id); if (!empty($adInfo)) { //update ad $adInfo->ad_promo = 1; $adInfo->ad_promo_until = $promoUntilDate; $adInfo->save(); //add money to wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Payment via Fortumo SMS')]; Wallet::create($wallet_data); //subtract money from wallet $wallet_data = ['user_id' => $adInfo->user_id, 'ad_id' => $ad_id, 'sum' => -$payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate])]; Wallet::create($wallet_data); $sms_reply = trans('payment_fortumo.Your ad #:ad_id is Promo Until :date.', ['ad_id' => $ad_id, 'date' => $promoUntilDate]); Cache::flush(); } } //add money to wallet if ($pay_type == 'w') { $user_id = mb_substr($message, 1); $userInfo = User::find($user_id); if (!empty($userInfo)) { //save money to wallet $wallet_data = ['user_id' => $userInfo->user_id, 'sum' => $payTypeInfo->pay_sum, 'wallet_date' => date('Y-m-d H:i:s'), 'wallet_description' => trans('payment_fortumo.Add Money to Wallet via Fortumo SMS')]; Wallet::create($wallet_data); $sms_reply = trans('payment_fortumo.You have added :money to your wallet.', ['money' => number_format($payTypeInfo->pay_sum, 2) . config('dc.site_price_sign')]); Cache::flush(); } } } catch (\Exception $e) { } } } echo $sms_reply; }
public function getAdmin() { $roles = Cache::remember('roles_count', Config::get('cache.ttl'), function () { return Role::count(); }); $wallets = Cache::remember('wallets_count', Config::get('cache.ttl'), function () { return Wallet::count(); }); $users = Cache::remember('users_count', Config::get('cache.ttl'), function () { return User::count(); }); $withdrawals = Cache::remember('withdrawals_count', Config::get('cache.ttl'), function () { return WalletsWithdrawal::count(); }); return view('admin.index', compact('roles', 'wallets', 'users', 'withdrawals')); }
/** * Get ticker data for pair. * * @param Request $request */ public function getIndex(Request $request) { /* "BTC_USD": { "high": 120, "low": 100, "avg": 110, "vol": 1020, "vol_curr": 1043420, "last_trade": 111, "buy_price": 110, "sell_price": 111, "updated": 1435517311 } */ $tickers = Wallet::getTickers(); return response()->json($tickers)->setCallback($request->input('callback')); }
/** * Execute the console command. * * @return mixed */ public function handle() { $intervals = [300, 900, 1800, 7200, 14400, 86400]; $base = Wallet::where('base', true)->get(); $all = Wallet::all(); foreach ($base as $base_wallet) { foreach ($all as $market_wallet) { if ($market_wallet->id == $base_wallet->id) { continue; } foreach ($intervals as $interval) { OrdersTransaction::selectRaw(' FLOOR(MIN(unix_timestamp(`created_at`))/' . $interval . ')*' . $interval . ' AS date, SUM(amount) AS volume, SUBSTRING_INDEX(MIN(CONCAT(unix_timestamp(`created_at`), \'_\', price)), \'_\', -1) AS `open`, MAX(price) AS high, MIN(price) AS low, SUBSTRING_INDEX(MAX(CONCAT(unix_timestamp(`created_at`), \'_\', price)), \'_\', -1) AS `close` ')->where(function (\Illuminate\Database\Eloquent\Builder $query) use($base_wallet, $market_wallet) { $query->where('wallet_id', $base_wallet->id)->where('want_wallet_id', $market_wallet->id); })->where('created_at', '>=', DB::raw('DATE_SUB(NOW(), INTERVAL 24 HOUR)'))->groupBy(DB::raw('FLOOR(unix_timestamp(`created_at`)/' . $interval . ')'))->orderBy('created_at', 'asc')->chunk(100000, function ($orders) use($base_wallet, $market_wallet, $interval) { foreach ($orders as $key => $order) { try { $cache = OrdersChart::firstOrNew(['wallet_id' => $base_wallet->id, 'want_wallet_id' => $market_wallet->id, 'date' => $order->date, 'interval' => $interval]); $cache->date = $order->date; $cache->open = $order->open; $cache->high = $order->high; $cache->low = $order->low; $cache->close = $order->close; $cache->volume = $order->volume; $cache->wallet_id = $base_wallet->id; $cache->want_wallet_id = $market_wallet->id; $cache->interval = $interval; $cache->save(); } catch (\Exception $e) { } } }); } } } }
public function getHistory() { $coins_list = function () { $data = ['' => 'All']; foreach (Cache::remember('coin_list', Config::get('cache.ttl'), function () { return Wallet::select('short as coin')->get(); }) as $wallet) { $data[$wallet->coin] = $wallet->coin; } return $data; }; $provider = new EloquentDataProvider(WalletsTransaction::selectRaw('wallets_transactions.id as id, wallets_transactions.amount, wallets_transactions.created_at, wallets_transactions.updated_at, wallets_transactions.txid, wallets_transactions.confirmed, wallets.short as coin')->where('user_id', Auth::user()->id)->leftJoin('wallets', 'wallets.id', '=', 'wallets_transactions.wallet_id')); Services::resourceManager()->ignoreCss(['bootstrap']); Services::resourceManager()->ignoreJs(['bootstrap']); $grid = new Grid($provider, [(new Column('wallets_transactions.id', 'ID'))->setValueFormatter(function ($value, WalletsTransaction $row = null) { if (!empty($row->id)) { return $row->id; } else { return $value; } }), new Column('txid', 'TxID'), (new Column('amount'))->setValueFormatter(function ($value, WalletsTransaction $row = null) { if (!empty($row)) { if ($value > 0) { return HTML::tag('span', '+' . $value, ['class' => 'label label-success']); } else { return HTML::tag('span', $value, ['class' => 'label label-danger']); } } else { return $value; } }), new Column('coin', 'Coin'), (new Column('confirmed'))->setValueFormatter(function ($value, WalletsTransaction $row = null) { if (!empty($row)) { if ($value) { return HTML::tag('span', 'Confirmed', ['class' => 'label label-success']); } else { return HTML::tag('span', 'Pending', ['class' => 'label label-info']); } } }), (new Column('wallets_transactions.created_at', 'Created At'))->setValueFormatter(function ($value, WalletsTransaction $row = null) { if (!empty($row->created_at)) { return $row->created_at; } else { return $value; } }), new Column('updated_at'), new AjaxDetailsRow(function (WalletsTransaction $row) { return url('/user/wallets/details', ['id' => $row->id]); }), new FilterControl('txid', FilterOperation::OPERATOR_STR_CONTAINS, new InputOption('txid', ['txid' => Input::get('txid')])), (new FilterControl('wallets.short', FilterOperation::OPERATOR_EQ, new InputOption('coin', ['coin' => Input::get('coin')])))->setView(new TemplateView('select', ['options' => $coins_list(), 'label' => 'Coin', 'inputAttributes' => ['style' => 'width: 50px;']])), (new FilterControl('confirmed', FilterOperation::OPERATOR_EQ, new InputOption('confirmed', ['confirmed' => Input::get('confirmed')])))->setView(new TemplateView('select', ['options' => ['' => 'All', 0 => 'Pending', 1 => 'Confirmed']])), new PageSizeSelectControl(new InputOption('ps', ['ps' => Input::get('ps')], 10), [10, 50, 100, 500, 1000]), new CsvExport(new InputOption('csv', ['csv' => Input::get('csv')])), new ResetButton(), new PageTotalsRow(['amount' => PageTotalsRow::OPERATION_SUM]), new PaginationControl(new InputOption('page', ['page' => Input::get('page')], 1), 10, $provider), new ColumnSortingControl('wallets_transactions.id', new InputOption('sort', ['sort' => Input::get('sort')], 'wallets_transactions.id-dir-desc')), new ColumnSortingControl('amount', new InputOption('sort', ['sort' => Input::get('sort')])), new ColumnSortingControl('wallets_transactions.created_at', new InputOption('sort', ['sort' => Input::get('sort')]))]); $customization = new BootstrapStyling(); $customization->apply($grid); $grid = $grid->render(); return view('user.wallets.history', compact('grid')); }
/** * Find orders to fullfill request. * * @param float $amount * @param float $price * @param Wallet $base_wallet * @param Wallet $want_wallet * @param WalletsAddress $user_base_wallet * @param string $request_order_type [s - sell, b - buy] */ public static function fullfillSuitable(&$amount, $price, Wallet $base_wallet, Wallet $want_wallet, WalletsAddress $user_base_wallet, $request_order_type) { $suitable_orders_found = true; if ($request_order_type == 's') { $price_finder = '>='; $type_finder = 'buy'; } else { $price_finder = '<='; $type_finder = 'sell'; } while ($suitable_orders_found) { $order = self::where('wallet_id', $base_wallet->id)->where('want_wallet_id', $want_wallet->id)->where('price', $price_finder, $price)->where('status', 'open')->where('type', $type_finder)->first(); if ($order && $amount > 0) { Log::debug('Fullfilling order #' . $order->id); if ($order->amount >= $amount) { $process_amount = $amount; } else { $process_amount = $order->amount; } $order->decrement('amount', $process_amount); Log::debug('Process amount: ' . $process_amount); $amount -= $process_amount; if ($order->amount <= 0) { $order->status = 'closed'; } $order->save(); $order_user_deposit = $order->type == 'sell' ? $process_amount * $price : $process_amount; $user_deposit = $order->type == 'sell' ? $process_amount : $process_amount * $price; if ($request_order_type == 's') { $user_wallet_id = $want_wallet->generateUserAddress($order->user()->first()); } else { $user_wallet_id = $base_wallet->generateUserAddress($order->user()->first()); } $order_user_wallet = WalletsAddress::where('id', $user_wallet_id)->first(); $transaction = new OrdersTransaction(); $transaction->user_id = $order->user_id; $transaction->order_id = $order->id; $transaction->amount = $process_amount; $transaction->price = $price; $transaction->wallet_id = $base_wallet->id; $transaction->want_wallet_id = $want_wallet->id; $transaction->fee = $user_base_wallet->user_id == $order->user_id ? 0 : config('exchange.trading.fee'); $transaction->type = $order->type; $transaction->save(); $order_user_fee = $user_base_wallet->user_id == $order->user_id ? 0 : self::calcFee($order_user_deposit); $result_deposit = sprintf('%.8f', $order_user_deposit - $order_user_fee); $order_user_wallet->deposit($result_deposit); Log::debug('[order] Deposit amount ' . $order_user_deposit . '(fee ' . $order_user_fee . ') (Result: ' . $result_deposit . '): w' . $order_user_wallet->wallet_id . 'u' . $order_user_wallet->user_id); self::depositFee($order_user_fee, $order_user_wallet->wallet_id); if ($request_order_type == 's') { $user_wallet_id = $base_wallet->generateUserAddress(Auth::user()); } else { $user_wallet_id = $want_wallet->generateUserAddress(Auth::user()); } $user_wallet = WalletsAddress::where('id', $user_wallet_id)->first(); $transaction = new OrdersTransaction(); $transaction->user_id = $user_wallet->user_id; $transaction->order_id = $order->id; $transaction->amount = $process_amount; $transaction->price = $price; $transaction->wallet_id = $base_wallet->id; $transaction->want_wallet_id = $want_wallet->id; $transaction->fee = config('exchange.trading.fee'); $transaction->type = $order->type == 'sell' ? 'buy' : 'sell'; $transaction->save(); $user_fee = self::calcFee($user_deposit); $user_wallet->deposit($user_deposit - $user_fee); Log::debug('[user] Deposit amount ' . $user_deposit . '(fee ' . $user_fee . '): w' . $user_wallet->wallet_id . 'u' . $user_wallet->user_id); self::depositFee($user_fee, $user_wallet->wallet_id); $withdrawal_amount = $order->type == 'sell' ? round($process_amount * $price, 8) : $process_amount; $user_base_wallet->withdrawal($withdrawal_amount); Log::debug('Withdrawal amount ' . $withdrawal_amount . ': w' . $user_base_wallet->wallet_id . 'u' . $user_base_wallet->user_id); Cache::tags('user' . $order->user_id)->forget('wallets'); Cache::tags('user' . $user_wallet->user_id)->forget('wallets'); } else { $suitable_orders_found = false; } } }
/** * Remove the specified resource from storage. * * @param int $id */ public function destroy($id) { Wallet::destroy($id); Session::flash('flash_message', 'Wallet deleted!'); return redirect('admin/wallets'); }
public function delete(Request $request) { //locations to be deleted $data = []; //check for single delete if (isset($request->id)) { $data[] = $request->id; } //check for mass delete if no single delete if (empty($data)) { $data = $request->input('wallet_id'); } //delete if (!empty($data)) { Wallet::destroy($data); //clear cache, set message, redirect to list Cache::flush(); session()->flash('message', trans('admin_common.Wallet Item deleted')); return redirect(url('admin/wallet')); } //nothing for deletion set message and redirect session()->flash('message', trans('admin_common.Nothing for deletion')); return redirect(url('admin/wallet')); }
public function doTask() { $txn_log = new Logger('TXN'); $txn_log->pushHandler(new StreamHandler(storage_path() . '/logs/transactions_cron.log', Logger::INFO)); $wallets = WalletModel::all(); foreach ($wallets as $wallet) { $result = $wallet->command('listtransactions', ['*', 1000]); if (empty($result->error)) { foreach ($result as $transaction) { if ($transaction->category == 'receive') { if ($transaction->account > 0) { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' start', (array) $transaction); $wallet_transaction = WalletsTransaction::where('txid', $transaction->txid)->where('wallet_id', $wallet->id)->first(); if (!$wallet_transaction) { $wallet_transaction = new WalletsTransaction(); $wallet_transaction->user_id = $transaction->account; $wallet_transaction->txid = $transaction->txid; $wallet_transaction->wallet_id = $wallet->id; $wallet_transaction->amount = $transaction->amount; $wallet_transaction->confirmed = false; $wallet_transaction->save(); Cache::tags('user' . $wallet_transaction->user_id)->forget('wallets'); } if (!empty($transaction->blockhash)) { $wallet_transaction->blockhash = $transaction->blockhash; } if ($wallet_transaction->confirmed) { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' already confirmed'); continue; } if ($transaction->confirmations >= $wallet->confirmations) { if ($transaction->amount > 0) { $address = WalletsAddress::where('wallet_id', $wallet->id)->where(function (\Illuminate\Database\Eloquent\Builder $query) use($transaction) { $query->where('address', $transaction->address)->orWhere('user_id', $transaction->account); })->first(); if ($address) { if ($address->user_id == $transaction->account) { $wallet_transaction->confirmed = true; $wallet_transaction->save(); $address->deposit($transaction->amount); $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' good', (array) $address); Cache::tags('user' . $wallet_transaction->user_id)->forget('wallets'); } else { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' users doesnt match'); } } else { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' user not found'); } } else { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' wrong amount'); } } else { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' not enough confirmations(need ' . $wallet->confirmations . ')'); } } else { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' account not defined'); } } else { $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' other category ' . $transaction->category); $wallet_transaction = WalletsTransaction::where('txid', $transaction->txid)->where('wallet_id', $wallet->id)->first(); if ($wallet_transaction) { if ($transaction->confirmations >= $wallet->confirmations) { $wallet_transaction->confirmed = true; $wallet_transaction->blockhash = $transaction->blockhash; $wallet_transaction->save(); $txn_log->info('wal#' . $wallet->id . '(' . $wallet->short . ') trans#' . $transaction->txid . ' confirmed'); } } } } } else { $txn_log->error('wal#' . $wallet->id . '(' . $wallet->short . ') error', (array) $result); } } }
public function getHistory() { $coins_list = function () { $data = ['' => 'All']; foreach (Cache::remember('coin_list', Config::get('cache.ttl'), function () { return Wallet::select('short as coin')->get(); }) as $wallet) { $data[$wallet->coin] = $wallet->coin; } return $data; }; $provider = new EloquentDataProvider(OrdersTransaction::selectRaw('0 as total, orders_transactions.fee as fee, orders_transactions.id as id, orders_transactions.order_id as order_id, orders_transactions.amount, orders_transactions.price, orders_transactions.created_at, orders_transactions.updated_at, orders_transactions.type, w1.short as coin1, w2.short as coin2')->where('user_id', Auth::user()->id)->leftJoin('wallets as w1', 'w1.id', '=', 'orders_transactions.wallet_id')->leftJoin('wallets as w2', 'w2.id', '=', 'orders_transactions.want_wallet_id')); Services::resourceManager()->ignoreCss(['bootstrap']); Services::resourceManager()->ignoreJs(['bootstrap']); $grid = new Grid($provider, [(new Column('orders_transactions.id', 'ID'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row->id)) { return $row->id; } else { return $value; } }), (new Column('orders_transactions.order_id', 'Order ID'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row->order_id)) { return $row->order_id; } else { return $value; } }), (new Column('coin1'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row)) { return $row->coin2 . '/' . $row->coin1; } else { return $value; } }), (new Column('type'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row)) { if ($value == 'buy') { return HTML::tag('span', $value, ['class' => 'label label-success']); } else { return HTML::tag('span', $value, ['class' => 'label label-danger']); } } else { return $value; } }), (new Column('amount'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row)) { return HTML::tag('span', sprintf('%.8f %s', $row->amount, $row->coin2)); } else { return $value; } }), (new Column('price'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row)) { return HTML::tag('span', sprintf('%.8f %s', $row->price, $row->coin1)); } else { return $value; } }), (new Column('fee'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row)) { if ($row->type == 'sell') { return HTML::tag('span', sprintf('%.8f %s (%.2f%%)', Order::calcFee($row->amount, $row->fee), $row->coin1, $row->fee)); } else { return HTML::tag('span', sprintf('%.8f %s (%.2f%%)', Order::calcFee($row->amount * $row->price, $row->fee), $row->coin2, $row->fee)); } } else { return $value; } }), (new Column('total'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row)) { if ($row->type == 'buy') { return HTML::tag('span', sprintf('%.8f %s', $row->amount - Order::calcFee($row->amount, $row->fee), $row->coin2)); } else { return HTML::tag('span', sprintf('%.8f %s', $row->amount * $row->price - Order::calcFee($row->amount * $row->price, $row->fee), $row->coin1)); } } else { return $value; } }), (new Column('orders_transactions.created_at', 'Created At'))->setValueFormatter(function ($value, OrdersTransaction $row = null) { if (!empty($row->created_at)) { return $row->created_at; } else { return $value; } }), new Column('updated_at'), (new FilterControl('wallets.short', FilterOperation::OPERATOR_EQ, new InputOption('coin', ['coin' => Input::get('coin')])))->setView(new TemplateView('select', ['options' => $coins_list(), 'label' => 'Coin', 'inputAttributes' => ['style' => 'width: 50px;']])), new PageSizeSelectControl(new InputOption('ps', ['ps' => Input::get('ps')], 10), [10, 50, 100, 500, 1000]), new CsvExport(new InputOption('csv', ['csv' => Input::get('csv')])), new ResetButton(), new PageTotalsRow(['amount' => PageTotalsRow::OPERATION_SUM]), new PaginationControl(new InputOption('page', ['page' => Input::get('page')], 1), 10, $provider), new ColumnSortingControl('orders_transactions.id', new InputOption('sort', ['sort' => Input::get('sort')], 'orders_transactions.id-dir-desc')), new ColumnSortingControl('amount', new InputOption('sort', ['sort' => Input::get('sort')])), new ColumnSortingControl('orders_transactions.created_at', new InputOption('sort', ['sort' => Input::get('sort')]))]); $customization = new BootstrapStyling(); $customization->apply($grid); $grid = $grid->render(); return view('user.orders.history', compact('grid')); }
<?php require 'bootstrap.php'; use App\Wallet; set_time_limit(3); $wallet = new Wallet(); if (isset($argv)) { $wallet->set_action($argv[1]); } $wallet->run();