public static void PubMerchantTransferToEx(long orderId, int priority) { LogHelper.Info($"Send MerchantTransferToEx msmq: {FiiiPayIpAddress}MerchantTransferToEx: orderId={orderId}"); RabbitMQSender.SendMessage("MerchantTransferToEx", orderId); //MSMQHelper msmq = new MSMQHelper(FiiiPosIpAddress + "MerchantTransferToEx", true); //msmq.SendMessage<long>(orderId, (MessagePriority)priority); }
/// <summary> /// 支付网关发起支付 /// </summary> /// <param name="tradeId">支付网关订单号</param> public GatewayOrderInfoOM GatewayPay(string tradeId) { var orderDetail = GetGatewayOrderDetail(tradeId); if (orderDetail == null) { throw new CommonException(GATEWAY_ORDER_NOT_EXISTS, Resources.EMGatewayOrderNotExist); } if (!orderDetail.UserAccountId.HasValue) { throw new CommonException(GATEWAY_ORDER_NOT_EXISTS, Resources.EMGatewayOrderNotExist); } var id = Guid.NewGuid(); ExcutePay(orderDetail, id); RabbitMQSender.SendMessage("FiiiPay_Gateway_PayCompleted", tradeId); return(new GatewayOrderInfoOM() { Timestamp = DateTime.UtcNow.ToUnixTime().ToString(), OrderId = orderDetail.Id, MerchantName = orderDetail.MerchantName, CryptoCode = orderDetail.Crypto, ActurlCryptoAmount = orderDetail.ActualCryptoAmount }); }
public static void PubRefundOrder(string orderno, int priority) { RabbitMQSender.SendMessage("RefundOrder", orderno); //MSMQHelper msmq = new MSMQHelper(FiiiPayIpAddress + "RefundOrder", true); //msmq.SendMessage<string>(orderno, (MessagePriority)priority); _log.Info($"Send order({orderno})'s refunded message success."); }
public ResultDto Refund(RefundVo model) { var result = new ResultDto(); var mallDac = new MallPaymentOrderDAC(); var order = mallDac.GetByOrderId(model.OrderId); if (order.Status != OrderStatus.Completed) { result.Code = OrderNoTrade; result.Message = Resource.OrderNoTrade; return(result); } if (order.Status == OrderStatus.Refunded) { result.Code = RefundedError; result.Message = Resource.RefundedError; return(result); } if (order.CryptoAmount != model.CryptoAmount) { result.Code = TradeAmountError; result.Message = Resource.TradeAmountError; return(result); } RabbitMQSender.SendMessage("PaymentGatewayRefund", order); result.Message = Resource.Success; return(result); }
//public void MiningConfirmed(List<Tuple<byte, Guid, decimal>> accountList) //{ // if (accountList == null || accountList.Count <= 0) // return; // MiningInfo info; // foreach (var item in accountList) // { // info = new MiningInfo { AccountType = item.Item1, AccountId = item.Item2, Amount = item.Item3 }; // RabbitMQSender.SendMessage("MiningConfirmed", JsonConvert.SerializeObject(info)); // } //} public void MiningConfirmed(byte accountType, Guid accountId, decimal amount) { var info = new MiningInfo { AccountType = accountType, AccountId = accountId, Amount = amount }; RabbitMQSender.SendMessage("MiningConfirmed", JsonConvert.SerializeObject(info)); }
private MerchantWithdrawal WithdrawalToOutside(MerchantWallet fromWallet, MerchantWithdrawal fromWithdraw, Cryptocurrency cryptocurrency, MerchantAccount account, decimal amount, decimal fee, string address, string tag, string clientIP) { var actualAmount = amount - fee; ILog _logger = LogManager.GetLogger("LogicError"); using (var scope = new TransactionScope()) { try { fromWithdraw.Status = TransactionStatus.UnSubmit; fromWithdraw = new MerchantWithdrawalDAC().Create(fromWithdraw); var fromWithdrawFee = new MerchantWithdrawalFee { Amount = amount, Fee = fee, Timestamp = DateTime.UtcNow, WithdrawalId = fromWithdraw.Id }; new MerchantWithdrawalFeeDAC().Create(fromWithdrawFee); new MerchantWalletDAC().Freeze(fromWallet.Id, amount); //var requestInfo = new FiiiFinanceAgent().TryCreateWithdraw(requestModel); //new MerchantWithdrawalDAC().UpdateTransactionId(fromWithdraw.Id, requestInfo.RequestID, // requestInfo.TransactionId); scope.Complete(); } catch (CommonException) { throw; } catch (Exception ex) { _logger.Info($"Withdraw ApplyWithdrawal faild.WithdrawID:{fromWithdraw.Id},OrderNo:{fromWithdraw.OrderNo}.request Parameter - . Error message:{ex.Message}"); throw; } } var requestModel = new CreateWithdrawModel { AccountID = account.Id, AccountType = AccountTypeEnum.Merchant, CryptoName = cryptocurrency.Code, ReceivingAddress = address, DestinationTag = tag, Amount = actualAmount, IPAddress = clientIP, TransactionFee = fee, WithdrawalId = fromWithdraw.Id }; RabbitMQSender.SendMessage("WithdrawSubmit", requestModel); return(fromWithdraw); }
public SaveResult SaveMerchantProfileVerifyL1(int AdminId, string AdminName, MerchantProfile profile) { var oldProfile = GetMerchantProfile(profile.MerchantId); var merchantAccount = FiiiPayDB.MerchantAccountDb.GetById(profile.MerchantId); merchantAccount.L1VerifyStatus = profile.L1VerifyStatus; if (oldProfile == null) { return(new SaveResult(false, "Data error")); } var profileSDK = new MerchantProfileAgent(); var verifyStatus = profileSDK.UpdateL1VerifyStatus(oldProfile.MerchantId, profile.L1VerifyStatus, profile.L1Remark); if (verifyStatus) { FiiiPayDB.MerchantAccountDb.Update(merchantAccount); if ((profile.L1VerifyStatus == VerifyStatus.Certified || profile.L1VerifyStatus == VerifyStatus.Disapproval)) { var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords() { AccountId = profile.MerchantId, Username = merchantAccount.Username, Body = profile.L1Remark, Type = profile.L1VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.MerchantLv1Verified : VerifyRecordType.MerchantLv1Reject, CreateTime = DateTime.UtcNow }); try { if (profile.L1VerifyStatus == VerifyStatus.Certified) { RabbitMQSender.SendMessage("MerchantLv1Verified", recordId); } else if (profile.L1VerifyStatus == VerifyStatus.Disapproval) { RabbitMQSender.SendMessage("MerchantLv1VerifiedFailed", recordId); } } catch (Exception ex) { log.Error(ex.Message); } } } ActionLog actionLog = new ActionLog(); actionLog.AccountId = AdminId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(MerchantProfileBLL).FullName + ".SaveMerchantProfileVerifyL1"; actionLog.Username = AdminName; actionLog.LogContent = string.Format("verify merchant profile.MerchantId:{0},l1verifystatus:{1}", profile.MerchantId, profile.L1VerifyStatus.ToString()); new ActionLogBLL().Create(actionLog); return(new SaveResult(verifyStatus)); }
private static void SendNotificationMessage(TradeType type, Guid mallId, string orderId, string tradeNo, string result) { RabbitMQSender.SendMessage("PaymentNotification", new NotificationModel { Type = type, OrderId = orderId, MallId = mallId, TradeNo = tradeNo, Status = result }); }
public SaveResult SaveResidenceVerify(int AdminId, string AdminName, UserProfile profile) { var oldProfile = GetUserProfile(profile.UserAccountId.Value); var userAccount = FiiiPayDB.UserAccountDb.GetById(profile.UserAccountId); userAccount.L2VerifyStatus = profile.L2VerifyStatus.Value; if (oldProfile == null) { return(new SaveResult(false, "Data error")); } var profileSDK = new UserProfileAgent(); var status = profileSDK.UpdateL2Status(profile.UserAccountId.Value, profile.L2VerifyStatus.Value, profile.L2Remark); if (status) { FiiiPayDB.UserAccountDb.Update(userAccount); if ((profile.L2VerifyStatus == VerifyStatus.Certified || profile.L2VerifyStatus == VerifyStatus.Disapproval)) { var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords() { AccountId = profile.UserAccountId.Value, Username = userAccount.Cellphone, Body = profile.L2Remark, Type = profile.L2VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.UserLv2Verified : VerifyRecordType.UserLv2Reject, CreateTime = DateTime.UtcNow }); if (profile.L2VerifyStatus == VerifyStatus.Certified) { RabbitMQSender.SendMessage("UserKYC_LV2_VERIFIED", recordId); } else if (profile.L2VerifyStatus == VerifyStatus.Disapproval) { RabbitMQSender.SendMessage("UserKYC_LV2_REJECT", recordId); } } } ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = AdminId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(UserProfileBLL).FullName + ".SaveResidenceVerify"; actionLog.Username = AdminName; actionLog.LogContent = string.Format("verify user residence.accountId:{0},verifystatus:{1}", profile.UserAccountId, profile.L1VerifyStatus.ToString()); new ActionLogBLL().Create(actionLog); return(new SaveResult(status)); }
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 SaveResult SaveProfileVerify(MerchantInformations info, int AdminId, string AdminName) { var oldInfo = FiiiPayDB.MerchantInformationDb.GetById(info.Id); //oldInfo.VerifyStatus = info.VerifyStatus; //oldInfo.Remark = info.Remark; //oldInfo.VerifyDate = DateTime.Now; var result = FiiiPayDB.MerchantInformationDb.Update(c => new MerchantInformations { VerifyStatus = info.VerifyStatus, Remark = info.Remark, VerifyDate = DateTime.UtcNow }, w => w.Id == info.Id); if (result && (info.VerifyStatus == VerifyStatus.Certified || info.VerifyStatus == VerifyStatus.Disapproval)) { var recordId = FiiiPayDB.VerifyRecordDb.InsertReturnIdentity(new VerifyRecords() { AccountId = info.MerchantAccountId, Username = "", Body = info.Remark, Type = info.VerifyStatus == VerifyStatus.Certified ? VerifyRecordType.StoreVerified : VerifyRecordType.StoreReject, CreateTime = DateTime.UtcNow }); if (info.VerifyStatus == VerifyStatus.Certified) { RabbitMQSender.SendMessage("STORE_VERIFIED", oldInfo.Id); } else if (info.VerifyStatus == VerifyStatus.Disapproval) { RabbitMQSender.SendMessage("STORE_REJECT", oldInfo.Id); } } ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = AdminId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(StoreManageBLL).FullName + ".SaveProfileVerify"; actionLog.Username = AdminName; actionLog.LogContent = string.Format("verify store merchantId:{0},verifystatus:{1}", info.MerchantAccountId, info.VerifyStatus.ToString()); new ActionLogBLL().Create(actionLog); return(new SaveResult(result)); }
public SaveResult Update(Articles article, int userId, string userName) { Articles oldArticle = FiiiPayDB.ArticlesDb.GetById(article.Id); oldArticle.Title = article.Title; oldArticle.ShouldPop = article.ShouldPop; oldArticle.Body = article.Body; oldArticle.Descdescription = article.Descdescription; oldArticle.AccountType = article.AccountType; oldArticle.UpdateTime = DateTime.UtcNow; bool saveSuccess = FiiiPayDB.ArticlesDb.Update(oldArticle); if (article.ShouldPop && article.ShouldPop && saveSuccess && (!article.HasPushed.HasValue || !article.HasPushed.Value)) { if (article.AccountType == ArticleAccountType.FiiiPay) { //Utils.MSMQ.UserArticle(article.Id,0); RabbitMQSender.SendMessage("UserArticle", article.Id); } else { RabbitMQSender.SendMessage("MerchantArticle", article.Id); } } // Create ActionLog ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = userId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(ArticleBLL).FullName + ".Update"; actionLog.Username = userName; actionLog.LogContent = "Update Article " + article.Id; ActionLogBLL ab = new ActionLogBLL(); ab.Create(actionLog); return(new SaveResult(saveSuccess)); }
public SaveResult Refund(string orderNo) { var sdk = new RefundAgent(); try { var result = sdk.Refund(orderNo); if (result) { //MSMQ.BackOfficeUserRefundOrder(orderNo, 0); //MSMQ.BackOfficeMerchantArticleRefundOrder(orderNo, 0); RabbitMQSender.SendMessage("FiiiPay_BackOfficeRefundOrder", orderNo); RabbitMQSender.SendMessage("FiiiPos_BackOfficeRefundOrder", orderNo); } return(new SaveResult(true)); } catch (CommonException ex) { return(new SaveResult(false, ex.Message)); } }
static void Main(string[] args) { Console.WriteLine("Please enter your name"); string name = Console.ReadLine(); RegisterTypes(); var connectionDetail = new RabbitMQConnectionDetail() { HostName = "localhost", UserName = "******", Password = "******" }; using (var scope = Container.BeginLifetimeScope()) { var connection = scope.Resolve <IRabbitMQConnectionFactory>(new TypedParameter(typeof(RabbitMQConnectionDetail), connectionDetail)); var client = new RabbitMQSender(connection.CreateConnection().CreateModel()); client.SendMessage(name); } string message = $"Hello my name is, {name}"; }
public SaveResult Update(BillerOrders order, int userId, string userName) { BillerOrders oldOrders = FiiiPayDB.BillerOrderDb.GetById(order.Id); oldOrders.Status = order.Status; oldOrders.Remark = order.Remark; oldOrders.FinishTime = DateTime.UtcNow; var result = FiiiPayDB.BillerOrderDb.Update(oldOrders); if (result && order.Status == BillerOrderStatus.Fail) { result = new RefundAgent().BillerRefund(oldOrders.OrderNo); } FiiiPayDB.DB.Updateable <UserTransactions>().SetColumns(t => new UserTransactions() { Status = (byte)order.Status }) .Where(w => w.Type == UserTransactionType.BillOrder && w.DetailId == oldOrders.Id.ToString() && w.AccountId == oldOrders.AccountId); // Create ActionLog ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = userId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(AccountBLL).FullName + ".Update"; actionLog.Username = userName; actionLog.LogContent = "Update BillerOrder " + order.Id; ActionLogBLL ab = new ActionLogBLL(); ab.Create(actionLog); if (order.Status != BillerOrderStatus.Pending) { RabbitMQSender.SendMessage("Biller", order.Id); } return(new SaveResult(result)); }
public SaveResult Create(Articles article, int userId, string userName) { article.CreateTime = DateTime.UtcNow; var articleId = FiiiPayDB.ArticlesDb.InsertReturnIdentity(article); bool saveSuccess = articleId > 0; if (article.ShouldPop && article.ShouldPop && saveSuccess && (!article.HasPushed.HasValue || !article.HasPushed.Value)) { if (article.AccountType == ArticleAccountType.FiiiPay) { //Utils.MSMQ.UserArticle(articleId,0); RabbitMQSender.SendMessage("UserArticle", articleId); } else { //Utils.MSMQ.MerchantArticle(articleId,0); RabbitMQSender.SendMessage("MerchantArticle", articleId); } article.HasPushed = true; article.Id = articleId; FiiiPayDB.ArticlesDb.Update(article); } if (saveSuccess) { ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = userId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(ArticleBLL).FullName + ".Create"; actionLog.Username = userName; actionLog.LogContent = "Create Article " + articleId; new ActionLogBLL().Create(actionLog); } return(new SaveResult(saveSuccess)); }
//private readonly Dictionary<string, int> _notificationErrorCount = new Dictionary<string, int>(); public void Payment(string message) { var orderModel = JsonConvert.DeserializeObject <MallPaymentOrder>(message); var userWalletDac = new UserWalletDAC(); var walletStatementDac = new UserWalletStatementDAC(); var gatewayOrderDac = new GatewayOrderDAC(); var mallDac = new MallPaymentOrderDAC(); var cryptoDac = new CryptocurrencyDAC(); var extsis = gatewayOrderDac.GetByOrderNo(orderModel.OrderId); if (extsis != null && extsis.Status == GatewayOrderStatus.Completed) { _log.Info("Order message " + message + " hased Payment."); return; } var cryptoFiii = cryptoDac.GetByCode("FIII"); var fiiiWallet = userWalletDac.GetByAccountId(orderModel.UserAccountId, cryptoFiii.Id); if (fiiiWallet.Balance < orderModel.CryptoAmount) { _log.ErrorFormat("message {0}, Insufficient balance", message); } try { var fiiiPrice = GetMarketPrice("USD", "FIII"); var fiiiFiatAmount = Math.Round(orderModel.CryptoAmount * fiiiPrice, 2); var trdeNo = NumberGenerator.GenerateUnixOrderNo(); var id = Guid.NewGuid(); using (var scope = new TransactionScope()) { userWalletDac.Decrease(fiiiWallet.Id, orderModel.CryptoAmount); walletStatementDac.Insert(new UserWalletStatement { WalletId = fiiiWallet.Id, Action = UserWalletStatementAction.Consume, Amount = -orderModel.CryptoAmount, Balance = fiiiWallet.Balance - orderModel.CryptoAmount, FrozenAmount = 0, FrozenBalance = fiiiWallet.FrozenBalance, Timestamp = DateTime.UtcNow }); var gatewayFiiiOrder = new GatewayOrder { Id = id, OrderNo = orderModel.OrderId, MerchantAccountId = Guid.Empty, MerchantName = "FiiiShop", CryptoId = cryptoFiii.Id, CryptoCode = "FIII", FiatAmount = fiiiFiatAmount, FiatCurrency = "USD", Status = GatewayOrderStatus.Completed, ExpiredTime = DateTime.UtcNow.AddMinutes(30), Markup = 0M, ExchangeRate = fiiiPrice, PaymentTime = DateTime.UtcNow, Timestamp = DateTime.UtcNow, UserAccountId = orderModel.UserAccountId, ActualCryptoAmount = orderModel.CryptoAmount, ActualFiatAmount = fiiiFiatAmount, CryptoAmount = orderModel.CryptoAmount, TransactionFee = 0, Remark = null, TradeNo = trdeNo }; gatewayOrderDac.Insert(gatewayFiiiOrder); mallDac.UpdateStatus(orderModel.Id, (byte)OrderStatus.Completed); mallDac.UpdateTradeNo(orderModel.Id, trdeNo); scope.Complete(); } RabbitMQSender.SendMessage("ShopPayment", id); SendNotificationMessage(TradeType.Payment, orderModel.Id, orderModel.OrderId, trdeNo, "success"); } catch (Exception exception) { //SendNotificationMessage(TradeType.Payment, orderModel.Id, orderModel.OrderId, string.Empty, "error"); _log.Error("Payment error, exception : " + exception.Message); } }
public void Refund(string message) { var orderModel = JsonConvert.DeserializeObject <MallPaymentOrder>(message); var userWalletDac = new UserWalletDAC(); var walletStatementDac = new UserWalletStatementDAC(); var gatewayOrderDac = new GatewayOrderDAC(); var mallDac = new MallPaymentOrderDAC(); var refundDac = new GatewayRefundOrderDAC(); var gatewayOrder = gatewayOrderDac.GetByTradeNo(orderModel.TradeNo); if (gatewayOrder.Status == GatewayOrderStatus.Pending) { _log.Error("Order message " + message + " not payment."); return; } if (gatewayOrder.Status == GatewayOrderStatus.Refunded) { _log.Info("Order message " + message + " has refund."); return; } var fiiiWallet = userWalletDac.GetByCryptoCode(orderModel.UserAccountId, "FIII"); try { var id = Guid.NewGuid(); var refundTradeNo = NumberGenerator.GenerateUnixOrderNo(); using (var scope = new TransactionScope()) { mallDac.UpdateStatus(orderModel.Id, (byte)OrderStatus.Refunded); mallDac.UpdateRefundTradeNo(orderModel.Id, refundTradeNo); gatewayOrderDac.UpdateStatus(gatewayOrder.Id, (byte)OrderStatus.Refunded); userWalletDac.Increase(fiiiWallet.Id, gatewayOrder.CryptoAmount); walletStatementDac.Insert(new UserWalletStatement { WalletId = fiiiWallet.Id, Action = UserWalletStatementAction.Refund, Amount = orderModel.CryptoAmount, Balance = fiiiWallet.Balance + gatewayOrder.CryptoAmount, FrozenAmount = 0, FrozenBalance = fiiiWallet.FrozenBalance, Timestamp = DateTime.UtcNow }); refundDac.Insert(new GatewayRefundOrder { Id = id, OrderId = gatewayOrder.Id, Remark = "", Status = RefundStatus.Completed, Timestamp = DateTime.UtcNow, RefundTradeNo = refundTradeNo }); scope.Complete(); } RabbitMQSender.SendMessage("ShopPaymentRefund", id); SendNotificationMessage(TradeType.Refund, orderModel.Id, orderModel.OrderId, refundTradeNo, "success"); } catch (Exception exception) { _log.Error("Refund error, exception : " + exception.Message); //SendNotificationMessage(TradeType.Refund, orderModel.Id, orderModel.OrderId, string.Empty, "error"); } }
public static void PubUserDeposit(long id, int priority) { RabbitMQSender.SendMessage("UserDeposit", id); _log.Info($"Send user deposit order({id})'s completed message success."); }
public override void PubWithdrawCompleted(long withdrawalId) { //UserMSMQ.PubUserWithdrawCompleted(withdrawalId, 0); RabbitMQSender.SendMessage("UserWithdrawCompleted", withdrawalId); _log.Info($"Send user withdraw order({withdrawalId})'s completed message success."); }
public override void PubDepositCancel(long depositId) { //UserMSMQ.PubUserDepositCancel(depositId, 0); RabbitMQSender.SendMessage("UserDepositCancel", depositId); _log.Info($"Send user deposit order({depositId})'s canceled message success."); }
public override void PubDepositCancel(long id) { //MerchantMSMQ.PubMerchantDepositCancel(depositId,0); RabbitMQSender.SendMessage("MerchantDepositCancel", id); _log.Info($"Send merchant deposit order ({id})'s canceled message success."); }
public override void PubDeposit(long id) { //MerchantMSMQ.PubMerchantDeposit(id,0); RabbitMQSender.SendMessage("MerchantDeposit", id); _log.Info($"Send merchant deposit order({id})'s completed message success."); }
public ResultDto Payment(PaymentVo model) { var result = new ResultDto(); var userAccountId = model.UserId; var userAccountDac = new UserAccountDAC(); var userWalletDac = new UserWalletDAC(); var mallDac = new MallPaymentOrderDAC(); var account = userAccountDac.GetById(userAccountId); if (account == null) { result.Code = AccountNotFound; result.Message = Resource.AccountNotFound; return(result); } if (!PasswordHasher.VerifyHashedPassword(account.Pin, model.PIN)) { result.Code = PINError; result.Message = Resource.PINError; return(result); } var wallet = userWalletDac.GetByCryptoCode(userAccountId, "FIII"); if (wallet == null) { result.Code = WalletNotFound; result.Message = Resource.WalletNotFound; return(result); } if (wallet.Balance < model.CryptoAmount) { result.Code = InsufficientBalance; result.Message = Resource.InsufficientBalance; return(result); } var extisorder = mallDac.GetByOrderId(model.OrderId); if (extisorder != null && extisorder.Status == OrderStatus.Completed) { result.Code = OrderExist; result.Message = Resource.OrderExist; return(result); } try { if (extisorder == null) { var order = new MallPaymentOrder { Id = Guid.NewGuid(), CryptoAmount = model.CryptoAmount, ExpiredTime = DateTime.UtcNow.AddMinutes(30), OrderId = model.OrderId, Remark = "", Status = OrderStatus.Pending, Timestamp = DateTime.UtcNow, UserAccountId = userAccountId, RefundTradeNo = string.Empty, TradeNo = string.Empty }; mallDac.Create(order); RabbitMQSender.SendMessage("PaymentGatewayPayOrder", order); } else { RabbitMQSender.SendMessage("PaymentGatewayPayOrder", extisorder); } result.Message = Resource.Success; return(result); } catch (Exception exception) { _log.Error(exception); result.Code = PaymentError; result.Message = Resource.PaymentError; return(result); } }
public static void PubUserInviteSuccessed(long id, int priority) { RabbitMQSender.SendMessage("MerchantInviteSuccessed", id); _log.Info($"Send user invite order({id})'s successed message success."); }
public static void PubMerchantWithdrawReject(long id, int priority) { RabbitMQSender.SendMessage("MerchantWithdrawReject", id); _log.Info($"Send merchant withdraw order({id})'s rejected message success."); }
public static void PubMerchantDepositCancel(long id, int priority) { RabbitMQSender.SendMessage("MerchantDepositCancel", id); _log.Info($"Send merchant deposit order ({id})'s canceled message success."); }
public override void PubWithdrawCompleted(long id) { //MerchantMSMQ.PubMerchantWithdrawCompleted(withdrawalId,0); RabbitMQSender.SendMessage("MerchantWithdrawCompleted", id); _log.Info($"Send merchant withdraw order({id})'s completed message success."); }
public override void PubDeposit(long id) { //UserMSMQ.PubUserDeposit(id, 0); RabbitMQSender.SendMessage("UserDeposit", id); _log.Info($"Send user deposit order({id})'s completed message success."); }
public TransferOM Transfer(UserAccount account, TransferIM im) { SecurityVerify.Verify(new PinVerifier(), SystemPlatform.FiiiPay, account.Id.ToString(), account.Pin, im.Pin); if (account.L1VerifyStatus != VerifyStatus.Certified) { throw new ApplicationException(); } if (account.IsAllowTransfer.HasValue && !account.IsAllowTransfer.Value) { throw new CommonException(ReasonCode.TRANSFER_FORBIDDEN, MessageResources.TransferForbidden); } var toAccount = new UserAccountDAC().GetByCountryIdAndCellphone(im.ToCountryId, im.ToCellphone); if (toAccount == null) { throw new CommonException(ReasonCode.ACCOUNT_NOT_EXISTS, MessageResources.AccountNotExist); } if (toAccount.IsAllowTransfer.HasValue && !toAccount.IsAllowTransfer.Value) { throw new CommonException(ReasonCode.TRANSFER_FORBIDDEN, MessageResources.ToAccountTransferForbidden); } if (im.Amount >= Convert.ToDecimal(Math.Pow(10, 11))) { throw new CommonException(ReasonCode.TRANSFER_AMOUNT_OVERFLOW, MessageResources.TransferAmountOverflow); } var currency = new CryptocurrencyDAC().GetById(im.CoinId); if (!currency.Status.HasFlag(CryptoStatus.Transfer) || currency.Enable == 0) { throw new CommonException(ReasonCode.CURRENCY_FORBIDDEN, MessageResources.CurrencyForbidden); } if (im.Amount < (decimal)Math.Pow(10, -currency.DecimalPlace)) { throw new CommonException(ReasonCode.TRANSFER_AMOUNT_OVERFLOW, MessageResources.TransferAmountTooSmall); } var decimalDigits = im.Amount.ToString().Length - im.Amount.ToString().IndexOf('.') - 1; if (decimalDigits > currency.DecimalPlace) { throw new CommonException(ReasonCode.TRANSFER_AMOUNT_OVERFLOW, MessageResources.TransferAmountOverflow); } if (account.Id == toAccount.Id) { throw new CommonException(ReasonCode.TRANSFER_TO_SELF, MessageResources.TransferToSelf); } var uwComponent = new UserWalletComponent(); var toWallet = uwComponent.GetUserWallet(toAccount.Id, im.CoinId); if (toWallet == null) { toWallet = uwComponent.GenerateWallet(toAccount.Id, currency.Id); } var country = new CountryComponent().GetById(im.ToCountryId); DateTime dtCreateTime = DateTime.UtcNow; var fromWallet = uwComponent.GetUserWallet(account.Id, im.CoinId); if (fromWallet.Balance < im.Amount) { throw new CommonException(ReasonCode.TRANSFER_BALANCE_LOW, MessageResources.TransferBalanceLow); } UserTransfer transfer = new UserTransfer { Timestamp = dtCreateTime, OrderNo = CreateOrderno(), FromUserAccountId = account.Id, FromUserWalletId = fromWallet.Id, CoinId = currency.Id, CoinCode = currency.Code, ToUserAccountId = toAccount.Id, ToUserWalletId = toWallet.Id, Amount = im.Amount, Status = (byte)TransactionStatus.Confirmed }; var uwDAC = new UserWalletDAC(); var uwsDAC = new UserWalletStatementDAC(); var utDAC = new UserTransactionDAC(); //var pushComponent = new FiiiPayPushComponent(); using (var scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, new TimeSpan(0, 0, 1, 30))) { transfer.Id = new UserTransferDAC().Insert(transfer); utDAC.Insert(new UserTransaction { Id = Guid.NewGuid(), AccountId = transfer.FromUserAccountId, CryptoId = transfer.CoinId, CryptoCode = transfer.CoinCode, Type = UserTransactionType.TransferOut, DetailId = transfer.Id.ToString(), Status = transfer.Status, Timestamp = dtCreateTime, Amount = transfer.Amount, OrderNo = transfer.OrderNo }); utDAC.Insert(new UserTransaction { Id = Guid.NewGuid(), AccountId = transfer.ToUserAccountId, CryptoId = transfer.CoinId, CryptoCode = transfer.CoinCode, Type = UserTransactionType.TransferIn, DetailId = transfer.Id.ToString(), Status = transfer.Status, Timestamp = dtCreateTime, Amount = transfer.Amount, OrderNo = transfer.OrderNo }); uwDAC.Decrease(fromWallet.Id, transfer.Amount); uwDAC.Increase(toWallet.Id, transfer.Amount); uwsDAC.Insert(new UserWalletStatement { WalletId = fromWallet.Id, Action = UserWalletStatementAction.TansferOut, Amount = -transfer.Amount, Balance = fromWallet.Balance - transfer.Amount, FrozenAmount = 0, FrozenBalance = fromWallet.FrozenBalance, Timestamp = dtCreateTime }); uwsDAC.Insert(new UserWalletStatement { WalletId = toWallet.Id, Action = UserWalletStatementAction.TansferIn, Amount = transfer.Amount, Balance = toWallet.Balance + transfer.Amount, FrozenAmount = 0, FrozenBalance = toWallet.FrozenBalance, Timestamp = dtCreateTime }); scope.Complete(); } RabbitMQSender.SendMessage("UserTransferOutFiiiPay", transfer.Id); RabbitMQSender.SendMessage("UserTransferIntoFiiiPay", transfer.Id); //pushComponent.PushTransferOut(transfer.Id); //pushComponent.PushTransferInto(transfer.Id); return(new TransferOM { Timestamp = dtCreateTime.ToUnixTime().ToString(), TracingId = transfer.Id, TracingNo = transfer.OrderNo, AccountName = country.PhoneCode + " " + toAccount.Cellphone }); }