From 6739e98662c16571da7aec0e9b52fab0afd3833b Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期五, 13 六月 2025 14:07:28 +0800 Subject: [PATCH] fix:修订支付回调和供应商回调并发问题 --- LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs index 74ddb7b..9e30708 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs @@ -53,7 +53,6 @@ /// <param name="input"></param> /// <returns></returns> [HttpPost] - [UnitOfWork] public async Task<WxRechargeNotifyResult> WxRechargeNotify(WxRechargeNotifyInput input) { try @@ -64,12 +63,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 +93,8 @@ { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10) }); + + await CurrentUnitOfWork.SaveChangesAsync(); } else { @@ -111,7 +113,6 @@ } catch (Exception ex) { - await CurrentUnitOfWork.RollbackAsync(); return new WxRechargeNotifyResult { Code = "FAIL", -- Gitblit v1.9.1