public string TransferInto(Guid openId, string pin, string coinCode, decimal amount)
        {
            var coin = new CryptocurrencyDAC().GetByCode(coinCode);

            if (coin == null)
            {
                throw new CommonException(ReasonCode.CRYPTO_NOT_EXISTS, R.ErrorCryptoCode);
            }

            var openAccountDac = new OpenAccountDAC();
            var openAccount    = openAccountDac.GetOpenAccount(openId);

            if (openAccount == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, R.AccountNotExist);
            }
            switch (openAccount.FiiiType)
            {
            case FiiiType.FiiiPay:
                var accountDac  = new UserAccountDAC();
                var userAccount = accountDac.GetById(openAccount.AccountId);
                new SecurityComponent().VerifyPin(userAccount, pin);
                return(this.FiiiPayTransferInto(userAccount, coin, amount));

            case FiiiType.FiiiPOS:
                MerchantAccount merchantAccount = new MerchantAccountDAC().GetById(openAccount.AccountId);
                new SecurityComponent().FiiiPOSVerifyPin(merchantAccount, pin);
                return(this.FiiiPOSTransferInto(merchantAccount, coin, amount));

            default:
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, R.AccountNotExist);
            }
        }
예제 #2
0
        /// <summary>
        /// 使用UserId获得KYC服务器地址
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private ProfileRouter QueryKYCRouter(Guid?id)
        {
            var dac         = new UserAccountDAC();
            var userAccount = dac.GetById(id.Value);

            return(ProfileFactory.GetByCountryId(userAccount.CountryId));
        }
예제 #3
0
        private PrePayOM GetUserPrePayOM(Guid userAccountId, MerchantInformation merchantInfo)
        {
            var userDAC             = new UserAccountDAC();
            var merchantDAC         = new MerchantInformationDAC();
            var merchantUserAccount = userDAC.GetById(merchantInfo.MerchantAccountId);
            var supportList         = new MerchantSupportCryptoDAC().GetList(merchantInfo.Id).ToList();
            var userWallets         = new UserWalletDAC().GetUserWallets(userAccountId);
            var coins     = new CryptocurrencyDAC().GetAllActived();
            var priceList = new PriceInfoDAC().GetPrice(merchantUserAccount.FiatCurrency);

            var whilteLabelCryptoCode = new POSDAC().GetWhiteLabelCryptoCode();

            coins.RemoveAll(t => t.Code == whilteLabelCryptoCode);

            return(new PrePayOM
            {
                FiatCurrency = merchantUserAccount.FiatCurrency,
                MarkupRate = merchantInfo.Markup.ToString(CultureInfo.InvariantCulture),
                WaletList = coins.Select(a =>
                {
                    var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);
                    decimal rate = 0;
                    rate = priceList.Where(t => t.CryptoID == a.Id).Select(t => t.Price).FirstOrDefault();
                    return GetUserSupportItem(userWallet, a, supportList, rate);
                }).OrderByDescending(a => a.MerchantSupported).ThenBy(a => a.PayRank).Select(a => new WalletItem
                {
                    Code = a.Code,
                    NewStatus = a.NewStatus,
                    ExchangeRate = a.ExchangeRate,
                    FrozenBalance = a.FrozenBalance,
                    IconUrl = a.IconUrl,
                    Id = a.Id,
                    MerchantSupported = a.MerchantSupported,
                    Name = a.Name,
                    UseableBalance = a.UseableBalance,
                    FiatBalance = a.FiatBalance,
                    DecimalPlace = a.DecimalPlace,
                    CryptoEnable = a.CryptoEnable
                }).ToList()
            });
        }
예제 #4
0
        public ResultDto Payment(PaymentVo model)
        {
            var result = new ResultDto();

            var userAccountId = model.UserId;

            var userAccountDac = new UserAccountDAC();
            var userWalletDac  = new UserWalletDAC();
            var mallDac        = new MallPaymentOrderDAC();

            var account = userAccountDac.GetById(userAccountId);

            if (account == null)
            {
                result.Code    = AccountNotFound;
                result.Message = Resource.AccountNotFound;

                return(result);
            }

            if (!PasswordHasher.VerifyHashedPassword(account.Pin, model.PIN))
            {
                result.Code    = PINError;
                result.Message = Resource.PINError;

                return(result);
            }

            var wallet = userWalletDac.GetByCryptoCode(userAccountId, "FIII");

            if (wallet == null)
            {
                result.Code    = WalletNotFound;
                result.Message = Resource.WalletNotFound;

                return(result);
            }

            if (wallet.Balance < model.CryptoAmount)
            {
                result.Code    = InsufficientBalance;
                result.Message = Resource.InsufficientBalance;

                return(result);
            }

            var extisorder = mallDac.GetByOrderId(model.OrderId);

            if (extisorder != null && extisorder.Status == OrderStatus.Completed)
            {
                result.Code    = OrderExist;
                result.Message = Resource.OrderExist;

                return(result);
            }

            try
            {
                if (extisorder == null)
                {
                    var order = new MallPaymentOrder
                    {
                        Id            = Guid.NewGuid(),
                        CryptoAmount  = model.CryptoAmount,
                        ExpiredTime   = DateTime.UtcNow.AddMinutes(30),
                        OrderId       = model.OrderId,
                        Remark        = "",
                        Status        = OrderStatus.Pending,
                        Timestamp     = DateTime.UtcNow,
                        UserAccountId = userAccountId,
                        RefundTradeNo = string.Empty,
                        TradeNo       = string.Empty
                    };
                    mallDac.Create(order);
                    RabbitMQSender.SendMessage("PaymentGatewayPayOrder", order);
                }
                else
                {
                    RabbitMQSender.SendMessage("PaymentGatewayPayOrder", extisorder);
                }

                result.Message = Resource.Success;
                return(result);
            }
            catch (Exception exception)
            {
                _log.Error(exception);

                result.Code    = PaymentError;
                result.Message = Resource.PaymentError;

                return(result);
            }
        }
