public ActionResult CNYWithdraw(bool withdrawToCode, int? accountID, decimal amount, PayWay payway, string bankAccount, string tradePassword, string sms_otp, string ga_otp) { //if (!CheckUserIsPassRealNameAuthAndEmailIsVerify()) //{ // return Json(new FCJsonResult(-1)); //} var result = default(FCJsonResult); var currencySetting = IoC.Resolve<ICurrencyQuery>().GetCurrency(CurrencyType.CNY); if (!this.CurrentUser.IsVerifyEmail) result = FCJsonResult.CreateFailResult(this.Lang("Please verify your email before withdraw.")); else if (string.IsNullOrEmpty(this.CurrentUser.IdNo)) result = FCJsonResult.CreateFailResult(this.Lang("Please update your identity informations before withdraw.")); else if (!Config.Debug && this.CurrentUser.IsOpenTwoFactorGA && !this.VerifyUserGA(ga_otp)) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your Google Authenticator code error.")); else if (!Config.Debug && this.CurrentUser.IsOpenTwoFactorSMS && !this.VerifyUserSms(sms_otp)) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your Sms Authenticator code error.")); else if (string.IsNullOrEmpty(tradePassword)) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your trade passowrd error.")); else { try { if (!withdrawToCode) { var cmd = new SubmitCNYWithdraw(accountID, this.CurrentUser.UserID, amount, payway, bankAccount.Trim(), tradePassword); this.CommandBus.Send(cmd); this.UpdateUserWithdrawDayLimitRemain(amount, CurrencyType.CNY); } else { var cmd = new WithdrawToDepositCode(CurrencyType.CNY, this.CurrentUser.UserID, amount, tradePassword); this.CommandBus.Send(cmd); this.UpdateUserWithdrawDayLimitRemain(amount, CurrencyType.CNY); return Json(new { Code = 2, Message = this.Lang("Withdraw to DotPay Deposit Code successfully."), DepositCode = cmd.CommandResult }); } } catch (CommandExecutionException ex) { if (ex.ErrorCode == (int)ErrorCode.TradePasswordError) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your trade passowrd error.")); else if (ex.ErrorCode == (int)ErrorCode.AccountBalanceNotEnough) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your balance is not enough.")); else if (ex.ErrorCode == (int)ErrorCode.WithdrawAmountOutOfRange) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Request amount out of range.")); else Log.Error("Action VirtualCoinWithdraw Error", ex); } } return Json(result); }
public ActionResult VirtualCoinWithdraw(bool withdrawToCode, CurrencyType currency, string address, decimal amount, string tradePassword, string sms_otp, string ga_otp) { var currencySetting = IoC.Resolve<ICurrencyQuery>().GetCurrency(currency); var result = FCJsonResult.CreateFailResult(this.Lang("Unknow Exception,Please refresh the page and try again")); if (!this.CurrentUser.IsVerifyEmail) result = FCJsonResult.CreateFailResult(this.Lang("Please verify your email before withdraw.")); else if (!Config.Debug && this.CurrentUser.IsOpenTwoFactorSMS && !this.VerifyUserGA(sms_otp)) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your Google Authenticator code error.")); else if (!Config.Debug && this.CurrentUser.IsOpenTwoFactorGA && !this.VerifyUserSms(ga_otp)) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your Sms Authenticator code error.")); else if (this.GetUserWithdrawDayLimitRemain(currency) < amount) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. You lack of withdrawal limit today.")); else if (string.IsNullOrEmpty(tradePassword)) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your trade passowrd error.")); else try { if (!withdrawToCode) { var cmd = new SubmitVirtualCoinWithdraw(this.CurrentUser.UserID, currency, amount, address.Trim(), tradePassword); this.CommandBus.Send(cmd); result = FCJsonResult.CreateSuccessResult(this.Lang("Submit successfuly.")); } else { var cmd = new WithdrawToDepositCode(currency, this.CurrentUser.UserID, amount, tradePassword); this.CommandBus.Send(cmd); return Json(new { Code = 2, Message = this.Lang("Withdraw to DotPay Deposit Code successfully."), DepositCode = cmd.CommandResult }); } } catch (CommandExecutionException ex) { if (ex.ErrorCode == (int)ErrorCode.TradePasswordError) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your trade passowrd error.")); else if (ex.ErrorCode == (int)ErrorCode.AccountBalanceNotEnough) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Your balance is not enough.")); else if (ex.ErrorCode == (int)ErrorCode.WithdrawAmountOutOfRange) result = FCJsonResult.CreateFailResult(this.Lang("Unable to submit your request. Request amount out of range.")); else Log.Error("Action VirtualCoinWithdraw Error", ex); } return Json(result); }