Exemplo n.º 1
0
        public ActionResult WaitSubmit(int withdrawID, string memo = "")
        {
            try
            {
                var cmd = new SubmitCNYWithdrawToProcess(withdrawID, this.CurrentUser.UserID);
                this.CommandBus.Send(cmd);

                return Json(JsonResult.Success);
            }
            catch (CommandExecutionException ex)
            {
                return Json(new JsonResult(ex.ErrorCode));
            }
        }
Exemplo 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;
                }
            }
        }