From e0f2b29f3349d43e7f4222e079c54ba9cc4b6ee1 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期一, 16 六月 2025 11:09:23 +0800 Subject: [PATCH] fix:支付回调及供应商回调并发问题修订 --- LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs index 3ff1a0d..8d1ae98 100644 --- a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs +++ b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs @@ -53,7 +53,7 @@ /// <param name="input"></param> /// <returns></returns> [HttpPost] - [UnitOfWork] + [UnitOfWork(false)] public async Task<WxRechargeNotifyResult> WxRechargeNotify(WxRechargeNotifyInput input) { try @@ -64,11 +64,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)); var key = $"WxRechargeNotify_{wxPayNotice.OutTradeNo}"; if (string.IsNullOrWhiteSpace(distributedCache.Get(key))) @@ -92,6 +94,9 @@ { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10) }); + + await CurrentUnitOfWork.SaveChangesAsync(); + _logger.LogInformation("浜嬪姟瀹屾垚"); } else { @@ -111,6 +116,7 @@ catch (Exception ex) { await CurrentUnitOfWork.RollbackAsync(); + _logger.LogError($"寰俊鏀粯鍥炶皟寮傚父锛歿ex.Message}", ex); return new WxRechargeNotifyResult { Code = "FAIL", -- Gitblit v1.9.1