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.Application/LifePay/LifePayService.cs | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 637ff94..258cc91 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -1484,7 +1484,6 @@ order.OutRequestNo = result.RequestNo.IsNullOrEmpty() ? null : result.RequestNo; order.ACOOLYOrderNo = result.ACOOLYOrderNo; order.ACOOLYStatus = ACOOLYStatusEnum.鍏呭�间腑; - await _lifePayOrderRepository.UpdateAsync(order); _logger.LogInformation("鐢熸椿缂磋垂璁㈠崟锛�" + order.ToJson()); /// 鍒涘缓鐢熸椿缂磋垂娑堣垂璁板綍 @@ -1499,9 +1498,9 @@ order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�; order.ACOOLYStatus = ACOOLYStatusEnum.鍏呭�煎け璐�; order.RefundApplyRemark = ex.Message; - await _lifePayOrderRepository.UpdateAsync(order); - _logger.LogError("鐢熸椿缂磋垂璁㈠崟鐘舵�侊細" + order.LifePayOrderStatus.ToString()); } + _logger.LogError("鐢熸椿缂磋垂璁㈠崟鐘舵�侊細" + order.LifePayOrderStatus.ToString()); + await _lifePayOrderRepository.UpdateAsync(order); } public async Task LifePayRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus) @@ -1532,12 +1531,12 @@ /// <returns></returns> public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount, string refundApplyRemark, decimal? parValue = 0, decimal? actualParValue = 0) { + await using var orderLock = await distributedLock.TryAcquireAsync($"LockKey:UpdateOrder:{orderNo}", TimeSpan.FromSeconds(60)); + _logger.LogInformation($"閿侊細LockKey:UpdateOrder:{orderNo} - {orderLock != null}"); + var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�"); - - await using var orderLock = await distributedLock.TryAcquireAsync($"LockKey:UpdateOrder:{orderNo}", TimeSpan.FromSeconds(60)); - _logger.LogInformation($"閿侊細LockKey:UpdateOrder:{orderNo} - {orderLock != null}"); if (order.ACOOLYStatus.HasValue && (int)order.ACOOLYStatus > (int)acoolyStatus) { @@ -1583,8 +1582,6 @@ order.RefundPrice = Math.Round((1 - ((order.ActualReceivedAmount ?? 0) / (order.RechargeAmount ?? 0))) * (order.PayAmount ?? 0), 2); } - await _lifePayOrderRepository.UpdateAsync(order); - if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�) { ///缁撶畻娓犻亾浣i噾 @@ -1610,6 +1607,8 @@ /// 鍒涘缓鐢熸椿缂磋垂娑堣垂璁板綍 await _lifePayOrderService.CreatLifePayConsumption(acoolyStatus, order.OrderNo, order.ACOOLYOrderNo, order.PlatformDeductionAmount ?? 0, order.ChannelId, order.CreationTime, order.FinishTime, order.ChannleRate, parValue, actualParValue); + + await CurrentUnitOfWork.SaveChangesAsync(); } /// <summary> -- Gitblit v1.9.1