public void ModifyCellphone(Guid accountId, string cellphone) { var dac = new MerchantAccountDAC(); var account = dac.GetById(accountId); SecurityVerify.Verify <ModifyCellphoneVerify>(new CustomVerifier("ModifyCellphone"), SystemPlatform.FiiiPOS, account.Id.ToString(), (model) => { return(model.PinVerified && model.NewCellphoneVerified && model.CombinedVerified); }); if (account.Cellphone == cellphone) { throw new CommonException(10000, Resources.新手机号码不能与原来的一致); } //修改手机号 dac.UpdateCellphone(accountId, cellphone); var agent = new MerchantProfileAgent(); var profile = new MerchantProfile { MerchantId = accountId, Cellphone = cellphone, Country = account.CountryId }; agent.UpdateCellphone(profile); }
public MerchantProfileSet GetMerchantProfileSet(Guid accountGid) { var profileSDK = new MerchantProfileAgent(); var data = profileSDK.GetMerchantProfileSet(accountGid); return(data); }
public bool ValidateLv1(Guid MerchantId) { var agent = new MerchantProfileAgent(); var account = agent.GetMerchantProfile(MerchantId); return(account.L1VerifyStatus == VerifyStatus.Certified); }
public SaveResult SaveMerchantProfileVerifyL1(int AdminId, string AdminName, MerchantProfile profile) { var oldProfile = GetMerchantProfile(profile.MerchantId); var merchantAccount = FiiiPayDB.MerchantAccountDb.GetById(profile.MerchantId); merchantAccount.L1VerifyStatus = profile.L1VerifyStatus; if (oldProfile == null) { return(new SaveResult(false, "Data error")); } var profileSDK = new MerchantProfileAgent(); var verifyStatus = profileSDK.UpdateL1VerifyStatus(oldProfile.MerchantId, profile.L1VerifyStatus, profile.L1Remark); if (verifyStatus) { FiiiPayDB.MerchantAccountDb.Update(merchantAccount); if ((profile.L1VerifyStatus == VerifyStatus.Certified || profile.L1VerifyStatus == VerifyStatus.Disapproval)) { var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords() { AccountId = profile.MerchantId, Username = merchantAccount.Username, Body = profile.L1Remark, Type = profile.L1VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.MerchantLv1Verified : VerifyRecordType.MerchantLv1Reject, CreateTime = DateTime.UtcNow }); try { if (profile.L1VerifyStatus == VerifyStatus.Certified) { RabbitMQSender.SendMessage("MerchantLv1Verified", recordId); } else if (profile.L1VerifyStatus == VerifyStatus.Disapproval) { RabbitMQSender.SendMessage("MerchantLv1VerifiedFailed", recordId); } } catch (Exception ex) { log.Error(ex.Message); } } } ActionLog actionLog = new ActionLog(); actionLog.AccountId = AdminId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(MerchantProfileBLL).FullName + ".SaveMerchantProfileVerifyL1"; actionLog.Username = AdminName; actionLog.LogContent = string.Format("verify merchant profile.MerchantId:{0},l1verifystatus:{1}", profile.MerchantId, profile.L1VerifyStatus.ToString()); new ActionLogBLL().Create(actionLog); return(new SaveResult(verifyStatus)); }
public void CommitIdentityImage(MerchantProfile profile) { var agent = new MerchantProfileAgent(); var sr = agent.CommitIdentityImage(profile); if (sr) { new MerchantAccountDAC().UpdateL1VerfiyStatus(profile.MerchantId, (byte)VerifyStatus.UnderApproval); } }
/// <summary> /// 修改商家执照认证 /// </summary> /// <param name="merchantId"></param> /// <param name="licenseNo"></param> /// <param name="businessLicense"></param> /// <returns>-1=修改失败 -2=已认证 -3=审核中 1=修改成功</returns> public void UpdateMerchantLicense(Guid merchantId, string companyName, string licenseNo, Guid businessLicense) { MerchantProfileAgent agent = new MerchantProfileAgent(); MerchantProfile profile = agent.GetMerchantProfile(merchantId); if (profile.L2VerifyStatus == VerifyStatus.Certified || profile.L2VerifyStatus == VerifyStatus.UnderApproval) { throw new CommonException(ReasonCode.FiiiPosReasonCode.VERIFYED_STATUS, "已审核的用户不能更改该信息"); } agent.UpdateMerchantLicense(merchantId, companyName, licenseNo, businessLicense); }
public List <Entities.MerchantProfile> GetMerchantProfilePageListL2(string keyword, int countryId, int?status, ref GridPager pager) { var profileSDK = new MerchantProfileAgent(); int totalCount = 0; bool isDesc = (pager.OrderBy.ToLower() == "desc"); List <Entities.MerchantProfile> data = profileSDK.GetMerchantVerifyListL2(keyword, countryId, status, pager.SortColumn, isDesc, pager.Size, pager.Page, out totalCount); pager.TotalPage = (int)Math.Ceiling((double)totalCount / (double)pager.Size); pager.Count = totalCount; return(data); }
/// <summary> /// 获取全局数据库的商家个人信息 /// </summary> /// <param name="merchantId"></param> /// <returns></returns> public MerchantProfile GetMerchantProfile(Guid merchantId) { MerchantProfileAgent agent = new MerchantProfileAgent(); MerchantProfile profile = agent.GetMerchantProfile(merchantId); if (profile == null) { throw new CommonException(ReasonCode.FiiiPosReasonCode.ACCOUNT_NOT_EXISTS, "当前商家个人资料不存在"); } return(profile); }
public void ModifyIdentity(MerchantProfile profile) { var agent = new MerchantProfileAgent(); //需求改变,FIIIPOS的KYC无需证件号限制 //int count = agent.GetCountByIdentityDocNo(profile.MerchantId, profile.IdentityDocNo); //if (count >= Constant.IDENTITY_LIMIT) //{ // throw new CommonException(ReasonCode.IDENTITYNO_USED_OVERLIMIT, Resources.IdentityUsedOverLimit); //} agent.ModifyIdentity(profile); }
/// <summary> /// 修改地址 /// </summary> /// <param name="merchantId"></param> /// <param name="postCode"></param> /// <param name="address1"></param> /// <param name="address2"></param> /// <returns></returns> public void UpdateAddress(Guid merchantId, string postCode, string address, string state, string city) { MerchantProfile model = new MerchantProfile(); model.Address1 = address; model.MerchantId = merchantId; model.Postcode = postCode; model.City = city; model.State = state; MerchantProfileAgent agent = new MerchantProfileAgent(); agent.ModifyAddress1(model); }
public void CommitIdentityImage(MerchantProfile profile) { var agent = new MerchantProfileAgent(); var merchant = new MerchantAccountDAC().GetById(profile.MerchantId); if (merchant.L1VerifyStatus != VerifyStatus.Uncertified && merchant.L1VerifyStatus != VerifyStatus.Disapproval) { throw new CommonException(ReasonCode.FiiiPosReasonCode.COMMITTED_STATUS, "该状态下不能提交审核。"); } var sr = agent.CommitIdentityImage(profile); if (sr) { new MerchantAccountDAC().UpdateL1VerfiyStatus(profile.MerchantId, (byte)VerifyStatus.UnderApproval); } }
public WithdrawalConditionInfo GetWithdrawalInfo(Guid accountId, int cryptoId) { var result = new WithdrawalConditionInfo(); var profileAgent = new MerchantProfileAgent(); var profile = profileAgent.GetMerchantProfile(accountId); var crypto = new CryptocurrencyDAC().GetById(cryptoId); result.NeedTag = crypto.NeedTag; var wallet = new MerchantWalletDAC().GetByAccountId(accountId, cryptoId) ?? GenerateWallet(accountId, cryptoId, crypto.Code); //余额 result.Balance = wallet.Balance.ToString(crypto.DecimalPlace); int level = profile.L2VerifyStatus == VerifyStatus.Certified ? 2 : profile.L1VerifyStatus == VerifyStatus.Certified ? 1 : 0; var masterSetting = GetMerchantWithdrawalMasterSettingWithCrypto(crypto, level); //最小提币量 result.MinWithdrawalAmount = masterSetting.ToOutsideMinAmount.ToString(CultureInfo.InvariantCulture); // to fiiipay min withdraw amount result.ToFiiiPayMinWithdrawalAmount = masterSetting.ToUserMinAmount.ToString(CultureInfo.InvariantCulture); //手续费率 result.HandleFeeTier = (crypto.Withdrawal_Tier ?? 0).ToString(CultureInfo.InvariantCulture); result.HandleFee = (crypto.Withdrawal_Fee ?? 0).ToString(CultureInfo.InvariantCulture); result.DecimalPlace = crypto.DecimalPlace; //限额 result.VerifyLevel = level; result.PerTxLimit = masterSetting.PerTxLimit.ToString(crypto.DecimalPlace); result.PerDayLimit = masterSetting.PerDayLimit.ToString(crypto.DecimalPlace); result.PerMonthLimit = masterSetting.PerMonthLimit.ToString(crypto.DecimalPlace); var dac = new MerchantWithdrawalDAC(); var today = DateTime.UtcNow.Date; decimal dailyWithdrawal = dac.DailyWithdrawal(accountId, cryptoId, today); decimal monthlyWithdrawal = dac.MonthlyWithdrawal(accountId, cryptoId, new DateTime(today.Year, today.Month, 1)); decimal dayUsable = masterSetting.PerDayLimit - dailyWithdrawal; decimal monthUsable = masterSetting.PerMonthLimit - monthlyWithdrawal; dayUsable = Math.Min(dayUsable, monthUsable); result.PerDayUsable = (dayUsable < 0 ? 0 : dayUsable).ToString(crypto.DecimalPlace); result.PerMonthUsable = (monthUsable < 0 ? 0 : monthUsable).ToString(crypto.DecimalPlace); return(result); }
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 void VerifyResetPinCombine(Guid accountId, string idNumber, string smsCode, string googleCode) { MerchantAccount merchant = new MerchantAccountDAC().GetById(accountId); if (merchant == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Resources.用户不存在); } List <CombinedVerifyOption> options = new List <CombinedVerifyOption> { new CombinedVerifyOption { AuthType = (byte)ValidationFlag.Cellphone, Code = smsCode }, new CombinedVerifyOption { AuthType = (byte)ValidationFlag.GooogleAuthenticator, Code = googleCode } }; UserSecrets userSecrets = new UserSecrets { ValidationFlag = merchant.ValidationFlag, GoogleAuthSecretKey = merchant.AuthSecretKey }; MerchantProfile profile = new MerchantProfileAgent().GetMerchantProfile(accountId); if (profile != null && profile.L1VerifyStatus == FiiiPay.Entities.Enums.VerifyStatus.Certified) { options.Add(new CombinedVerifyOption { AuthType = (byte)ValidationFlag.IDNumber, Code = idNumber }); userSecrets.IdentityNo = profile.IdentityDocNo; } SecurityVerify.CombinedVerify(SystemPlatform.FiiiPOS, accountId.ToString(), userSecrets, options); var model = new ResetPinVerify { CombinedVerified = true }; SecurityVerify.SetModel(new CustomVerifier("ResetPin"), SystemPlatform.FiiiPOS, accountId.ToString(), model); }
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); }
/// <summary> /// 修改商家部分account和profiles /// </summary> /// <param name="merchantId"></param> /// <param name="merchantName"></param> /// <param name="email"></param> /// <param name="cityId"></param> /// <param name="postCode"></param> /// <param name="address1"></param> /// <param name="address2"></param> /// <returns></returns> public void UpdateMerchantProfiles(Guid merchantId, string merchantName, string email, int cityId, string postCode, string address1) { MerchantProfileAgent agent = new MerchantProfileAgent(); agent.UpdateMerchantProfiles(merchantId, merchantName, email, postCode, address1, ""); }
public void ModifyFullname(MerchantProfile profile) { var agent = new MerchantProfileAgent(); agent.ModifyFullname(profile); }
public void ModifyAddress1(MerchantProfile profile) { var agent = new MerchantProfileAgent(); agent.ModifyAddress1(profile); }
/// <summary> /// 修改商家头像 /// </summary> /// <param name="merchantId"></param> /// <param name="photoId"></param> /// <returns></returns> public void UpdateMerchantHeadImage(Guid merchantId, string photoId) { MerchantProfileAgent agent = new MerchantProfileAgent(); new MerchantAccountDAC().UpdateMerchantHeadImage(merchantId, photoId); }
public MerchantWithdrawal Withdrawal(Guid accountId, decimal amount, int cryptoId, string address, string tag, string clientIP) { SecurityVerify.Verify <WithdrawVerify>(new CustomVerifier("MerchantWithdraw"), SystemPlatform.FiiiPOS, accountId.ToString(), (model) => { return(model.PinVerified && model.CombinedVerified); }); var cryptocurrency = new CryptocurrencyDAC().GetById(cryptoId); CryptoAddressValidation.ValidateAddress(cryptocurrency.Code, address); if (!string.IsNullOrEmpty(tag)) { CryptoAddressValidation.ValidateTag(cryptocurrency.Code, tag); } var account = new MerchantAccountDAC().GetById(accountId); if (!new ProfileComponent().ValidateLv1(accountId)) { throw new CommonException(ReasonCode.NOT_VERIFY_LV1, Resources.需要Lv1认证才能使用相关功能); } if (!account.IsAllowWithdrawal) { throw new CommonException(ReasonCode.Not_Allow_Withdrawal, Resources.禁止提币); } if (!cryptocurrency.Status.HasFlag(CryptoStatus.Withdrawal)) { throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, Resources.CurrencyForbidden); } if (cryptocurrency.Enable == (byte)CurrencyStatus.Forbidden) { throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, Resources.CurrencyForbidden); } var fromWallet = new MerchantWalletDAC().GetByAccountId(accountId, cryptoId); if (fromWallet == null) { throw new CommonException(ReasonCode.Not_Allow_Withdrawal, Resources.禁止提币); } if (fromWallet.Balance < amount) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.余额不足); } var profileAgent = new MerchantProfileAgent(); var profile = profileAgent.GetMerchantProfile(accountId); int level = profile.L2VerifyStatus == VerifyStatus.Certified ? 2 : profile.L1VerifyStatus == VerifyStatus.Certified ? 1 : 0; var masterSetting = GetMerchantWithdrawalMasterSettingWithCrypto(cryptocurrency, level); if (amount > masterSetting.PerTxLimit) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.能高于单次提币量); } var dac = new MerchantWithdrawalDAC(); var today = DateTime.UtcNow.Date; decimal dailyWithdrawal = dac.DailyWithdrawal(accountId, cryptoId, today); if (amount > masterSetting.PerDayLimit - dailyWithdrawal) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.今日提币达到限额); } decimal monthlyWithdrawal = dac.MonthlyWithdrawal(accountId, cryptoId, new DateTime(today.Year, today.Month, 1)); if (amount > masterSetting.PerMonthLimit - monthlyWithdrawal) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.本月提币达到限额); } var fromWithdraw = new MerchantWithdrawal { MerchantAccountId = accountId, MerchantWalletId = fromWallet.Id, Address = address, Tag = tag, Amount = amount, Status = TransactionStatus.UnSubmit, Timestamp = DateTime.UtcNow, OrderNo = NumberGenerator.GenerateUnixOrderNo(), CryptoId = fromWallet.CryptoId, CryptoCode = fromWallet.CryptoCode }; var merchantWalletDac = new MerchantWalletDAC(); var userWalletDac = new UserWalletDAC(); //是否是商户地址 var toMerchantWallet = merchantWalletDac.GetByAddress(address, cryptocurrency.NeedTag ? tag : null); if (toMerchantWallet != null) { //if (toMerchantWallet.CryptoId != cryptoId) // throw new CommonException(10000, string.Format(Resources.提币地址不是有效的地址, cryptocurrency.Code)); //if (toMerchantWallet.MerchantAccountId == accountId) // throw new CommonException(ReasonCode.CANNOT_TRANSFER_TO_YOURSELF, Resources.提币地址不能是自己账户的地址); //return WithdrawalToMerchantAccount(fromWallet, fromWithdraw, toMerchantWallet); // 042018 throw new CommonException(ReasonCode.CAN_NOT_WITHDRAW_TO_FiiiPOS, Resources.FiiiPOSCantWithdrawToFiiiPOS); } //是否是用户地址 var toUserWallet = userWalletDac.GetByAddressAndCrypto(cryptoId, address, cryptocurrency.NeedTag ? tag : null); if (toUserWallet != null) { if (toUserWallet.CryptoId != cryptoId) { throw new CommonException(ReasonCode.GENERAL_ERROR, FiiiPay.Framework.Component.Properties.GeneralResources.EMInvalidAddress); } if (amount < masterSetting.ToUserMinAmount) { throw new CommonException(10000, Resources.能低于最低提币量); } var fee = (fromWithdraw.Amount * masterSetting.ToUserHandleFeeTier).ToSpecificDecimal(cryptocurrency.DecimalPlace); if (amount <= fee) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.到账数量不能为零或者负数); } return(WithdrawalToUserAccount(fromWallet, fromWithdraw, toUserWallet, fee)); } //平台内提币如果tag不对,创建一条失败记录 if (cryptocurrency.NeedTag && (userWalletDac.IsUserWalletAddress(address) || merchantWalletDac.IsMerchantWalletAddress(address))) { return(CancelWithdrawal(fromWithdraw)); } //如果都不是,提币到场外 if (amount < masterSetting.ToOutsideMinAmount) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.能低于最低提币量); } var baseFee = cryptocurrency.Withdrawal_Fee ?? 0; var tier = cryptocurrency.Withdrawal_Tier ?? 0; var fee1 = (amount * tier).ToSpecificDecimal(cryptocurrency.DecimalPlace); var totalFee = baseFee + fee1; if (amount <= totalFee) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.到账数量不能为零或者负数); } return(WithdrawalToOutside(fromWallet, fromWithdraw, cryptocurrency, account, amount, totalFee, address, tag, clientIP)); }
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)); }