Exemplo n.º 1
0
        public ActionResult RealNameAuthentication(string realname, string identityno, IdNoType idNoType = IdNoType.IdentificationCard)
        {
            var result = FCJsonResult.CreateFailResult(this.Lang("Unable to update your identity informations. Please try again."));

            if (!string.IsNullOrEmpty(realname.NullSafe()) && !string.IsNullOrEmpty(identityno.NullSafe()))
            {
                if (idNoType == IdNoType.IdentificationCard && (identityno.NullSafe().Length >= 6 && identityno.NullSafe().Length <= 18))
                {
                    try
                    {
                        var cmd = new UserRealNameAuth(this.CurrentUser.UserID, realname, idNoType, identityno);
                        this.CommandBus.Send(cmd);
                        this.CurrentUser.IdNoType = idNoType;
                        this.CurrentUser.IdNo = identityno;
                        this.CurrentUser.RealName = realname;
                        result = FCJsonResult.CreateSuccessResult(this.Lang("Identity information updated successfuly."));
                    }
                    catch (CommandExecutionException ex)
                    {
                        if (ex.ErrorCode == (int)ErrorCode.RealNameAuthenticationIsPassed)
                            result = FCJsonResult.CreateFailResult(this.Lang("Identity informations have updated yet! Please refresh the page to see your identity infomations."));
                        else
                            Log.Error("Action RealNameAuthentication Error", ex);
                    }
                }
            }
            return Json(result);
        }
Exemplo n.º 2
0
        public ActionResult SetRealNameAuthentication(string truename, IdNoType idNoType, string number)
        {
            if (string.IsNullOrEmpty(truename.NullSafe()) || string.IsNullOrEmpty(number.NullSafe()))
                return Json(new FCJsonResult(-1));

            if (idNoType == IdNoType.IdentificationCard && number.NullSafe().Length < 6 && number.NullSafe().Length > 18)
                return Json(new { Code = -2, Msg = "身份证号不合法" });
            try
            {
                var cmd = new UserRealNameAuth(this.CurrentUser.UserID, truename, idNoType, number);
                this.CommandBus.Send(cmd);
                return Redirect("~/myfullcoin");
            }
            catch (CommandExecutionException ex)
            {
                return Json(new FCJsonResult(ex.ErrorCode));
            }
        }
Exemplo n.º 3
0
        public void TestUserRealNameAuthentication()
        {
            var userID = new Random().Next(1, 10);
            var realName = "张三";
            var idno = "210224195506031426";
            var idType = IdNoType.IdentificationCard;

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

            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(realNameAuth);
            });

            var savedUser = IoC.Resolve<IRepository>().FindById<User>(userID);

            Assert.Equal(savedUser.Membership.RealName, realName);
            Assert.Equal(savedUser.Membership.IdNo, idno);
            Assert.Equal(savedUser.Membership.IdNoType, idType);
        }
Exemplo n.º 4
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;
                }
            }
        }