Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tuple">
        /// Guid为fiiipay用户的id,long为POSMerchantBindRecords的主键
        /// </param>
        public void InviteFiiiposSuccess(Tuple <Guid, long> tuple)
        {
            var record    = new POSMerchantBindRecordDAC().GetById(tuple.Item2);
            var accountId = tuple.Item1;
            var merchant  = new MerchantAccountDAC().GetById(record.MerchantId);

            var regId = RedisHelper.StringGet($"FiiiPay:Notice:UserId:{accountId}");
            var lang  = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"FiiiPay:Language:{accountId}") ?? "en";

            string titleKey    = "InviteFiiiposSuccessTitle";
            string subTitleKey = "InviteFiiiposSuccessSubTitle";

            if (!(_resourcePropertyNames.Contains(titleKey) && _resourcePropertyNames.Contains(subTitleKey)))
            {
                throw new Exception("没有找到资源");
            }
            var title    = ResourceHelper.FiiiPay.GetResource(titleKey, new CultureInfo(lang));
            var subTitle = ResourceHelper.FiiiPay.GetFormatResource(subTitleKey, new CultureInfo(lang), merchant.MerchantName);

            string noticeId = "";

            MessagesComponent.AddMessage(accountId, UserType.User, record.Id.ToString(), FiiiPayPushType.TYPE_INVITE_FIIIPOS_SUCCESS, titleKey, subTitleKey, merchant.MerchantName, title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_INVITE_FIIIPOS_SUCCESS, new List <string> {
                regId
            }, record.Id, title, subTitle, noticeId);

            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
Exemplo n.º 2
0
        public BonusMessageOM InviteFiiiposSuccessMessage(long id)
        {
            var record   = new POSMerchantBindRecordDAC().GetById(id);
            var merchant = new MerchantAccountDAC().GetById(record.MerchantId);

            return(new BonusMessageOM()
            {
                Title = Resources.InviteFiiiposSuccessTitle,
                Content = Format(Resources.InviteFiiiposSuccessSubTitle, merchant.MerchantName),
                Timestamp = record.BindTime.ToUnixTime().ToString()
            });
        }
        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 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));
        }