From 7a540f529d2c9a541993bc9818cad9c9093fec91 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期三, 03 十二月 2025 11:04:35 +0800
Subject: [PATCH] fix: bug
---
LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs
index 74ddb7b..cf0adc1 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs
@@ -1,4 +1,5 @@
-锘縰sing LifePayment.Application.Contracts;
+锘縰sing Alipay.AopSdk.Core.Domain;
+using LifePayment.Application.Contracts;
using LifePayment.Domain;
using LifePayment.Domain.Shared;
using Medallion.Threading;
@@ -53,7 +54,7 @@
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
- [UnitOfWork]
+ [UnitOfWork(false)]
public async Task<WxRechargeNotifyResult> WxRechargeNotify(WxRechargeNotifyInput input)
{
try
@@ -64,12 +65,13 @@
_logger.LogInformation($"鐢熸椿绠″寰俊鍏呭�煎洖璋冮�氱煡data锛�" + data);
var wxPayNotice = JsonConvert.DeserializeObject<WxPayNotice>(data);
+ await using var orderLock = await distributedLock.TryAcquireAsync($"LockKey:UpdateOrder:{wxPayNotice.OutTradeNo}", TimeSpan.FromSeconds(60));
+ _logger.LogInformation($"閿侊細LockKey:UpdateOrder:{wxPayNotice.OutTradeNo} - {orderLock != null}");
+
if (wxPayNotice.OutTradeNo.Contains("JF"))
{
if (wxPayNotice.TradeState == LifePaymentConstant.WxPayStatus.鏀粯鎴愬姛)
{
- await using var orderLock = await distributedLock.TryAcquireAsync($"LockKey:UpdateOrder:{wxPayNotice.OutTradeNo}", TimeSpan.FromSeconds(60));
- _logger.LogInformation($"閿侊細LockKey:UpdateOrder:{wxPayNotice.OutTradeNo} - {orderLock != null}");
var key = $"WxRechargeNotify_{wxPayNotice.OutTradeNo}";
if (string.IsNullOrWhiteSpace(distributedCache.Get(key)))
@@ -93,6 +95,9 @@
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
});
+
+ await CurrentUnitOfWork.SaveChangesAsync();
+ _logger.LogInformation("浜嬪姟瀹屾垚");
}
else
{
@@ -112,6 +117,7 @@
catch (Exception ex)
{
await CurrentUnitOfWork.RollbackAsync();
+ _logger.LogError($"寰俊鏀粯鍥炶皟寮傚父锛歿ex.Message}", ex);
return new WxRechargeNotifyResult
{
Code = "FAIL",
@@ -136,7 +142,8 @@
{
try
{
- _logger.LogError($"寰俊閫�娆惧洖璋冮�氱煡锛氳繘鍏ュ井淇″洖璋�");
+ var req = input.ToJson();
+ _logger.LogError($"寰俊閫�娆惧洖璋冮�氱煡锛氳繘鍏ュ井淇″洖璋冿細" + req);
var data = _wxPayApi.AesGcmDecrypt(input.Resource.AssociatedData, input.Resource.Nonce, input.Resource.Ciphertext);
_logger.LogError($"寰俊閫�娆惧洖璋冮�氱煡data锛�" + data);
var wxPayNotice = JsonConvert.DeserializeObject<WxPayDomesticRefundsNotice>(data);
@@ -170,7 +177,7 @@
}
catch (Exception ex)
{
-
+ _logger.LogError($"寰俊閫�娆惧洖璋冮�氱煡閿欒锛�" + ex.Message);
return new WxRechargeNotifyResult
{
Code = "FAIL",
@@ -183,5 +190,38 @@
Code = "SUCCESS",
};
}
+
+ [HttpPost]
+ [UnitOfWork]
+ public async Task WxPayDomesticRefundsNotifyImp(WxPayDomesticRefundsNotice input)
+ {
+ var wxPayNotice = input;
+ if (wxPayNotice.OutTradeNo.Contains("JF"))
+ {
+
+ switch (wxPayNotice.RefundStatus)
+ {
+ case LifePaymentConstant.WxPayRefundStatus.閫�娆炬垚鍔�:
+ await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.宸查��娆�);
+ // 鎻掑叆鏀舵敮娴佹按
+ await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
+ {
+ OrderNo = wxPayNotice.OutTradeNo,
+ OutRefundNo = wxPayNotice.OutRefundNo,
+ OutOrderNo = wxPayNotice.TransactionId,
+ LifePayType = LifePayTypeEnum.WxPay,
+ ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts,
+ Amount = wxPayNotice.Amount.Total
+ });
+ break;
+ case LifePaymentConstant.WxPayRefundStatus.閫�娆惧叧闂�:
+ case LifePaymentConstant.WxPayRefundStatus.閫�娆惧鐞嗕腑:
+ case LifePaymentConstant.WxPayRefundStatus.閫�娆惧紓甯�:
+ await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);
+ break;
+ default: await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑); break;
+ }
+ }
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.1