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 OrderDetailDTO OrderDetail(long accountId, Guid orderId) { InvestorOrder order = new InvestorOrderDAC().GetById(accountId, orderId); if (order == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.订单不存在); } UserAccount userAccount = new UserAccountDAC().GetById(order.UserAccountId); if (userAccount == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.用户不存在); } Country country = new CountryDAC().GetById(userAccount.CountryId); if (country == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.用户不存在); } var profile = new UserProfileAgent().GetUserProfile(userAccount.Id); Cryptocurrency crypto = new CryptocurrencyDAC().GetById(order.CryptoId); return(new OrderDetailDTO { OrderId = order.Id, OrderNo = order.OrderNo, TransactionType = order.TransactionType, Status = order.Status, CryptoCode = crypto.Code, Amount = order.CryptoAmount.ToString(crypto.DecimalPlace), UserAccount = GetMaskedCellphone(country.PhoneCode, userAccount.Cellphone), Username = profile == null ? "" : ((string.IsNullOrEmpty(profile.FirstName) ? "" : "* ") + profile.LastName), Timestamp = order.Timestamp.ToUnixTime() }); }
private async Task <LoginDto> IssueAccessToken(UserAccount user) { //var keyLoginTokenPrefix = "FiiiShop:Token:"; //var keyLoginToken = $"{keyLoginTokenPrefix}{user.Id}"; //var accessToken = AccessTokenGenerator.IssueToken(user.Id.ToString()); //RedisHelper.StringSet(Constant.REDIS_TOKEN_DBINDEX, keyLoginToken, accessToken, TimeSpan.FromSeconds(AccessTokenGenerator.DefaultExpiryTime)); ProfileRouter pRouter = new ProfileRouterDAC().GetRouter(user.CountryId); var profile = GetProfileByAccountId(pRouter, user.Id); string countryCode = ""; if (profile.Country.HasValue) { var country = new CountryDAC().GetById(user.CountryId); if (country != null) { countryCode = country.Code; } } var result = new LoginDto { UserId = user.Id.ToString("N"), Email = user.Email, LastName = profile.LastName, FirstName = profile.FirstName, CountryCode = countryCode, ProvinceName = profile.State, CityName = profile.City, Address = profile.Address1 + (string.IsNullOrEmpty(profile.Address1 + profile.Address2) ? "" : " ") + profile.Address2, Postcode = profile.Postcode, Cellphone = profile.Cellphone }; return(await Task.FromResult(result)); }
public List <Country> ALL() { var countryDAC = new CountryDAC(); return(countryDAC.Select()); }
public TransferResult Transfer(InvestorAccount account, int countryId, string cellphone, decimal amount, string pinToken) { new SecurityVerification(SystemPlatform.FiiiCoinWork).VerifyToken(pinToken, SecurityMethod.Pin); CountryDAC countryDac = new CountryDAC(); UserAccountDAC userAccountDac = new UserAccountDAC(); Country country = countryDac.GetById(countryId); if (country == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.AccountNotExist); } UserAccount userAccount = userAccountDac.GetByCountryIdAndCellphone(countryId, cellphone); if (userAccount == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.AccountNotExist); } InvestorAccountDAC accountDac = new InvestorAccountDAC(); if (account.Balance < amount) { throw new CommonException(ReasonCode.GENERAL_ERROR, R.余额不足); } UserWalletDAC userWalletDac = new UserWalletDAC(); UserWallet userWallet = userWalletDac.GetByAccountId(userAccount.Id, FiiiCoinUtility.Cryptocurrency.Id); InvestorOrder investorOrder; UserDeposit userDeposit; using (var scope = new TransactionScope()) { if (userWallet == null) { userWallet = new UserWalletComponent().GenerateWallet(userAccount.Id, FiiiCoinUtility.Cryptocurrency.Id); } accountDac.Decrease(account.Id, amount); investorOrder = new InvestorOrderDAC().Insert(new InvestorOrder { Id = Guid.NewGuid(), OrderNo = CreateOrderNo(), TransactionType = InvestorTransactionType.Transfer, Status = 1, InverstorAccountId = account.Id, UserAccountId = userAccount.Id, CryptoId = FiiiCoinUtility.Cryptocurrency.Id, CryptoAmount = amount, Timestamp = DateTime.UtcNow }); new InvestorWalletStatementDAC().Insert(new InvestorWalletStatement { Id = Guid.NewGuid(), InvestorId = account.Id, TagAccountId = userAccount.Id, Action = InvestorTransactionType.Transfer, Amount = -amount, Balance = account.Balance - amount, Timestamp = DateTime.UtcNow }); // 2018-06-26: new rules IncreaseFrozen -> Increase userWalletDac.Increase(userWallet.Id, amount); userDeposit = new UserDepositDAC().Insert(new UserDeposit { UserAccountId = userAccount.Id, UserWalletId = userWallet.Id, FromAddress = null, FromTag = null, ToAddress = null, ToTag = null, Amount = amount, Status = TransactionStatus.Confirmed, Timestamp = DateTime.UtcNow, OrderNo = CreateOrderNo(), TransactionId = account.Id.ToString(), SelfPlatform = true, RequestId = null }); scope.Complete(); } InvestorMSMQ.PubUserDeposit(userDeposit.Id, 0); return(new TransferResult { OrderId = investorOrder.Id, OrderNo = investorOrder.OrderNo, TargetAccount = GetMaskedCellphone(country.PhoneCode, userAccount.Cellphone), Timestamp = DateTime.UtcNow.ToUnixTime() }); }
/// <summary> /// Update method. /// </summary> /// <param name="country"></param> public void Edit(Country country) { var countryDac = new CountryDAC(); countryDac.UpdateById(country); }
/// <summary> /// Delete method. /// </summary> /// <param name="id"></param> public void Remove(int id) { var countryDac = new CountryDAC(); countryDac.DeleteById(id); }
/// <summary> /// Add method. /// </summary> /// <param name="country"></param> /// <returns></returns> public Country Add(Country country) { var countryDac = new CountryDAC(); return(countryDac.Create(country)); }
/// <summary> /// /// </summary> /// <param name="Country"></param> public void Edit(Country Country) { var CountryDac = new CountryDAC(); CountryDac.UpdateById(Country); }
public async Task <bool> FiiipayMerchantCreateAsync(UserAccount account, FiiiPayMerchantInfoCreateIM model) { var uaDAC = new UserAccountDAC(); if (account.L1VerifyStatus != VerifyStatus.Certified) { throw new CommonException(ReasonCode.NOT_VERIFY_LV1, Resources.EMNeedLV1Verfied); } var inviteAccount = uaDAC.GetByInvitationCode(model.InviteCode); bool needInviteRecord = true; if (!string.IsNullOrEmpty(model.InviteCode)) { if (inviteAccount == null) { throw new CommonException(ReasonCode.INVITORCODE_NOT_EXISTS, MessageResources.InvalidInvitation); } if (inviteAccount.InvitationCode == account.InvitationCode) { throw new CommonException(ReasonCode.INVALID_INVITECODE, MessageResources.InviteCodeCanotInputSelf); } var existInviteRecord = await new InviteRecordDAC().GetDetailByAccountIdAsync(account.Id, InviteType.FiiipayMerchant); if (existInviteRecord != null) { needInviteRecord = false; } } else { needInviteRecord = false; } var merchantCountry = new CountryDAC().GetById(model.CountryId); if (merchantCountry == null) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (!merchantCountry.IsSupportStore) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } Regions stateRegion; Regions cityRegion; if (model.StateId.HasValue) { stateRegion = await new RegionDAC().GetByIdAsync(model.StateId.Value); if (stateRegion == null) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (stateRegion.CountryId != model.CountryId) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (model.CityId.HasValue) { cityRegion = await new RegionDAC().GetByIdAsync(model.CityId.Value); if (cityRegion == null) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (cityRegion.CountryId != model.CountryId || cityRegion.ParentId != stateRegion.Id) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } } } #region entities Guid merchantInfoId = Guid.NewGuid(); DateTime dtNow = DateTime.UtcNow; MerchantInformation merchantInfo = new MerchantInformation { Id = merchantInfoId, CreateTime = dtNow, FromType = InputFromType.UserInput, MerchantName = model.MerchantName, WeekTxt = model.WeekTxt, Tags = model.TagList == null ? "" : string.Join(",", model.TagList), Introduce = model.Introduce, CountryId = merchantCountry.Id, StateId = model.StateId, CityId = model.CityId, PhoneCode = account.PhoneCode, Address = model.Address, Lng = model.Lng, Lat = model.Lat, Status = Status.Stop, VerifyStatus = VerifyStatus.UnderApproval, MerchantAccountId = account.Id, Phone = model.Phone, IsPublic = Status.Stop, FileId = model.StorefrontImg[0], ThumbnailId = model.StorefrontImg[1], AccountType = AccountType.User, Markup = 0, FeeRate = 0, IsAllowExpense = false, Week = Week.Monday, ApplicantName = model.ApplicantName, UseFiiiDeduct = model.UseFiiiDeduction }; InviteRecord inviteRecord = new InviteRecord { AccountId = account.Id, InviterCode = model.InviteCode, Type = InviteType.FiiipayMerchant, InviterAccountId = inviteAccount?.Id ?? Guid.Empty, Timestamp = dtNow }; FiiipayMerchantVerifyRecord record = new FiiipayMerchantVerifyRecord { CreateTime = dtNow, MerchantInfoId = merchantInfoId, BusinessLicenseImage = model.BusinessLicenseImage, LicenseNo = model.LicenseNo, VerifyStatus = VerifyStatus.UnderApproval }; List <MerchantCategory> categorys = model.MerchantCategorys.Select(t => new MerchantCategory { MerchantInformationId = merchantInfoId, Category = t }).ToList(); List <MerchantOwnersFigure> figuresList = new List <MerchantOwnersFigure>(); if (model.FigureImgList != null) { for (int i = 0; i < model.FigureImgList.Length; i++) { figuresList.Add(new MerchantOwnersFigure { MerchantInformationId = merchantInfoId, FileId = model.FigureImgList[i][0], Sort = i, ThumbnailId = model.FigureImgList[i][1] }); } } var coinList = await new CryptocurrencyDAC().GetAllAsync(); List <MerchantSupportCrypto> supportCryptoList = model.SupportCoins.Select(t => { var c = coinList.Find(m => m.Id == t); if (c != null) { return(new MerchantSupportCrypto { MerchantInfoId = merchantInfoId, CryptoId = t, CryptoCode = c.Code }); } return(null); }).Where(x => x != null).ToList(); #endregion var mInfoDAC = new MerchantInformationDAC(); var fmVerfiyRecordDAC = new FiiipayMerchantVerifyRecordDAC(); var mCategoryDAC = new MerchantCategoryDAC(); var mFigureDAC = new MerchantOwnersFigureDAC(); var mSupportCryptoDAC = new MerchantSupportCryptoDAC(); var inviteDAC = new InviteRecordDAC(); using (var scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 1, 30))) { mInfoDAC.Insert(merchantInfo); fmVerfiyRecordDAC.Insert(record); if (needInviteRecord) { inviteDAC.Insert(inviteRecord); } if (categorys != null && categorys.Count > 0) { foreach (var item in categorys) { mCategoryDAC.Insert(item); } } if (figuresList != null && figuresList.Count > 0) { foreach (var item in figuresList) { mFigureDAC.Insert(item); } } if (supportCryptoList != null && supportCryptoList.Count > 0) { foreach (var item in supportCryptoList) { mSupportCryptoDAC.Insert(item); } } scope.Complete(); } return(true); }