From e6fa2ea5f826c22382ac7dc4462097f5d4aa014f Mon Sep 17 00:00:00 2001 From: zpc Date: Wed, 28 Aug 2024 14:33:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AE=A2=E5=8D=95=E5=8F=91?= =?UTF-8?q?=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppExtend/AppConfigurationExtend.cs | 12 ++ .../Base/RedisConnection.cs | 18 ++ .../Payment/PaymentExtend.cs | 2 +- .../Users/UserCurrencyBLL.cs | 14 +- .../DbSqlServer/Db_MiaoYu/MiaoYuContext.cs | 74 ++++++++ .../DbSqlServer/Db_MiaoYu/T_Order.cs | 68 +++++++ .../DbSqlServer/Db_MiaoYu/T_OrderItems.cs | 37 ++++ .../DbSqlServer/Db_MiaoYu/T_User_Currency.cs | 6 +- .../EnumModel/OrderState.cs | 31 +++ .../Controllers/PayController.cs | 179 ++++++++++++++++-- 10 files changed, 410 insertions(+), 31 deletions(-) create mode 100644 src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Order.cs create mode 100644 src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_OrderItems.cs create mode 100644 src/0-core/HuanMeng.MiaoYu.Model/EnumModel/OrderState.cs diff --git a/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs index 9f4cfc6..ed27bfa 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/AppExtend/AppConfigurationExtend.cs @@ -60,6 +60,18 @@ namespace HuanMeng.MiaoYu.Code.AppExtend return AppConfigs.FirstOrDefault().Value; } + /// + /// 获取配置项 + /// + /// + /// + public static AppConfig? GetAppConfigIdentifier(string identifier) + { + var app = AppConfigs.Where(it => it.Value.Identifier == identifier).Select(it => it.Value).FirstOrDefault(); + + return app; + } + /// /// 配置版本号 diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Base/RedisConnection.cs b/src/0-core/HuanMeng.MiaoYu.Code/Base/RedisConnection.cs index 267dd1c..695a243 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/Base/RedisConnection.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/Base/RedisConnection.cs @@ -1,3 +1,7 @@ +using HuanMeng.MiaoYu.Code.AppExtend; + +using Microsoft.IdentityModel.Tokens; + using StackExchange.Redis; using System; @@ -38,6 +42,20 @@ namespace HuanMeng.MiaoYu.Code.Base //database.StringSet("", "", TimeSpan.FromSeconds(10),when: When.NotExists); return database; } + + /// + /// + /// + /// + /// + public static IDatabase GetRedis(AppConfig appConfig) + { + if (appConfig == null || string.IsNullOrEmpty(appConfig.RedisConnectionString)) + { + throw new ArgumentNullException("AppConfig不能为空"); + } + return GetRedis(appConfig.RedisConnectionString); + } /// /// /// diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs index ede5d5f..cac5059 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs @@ -134,7 +134,7 @@ namespace HuanMeng.MiaoYu.Code.Payment Notes = "", ProductId = productCache.ProductId, Quantity = 1, - Status = 0, + Status = (int)OrderState.已下单, UpdatedAt = DateTime.Now, OrderId = orderId, }; diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Users/UserCurrencyBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Users/UserCurrencyBLL.cs index 618ef2a..45ba2d8 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/Users/UserCurrencyBLL.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/Users/UserCurrencyBLL.cs @@ -108,14 +108,14 @@ namespace HuanMeng.MiaoYu.Code.Users /// /// /// - public static bool ConsumeMoneyNoWork(this T_User user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null) + public static bool ConsumeMoneyNoWork(this T_User user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string remarks = "") { if (user == null || user.Id == 0) { throw new ArgumentNullException("用户不能为空"); } int userId = user.Id; - return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, _currency); + return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, _currency, remarks); } /// /// 扣除或者充值货币 @@ -128,14 +128,14 @@ namespace HuanMeng.MiaoYu.Code.Users /// /// /// - public static bool ConsumeMoneyNoWork(this T_User_Data user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null) + public static bool ConsumeMoneyNoWork(this T_User_Data user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string remarks = "") { if (user == null || user.UserId == 0) { throw new ArgumentNullException("用户不能为空"); } int userId = user.UserId; - return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, _currency); + return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, _currency, remarks); } @@ -170,7 +170,7 @@ namespace HuanMeng.MiaoYu.Code.Users /// 数据库 /// /// - public static bool ConsumeMoneyNoWork(int userId, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null) + public static bool ConsumeMoneyNoWork(int userId, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string remarks = "") { var userCurrency = dao.daoDbMiaoYu.context.T_User_Currency.FirstOrDefault(it => it.UserId == userId && it.CurrencyType == (int)userCurrencyType); if (userCurrency == null) @@ -204,7 +204,7 @@ namespace HuanMeng.MiaoYu.Code.Users if (userCurrencyType == UserCurrencyType.聊天次数 && userCurrencyConsumeType == UserCurrencyConsumeType.消耗) { var mintes = DateTime.Now.AddMinutes(-5); - log = dao.daoDbMiaoYu.context.T_User_Currency_Log.Where(it => it.CreateTime > mintes).OrderByDescending(it => it.CreateTime).FirstOrDefault(); + log = dao.daoDbMiaoYu.context.T_User_Currency_Log.Where(it => it.CreateTime > mintes && it.ConsumeType == (int)UserCurrencyConsumeType.消耗 && it.CurrencyType == (int)userCurrencyType).OrderByDescending(it => it.CreateTime).FirstOrDefault(); } var tempMoney = Math.Abs(money); //消费 @@ -219,7 +219,7 @@ namespace HuanMeng.MiaoYu.Code.Users TenantId = dao.daoDbMiaoYu.context.TenantInfo.TenantId, UpdateTime = DateTime.Now, UserId = userId, - Remarks = "" + Remarks = remarks }; dao.daoDbMiaoYu.context.T_User_Currency_Log.Add(log); } diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs index 6ca8953..febdf84 100644 --- a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs @@ -148,6 +148,16 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext /// public virtual DbSet T_Model_Config { get; set; } + /// + /// 订单完成表 + /// + public virtual DbSet T_Order { get; set; } + + /// + /// 订单详情表 + /// + public virtual DbSet T_OrderItems { get; set; } + /// /// 商城表 /// @@ -828,6 +838,70 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext } }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_Order__3214EC07C8DD7EE1"); + + entity.ToTable(tb => tb.HasComment("订单完成表")); + + entity.Property(e => e.CreatedAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.OrderDate) + .HasComment("订单创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.OrderId) + .HasMaxLength(64) + .HasComment("订单编号"); + entity.Property(e => e.PaymentDate) + .HasComment("订单支付时间") + .HasColumnType("datetime"); + entity.Property(e => e.PaymentDay).HasComment("订单创建天"); + entity.Property(e => e.PaymentMethod) + .HasMaxLength(10) + .HasComment("订单支付方式"); + entity.Property(e => e.ProductId) + .HasMaxLength(100) + .HasComment("购买的产品Id"); + entity.Property(e => e.Status).HasComment("订单状态"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.TotalPrice) + .HasComment("价格") + .HasColumnType("money"); + entity.Property(e => e.UpdatedAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_OrderI__3214EC077E53EC22"); + + entity.ToTable(tb => tb.HasComment("订单详情表")); + + entity.Property(e => e.OrderId) + .HasMaxLength(64) + .HasComment("订单id"); + entity.Property(e => e.PaymentInfo).HasComment("支付信息"); + entity.Property(e => e.Product).HasComment("产品id、主键"); + entity.Property(e => e.ProductId) + .HasMaxLength(100) + .HasComment("产品id"); + entity.Property(e => e.RewardInfo).HasComment("发放奖励信息"); + entity.Property(e => e.TenantId).HasComment("租户"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK__T_Products__3214EC07DC10A165"); diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Order.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Order.cs new file mode 100644 index 0000000..b601d46 --- /dev/null +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_Order.cs @@ -0,0 +1,68 @@ +using System; + +namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu; + +/// +/// 订单完成表 +/// +public partial class T_Order: MultiTenantEntity +{ + public virtual int Id { get; set; } + + public override Guid TenantId { get; set; } + + /// + /// 订单编号 + /// + public virtual string OrderId { get; set; } = null!; + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 订单创建时间 + /// + public virtual DateTime OrderDate { get; set; } + + /// + /// 订单支付时间 + /// + public virtual DateTime PaymentDate { get; set; } + + /// + /// 订单支付方式 + /// + public virtual string PaymentMethod { get; set; } = null!; + + /// + /// 购买的产品Id + /// + public virtual string ProductId { get; set; } = null!; + + /// + /// 价格 + /// + public virtual decimal TotalPrice { get; set; } + + /// + /// 订单状态 + /// + public virtual int Status { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreatedAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdatedAt { get; set; } + + /// + /// 订单创建天 + /// + public virtual DateOnly PaymentDay { get; set; } +} diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_OrderItems.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_OrderItems.cs new file mode 100644 index 0000000..9f84d65 --- /dev/null +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_OrderItems.cs @@ -0,0 +1,37 @@ + +namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu; + +/// +/// 订单详情表 +/// +public partial class T_OrderItems: MultiTenantEntity +{ + public virtual int Id { get; set; } + + public override Guid TenantId { get; set; } + + /// + /// 产品id + /// + public virtual string ProductId { get; set; } = null!; + + /// + /// 订单id + /// + public virtual string OrderId { get; set; } = null!; + + /// + /// 发放奖励信息 + /// + public virtual string? RewardInfo { get; set; } + + /// + /// 产品id、主键 + /// + public virtual int Product { get; set; } + + /// + /// 支付信息 + /// + public virtual string? PaymentInfo { get; set; } +} diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Currency.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Currency.cs index 9669557..7ce616d 100644 --- a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Currency.cs +++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/T_User_Currency.cs @@ -1,11 +1,11 @@ -using System; +using System; namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu; /// /// 用户货币表 /// -public partial class T_User_Currency: MultiTenantEntity +public partial class T_User_Currency : MultiTenantEntity { public virtual int Id { get; set; } @@ -40,4 +40,4 @@ public partial class T_User_Currency: MultiTenantEntity public virtual int UserId { get; set; } public override Guid TenantId { get; set; } - } +} diff --git a/src/0-core/HuanMeng.MiaoYu.Model/EnumModel/OrderState.cs b/src/0-core/HuanMeng.MiaoYu.Model/EnumModel/OrderState.cs new file mode 100644 index 0000000..7f85e7d --- /dev/null +++ b/src/0-core/HuanMeng.MiaoYu.Model/EnumModel/OrderState.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HuanMeng.MiaoYu.Model.EnumModel +{ + /// + /// 订单状态 + /// + public enum OrderState + { + /// + /// 已下单 + /// + 已下单 = 0, + /// + /// 正在发货 + /// + 正在发货 = 1, + /// + /// 已完成 + /// + 已完成 = 2, + /// + /// 发货失败 + /// + 发货失败 = 3 + } +} diff --git a/src/2-api/HuanMeng.MiaoYu.WebPayApi/Controllers/PayController.cs b/src/2-api/HuanMeng.MiaoYu.WebPayApi/Controllers/PayController.cs index 981c964..99d81be 100644 --- a/src/2-api/HuanMeng.MiaoYu.WebPayApi/Controllers/PayController.cs +++ b/src/2-api/HuanMeng.MiaoYu.WebPayApi/Controllers/PayController.cs @@ -1,40 +1,178 @@ +using HuanMeng.DotNetCore.MultiTenant.Contract; +using HuanMeng.DotNetCore.Utility; +using HuanMeng.MiaoYu.Code.AppExtend; +using HuanMeng.MiaoYu.Code.Base; +using HuanMeng.MiaoYu.Code.DataAccess; +using HuanMeng.MiaoYu.Code.Payment; +using HuanMeng.MiaoYu.Code.Users; +using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu; +using HuanMeng.MiaoYu.Model.EnumModel; +using HuanMeng.MiaoYu.Model.EnumModel.User; + using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; + +using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models; + +using System; using System.Text; namespace HuanMeng.MiaoYu.WebPayApi.Controllers { [Route("api/[controller]/")] [ApiController] - public class PayController(ILogger logger, IHttpContextAccessor httpContextAccessor) : ControllerBase + public class PayController(ILogger logger, IHttpContextAccessor httpContextAccessor, IServiceProvider serviceProvider) : ControllerBase { - /// - /// - /// - /// - [HttpGet("{tenant?}/{pay?}/{orderId?}")] - public async Task Get(string? tenant, string? pay, string? orderId) - { - var context = httpContextAccessor.HttpContext; - context.Request.EnableBuffering(); // Enable buffering to allow the body to be read multiple times - using (var reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, leaveOpen: true)) - { - var bodyContent = await reader.ReadToEndAsync(); - logger.LogInformation($"请求支付回调接口,请求路径: {context.Request.Path}, 请求Body: {bodyContent}"); - context.Request.Body.Position = 0; - } - return $"success"; - } + ///// + ///// + ///// + ///// + //[HttpGet("{tenant?}/{pay?}/{orderId?}")] + //public async Task Get(string? tenant, string? pay, string? orderId) + //{ + // var context = httpContextAccessor.HttpContext; + // context.Request.EnableBuffering(); // Enable buffering to allow the body to be read multiple times + // using (var reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, leaveOpen: true)) + // { + // var bodyContent = await reader.ReadToEndAsync(); + // logger.LogInformation($"请求支付回调接口,请求路径: {context.Request.Path}, 请求Body: {bodyContent}"); + // context.Request.Body.Position = 0; + // } + // return $"success"; + //} /// - /// ${tenant}/zfb/${orderId} + /// ${tenant}/zfb/${orderId} http://localhost:90/api/Pay/default/wx/WX0T1724769806U000002P001M001RLZ/c2e0468ed21e79ebb4f3164b2a3209ac /// /// [HttpPost("{tenant?}/{pay?}/{orderId?}/{sign?}")] - public async Task Post(string? tenant, string? pay, string? orderId,string? sign) + public async Task Post(string? tenant, string? pay, string? orderId, string? sign) { + #region 验证签名 var context = httpContextAccessor.HttpContext; + var orderInfo = PaymentExtend.ParseCustomString(orderId); + string newSign = $"{tenant}{orderId}{orderInfo.UserId}"; + newSign = MD5Encryption.ComputeMD5Hash(newSign); + //签名不对 + if (newSign != sign) + { + logger.LogError($"{orderId}订单支付签名不对==>{newSign}==>{context.Request.Path}"); + return "error;签名不对"; + } + #endregion + var appConfig = AppConfigurationExtend.GetAppConfigIdentifier(tenant); + if (appConfig == null) + { + return "error;租户不存在"; + } + //重复请求锁 + var baseKey = $"pay:lock:{orderId}"; + var redis = RedisConnection.GetRedis(appConfig); + if (!redis.StringSetLock(baseKey, "", 3)) + { + return "error;重复请求"; + } + var temantInfo = serviceProvider.GetRequiredService(); + appConfig.ToITenantInfo(temantInfo); + DAO dao = new DAO(serviceProvider); + var intentOrder = await dao.daoDbMiaoYu.context.T_User_IntentOrder.FirstOrDefaultAsync(it => it.OrderId == orderId); + if (intentOrder == null) + { + redis.KeyDelete(baseKey); + return "error;订单不存在"; + } + if (intentOrder.Status != (int)OrderState.已下单) + { + redis.KeyDelete(baseKey); + return $"error;订单{((OrderState)intentOrder.Status).ToString()}"; + } + intentOrder.Status = (int)OrderState.正在发货; + await dao.daoDbMiaoYu.context.SaveChangesAsync(); + + var product = await dao.daoDbMiaoYu.context.T_Products.Where(it => it.ProductId == intentOrder.ProductId).FirstOrDefaultAsync(); + if (product == null) + { + intentOrder.Status = (int)OrderState.发货失败; + await dao.daoDbMiaoYu.context.SaveChangesAsync(); + return $"error;订单不存在"; + } + var user = await dao.daoDbMiaoYu.context.T_User.FirstOrDefaultAsync(it => it.Id == intentOrder.UserId); + if (user == null) + { + intentOrder.Status = (int)OrderState.发货失败; + await dao.daoDbMiaoYu.context.SaveChangesAsync(); + return $"error;用户不存在"; + } + var chargeMoneyCount = dao.daoDbMiaoYu.context.T_Order.Count(it => it.UserId == intentOrder.UserId && it.ProductId == it.ProductId); + var productReward = await dao.daoDbMiaoYu.context.T_Products_Reward.Where(it => it.ProductId == intentOrder.ProductId).ToListAsync(); + + if (productReward != null && productReward.Count > 0) + { + using (IDbContextTransaction transaction = dao.daoDbMiaoYu.context.Database.BeginTransaction()) + { + try + { + //List user_Currencies = new List(); + foreach (var reward in productReward) + { + var money = reward.Money; + if (product.IsFirstCharge && chargeMoneyCount == 0) + { + money = reward.FirstChargeMoney ?? reward.Money; + } + var currency = (UserCurrencyType)reward.CurrencyType; + var userCurrency = new T_User_Currency(); + user.ConsumeMoneyNoWork(currency, money, dao, userCurrency, orderId); + } + T_Order order = new T_Order() + { + OrderId = orderId, + CreatedAt = DateTime.Now, + OrderDate = intentOrder.IntentDate, + PaymentDate = DateTime.Now, + PaymentDay = DateOnly.FromDateTime(DateTime.Now), + PaymentMethod = pay, + ProductId = intentOrder.ProductId, + Status = (int)OrderState.已完成, + TenantId = intentOrder.TenantId, + TotalPrice = intentOrder.Price, + UpdatedAt = DateTime.Now, + UserId = intentOrder.UserId, + }; + T_OrderItems t_OrderItems = new T_OrderItems() + { + OrderId = orderId, + PaymentInfo = "", + Product = product.Id, + ProductId = intentOrder.ProductId, + RewardInfo = JsonConvert.SerializeObject(productReward), + TenantId = intentOrder.TenantId, + }; + dao.daoDbMiaoYu.context.T_OrderItems.Add(t_OrderItems); + dao.daoDbMiaoYu.context.T_Order.Add(order); + intentOrder.Status = (int)OrderState.已完成; + await dao.daoDbMiaoYu.context.SaveChangesAsync(); + await transaction.CommitAsync(); + } + catch (Exception ex) + { + await transaction.RollbackAsync(); + intentOrder.Status = (int)OrderState.发货失败; + await dao.daoDbMiaoYu.context.SaveChangesAsync(); + throw; + } + } + + + } + + //redis.ListRightPush("myQueue", "value3"); + //await redis.PublishAsync("order_rewards_queue", orderData); context.Request.EnableBuffering(); // Enable buffering to allow the body to be read multiple times using (var reader = new StreamReader(context.Request.Body, Encoding.UTF8, true, 1024, leaveOpen: true)) { @@ -42,6 +180,7 @@ namespace HuanMeng.MiaoYu.WebPayApi.Controllers logger.LogInformation($"请求支付回调接口,请求路径: {context.Request.Path}, 请求Body: {bodyContent}"); context.Request.Body.Position = 0; } + redis.KeyDelete(baseKey); return $"success"; } }