321
This commit is contained in:
parent
a0c22015d7
commit
e39fee2352
|
|
@ -39,10 +39,11 @@ namespace CoreCms.Net.Core.Config
|
||||||
typeof(LogingSubscribe),
|
typeof(LogingSubscribe),
|
||||||
|
|
||||||
typeof(UserSubscribe),
|
typeof(UserSubscribe),
|
||||||
# if DEBUG
|
|
||||||
typeof(WeChatPayNoticeSubscribe),
|
typeof(WeChatPayNoticeSubscribe),
|
||||||
# endif
|
|
||||||
typeof(SendWxTemplateMessageSubscribe),
|
typeof(SendWxTemplateMessageSubscribe),
|
||||||
|
|
||||||
typeof(AfterSalesReviewSubscribe),
|
typeof(AfterSalesReviewSubscribe),
|
||||||
};
|
};
|
||||||
//显示日志
|
//显示日志
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||||
using Essensoft.Paylink.WeChatPay;
|
using Essensoft.Paylink.WeChatPay;
|
||||||
using Essensoft.Paylink.WeChatPay.V2;
|
using Essensoft.Paylink.WeChatPay.V2;
|
||||||
using Essensoft.Paylink.WeChatPay.V2.Notify;
|
using Essensoft.Paylink.WeChatPay.V2.Notify;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
||||||
{
|
{
|
||||||
|
|
@ -59,18 +62,38 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// 先读取原始请求 Body
|
||||||
|
Request.EnableBuffering(); // 允许多次读取流
|
||||||
|
string body = "";
|
||||||
|
using (var reader = new StreamReader(Request.Body, Encoding.UTF8, leaveOpen: true))
|
||||||
|
{
|
||||||
|
body = await reader.ReadToEndAsync();
|
||||||
|
Request.Body.Position = 0; // 重置流指针,保证后续能再次读取
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打印原始请求内容(方便定位问题)
|
||||||
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调原始请求", body);
|
||||||
|
|
||||||
|
|
||||||
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调解析结果_optionsAccessor", JsonConvert.SerializeObject(_optionsAccessor.Value));
|
||||||
var notify = await _client.ExecuteAsync<WeChatPayUnifiedOrderNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.ExecuteAsync<WeChatPayUnifiedOrderNotify>(Request, _optionsAccessor.Value);
|
||||||
|
// 打印解析后的对象
|
||||||
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调解析结果", JsonConvert.SerializeObject(notify));
|
||||||
|
|
||||||
|
|
||||||
if (notify.ReturnCode == WeChatPayCode.Success)
|
if (notify.ReturnCode == WeChatPayCode.Success)
|
||||||
{
|
{
|
||||||
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayNotice, JsonConvert.SerializeObject(notify));
|
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.WeChatPayNotice, JsonConvert.SerializeObject(notify));
|
||||||
return WeChatPayNotifyResult.Success;
|
return WeChatPayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调", JsonConvert.SerializeObject(notify));
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调", JsonConvert.SerializeObject(notify));
|
||||||
|
//Request.Body
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调", "统一下单支付结果通知", ex);
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功回调", "统一下单支付结果通知" + $"异常: {ex.Message}", ex);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,9 +156,9 @@
|
||||||
},
|
},
|
||||||
"PayCallBack": {
|
"PayCallBack": {
|
||||||
//微信支付回调
|
//微信支付回调
|
||||||
"WeChatPayUrl": "https://api.demo.coreshop.cn/Notify/WeChatPay/Unifiedorder",
|
"WeChatPayUrl": "https://sqqp.zpc-xy.com/Notify/WeChatPay/Unifiedorder",
|
||||||
//微信退款回调
|
//微信退款回调
|
||||||
"WeChatRefundUrl": "https://api.demo.coreshop.cn/Notify/WeChatPay/Refund",
|
"WeChatRefundUrl": "https://sqqp.zpc-xy.com/Notify/WeChatPay/Refund",
|
||||||
//支付宝支付回调
|
//支付宝支付回调
|
||||||
"AlipayUrl": "",
|
"AlipayUrl": "",
|
||||||
//支付宝退款回调
|
//支付宝退款回调
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user