示例#1
0
        public MerchantProfile GetMerchantProfile(Guid accountGid)
        {
            var profileSDK = new MerchantProfileAgent();
            var data       = profileSDK.GetMerchantProfile(accountGid);

            return(data);
        }
示例#2
0
        public bool ValidateLv1(Guid MerchantId)
        {
            var agent   = new MerchantProfileAgent();
            var account = agent.GetMerchantProfile(MerchantId);

            return(account.L1VerifyStatus == VerifyStatus.Certified);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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 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);
        }
示例#6
0
        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 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));
        }