Beispiel #1
0
        public bool ScanLogin(string code, Guid accountId)
        {
            var codeEntity = QRCode.Deserialize(code);

            if (codeEntity.SystemPlatform != SystemPlatform.FiiiShop || codeEntity.QrCodeEnum != QRCodeEnum.FiiiPayLogin)
            {
                throw new CommonException(ReasonCode.INVALID_QRCODE, MessageResources.InvalidQRCode);
            }

            string           cKey = "FiiiShop:Login:" + codeEntity.QRCodeKey;
            FiiiShopLoginDTO dto  = new FiiiShopLoginDTO
            {
                AccountId = accountId,
                Status    = (byte)LoginStatus.Logined
            };

            RedisHelper.Set(Constant.REDIS_TOKEN_DBINDEX, cKey, dto, TimeSpan.FromMinutes(3));
            return(true);
        }
Beispiel #2
0
        public ServiceResult <bool> Login(FiiiEXLoginIM im)
        {
            var  codeEntity = QRCode.Deserialize(im.Code);
            bool result     = false;

            if (codeEntity.SystemPlatform == SystemPlatform.FiiiEX)
            {
                if (codeEntity.QRCodeBusiness == QRCodeBusiness.FiiiPayLogin)
                {
                    result = new FiiiEXLoginComponent().FiiiPayLogin(im.Code.Replace('-', ':'), this.GetUser());
                }
            }
            if (!result)
            {
                throw new Framework.Exceptions.CommonException(ReasonCode.INVALID_QRCODE, Framework.Properties.R.无效二维码);
            }
            return(new ServiceResult <bool>
            {
                Data = result
            });
        }
Beispiel #3
0
        public async Task <LoginDto> GetLoginStatus(string code)
        {
            var codeEntity = QRCode.Deserialize(code);

            if (codeEntity.SystemPlatform != SystemPlatform.FiiiShop || codeEntity.QrCodeEnum != QRCodeEnum.FiiiPayLogin)
            {
                throw new CommonException(ReasonCode.INVALID_QRCODE, "");
            }

            string cKey      = "FiiiShop:Login:"******"");
            }
            if (loginInfo.Status == LoginStatus.Logined)
            {
                var user = new UserAccountDAC().GetById(loginInfo.AccountId);
                RedisHelper.KeyDelete(Constant.REDIS_TOKEN_DBINDEX, cKey);
                return(await IssueAccessToken(user));
            }
            throw new CommonException(ReasonCode.FiiiShopCode.ScanLogining, "");
        }
        public GatewayOrderInfoOM PrePay(string code, UserAccount account)
        {
            var codeEntity = QRCode.Deserialize(code);

            if (codeEntity.SystemPlatform != SystemPlatform.Gateway || codeEntity.QrCodeEnum != QRCodeEnum.GateWayPay)
            {
                throw new CommonException(ReasonCode.INVALID_QRCODE, MessageResources.InvalidQRCode);
            }

            var orderDetail = GetGatewayOrderDetail(codeEntity.QRCodeKey);

            if (orderDetail == null)
            {
                throw new CommonException(ReasonCode.INVALID_QRCODE, MessageResources.InvalidQRCode);
            }


            var cryptoCurrency = new CryptocurrencyDAC().GetByCode(orderDetail.Crypto);

            if (cryptoCurrency == null || cryptoCurrency?.Id == null)
            {
                throw new CommonException(ReasonCode.CRYPTO_NOT_EXISTS, "Error: Invalid Cryptocurrency");
            }

            var goDAC        = new GatewayOrderDAC();
            var gatewayOrder = goDAC.GetByTradeNo(orderDetail.Id.ToString());

            if (gatewayOrder != null)
            {
                if (gatewayOrder.Status != GatewayOrderStatus.Pending)
                {
                    throw new CommonException(ReasonCode.ORDER_HAD_COMPLETE, MessageResources.OrderComplated);
                }
            }
            else
            {
                gatewayOrder = new GatewayOrder()
                {
                    OrderNo            = IdentityHelper.OrderNo(),
                    TradeNo            = orderDetail.Id.ToString(),
                    Id                 = Guid.NewGuid(),
                    CryptoId           = cryptoCurrency.Id,
                    MerchantAccountId  = orderDetail.MerchantAccountId,
                    FiatAmount         = orderDetail.FiatAmount,
                    MerchantName       = orderDetail.MerchantName,
                    UserAccountId      = account.Id,
                    CryptoAmount       = orderDetail.CryptoAmount,
                    ActualCryptoAmount = orderDetail.ActualCryptoAmount,
                    FiatCurrency       = orderDetail.FiatCurrency,
                    Markup             = orderDetail.MarkupRate,
                    ActualFiatAmount   = orderDetail.ActualFiatAmount,
                    Status             = GatewayOrderStatus.Pending,
                    ExchangeRate       = orderDetail.ExchangeRate,
                    ExpiredTime        = orderDetail.ExpiredTime,
                    TransactionFee     = orderDetail.TransactionFee,
                    Timestamp          = DateTime.UtcNow,
                    Remark             = orderDetail.Remark
                };
                goDAC.Insert(gatewayOrder);
            }

            return(new GatewayOrderInfoOM()
            {
                Timestamp = DateTime.UtcNow.ToUnixTime().ToString(),
                OrderId = gatewayOrder.Id,
                MerchantName = gatewayOrder.MerchantName,
                CryptoCode = cryptoCurrency.Code,
                ActurlCryptoAmount = gatewayOrder.ActualCryptoAmount
            });
        }
