示例#1
0
        public GetOpenedSecuritiesOM GetMerchantOpenedSecurities(Guid merchantId)
        {
            var merchant = new MerchantAccountDAC().GetById(merchantId);

            if (merchant == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Resources.用户不存在);
            }
            GetOpenedSecuritiesOM entity = new GetOpenedSecuritiesOM();

            entity.IsOpenedAuthencator = ValidationFlagComponent.CheckSecurityOpened(merchant.ValidationFlag, ValidationFlag.GooogleAuthenticator);
            entity.CellPhone           = GetMaskedCellphone(merchant.PhoneCode, merchant.Cellphone);
            return(entity);
        }
示例#2
0
        public GetStatusOfSecurityOM GetMerchantStatusOfSecurity(Guid merchantId)
        {
            var merchant = new MerchantAccountDAC().GetById(merchantId);

            if (merchant == null)
            {
                throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, Resources.用户不存在);
            }
            GetStatusOfSecurityOM entity = new GetStatusOfSecurityOM();

            entity.GoogleAuthenticator = new SecurityStatus
            {
                HasBinded = !string.IsNullOrEmpty(merchant.AuthSecretKey),
                HasOpened = ValidationFlagComponent.CheckSecurityOpened(merchant.ValidationFlag, ValidationFlag.GooogleAuthenticator)
            };
            return(entity);
        }
        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 AccountNeedVerifyInfo VerifyMerchantAccount(int countryId, string cellphone, string code, string merchantAccount)
        {
            SecurityVerify.Verify(new BindAccountCellphoneVerifier(), SystemPlatform.FiiiPOS, merchantAccount, code);

            var accountDac = new MerchantAccountDAC();
            var account    = accountDac.GetByUsername(merchantAccount);

            if (account == null)
            {
                throw new GeneralException(Resources.AccountNotExists);
            }

            var country = new CountryComponent().GetById(countryId);

            if (country == null)
            {
                throw new CommonException(10000, Resources.国家不存在);
            }

            string fullCellphone = $"{account.PhoneCode}{account.Cellphone}";

            if (!string.Equals(fullCellphone, country.PhoneCode + cellphone, StringComparison.InvariantCulture))
            {
                throw new GeneralException(Resources.当前手机号与账号绑定的手机号不一致);
            }

            var model = new BindAccountVerify
            {
                MerchantAccount   = merchantAccount,
                CellphoneVerified = true
            };

            SecurityVerify.SetModel(new CustomVerifier("BindAccount"), SystemPlatform.FiiiPOS, merchantAccount, model);

            return(new AccountNeedVerifyInfo
            {
                PIN = true,
                GoogleAuth = ValidationFlagComponent.CheckSecurityOpened(account.ValidationFlag, ValidationFlag.GooogleAuthenticator)
            });
        }
        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));
        }