public void PushTransferToEx(long id)
        {
            var order  = new UserExTransferOrderDAC().GetById(id);
            var crypto = new CryptocurrencyDAC().GetById(order.CryptoId);

            var regId = RedisHelper.StringGet($"FiiiPay:Notice:UserId:{order.AccountId}");

            var lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"FiiiPay:Language:{order.AccountId}") ?? "en";
            var titleKey    = "TransferToFiiiExTitle";
            var subTitleKey = "TransferToFiiiExSubTitle";

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

            string noticeId = "";

            //写MongoDB []
            MessagesComponent.AddMessage(order.AccountId, UserType.User, id.ToString(), FiiiPayPushType.TYPE_TRANSFER_TO_EX, titleKey, subTitleKey, crypto.Code, title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_TRANSFER_TO_EX, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
Exemple #2
0
        public UserExTransferOrderOM FiiiPayTransferDetail(UserAccount account, long id)
        {
            var dac   = new UserExTransferOrderDAC();
            var order = dac.GetById(id);

            if (order == null)
            {
                return(null);
            }

            if (order.AccountId != account.Id)
            {
                return(null);
            }

            var coin = new CryptocurrencyDAC().GetById(order.CryptoId);

            return(new UserExTransferOrderOM
            {
                Id = order.Id,
                Amount = order.Amount.ToString(coin.DecimalPlace),
                ExTransferType = order.OrderType,
                ExTransferTypeStr = GetExTransferTypeString(order.OrderType),
                CryptoCode = coin.Code,
                Status = order.Status,
                StatusStr = R.OrderCompleted,
                Timestamp = order.Timestamp.ToUnixTime(),
                OrderNo = order.OrderNo
            });
        }
Exemple #3
0
        public TransferResult FiiiPayTransferToEx(UserAccount account, int cryptoId, decimal amount, string pin)
        {
            new SecurityComponent().VerifyPin(account, pin);

            var openAccountDac = new OpenAccountDAC();
            var openAccount    = openAccountDac.GetOpenAccount(FiiiType.FiiiPay, account.Id);

            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 UserWalletDAC();
            var wallet    = walletDac.GetByAccountId(account.Id, 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失败);
            }
            UserExTransferOrder order;

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

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

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

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