Beispiel #5
0
        public async Task <ScanMerchantQRCodeOM> ScanMerchantQRCode(UserAccount user, string code)
        {
            var codeEntity = QRCode.Deserialize(code);

            if (codeEntity.SystemPlatform != SystemPlatform.FiiiPOS || codeEntity.QrCodeEnum != QRCodeEnum.MerchantScanPay)
            {
                throw new CommonException(ReasonCode.INVALID_QRCODE, MessageResources.InvalidQRCode);
            }
            Guid merchantId         = Guid.Parse(codeEntity.QRCodeKey);
            ScanMerchantQRCodeOM om = new ScanMerchantQRCodeOM();

            var merchantAccount = GetMerchantAccountByIdOrCode(merchantId, null);

            //if (merchantAccount.POSId == null)
            //{
            //    throw new CommonException(ReasonCode.INVALID_QRCODE, MessageResources.InvalidQRCode);
            //}

            if (merchantAccount.Status == AccountStatus.Locked || !merchantAccount.IsAllowAcceptPayment)
            {
                throw new CommonException(ReasonCode.MERCHANT_ACCOUNT_DISABLED, MessageResources.MerchantAccountDisabled);
            }

            Guid.TryParse(merchantAccount.Photo, out Guid merchantAvatar);

            var uwDAC = new UserWalletDAC();
            var mwDAC = new MerchantWalletDAC();

            var userWallets     = uwDAC.GetUserWallets(user.Id);
            var merchantWallets = mwDAC.GetByAccountId(merchantAccount.Id);
            var coins           = new CryptocurrencyDAC().GetAllActived();
            var priceList       = new PriceInfoDAC().GetPrice(merchantAccount.FiatCurrency);

            //判断Pos机是否白标用户
            bool showWhiteLable = false;

            if (merchantAccount.POSId.HasValue)
            {
                var pos = new POSDAC().GetById(merchantAccount.POSId.Value);
                if (pos.IsWhiteLabel)
                {
                    showWhiteLable = true;
                }
            }

            if (!showWhiteLable)
            {
                var whilteLabelCryptoCode = new POSDAC().GetWhiteLabelCryptoCode();
                coins.RemoveAll(t => t.Code == whilteLabelCryptoCode);
            }

            return(await Task.FromResult(new ScanMerchantQRCodeOM
            {
                MerchantId = merchantAccount.Id,
                MerchantName = merchantAccount.MerchantName,
                Avatar = merchantAvatar,
                L1VerifyStatus = (byte)merchantAccount.L1VerifyStatus,
                L2VerifyStatus = (byte)merchantAccount.L2VerifyStatus,
                FiatCurrency = merchantAccount.FiatCurrency,
                MarkupRate = merchantAccount.Markup.ToString(CultureInfo.InvariantCulture),
                WaletInfoList = 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 GetItem(userWallet, a, merchantWallets, 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()
            }));
        }