From 4400bd4883aab583dd1fb49c1b6d6d833dc36743 Mon Sep 17 00:00:00 2001 From: yzp Date: Fri, 28 Feb 2025 23:26:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?CreatePayTransaction=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=AE=9A=E5=8D=95=E6=97=B6=E5=90=8C=E6=97=B6=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=EF=BC=8C=E5=87=8F=E5=B0=91=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Wechat/Dto/WechatPayOutput.cs | 20 +++++++++---------- .../Service/Wechat/SysWechatPayService.cs | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs b/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs index 5e2bc2e2..d65d1e7b 100644 --- a/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs +++ b/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs @@ -68,23 +68,23 @@ public class CreatePayTransactionOutput { public string PrepayId { get; set; } public string OutTradeNumber { get; set; } - //public WechatPayParaOutput SingInfo { get; set; } + public WechatPayParaOutput SingInfo { get; set; } } -//public class WechatPayParaOutput -//{ -// public string AppId { get; set; } +public class WechatPayParaOutput +{ + public string AppId { get; set; } -// public string TimeStamp { get; set; } + public string TimeStamp { get; set; } -// public string NonceStr { get; set; } + public string NonceStr { get; set; } -// public string Package { get; set; } + public string Package { get; set; } -// public string SignType { get; set; } + public string SignType { get; set; } -// public string PaySign { get; set; } -//} + public string PaySign { get; set; } +} public class CreatePayTransactionNativeOutput { diff --git a/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs b/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs index a7a4fcb5..38eaafa2 100644 --- a/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs @@ -5,6 +5,7 @@ // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! using Furion.Logging.Extensions; +using NewLife; using Newtonsoft.Json; namespace Admin.NET.Core.Service; @@ -135,12 +136,12 @@ public class SysWechatPayService : IDynamicApiController, ITransient await _sysWechatPayRep.InsertAsync(wechatPay); } - //var singInfo = GenerateParametersForJsapiPay(new WechatPayParaInput() { PrepayId = response.PrepayId }); + var singInfo = GenerateParametersForJsapiPay(new WechatPayParaInput() { PrepayId = response.PrepayId }); return new CreatePayTransactionOutput { PrepayId = response.PrepayId, OutTradeNumber = request.OutTradeNumber, - //SingInfo = singInfo + SingInfo = singInfo }; } From e438bbf1f2fad9d168f2cf2edf252095c785c7ba Mon Sep 17 00:00:00 2001 From: yzp Date: Fri, 28 Feb 2025 23:27:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?BUG:=E5=9C=A8TASK=E5=86=85=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=94=AF=E4=BB=98=E6=8B=A6=E6=88=AA=E5=99=A8=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=A4=96=E5=B1=82=E7=9A=84=E4=BB=A3=E7=A0=81=E6=8A=8A?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=86=85=E5=AE=B9=E6=94=B9=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin.NET.Core/Service/Wechat/SysWechatPayService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs b/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs index 38eaafa2..b7659189 100644 --- a/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs @@ -16,7 +16,7 @@ namespace Admin.NET.Core.Service; [ApiDescriptionSettings(Order = 210, Description = "微信支付")] public class SysWechatPayService : IDynamicApiController, ITransient { - private static readonly List wechatPayEventHandlers = [new WechatPayEventInterceptor() { Order = int.MaxValue }]; + private static readonly List wechatPayEventHandlers = new List(); /// /// 注册支付记录变化事件处理器 @@ -311,7 +311,8 @@ public class SysWechatPayService : IDynamicApiController, ITransient { try { - if (!await eh.PayInforChanged(wechatPayOld, wechatPayNew)) + //这里一定要用 DeepCopy 来创一个新的对象传进不,不然会被外面的 主线程改变就麻烦了 + if (!await eh.PayInforChanged(wechatPayOld, wechatPayNew.DeepCopy())) break; } catch (Exception ex) @@ -322,7 +323,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient }); } // 下面这里创建一个新的对象,是因为不想把全部字段都返回 - wechatPayNew = new SysWechatPay() + var result = new SysWechatPay() { AppId = _wechatPayOptions.AppId, MerchantId = _wechatPayOptions.MerchantId, @@ -338,7 +339,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient SuccessTime = response.SuccessTime.HasValue ? response.SuccessTime.Value.DateTime : DateTime.Now // 支付完成时间 }; - return wechatPayNew; + return result; } ///