Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void TestSubmitCNYWithdraw_Common_Process_Flow()
        {
            var userID = 0;
            var withdrawAmount = 0M;
            var bank = Bank.CCB;
            var bankAccount = "6222023400022443546";
            var bankAddress = "上海市XX路XX号";
            var openBankName = "上海市XX建设银行";

            for (int i = 0; i < 50; i++)
            {
                userID = i;

                var cnyAccount = IoC.Resolve<IAccountRepository>().FindByUserIDAndCurrency(userID, CurrencyType.CNY);

                if (cnyAccount != null && cnyAccount.Balance > 0)
                {
                    var realName = "张三" + userID;
                    var idno = "210224195506031426" + userID;
                    var idType = IdNoType.IdentificationCard;

                    var realNameAuth = new UserRealNameAuth(userID, realName, idType, idno);

                    this.commandBus.Send(realNameAuth);
                    withdrawAmount = cnyAccount.Balance / 4;
                    break;
                }
            }

            var submitWithdrawCMD = new SubmitCNYWithdraw(null, userID, withdrawAmount, PayWay.Alipay, bankAccount, "123456");

            Assert.DoesNotThrow(() => { this.commandBus.Send(submitWithdrawCMD); });

            for (int i = 0; i < 50; i++)
            {
                var cnyWithdraw = IoC.Resolve<IRepository>().FindById<CNYWithdraw>(i);

                if (cnyWithdraw != null && cnyWithdraw.State == WithdrawState.WaitVerify)
                {
                    var cnyAccount = IoC.Resolve<IAccountRepository>().FindByUserIDAndCurrency(cnyWithdraw.UserID, CurrencyType.CNY);
                    var cnyLocked = cnyAccount.Locked;
                    var verifyWithdrawCMD = new CNYWithdrawVerify(cnyWithdraw.ID, "提现额度审核通过", userID);

                    Assert.DoesNotThrow(() => { this.commandBus.Send(verifyWithdrawCMD); });
                    cnyWithdraw = IoC.Resolve<IRepository>().FindById<CNYWithdraw>(i);

                    Assert.Equal(cnyWithdraw.State, WithdrawState.WaitSubmit);
                    Assert.True(cnyWithdraw.VerifyAt > 0);

                    var submitWithdrawToProcessCMD = new SubmitCNYWithdrawToProcess(cnyWithdraw.ID, userID);

                    Assert.DoesNotThrow(() => { this.commandBus.Send(submitWithdrawToProcessCMD); });
                    cnyWithdraw = IoC.Resolve<IRepository>().FindById<CNYWithdraw>(i);

                    Assert.Equal(cnyWithdraw.State, WithdrawState.Processing);
                    Assert.True(cnyWithdraw.SubmitAt > 0);

                    var transferAccount = 1;
                    var transferNO = "2014050131452186354664188416";
                    var cnyWithdrawMarkAsSuccessCMD = new CNYWithdrawMarkAsSuccess(cnyWithdraw.ID, transferAccount, transferNO, userID);

                    Assert.DoesNotThrow(() => { this.commandBus.Send(cnyWithdrawMarkAsSuccessCMD); });
                    cnyWithdraw = IoC.Resolve<IRepository>().FindById<CNYWithdraw>(i);

                    cnyAccount = IoC.Resolve<IAccountRepository>().FindByUserIDAndCurrency(cnyWithdraw.UserID, CurrencyType.CNY);

                    Assert.Equal(cnyWithdraw.State, WithdrawState.Complete);
                    Assert.True(cnyWithdraw.DoneAt > 0);
                    Assert.Equal(cnyLocked, cnyAccount.Locked + cnyWithdraw.Amount);

                    break;
                }
            }
        }