sunpengfei
2025-06-11 1605af1ced748313e99f38e5eb6888768fbc7d54
LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -18,6 +18,7 @@
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus.Distributed;
using Z.EntityFramework.Plus;
@@ -44,6 +45,7 @@
    private readonly ILifePayOrderService _lifePayOrderService;
    private readonly IDataFilter dataFilter;
    private readonly IChannelFilter _channelFilter;
    private readonly IAbpDistributedLock distributedLock;
    private readonly IAliPayApi _aliPayApi;
    private readonly IAlipayInterfaceManager _alipayInterfaceManager;
    private readonly IWxPayApi _wxPayApi;
@@ -73,7 +75,8 @@
                          IRepository<LifePayChannles, Guid> lifePayChannlesRep,
                          IRepository<LifePayAccount, Guid> lifePayAccount,
                          IDataFilter dataFilter,
                          IChannelFilter channelFilter)
                          IChannelFilter channelFilter,
                          IAbpDistributedLock distributedLock)
    {
        _logger = logger;
        _aCOOLYManager = aCOOLYManager;
@@ -95,6 +98,7 @@
        _lifePayAccount = lifePayAccount;
        this.dataFilter = dataFilter;
        _channelFilter = channelFilter;
        this.distributedLock = distributedLock;
        _operateHistory = operateHistory;
    }
@@ -1528,8 +1532,11 @@
    public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount, string refundApplyRemark, decimal? parValue = 0, decimal? actualParValue = 0)
    {
        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));
        if (order.ACOOLYStatus.HasValue && (int)order.ACOOLYStatus > (int)acoolyStatus)
        {
            _logger.LogInformation($"订单({orderNo})由{order.ACOOLYStatus}至{acoolyStatus}失败,不可回滚状态");