예제 #5
0
        public UserProfileSet GetUserProfileSet(Guid id)
        {
            var            profileSet     = new UserProfileSet();
            UserAccountDAC userAccountDAC = new UserAccountDAC();
            UserAccount    userAccount    = userAccountDAC.GetById(id);

            if (userAccount == null)
            {
                return(null);//查无
            }
            //赋值
            profileSet.Id                = userAccount.Id;
            profileSet.Cellphone         = userAccount.Cellphone;
            profileSet.Email             = userAccount.Email;
            profileSet.IsVerifiedEmail   = userAccount.IsVerifiedEmail;
            profileSet.RegistrationDate  = userAccount.RegistrationDate;
            profileSet.CountryId         = userAccount.CountryId;
            profileSet.Photo             = userAccount.Photo;
            profileSet.Password          = userAccount.Password;
            profileSet.Pin               = userAccount.Pin;
            profileSet.SecretKey         = userAccount.SecretKey;
            profileSet.Status            = userAccount.Status;
            profileSet.IsAllowWithdrawal = userAccount.IsAllowWithdrawal;
            profileSet.IsAllowExpense    = userAccount.IsAllowExpense;
            profileSet.FiatCurrency      = userAccount.FiatCurrency;
            profileSet.InvitationCode    = userAccount.InvitationCode;
            profileSet.InviterCode       = userAccount.InviterCode;
            profileSet.ValidationFlag    = userAccount.ValidationFlag;
            profileSet.AuthSecretKey     = userAccount.AuthSecretKey;


            var         routerDAC   = new ProfileRouterDAC();
            var         server      = routerDAC.GetRouter(userAccount.CountryId);
            UserProfile userProfile = null;

            if (server == null)
            {
                throw new InvalidProfileServiceException();
            }

            var userProfileDAC = new UserProfileRPC(server);

            userProfile = userProfileDAC.GetById(userAccount.Id);
            if (userProfile != null)
            {
                profileSet.UserAccountId = userProfile.UserAccountId;
                profileSet.LastName      = userProfile.LastName;
                profileSet.FirstName     = userProfile.FirstName;
                //profileSet.Fullname = userProfile.Fullname;
                profileSet.IdentityDocNo   = userProfile.IdentityDocNo;
                profileSet.IdentityDocType = userProfile.IdentityDocType;
                //profileSet.IdentityDocFile = userProfile.IdentityDocFile;
                //profileSet.IsIdentityDocVerified = userProfile.IsIdentityDocVerified;
                profileSet.IdentityExpiryDate = userProfile.IdentityExpiryDate;
                profileSet.DateOfBirth        = userProfile.DateOfBirth;
                profileSet.Address1           = userProfile.Address1;
                profileSet.Address2           = userProfile.Address2;
                profileSet.City               = userProfile.City;
                profileSet.State              = userProfile.State;
                profileSet.Postcode           = userProfile.Postcode;
                profileSet.Country            = userProfile.Country;
                profileSet.Gender             = userProfile.Gender;
                profileSet.FrontIdentityImage = userProfile.FrontIdentityImage;
                profileSet.ResidentImage      = userProfile.ResidentImage;
                profileSet.BackIdentityImage  = userProfile.BackIdentityImage;
                profileSet.HandHoldWithCard   = userProfile.HandHoldWithCard;
                profileSet.L1VerifyStatus     = userProfile.L1VerifyStatus;
                profileSet.L2VerifyStatus     = userProfile.L2VerifyStatus;
                profileSet.L1SubmissionDate   = userProfile.L1SubmissionDate;
                profileSet.L2SubmissionDate   = userProfile.L2SubmissionDate;
                profileSet.L1Remark           = userProfile.L1Remark;
                profileSet.L2Remark           = userProfile.L2Remark;
            }
            return(profileSet);
        }