public SignonDTO Signon(string possn, string merchantAccount, string pin) { var account = new MerchantAccountDAC().GetByUsername(merchantAccount); // 账号不存在 if (account == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.AccountNotExists); } // 账号未绑定到POS机 if (!account.POSId.HasValue) { throw new CommonException(ReasonCode.ACCOUNT_UNBUNDLED, Resources.AccountNotExists); } if (account.Status == AccountStatus.Locked) { throw new CommonException(ReasonCode.ACCOUNT_LOCKED, Resources.帐号已锁定); } var pos = new POSDAC().GetBySn(possn); // 不存在和未激活提示SN异常 if (pos == null || !pos.Status) { throw new CommonException(ReasonCode.POSSN_ERROR, Resources.SN码不存在); } if (account.POSId != pos.Id) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.NoBindRelationship); } new SecurityComponent().FiiiPOSVerifyPin(account, pin); return(GetAccessToken(pos, account)); }
public void CheckAccount(string username, string sn) { POS pos = new POSDAC().GetBySn(sn); if (pos == null || !pos.Status) { throw new CommonException(ReasonCode.POSSN_ERROR, Resources.SN码不存在); } if (!pos.IsMiningEnabled) { throw new CommonException(ReasonCode.NOT_ALLOW_MINING, "Not allow mining"); } MerchantAccount account = new MerchantAccountDAC().GetByPosSn(sn, username); if (account == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, "Account not exist"); } if (account.Status == AccountStatus.Locked) { throw new CommonException(ReasonCode.ACCOUNT_LOCKED, "Account locked"); } }
public void SendSignupSMS(string cellphone, int countryId, string possn) { var country = new CountryComponent().GetById(countryId); if (country == null) { throw new CommonException(10000, Resources.国家不存在); } var posDac = new POSDAC(); var pos = posDac.GetBySn(possn); if (pos == null) { throw new GeneralException(Resources.SN码不存在); } if (pos.Status) { throw new GeneralException(Resources.POSHasBoundOtherAccount); } Dictionary <string, string> dic = new Dictionary <string, string> { { "Cellphone", cellphone }, { "CountryId", countryId.ToString() }, { "FiatCurrency", country.FiatCurrency }, { "PhoneCode", country.PhoneCode } }; var verifier = new FiiiPosRegisterVerifier(); SecurityVerify.SendCode(verifier, SystemPlatform.FiiiPOS, $"{countryId}{cellphone}", $"{country.PhoneCode}{cellphone}"); verifier.CacheRegisterModel(SystemPlatform.FiiiPOS, $"{countryId}{cellphone}", dic); }
public List <CryptoAddressIndexES> GetMerchantCryptoAddress(Guid merchantAccountId) { var list = new CryptoAddressDAC().GetByAccountId(merchantAccountId); var cryptoList = new CryptocurrencyDAC().GetAllActived(); cryptoList.MoveTop(t => t.Code == "FIII"); var account = new MerchantAccountDAC().GetById(merchantAccountId); var pos = new POSDAC().GetById(account.POSId.Value); if (!pos.IsWhiteLabel) { cryptoList.RemoveAll(t => t.IsWhiteLabel == 1); } else { cryptoList.MoveTop(t => t.Code == pos.FirstCrypto); } return(cryptoList.Select(e => { return new CryptoAddressIndexES { CryptoId = e.Id, Code = e.Code, NeedTag = e.NeedTag, Count = list.Count(c => c.CryptoId == e.Id) }; }).ToList()); }
//public string GetByPosSn(string sn) //{ // MerchantAccountDAC dac = new MerchantAccountDAC(); // MerchantAccount account = dac.GetByPosSn(sn); // return account?.Username; //} public MerchantAccount GetByPosSn(string posSn, string merchantAccount) { MerchantAccount account = new MerchantAccountDAC().GetByUsername(merchantAccount); if (account == null) { throw new CommonException(ReasonCode.UNAUTHORIZED, "UNAUTHORIZED"); } if (!account.POSId.HasValue) { throw new CommonException(ReasonCode.ACCOUNT_UNBUNDLED, Resources.AccountUnbundled); } if (account.Status == AccountStatus.Locked) { throw new CommonException(ReasonCode.ACCOUNT_LOCKED, "Account is locked"); } POS pos = new POSDAC().GetBySn(posSn); if (pos == null || pos.Id != account.POSId) { throw new CommonException(ReasonCode.POSSN_ERROR, Resources.SN码不存在); } return(account); }
public OrderDetailDTO GetById(Guid merchantAccountId, Guid orderId) { var order = new OrderDAC().GetById(orderId); var merchantAccount = new MerchantAccountDAC().GetById(merchantAccountId); var pos = new POSDAC().GetById(merchantAccount.POSId.Value); if (order == null) { throw new CommonException(10000, Resources.订单不存在); } if (order.MerchantAccountId != merchantAccountId) { throw new CommonException(10000, Resources.只能查看自己的订单); } var coin = new CryptocurrencyDAC().GetById(order.CryptoId); var er = order.ExchangeRate; var cer = GetExchangeRate(merchantAccount.CountryId, order.FiatCurrency, coin); var iRate = ((cer - er) / er) * 100; var result = new OrderDetailDTO { Id = order.Id, OrderNo = order.OrderNo, OrderStatus = order.Status, Timestamp = order.Timestamp.ToUnixTime(), CryptoStatus = coin.Status, CryptoEnable = coin.Enable, CryptoCode = coin.Code, CryptoAmount = order.CryptoAmount.ToString(coin.DecimalPlace), FiatCurrency = order.FiatCurrency, FiatAmount = order.FiatAmount.ToString(2), Markup = order.Markup, ActualFiatAmount = order.ActualFiatAmount.ToString(2), TransactionFee = order.TransactionFee.ToString(coin.DecimalPlace), ActualCryptoAmount = order.ActualCryptoAmount.ToString(coin.DecimalPlace), UserAccount = order.UserAccountId.HasValue ? GetUserMastMaskedCellphone(order.UserAccountId.Value) : string.Empty, SN = pos.Sn, ExchangeRate = er.ToString(4), CurrentExchangeRate = cer.ToString(4), IncreaseRate = iRate > 0 ? $"+{iRate.ToString(2)}" : iRate.ToString(2) }; if (result.OrderStatus == OrderStatus.Refunded) { var refund = new RefundDAC().GetByOrderId(result.Id); if (refund?.Timestamp != null) { result.RefundTimestamp = refund.Timestamp.ToUnixTime(); } } return(result); }
public PrePayOM PrePay(UserAccount user, PrePayIM im) { var merchantAccount = GetMerchantAccountByIdOrCode(im.MerchantId, im.MerchantCode); var userWallets = new UserWalletDAC().GetUserWallets(user.Id); var merchantWallets = new MerchantWalletDAC().GetByAccountId(merchantAccount.Id); var coins = new CryptocurrencyDAC().GetAllActived(); var priceList = new PriceInfoDAC().GetPrice(merchantAccount.FiatCurrency); 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(new PrePayOM { FiatCurrency = merchantAccount.FiatCurrency, MarkupRate = merchantAccount.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 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() }); }
public PrintOrderInfoDTO PrintOrder(Guid merchantAccountId, string orderNo) { var order = new OrderDAC().GetByOrderNo(orderNo); var merchantAccount = new MerchantAccountDAC().GetById(merchantAccountId); var pos = new POSDAC().GetById(merchantAccount.POSId.Value); if (order == null) { throw new CommonException(10000, Resources.订单不存在); } if (order.MerchantAccountId != merchantAccountId) { throw new CommonException(10000, Resources.只能查看自己的订单); } var coin = new CryptocurrencyDAC().GetById(order.CryptoId); var result = new PrintOrderInfoDTO { Id = order.Id, OrderNo = order.OrderNo, OrderStatus = order.Status, Timestamp = order.Timestamp.ToUnixTime(), CryptoCode = coin.Code, CryptoAmount = order.CryptoAmount.ToString(coin.DecimalPlace), FiatCurrency = order.FiatCurrency, FiatAmount = order.FiatAmount.ToString(2), Markup = order.Markup, ActualFiatAmount = order.ActualFiatAmount.ToString(2), ExchangeRate = $"1 {coin.Code} = {order.ExchangeRate.ToString(4)} {order.FiatCurrency}", TransactionFee = order.TransactionFee.ToString(coin.DecimalPlace), ActualCryptoAmount = order.ActualCryptoAmount.ToString(coin.DecimalPlace), UserAccount = order.UserAccountId.HasValue ? GetUserMastMaskedCellphone(order.UserAccountId.Value) : string.Empty, SN = pos.Sn, AvatarId = merchantAccount.Photo, MerchantName = merchantAccount.MerchantName, CryptoImage = coin.IconURL }; if (result.OrderStatus == OrderStatus.Refunded) { var refund = new RefundDAC().GetByOrderId(result.Id); if (refund?.Timestamp != null) { result.RefundTimestamp = refund.Timestamp.ToUnixTime(); } } return(result); }
public SaveResult UnMarkWhiteLabel(List <long> ids, int userId, string userName) { POSDAC dac = new POSDAC(); ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = userId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(POSBLL).FullName + ".BatchUnMarkWhiteLabel"; actionLog.Username = userName; actionLog.LogContent = "BatchUpdate POS Ids:" + ids; new ActionLogBLL().Create(actionLog); return(new SaveResult(dac.BatchUnMarkWhiteLabel(ids))); }
public void UnbindingAccount(Guid merchantAccountId) { SecurityVerify.Verify <UnBindAccountVerify>(new CustomVerifier("UnBindAccount"), SystemPlatform.FiiiPOS, merchantAccountId.ToString(), (model) => { return(model.PinVerified && model.CombinedVerified); }); var accountDAC = new MerchantAccountDAC(); var account = accountDAC.GetById(merchantAccountId); var posDAC = new POSDAC(); var pos = posDAC.GetById(account.POSId.Value); var recordId = new POSMerchantBindRecordDAC().GetByMerchantId(merchantAccountId).Id; var invitorId = new InviteRecordDAC().GetInvitorIdBySn(pos.Sn); account.POSId = null; bool bindingGoogleAuth = !string.IsNullOrEmpty(account.AuthSecretKey); bool openedGoogleAuth = ValidationFlagComponent.CheckSecurityOpened(account.ValidationFlag, ValidationFlag.GooogleAuthenticator); if (bindingGoogleAuth && !openedGoogleAuth) { account.ValidationFlag = ValidationFlagComponent.AddValidationFlag(account.ValidationFlag, ValidationFlag.GooogleAuthenticator); } using (var scope = new TransactionScope()) { accountDAC.UnbindingAccount(account); new POSDAC().InactivePOS(pos); new POSMerchantBindRecordDAC().UnbindRecord(account.Id, pos.Id); if (!string.IsNullOrEmpty(account.InvitationCode)) { UnBindInviter(pos.Sn); } scope.Complete(); } //Task.Run(() => RemoveRegInfoByUserId(merchantAccountId)); if (!string.IsNullOrEmpty(account.InvitationCode)) { RabbitMQSender.SendMessage("UnBindingAccount", new Tuple <Guid, long>(invitorId, recordId)); } RemoveRegInfoByUserId(merchantAccountId); }
public MerchantAccountDTO GetMerchantInfoById(Guid accountId) { MerchantAccount account = new MerchantAccountDAC().GetById(accountId); MerchantProfile profile = new MerchantProfileAgent().GetMerchantProfile(accountId); //LogHelper.Info("GetMerchantInfoById " + accountId); var token = Generate(account.SecretKey, account.RegistrationDate); string key = string.Format(RedisKeys.FiiiPOS_APP_BroadcastNo, token); var result = RedisHelper.StringGet(FiiiPOSTokenDbIndex, key); if (string.IsNullOrWhiteSpace(result)) { RedisHelper.StringSet(FiiiPOSTokenDbIndex, key, accountId.ToString()); } bool isMiningEnabled = false; if (account.POSId.HasValue) { POS pos = new POSDAC().GetById(account.POSId.Value); isMiningEnabled = pos?.IsMiningEnabled ?? false; } return(new MerchantAccountDTO { Id = account.Id, Cellphone = CellphoneExtension.GetMaskedCellphone(account.PhoneCode, account.Cellphone), Username = account.Username, MerchantName = account.MerchantName, Status = account.Status, Email = account.Email, CountryId = account.CountryId, IsAllowWithdrawal = account.IsAllowWithdrawal, IsAllowAcceptPayment = account.IsAllowAcceptPayment, FiatCurrency = account.FiatCurrency, Receivables_Tier = account.Receivables_Tier, Markup = account.Markup, ValidationFlag = account.ValidationFlag, Lv1VerifyStatus = profile.L1VerifyStatus, Type = account.WithdrawalFeeType, IsMiningEnabled = isMiningEnabled, BroadcastNo = token }); }
public List <MerchantWalletDTO> GetMerchantWalletList(Guid merchantAccountId) { var account = new MerchantAccountDAC().GetById(merchantAccountId); var cryptoList = new CryptocurrencyDAC().GetAllActived(); cryptoList.MoveTop(t => t.Code == FIIICOIN_CODE); var pos = new POSDAC().GetById(account.POSId.Value); if (!pos.IsWhiteLabel) { cryptoList.RemoveAll(t => t.IsWhiteLabel == 1); } else { cryptoList.MoveTop(t => t.Code == pos.FirstCrypto); } var walletList = new MerchantWalletDAC().GetByAccountId(merchantAccountId); var currencyId = new CurrenciesDAC().GetByCode(account.FiatCurrency).ID; var exchangeRate = new PriceInfoDAC().GetByCurrencyId(currencyId).ToDictionary(item => item.CryptoID); return(cryptoList.Select(e => { var wallet = walletList.FirstOrDefault(w => w.CryptoId == e.Id); return new MerchantWalletDTO { WalletId = wallet?.Id ?? 0, CryptoId = e.Id, CryptoStatus = e.Status, CryptoCode = e.Code, CryptoName = e.Name, IconURL = e.IconURL, DecimalPlace = e.DecimalPlace, Balance = (wallet?.Balance ?? 0).ToString(e.DecimalPlace), FrozenBalance = (wallet?.FrozenBalance ?? 0).ToString(e.DecimalPlace), FiatExchangeRate = (exchangeRate.ContainsKey(e.Id) ? exchangeRate[e.Id].Price : 0m).ToString(4), FiatBalance = (((wallet?.Balance ?? 0) + (wallet?.FrozenBalance ?? 0)) * (exchangeRate.ContainsKey(e.Id) ? exchangeRate[e.Id].Price : 0m)).ToString(4), FiatCode = account.FiatCurrency, CryptoEnable = e.Enable }; }).ToList()); }
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() }); }
public void SendBindingSMS(string cellphone, int countryId, string merchantAccount, string sn) { var pos = new POSDAC().GetBySn(sn); if (pos == null) { throw new CommonException(ReasonCode.POSSN_ERROR, Resources.SN码不存在); } var account = new MerchantAccountDAC().GetByUsername(merchantAccount); if (account == null) { throw new GeneralException(Resources.AccountNotExists); } if (account.POSId.HasValue) { if (account.POSId == pos.Id) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.AccountHasBoundThisPOS); } else { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.AccountHasBoundOtherPOS); } } var country = new CountryComponent().GetById(countryId); if (country == null) { throw new CommonException(10000, Resources.国家不存在); } if (account.PhoneCode != country.PhoneCode || account.Cellphone != cellphone) { throw new GeneralException(Resources.当前手机号与账号绑定的手机号不一致); } SecurityVerify.SendCode(new BindAccountCellphoneVerifier(), SystemPlatform.FiiiPOS, merchantAccount, $"{account.PhoneCode}{account.Cellphone}"); }
public bool FiiiPosLogin(string QRCode, Guid accountId) { if (!RedisHelper.KeyExists(0, QRCode)) { throw new CommonException(ReasonCode.INVALID_QRCODE, R.无效二维码); } MerchantAccount account = new MerchantAccountDAC().GetById(accountId); if (account == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, R.用户不存在); } var country = new CountryDAC().GetById(account.CountryId); var pos = new POSDAC().GetById(account.POSId.Value); var openAccount = new OpenAccountDAC().GetOpenAccount(FiiiType.FiiiPOS, account.Id); if (openAccount == null) { openAccount = new OpenAccountComponent().Create((int)SystemPlatform.FiiiEX, FiiiType.FiiiPOS, account.Id); } var om = new { OpenId = openAccount.OpenId, AccountName = account.Username, UserType = 1,//0FiiiPay 1FiiiPos CountryId = country.Id, PosCode = pos.Sn, CountryName = country.Name, CountryName_CN = country.Name_CN, FullName = account.MerchantName, Cellphone = GetMaskedCellphone(account.PhoneCode, account.Cellphone) }; RedisHelper.StringSet(0, QRCode, JsonConvert.SerializeObject(om), TimeSpan.FromMinutes(5)); return(true); }
public List <CryptocurrencyDTO> GetMerchentCryptoList(Guid accountId) { var account = new MerchantAccountDAC().GetById(accountId); var pos = new POSDAC().GetById(account.POSId.Value); var ccDac = new CryptocurrencyDAC(); var list = ccDac.GetAllActived(); if (!pos.IsWhiteLabel) { list.RemoveAll(t => t.IsWhiteLabel == 1); } return(list.Select(e => new CryptocurrencyDTO { Id = e.Id, Code = e.Code, Status = e.Status, IconURL = e.IconURL, Name = e.Name, CryptoEnable = e.Enable }).ToList()); }
public ProfileDTO GetProfile(Guid accountId) { var dac = new MerchantAccountDAC(); var agent = new MerchantProfileAgent(); var account = dac.GetById(accountId); var profile = agent.GetMerchantProfile(accountId); var pos = new POSDAC().GetById(account.POSId.Value); var country = new CountryComponent().GetById(account.CountryId); var result = new ProfileDTO { MerchantAccount = account.Username, LastName = profile.LastName, FirstName = profile.FirstName, IdentityDocNo = profile.IdentityDocNo, IdentityDocType = (profile.IdentityDocType != IdentityDocType.IdentityCard && profile.IdentityDocType != IdentityDocType.Passport) ? IdentityDocType.IdentityCard : profile.IdentityDocType, FrontIdentityImage = profile.FrontIdentityImage, BackIdentityImage = profile.BackIdentityImage, HandHoldWithCard = profile.HandHoldWithCard, MerchantName = account.MerchantName, CompanyName = profile?.CompanyName, Email = account.Email, Cellphone = $"{account.PhoneCode} {account.Cellphone}", PosSn = pos.Sn, Country = country.Name, L1VerifyStatus = (int)(profile?.L1VerifyStatus ?? 0), L2VerifyStatus = (int)(profile?.L2VerifyStatus ?? 0), Address1 = profile?.Address1, Address2 = profile?.Address2, Postcode = profile?.Postcode, City = profile?.City, State = profile?.State }; return(result); }
public MerchantTotalAssetsDTO GetMerchantTotalAssets(Guid accountId) { var account = new MerchantAccountDAC().GetById(accountId); var walletList = new MerchantWalletDAC().GetByAccountId(accountId); decimal totalPrice = 0m; if (walletList.Count > 0) { var cryptoList = new CryptocurrencyDAC().GetAllActived(); if (account.POSId.HasValue) { var pos = new POSDAC().GetById(account.POSId.Value); if (!pos.IsWhiteLabel) { cryptoList.RemoveAll(t => t.IsWhiteLabel == 1); } } var marketPriceList = new MarketPriceComponent().GetMarketPrice(account.FiatCurrency); totalPrice = walletList.Sum(e => { var coin = cryptoList.FirstOrDefault(c => c.Id == e.CryptoId); var marketPrice = marketPriceList.FirstOrDefault(m => m.CryptoName == coin?.Code); return((e.Balance + e.FrozenBalance) * (marketPrice?.Price ?? 0)); }); } return(new MerchantTotalAssetsDTO { FiatCurrency = account.FiatCurrency, Amount = totalPrice.ToString("N", CultureInfo.InvariantCulture), IsAllowWithDrawal = account.IsAllowWithdrawal }); }
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() })); }
public void SettingCrytocurrencies(Guid accountId, List <int> cryptoIds) { var mwDac = new MerchantWalletDAC(); var mwList = mwDac.GetByAccountId(accountId).ToList(); var cryptoList = new CryptocurrencyDAC().GetByIds(cryptoIds.ToArray()); // FIII 不参与排序 var fiiiCrypto = cryptoList.FirstOrDefault(e => e.Code == FIIICOIN_CODE); if (fiiiCrypto != null) { cryptoIds.Remove(fiiiCrypto.Id); var fiiiWallet = mwList.FirstOrDefault(e => e.CryptoId == fiiiCrypto.Id); if (fiiiWallet != null) { mwList.Remove(fiiiWallet); } } // 白标POS机的白标币不参与排序 var account = new MerchantAccountDAC().GetById(accountId); var pos = new POSDAC().GetById(account.POSId.Value); if (pos.IsWhiteLabel) { var whiteCrypto = cryptoList.FirstOrDefault(e => e.Code == pos.FirstCrypto); if (whiteCrypto != null) { cryptoIds.Remove(whiteCrypto.Id); var whiteWallet = mwList.FirstOrDefault(e => e.CryptoId == whiteCrypto.Id); if (whiteWallet != null) { mwList.Remove(whiteWallet); } } } for (int i = 0; i < cryptoIds.Count; i++) { int seq = i + 1; var crypto = cryptoList.FirstOrDefault(e => e.Id == cryptoIds[i]); if (crypto == null) { continue; } var wallet = mwList.FirstOrDefault(e => e.CryptoId == cryptoIds[i]); // 新增 if (wallet == null) { GenerateWallet(accountId, crypto.Id, crypto.Code, seq, true); continue; } // 启用 if (!wallet.SupportReceipt || wallet.Sequence != seq) { mwDac.Support(accountId, crypto.Id, seq); } mwList.Remove(wallet); } mwList.RemoveAll(e => !e.SupportReceipt); // 禁用 foreach (var wallet in mwList) { mwDac.Reject(accountId, wallet.CryptoId); } }
/// <summary> /// 获得MerchantProfile+Account信息体 /// </summary> /// <param name="id"></param> /// <returns></returns> public MerchantProfileSet GetMerchantProfileSet(Guid id) { MerchantProfileSet profileSet = new MerchantProfileSet(); //使用Id查询本库的基本信息 MerchantAccountDAC merchantAccountDAC = new MerchantAccountDAC(); var merchantAccount = merchantAccountDAC.GetById(id); if (merchantAccount == null) { return(null);//查无此人 } //赋值 profileSet.Id = merchantAccount.Id; profileSet.Cellphone = merchantAccount.Cellphone; profileSet.Username = merchantAccount.Username; profileSet.MerchantName = merchantAccount.MerchantName; //profileSet.IsVerified = merchantAccount.IsVerified; profileSet.POSId = merchantAccount.POSId; //profileSet.BeaconId = merchantAccount.BeaconId; profileSet.Email = merchantAccount.Email; profileSet.IsVerifiedEmail = merchantAccount.IsVerifiedEmail; profileSet.CountryId = merchantAccount.CountryId; profileSet.RegistrationDate = merchantAccount.RegistrationDate; profileSet.Photo = merchantAccount.Photo; profileSet.PIN = merchantAccount.PIN; profileSet.SecretKey = merchantAccount.SecretKey; profileSet.IsAllowWithdrawal = merchantAccount.IsAllowWithdrawal; profileSet.IsAllowAcceptPayment = merchantAccount.IsAllowAcceptPayment; profileSet.FiatCurrency = merchantAccount.FiatCurrency; profileSet.AuthSecretKey = merchantAccount.AuthSecretKey; profileSet.ValidationFlag = merchantAccount.ValidationFlag; //使用基本信息中的国别匹配kyc服务器的位置 if (merchantAccount.POSId.HasValue) { POS pos = new POSDAC().GetById(merchantAccount.POSId.Value); if (pos != null) { profileSet.SN = pos.Sn; } } var server = ProfileFactory.GetByCountryId(merchantAccount.CountryId); MerchantProfile merchantProfile = null; if (server == null) { //查询HK数据库 MerchantProfileDAC merchantProfileDAC = new MerchantProfileDAC(); //赋值 merchantProfile = merchantProfileDAC.GetById(id); } else { MerchantProfileRPC merchantProfileDAC = new MerchantProfileRPC(server); //赋值 merchantProfile = merchantProfileDAC.GetById(id); } if (merchantProfile != null) { profileSet.Address1 = merchantProfile.Address1; profileSet.Address2 = merchantProfile.Address2; profileSet.City = merchantProfile.City; profileSet.L1VerifyStatus = merchantProfile.L1VerifyStatus; profileSet.L2VerifyStatus = merchantProfile.L2VerifyStatus; profileSet.Postcode = merchantProfile.Postcode; profileSet.Country = merchantProfile.Country; profileSet.BusinessLicenseImage = merchantProfile.BusinessLicenseImage; profileSet.LicenseNo = merchantProfile.LicenseNo; profileSet.CompanyName = merchantProfile.CompanyName; profileSet.IdentityDocNo = merchantProfile.IdentityDocNo; profileSet.IdentityDocType = merchantProfile.IdentityDocType; profileSet.FirstName = merchantProfile.FirstName; profileSet.LastName = merchantProfile.LastName; profileSet.BackIdentityImage = merchantProfile.BackIdentityImage; profileSet.FrontIdentityImage = merchantProfile.FrontIdentityImage; profileSet.HandHoldWithCard = merchantProfile.HandHoldWithCard; } return(profileSet); }
public List <MerchantSupportReceiptWalletDTO> SupportReceiptList(Guid accountId) { var account = new MerchantAccountDAC().GetById(accountId); var dac = new MerchantWalletDAC(); var cryptoList = new CryptocurrencyDAC().GetAllActived(); var fiiiCrypto = cryptoList.First(w => w.Code == FIIICOIN_CODE); var fiiiWallet = dac.GetByAccountId(account.Id, fiiiCrypto.Id) ?? GenerateWallet(accountId, fiiiCrypto.Id, fiiiCrypto.Code, FIIICOIN_SEQUENCE, true); if (!fiiiWallet.SupportReceipt || fiiiWallet.Sequence != FIIICOIN_SEQUENCE) { dac.Support(account.Id, fiiiWallet.CryptoId, FIIICOIN_SEQUENCE); } List <MerchantWallet> supportReceiptList; var pos = new POSDAC().GetById(account.POSId.Value); if (pos.IsWhiteLabel) { var whiteCrypto = cryptoList.First(w => w.Code == pos.FirstCrypto); var whiteWallet = dac.GetByAccountId(account.Id, whiteCrypto.Id); if (whiteWallet == null) { GenerateWallet(accountId, whiteCrypto.Id, whiteCrypto.Code, WHITECOIN_SEQUENCE, true); } else if (!whiteWallet.SupportReceipt || whiteWallet.Sequence != WHITECOIN_SEQUENCE) { dac.Support(account.Id, whiteWallet.CryptoId, WHITECOIN_SEQUENCE); } supportReceiptList = dac.SupportReceiptList(accountId).OrderBy(e => e.Sequence).ToList(); } else { var whiteCryptoList = cryptoList.Where(e => e.IsWhiteLabel == 1).ToList(); supportReceiptList = dac.SupportReceiptList(accountId).OrderBy(e => e.Sequence).ToList(); supportReceiptList.RemoveAll(e => whiteCryptoList.Exists(a => a.Id == e.CryptoId)); } var marketPriceList = new PriceInfoDAC().GetPrice(account.FiatCurrency); return(supportReceiptList.Select(e => { var crypto = cryptoList.FirstOrDefault(w => w.Id == e.CryptoId); if (crypto == null) { return null; } return new MerchantSupportReceiptWalletDTO { WalletId = e.Id, CryptoId = crypto.Id, CryptoStatus = crypto.Status, CryptoCode = crypto.Code, CryptoName = crypto.Name, IconURL = crypto.IconURL, DecimalPlace = crypto.DecimalPlace, Markup = account.Markup, MarketPrice = marketPriceList.FirstOrDefault(m => crypto.Code == m.CryptoName)?.Price.ToString(4), Balance = string.Equals("FIII", crypto.Code, StringComparison.CurrentCultureIgnoreCase) ? e.Balance : 0, IsDefault = e.CryptoId == fiiiCrypto.Id || (pos.IsWhiteLabel && crypto.Code == pos.FirstCrypto) ? 1 : 0, CryptoEnable = crypto.Enable }; }).Where(w => w != null).ToList()); }
public SignonDTO BindingAccount(string merhcantAccount, string posSN) { var accountDac = new MerchantAccountDAC(); MerchantAccount account = accountDac.GetByUsername(merhcantAccount); SecurityVerify.Verify <BindAccountVerify>(new CustomVerifier("BindAccount"), SystemPlatform.FiiiPOS, merhcantAccount, (model) => { bool result = true; result = result && merhcantAccount.Equals(model.MerchantAccount); result = result && model.CellphoneVerified && model.PinVerified; if (account == null) { return(false); } if (ValidationFlagComponent.CheckSecurityOpened(account.ValidationFlag, ValidationFlag.GooogleAuthenticator)) { result = result && model.GoogleVerified; } return(result); }); var posDac = new POSDAC(); if (account.Status == AccountStatus.Locked) { throw new CommonException(ReasonCode.ACCOUNT_LOCKED, Resources.帐号已锁定); } var pos = posDac.GetBySn(posSN); if (pos == null) { throw new GeneralException(Resources.SN码不存在); } if (account.POSId.HasValue) { if (account.POSId == pos.Id) { throw new GeneralException(Resources.AccountHasBoundThisPOS); } else { throw new GeneralException(Resources.AccountHasBoundOtherPOS); } } if (pos.Status) { throw new GeneralException(Resources.POSHasBoundOtherAccount); } UserAccount userAccount = null; if (!string.IsNullOrEmpty(account.InvitationCode)) { userAccount = new UserAccountDAC().GetByInvitationCode(account.InvitationCode); } POSMerchantBindRecord posBindRecord = new POSMerchantBindRecord { POSId = pos.Id, SN = pos.Sn, MerchantId = account.Id, MerchantUsername = account.Username, BindTime = DateTime.UtcNow, BindStatus = (byte)POSBindStatus.Binded }; using (var scope = new TransactionScope()) { account.POSId = pos.Id; accountDac.BindPos(account); posDac.ActivePOS(pos); new POSMerchantBindRecordDAC().Insert(posBindRecord); if (!string.IsNullOrEmpty(account.InvitationCode) && userAccount != null) { ReBindInviter(posSN, account.Id, userAccount.Id, account.InvitationCode); } scope.Complete(); } return(GetAccessToken(pos, account)); }
public SignonDTO Signup(int countryId, string cellphone, string merchantAccount, string merchantName, string posSn, string invitationCode, string pin) { SecurityVerify.Verify <FiiiPosSignUpVerify>(new CustomVerifier("FiiiPosSignUp"), SystemPlatform.FiiiPOS, $"{countryId}:{cellphone}", (model) => { return(model.CellphoneVerified); }); var country = new CountryComponent().GetById(countryId); if (country == null) { throw new CommonException(10000, Resources.国家不存在); } var cacheKey = $"{countryId}{cellphone}"; var verifier = new FiiiPosRegisterVerifier(); var dic = verifier.GetRegisterModel(SystemPlatform.FiiiPOS, cacheKey, false); MerchantAccount excistAccount = new MerchantAccountDAC().GetByUsername(merchantAccount); if (excistAccount != null) { throw new CommonException(ReasonCode.ACCOUNT_EXISTS, Resources.帐号已存在); } UserAccount inviterAccount = new UserAccount(); if (!string.IsNullOrEmpty(invitationCode)) { inviterAccount = new UserAccountDAC().GetUserAccountByInviteCode(invitationCode); if (inviterAccount == null) { throw new CommonException(ReasonCode.INVITORCODE_NOT_EXISTS, Resources.邀请码不存在); } } var posDac = new POSDAC(); var pos = posDac.GetInactivedBySn(posSn); if (pos == null) { throw new CommonException(ReasonCode.POSSN_ERROR, Resources.SN码不存在); } var merchantMS = new MasterSettingDAC().SelectByGroup("Merchant"); Guid beInvitedAccountId = Guid.NewGuid(); MerchantAccount account = new MerchantAccount { CountryId = countryId, Cellphone = cellphone, Username = merchantAccount, MerchantName = merchantName, PIN = PasswordHasher.HashPassword(pin), Id = beInvitedAccountId, POSId = pos.Id, IsVerifiedEmail = false, PhoneCode = dic["PhoneCode"], RegistrationDate = DateTime.UtcNow, Status = AccountStatus.Active, SecretKey = beInvitedAccountId.ToString(), FiatCurrency = dic["FiatCurrency"], Markup = Convert.ToDecimal(merchantMS.First(e => e.Name == "Merchant_Markup").Value), Receivables_Tier = Convert.ToDecimal(merchantMS.First(e => e.Name == "Merchant_TransactionFee").Value), //默认开启手机验证 ValidationFlag = (byte)ValidationFlag.Cellphone, InvitationCode = invitationCode }; POSMerchantBindRecord posBindRecord = new POSMerchantBindRecord { POSId = pos.Id, SN = pos.Sn, MerchantId = account.Id, MerchantUsername = merchantAccount, BindTime = DateTime.UtcNow, BindStatus = (byte)POSBindStatus.Binded }; MerchantProfile profile = new MerchantProfile { MerchantId = account.Id, Country = account.CountryId, Cellphone = account.Cellphone, L1VerifyStatus = VerifyStatus.Uncertified, L2VerifyStatus = VerifyStatus.Uncertified }; MerchantProfileAgent agent = new MerchantProfileAgent(); bool addProfileResult = agent.AddMerchant(profile); if (!addProfileResult) { throw new CommonException(ReasonCode.GENERAL_ERROR, "Add merchant profile error."); } int recordId = default(int); try { using (var scope = new TransactionScope()) { posDac.ActivePOS(pos); new MerchantAccountDAC().Insert(account); recordId = new POSMerchantBindRecordDAC().Insert(posBindRecord); if (!string.IsNullOrEmpty(invitationCode)) { BindInviter(posSn, beInvitedAccountId, inviterAccount.Id, invitationCode); } scope.Complete(); } } catch (Exception ex) { agent.RemoveMerchantById(profile); //LogHelper.Error(ex); throw; } if (!string.IsNullOrEmpty(invitationCode)) { RabbitMQSender.SendMessage("InvitePosBindSuccess", new Tuple <Guid, long>(inviterAccount.Id, recordId)); } verifier.DeleteCacheModel(SystemPlatform.FiiiPOS, cacheKey); return(GetAccessToken(pos, account)); }