public function addressIsDesposited($address) { $deposit = Deposit::where('address', $address)->first(); if (isset($deposit->address)) { return 1; } else { return 0; } }
public function blocknotifyUpdateDeposit($wallet_type = '') { $blockhash = isset($_GET['trxhash']) ? $_GET['trxhash'] : 0; $logFile = 'laravel_' . $wallet_type . '.log'; Log::useDailyFiles(storage_path() . '/logs/callbackdeposits/' . $logFile); Log::info("*******New Blocknotify Update Deposit: " . $blockhash . " -- wallet_type: " . $wallet_type); Log::info("\n" . "-- wallet_type: " . $wallet_type); if ($wallet_type != '') { $wallet = Wallet::where('type', strtoupper($wallet_type))->first(); $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); $limit_confirmations = empty($wallet->limit_confirmations) || $wallet->limit_confirmations <= 0 ? 3 : $wallet->limit_confirmations; $listtrans = $wallet->getListTransactions(); @Log::info("\n" . 'Result listtrans: ', $listtrans); $balance = new Balance(); foreach ($listtrans as $key => $value) { try { $transaction_id = $value['txid']; $trans = $wallet->getTransaction($transaction_id); if ($trans != null) { $account = $trans["details"][0]["account"]; $category = $trans["details"][0]["category"]; $confirms = $trans["confirmations"]; //send,receive $address_ = $trans["details"][0]["address"]; $amount = $trans["amount"]; Log::info("\n" . "transaction: ", $trans); Log::info("\n" . "------Account: " . $account . " -- category:" . $category . " --address: " . $address_); //mail("*****@*****.**", 'Deposit Cron: ', var_export($trans, true)); $deposit = Deposit::where('transaction_id', $transaction_id)->first(); $user = User::where('username', $account)->first(); if (isset($deposit->transaction_id)) { if ($deposit->paid == 0) { if ($category == "receive" && $confirms >= $limit_confirmations && isset($user->id)) { Deposit::where('id', $deposit->id)->update(array('paid' => 1, 'confirmations' => $confirms)); $balance->addMoney($amount, $wallet->id, $user->id); $message .= "<br>" . $amount . " " . $wallet->type . " was credited to your account"; Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account"); } } else { Deposit::where('id', $deposit->id)->update(array('confirmations' => $confirms)); Log::info("\n" . $amount . " " . $wallet->type . " was already credited to your account. contact support if you need further assistance."); } } else { if ($category == "receive" && isset($user->id)) { if ($confirms >= $limit_confirmations) { Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 1, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'))); $balance->addMoney($amount, $wallet->id, $user->id); Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account"); } else { Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 0, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'))); Log::info("\n" . "This Deposit is unconfirmed. Current confirmations:" . $confirms . ". Required : 3."); } } else { Log::info("\n" . "transaction is not a deposit or account is invalid."); } } } else { Log::info("\n" . "We can't find any information about this deposit. contact support."); } //trans } catch (Exception $e) { Log::info('Caught exception: ' . $e->getMessage() . "\n"); } } } else { Log::info('------------------- Error: not param wallet_type from _GET'); } Log::info("*******Stop New Blocknotify Update Deposit*************"); }
public function del_deposit($id) { $result = Deposit::where('req_sub_id', $id)->delete(); if ($result) { $data = DB::Select(' select * from c_deposit c1 left join c_req_cars c2 on c2.req_car_id=c1.req_sub_id where c1.req_main_id=' . $id . ' '); $t = '<ul class="uk-list uk-list-striped">'; foreach ($data as $k) { $t .= '<li>'; $t .= '<span class="uk-text-warning">ฝ่ายที่ไป:</span> ' . $k->department . ' <span class="uk-text-warning">สถานที่ไป:</span> ' . $k->location . ' <span class="uk-text-warning">วันที่ไป:</span> ' . $k->godate . ' <span class="uk-text-warning">เวลาไป:</span> ' . $k->gotime_start . ' ' . '<span>' . '<a href="#" title="ลบข้อมูล" onclick="del_deposit(' . $k->req_car_id . ')" > ' . '<i class="uk-icon-trash-o"></i>' . ' </a>' . '</span>'; $t .= '</li>'; } $t .= '</ul>'; return $t; } }
public function addDepositCurrency() { $wallet_id = Input::get('wallet_id'); $wallet = Wallet::find($wallet_id); if (!$wallet->enable_deposit) { return Redirect::to('user/deposit/' . $wallet_id)->with('error', Lang::get('user_texts.notify_deposit_disable', array('coin' => $wallet->name))); } $user = Confide::user(); $find_deposit = Deposit::where('user_id', $user->id)->where('wallet_id', $wallet_id)->where('paid', 0)->where('created_at', '>=', date('Y-m-d'))->first(); if (isset($find_deposit->id)) { return Redirect::to('user/deposit/' . $wallet_id)->with('error', Lang::get('messages.you_deposited_today')); } $amount = Input::get('amount'); $address = Input::get('address'); $transaction_id = Input::get('transaction_id'); $deposit = new Deposit(); $deposit->user_id = $user->id; $deposit->transaction_id = $transaction_id; $deposit->address = $address; $deposit->paid = 0; $deposit->amount = $amount; $deposit->wallet_id = $wallet_id; $deposit->save(); if ($deposit->id) { return Redirect::to('user/deposit/' . $wallet_id)->with('notice', Lang::get('messages.message_created_deposit')); } else { return Redirect::to('user/deposit/' . $wallet_id)->with('error', Lang::get('messages.not_add_deposit')); } }
public function deleteWallet() { $wallet_id = Input::get('wallet_id'); $wallet = Wallet::find($wallet_id); if (isset($wallet->id)) { $markets = Market::where("wallet_from", $wallet_id)->orwhere("wallet_to", $wallet_id)->get(); $arr_markets = array(0); foreach ($markets as $market) { $arr_markets[] = $market->id; } FeeWithdraw::where("wallet_id", $wallet_id)->delete(); WalletLimitTrade::where("wallet_id", $wallet_id)->delete(); UserAddressDeposit::where("wallet_id", $wallet_id)->delete(); Balance::where("wallet_id", $wallet_id)->delete(); Transfer::where("wallet_id", $wallet_id)->delete(); Deposit::where("wallet_id", $wallet_id)->delete(); Withdraw::where("wallet_id", $wallet_id)->delete(); Order::whereIn('market_id', $arr_markets)->delete(); Trade::whereIn('market_id', $arr_markets)->delete(); FeeTrade::whereIn('market_id', $arr_markets)->delete(); Market::where("wallet_from", $wallet_id)->orwhere("wallet_to", $wallet_id)->delete(); Wallet::where('id', $wallet_id)->delete(); $message = $wallet->type . " " . Lang::get('admin_messages.delete_success'); if (Input::get('isAjax')) { echo json_encode(array('status' => 'success', 'message' => $message)); exit; } else { return Redirect::to('admin/manage/wallets')->with('success', $message); } } else { $message = Lang::get('admin_messages.wallet_not_exist'); if (Input::get('isAjax')) { echo json_encode(array('status' => 'error', 'message' => $message)); exit; } else { return Redirect::to('admin/manage/wallets')->with('error', $message); } } }