Ejemplo n.º 1
0
        public void ModifyCellphone(Guid accountId, string cellphone, string smsToken, string token, string gToken)
        {
            //
            var dac     = new MerchantAccountDAC();
            var account = dac.GetById(accountId);

            if (account.Cellphone == cellphone)
            {
                throw new CommonException(ReasonCode.FiiiPosReasonCode.CELLPHONE_MUST_BE_DIFFERENT, "新手机号码不能与原来的一致");
            }

            //验证短信码
            SecurityVerification sv = new SecurityVerification(SystemPlatform.FiiiPOS);

            sv.VerifyToken(accountId, smsToken, SecurityMethod.CellphoneCode);

            //验证pin码
            sv.VerifyToken(accountId, token, SecurityMethod.Pin);

            //验证google token 20180521
            new SecurityVerification(SystemPlatform.FiiiPOS).VerifyToken(accountId, gToken, SecurityMethod.SecurityValidate);

            //修改手机号
            dac.UpdateCellphone(accountId, cellphone);
        }
Ejemplo n.º 2
0
        public TransferResult FiiiPOSTransferToEx(Guid accountId, int cryptoId, decimal amount, string pinToken)
        {
            var securityVerify = new SecurityVerification(SystemPlatform.FiiiPOS);

            securityVerify.VerifyToken(accountId, pinToken, SecurityMethod.Pin);

            var openAccountDac = new OpenAccountDAC();
            var openAccount    = openAccountDac.GetOpenAccount(FiiiType.FiiiPOS, accountId);

            if (openAccount == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.FiiiExAccountNotExist);
            }

            var crypto = new CryptocurrencyDAC().GetById(cryptoId);

            if (crypto == null)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, R.CurrencyForbidden);
            }

            var walletDac = new MerchantWalletDAC();
            var wallet    = walletDac.GetByAccountId(accountId, crypto.Id);

            if (wallet.Balance < amount)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.余额不足);
            }
            //10091=参数不符合要求 10013=用户信息不存在 10020=币不存在 0=成功
            int result = FiiiExCoinIn(openAccount.OpenId, crypto.Code, amount, out string recordId);

            if (result != 0)
            {
                throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.从FiiiEx划转失败);
            }
            MerchantExTransferOrder order;

            using (var scope = new TransactionScope())
            {
                walletDac.Decrease(wallet.Id, amount);
                order = new MerchantExTransferOrder
                {
                    Timestamp  = DateTime.UtcNow,
                    OrderNo    = CreateOrderNo(),
                    OrderType  = ExTransferType.ToEx,
                    AccountId  = accountId,
                    WalletId   = wallet.Id,
                    CryptoId   = crypto.Id,
                    CryptoCode = crypto.Code,
                    Amount     = amount,
                    Status     = 1,
                    Remark     = null,
                    ExId       = recordId
                };

                order = new MerchantExTransferOrderDAC().Create(order);
                scope.Complete();
            }

            try
            {
                FiiiEXTransferMSMQ.PubMerchantTransferToEx(order.Id, 0);
            }
            catch (Exception ex)
            {
                LogHelper.Info("FiiiPOSTransferToEx - error", ex);
            }

            return(new TransferResult
            {
                Id = order.Id,
                Amount = order.Amount.ToString(crypto.DecimalPlace),
                OrderNo = order.OrderNo,
                Timestamp = order.Timestamp.ToUnixTime(),
                CryptoCode = crypto.Code
            });
        }