Esempio n. 1
0
 public function cancelWithdraw()
 {
     if (Auth::guest()) {
         echo json_encode(array('status' => 'error', 'message' => Lang::get('messages.login_to_buy')));
         exit;
     }
     Log::info('------------------------- Do Cancel Withdraw -----------------------------');
     $user = Confide::user();
     $withdraw_id = $_POST['withdraw_id'];
     $withdraw = Withdraw::find($withdraw_id);
     if ($withdraw->user_id == $user->id) {
         //this condition use to avoid case a user cancel order of other user
         //delete order
         $withdraw->delete();
         echo json_encode(array('status' => 'success', 'message' => "The withdraw " . $withdraw_id . " was cancled!"));
         exit;
     } else {
         echo json_encode(array('status' => 'error', 'message' => "Sorry. You were not allowed cancel this withdraw!"));
         exit;
     }
 }
 public function doUpdateTakeMoneyWithdraw()
 {
     $username = Input::get('username');
     $amount = Input::get('amount');
     $transaction_id = Input::get('transaction_id');
     $take_money = Input::get('take_money');
     if (empty($take_money)) {
         $take_money = 0;
     }
     $withdraw_id = Input::get('withdraw_id');
     $redirect = Input::get('redirect');
     $fee = Input::get('fee');
     $receive_amount = $amount - $fee;
     $user = User::where('username', $username)->first();
     //echo "<pre>Input: "; print_r(Input::all()); echo "</pre>"; exit;
     if (!isset($user->id)) {
         return Redirect::to($redirect)->with('error', Lang::get('admin_messages.user_not_exist'));
     } else {
         $withdraw = Withdraw::find($withdraw_id);
         if (isset($withdraw->id)) {
             $withdraw->amount = $amount;
             $withdraw->transaction_id = $transaction_id;
             $withdraw->status = $take_money;
             $withdraw->save();
             $message = '';
             if ($take_money) {
                 $balance = new Balance();
                 $wallet = new Wallet();
                 $balance->takeMoney($amount, $withdraw->wallet_id, $user->id);
                 $message = ". " . Lang::get('admin_messages.take_money_user', array('amount' => $amount, 'coin' => $wallet->getType($withdraw->wallet_id), 'username' => $user->username));
             }
             return Redirect::to($redirect)->with('success', Lang::get('admin_messages.update_success') . $message);
         } else {
             return Redirect::to($redirect)->with('error', Lang::get('admin_messages.withdraw_not_exist'));
         }
     }
 }