| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [UnitOfWork] |
| | | [UnitOfWork(false)] |
| | | public async Task<WxRechargeNotifyResult> WxRechargeNotify(WxRechargeNotifyInput input) |
| | | { |
| | | try |
| | |
| | | _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))) |
| | |
| | | { |
| | | AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10) |
| | | }); |
| | | |
| | | await CurrentUnitOfWork.CompleteAsync(); |
| | | _logger.LogInformation("事务完成"); |
| | | } |
| | | else |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | await CurrentUnitOfWork.RollbackAsync(); |
| | | _logger.LogError($"微信支付回调异常:{ex.Message}", ex); |
| | | return new WxRechargeNotifyResult |
| | | { |
| | | Code = "FAIL", |