public static void PubPayOrder(SendPayOrderModel model, int priority) { RabbitMQSender.SendMessage <SendPayOrderModel>("PayOrder", model); _log.Info($"Send order({model.OrderNo})'s paying message success."); }
public string CreateOrder(Guid merchantAccountId, string fiatCurrency, int cryptoId, decimal amount, PaymentType paymentType, string userToken, string clientIP) { var accountDAC = new MerchantAccountDAC(); var account = accountDAC.GetById(merchantAccountId); if (!account.IsAllowAcceptPayment) { throw new CommonException(ReasonCode.Not_Allow_Withdrawal, Resources.禁止收款); } var coin = new CryptocurrencyDAC().GetById(cryptoId); if (!coin.Status.HasFlag(CryptoStatus.Pay)) { throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, Resources.CurrencyForbidden); } if (coin.Enable == (byte)CurrencyStatus.Forbidden) { throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, Resources.CurrencyForbidden); } var order = new RedisOrderDTO() { FiatAmount = amount, CryptoId = cryptoId, FiatCurrency = fiatCurrency, MerchantGuid = account.Id, OrderNo = NumberGenerator.GenerateUnixOrderNo(), CountryId = account.CountryId, Markup = account.Markup, Type = paymentType, UserId = Guid.Empty }; Guid?userAccountId = null; if (!string.IsNullOrEmpty(userToken)) { if (!userToken.StartsWith(Constant.PAYMENT_CODE_PREFIX)) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.无效的用户Token); } var paymentInfo = RedisHelper.Get <PaymentCodeDTO>( Constant.REDIS_PAYMENT_CODE_DBINDEX, $"{Constant.REDIS_PAYMENT_CODE_PREFIX}{userToken}"); if (paymentInfo == null) { throw new CommonException(ReasonCode.GENERAL_ERROR, Resources.无效的用户Token); } userAccountId = paymentInfo.UserId; } if (userAccountId.HasValue) { order.UserId = userAccountId.Value; SendPayOrderModel model = new SendPayOrderModel(); model.OrderNo = order.OrderNo; model.UserAccountId = userAccountId.Value.ToString(); MerchantMSMQ.PubPayOrder(model, 0); } RedisHelper.StringSet($"fiiipos:order:{ order.OrderNo}", JsonConvert.SerializeObject(order), TimeSpan.FromMinutes(30)); return(order.OrderNo); }