public async Task <ServiceResult <ScanMerchantQRCodeModel> > ScanMerchantQRCode(ScanQRCodeIM im) { ScanMerchantQRCodeOM om = await new OrderComponent().ScanMerchantQRCode(this.GetUser(), im.Code); ScanMerchantQRCodeModel result = new ScanMerchantQRCodeModel(); result.MerchantId = om.MerchantId; result.MerchantName = om.MerchantName; result.Avatar = om.Avatar; result.L1VerifyStatus = om.L1VerifyStatus; result.L2VerifyStatus = om.L2VerifyStatus; result.FiatCurrency = om.FiatCurrency; result.MarkupRate = om.MarkupRate; if (om.WaletInfoList != null) { result.WaletInfoList = new System.Collections.Generic.List <WalletInfo>(); foreach (var item in om.WaletInfoList) { result.WaletInfoList.Add(new WalletInfo { Id = item.Id, IconUrl = item.IconUrl, NewStatus = item.NewStatus, Code = item.Code, Name = item.Name, UseableBalance = item.UseableBalance, FrozenBalance = item.FrozenBalance, ExchangeRate = item.ExchangeRate, FiatBalance = item.FiatBalance, MerchantSupported = item.MerchantSupported, DecimalPlace = item.DecimalPlace, CryptoEnable = item.CryptoEnable }); } } return(new ServiceResult <ScanMerchantQRCodeModel> { Data = result }); }
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() })); }