diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs
index ef69039d..7498296c 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/PayService.cs
@@ -79,14 +79,15 @@ public class PayService : ApplicationService, IPayService
notifyData[item.Key] = item.Value.ToString();
}
- _logger.LogInformation($"收到支付宝回调通知:{System.Text.Json.JsonSerializer.Serialize(notifyData)}");
+ var signStr = string.Join("&", notifyData.Select(kv => $"{kv.Key}={kv.Value}"));
+ _logger.LogInformation($"收到支付宝回调通知:{signStr}");
// 2. 验证签名
await _alipayManager.VerifyNotifyAsync(notifyData);
// 3. 记录支付通知
- await _payManager.RecordPayNoticeAsync(notifyData);
+ await _payManager.RecordPayNoticeAsync(notifyData,signStr);
// 4. 更新订单状态
var outTradeNo = notifyData.GetValueOrDefault("out_trade_no", string.Empty);
diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Alipay/AlipayManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Alipay/AlipayManager.cs
index 007d2b37..f967fa15 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Alipay/AlipayManager.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Alipay/AlipayManager.cs
@@ -55,7 +55,6 @@ public class AlipayManager : DomainService
///
public Task VerifyNotifyAsync(Dictionary form)
{
- // 注意:不要对参数进行排序,保持支付宝回调的原始参数顺序
// 支付宝的验签需要保持原始参数顺序,排序会导致验签失败
var result = Factory.Payment.Common().VerifyNotify(form);
if (result == false)
diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Pay/PayNoticeRecordAggregateRoot.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Pay/PayNoticeRecordAggregateRoot.cs
index b027788b..b205c773 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Pay/PayNoticeRecordAggregateRoot.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/Pay/PayNoticeRecordAggregateRoot.cs
@@ -55,4 +55,10 @@ public class PayNoticeRecordAggregateRoot: FullAuditedAggregateRoot
///
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string NotifyData { get; set; } = string.Empty;
+
+ ///
+ /// 原始signstr
+ ///
+ [SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
+ public string SignStr { get; set; }
}
\ No newline at end of file
diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/PayManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/PayManager.cs
index 58c91afa..316b4e15 100644
--- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/PayManager.cs
+++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/PayManager.cs
@@ -12,10 +12,10 @@ namespace Yi.Framework.AiHub.Domain.Managers;
///
public class PayManager : DomainService
{
-
private readonly ISqlSugarRepository _payNoticeRepository;
private readonly ICurrentUser _currentUser;
private readonly ISqlSugarRepository _payOrderRepository;
+
public PayManager(
ISqlSugarRepository payNoticeRepository,
ICurrentUser currentUser, ISqlSugarRepository payOrderRepository)
@@ -82,26 +82,31 @@ public class PayManager : DomainService
{
order.TradeNo = tradeNo;
}
+
await _payOrderRepository.UpdateAsync(order);
}
-
+
///
/// 记录支付通知
///
/// 通知数据
+ ///
///
- public async Task RecordPayNoticeAsync(Dictionary notifyData)
+ public async Task RecordPayNoticeAsync(Dictionary notifyData, string signStr)
{
var payNotice = new PayNoticeRecordAggregateRoot
{
- NotifyTime =DateTime.Parse(notifyData.GetValueOrDefault("notify_time", string.Empty)) ,
+ NotifyTime = DateTime.Parse(notifyData.GetValueOrDefault("notify_time", string.Empty)),
TradeNo = notifyData.GetValueOrDefault("trade_no", string.Empty),
OutTradeNo = notifyData.GetValueOrDefault("out_trade_no", string.Empty),
BuyerId = notifyData.GetValueOrDefault("buyer_id", string.Empty),
TradeStatus = ParseTradeStatus(notifyData.GetValueOrDefault("trade_status", string.Empty)),
- TotalAmount = decimal.TryParse(notifyData.GetValueOrDefault("total_amount", "-1"), out var amount) ? amount : 0,
+ TotalAmount = decimal.TryParse(notifyData.GetValueOrDefault("total_amount", "-1"), out var amount)
+ ? amount
+ : 0,
NotifyData = JsonSerializer.Serialize(notifyData),
+ SignStr = signStr
};
await _payNoticeRepository.InsertAsync(payNotice);