mirror of https://github.com/EasyAbp/EShop.git
Browse Source
Refactor DefaultUnpaidOrderAutoCancelProvider Improve PaymentCanceledEventHandler to check paymentId Remove StoreOwnerCacheItemInvalidator Disassemble IUnpaidOrderAutoCancelProvider into OrderAutoCancelOnCreatedHandler and OrderAutoCancelOnUpdatedHandlerpull/122/head 2.4.0
293 changed files with 34282 additions and 30807 deletions
@ -1,10 +1,10 @@ |
|||||
<Project> |
<Project> |
||||
<PropertyGroup> |
<PropertyGroup> |
||||
|
|
||||
<AbpVersion>4.4.0</AbpVersion> |
<AbpVersion>5.0.1</AbpVersion> |
||||
<EasyAbpAbpTreesModuleVersion>2.4.0</EasyAbpAbpTreesModuleVersion> |
<EasyAbpAbpTreesModuleVersion>2.5.1</EasyAbpAbpTreesModuleVersion> |
||||
<EasyAbpPaymentServiceModuleVersion>1.10.3</EasyAbpPaymentServiceModuleVersion> |
<EasyAbpPaymentServiceModuleVersion>2.0.1</EasyAbpPaymentServiceModuleVersion> |
||||
<EasyAbpAbpTagHelperPlusModuleVersion>0.7.1</EasyAbpAbpTagHelperPlusModuleVersion> |
<EasyAbpAbpTagHelperPlusModuleVersion>0.8.1</EasyAbpAbpTagHelperPlusModuleVersion> |
||||
|
|
||||
</PropertyGroup> |
</PropertyGroup> |
||||
</Project> |
</Project> |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace EasyAbp.EShop; |
||||
|
|
||||
|
public class EShopRemoteServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "EasyAbpEShop"; |
||||
|
|
||||
|
public const string ModuleName = "easyAbpEShop"; |
||||
|
} |
||||
@ -1,16 +1,14 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\..\..\common.props" /> |
|
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net5.0</TargetFramework> |
<TargetFramework>net6.0</TargetFramework> |
||||
<RootNamespace /> |
<RootNamespace /> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\..\src\EasyAbp.EShop.Application\EasyAbp.EShop.Application.csproj" /> |
<ProjectReference Include="..\..\src\EasyAbp.EShop.Application\EasyAbp.EShop.Application.csproj" /> |
||||
<ProjectReference Include="..\EasyAbp.EShop.Domain.Tests\EasyAbp.EShop.Domain.Tests.csproj" /> |
<ProjectReference Include="..\EasyAbp.EShop.Domain.Tests\EasyAbp.EShop.Domain.Tests.csproj" /> |
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,8 @@ |
|||||
|
namespace EasyAbp.EShop.Orders; |
||||
|
|
||||
|
public class EShopOrdersRemoteServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "EasyAbpEShopOrders"; |
||||
|
|
||||
|
public const string ModuleName = "easyAbpEShopOrders"; |
||||
|
} |
||||
@ -1,66 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.BackgroundJobs; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
using Volo.Abp.Domain.Entities.Events; |
|
||||
using Volo.Abp.EventBus; |
|
||||
using Volo.Abp.EventBus.Distributed; |
|
||||
using Volo.Abp.Timing; |
|
||||
using Volo.Abp.Uow; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Orders.Orders |
|
||||
{ |
|
||||
[Dependency(TryRegister = true)] |
|
||||
[UnitOfWork] |
|
||||
public class DefaultUnpaidOrderAutoCancelProvider : |
|
||||
IUnpaidOrderAutoCancelProvider, |
|
||||
ILocalEventHandler<EntityCreatedEventData<Order>>, |
|
||||
ILocalEventHandler<OrderPaymentIdChangedEto>, |
|
||||
ITransientDependency |
|
||||
{ |
|
||||
private readonly IClock _clock; |
|
||||
private readonly IOrderManager _orderManager; |
|
||||
private readonly IBackgroundJobManager _backgroundJobManager; |
|
||||
|
|
||||
public DefaultUnpaidOrderAutoCancelProvider( |
|
||||
IClock clock, |
|
||||
IOrderManager orderManager, |
|
||||
IBackgroundJobManager backgroundJobManager) |
|
||||
{ |
|
||||
_clock = clock; |
|
||||
_orderManager = orderManager; |
|
||||
_backgroundJobManager = backgroundJobManager; |
|
||||
} |
|
||||
|
|
||||
public virtual async Task HandleEventAsync(EntityCreatedEventData<Order> eventData) |
|
||||
{ |
|
||||
if (!eventData.Entity.PaymentExpiration.HasValue) |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
var args = new UnpaidOrderAutoCancelArgs |
|
||||
{ |
|
||||
TenantId = eventData.Entity.TenantId, |
|
||||
OrderId = eventData.Entity.Id |
|
||||
}; |
|
||||
|
|
||||
await _backgroundJobManager.EnqueueAsync( |
|
||||
args: args, |
|
||||
delay: eventData.Entity.PaymentExpiration.Value.Subtract(_clock.Now) // Todo: use a absolute time.
|
|
||||
); |
|
||||
} |
|
||||
|
|
||||
public virtual async Task HandleEventAsync(OrderPaymentIdChangedEto eventData) |
|
||||
{ |
|
||||
if (!eventData.Order.PaymentExpiration.HasValue || eventData.ToPaymentId.HasValue) |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
if (_clock.Now > eventData.Order.PaymentExpiration.Value && !eventData.Order.CanceledTime.HasValue) |
|
||||
{ |
|
||||
await _orderManager.CancelAsync(eventData.Order, OrdersConsts.CancellationReason); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,7 +0,0 @@ |
|||||
namespace EasyAbp.EShop.Orders.Orders |
|
||||
{ |
|
||||
public interface IUnpaidOrderAutoCancelProvider |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,40 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.BackgroundJobs; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Entities.Events.Distributed; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Orders.Orders |
||||
|
{ |
||||
|
public class OrderAutoCancelOnCreatedHandler : |
||||
|
IDistributedEventHandler<EntityCreatedEto<OrderEto>>, |
||||
|
ITransientDependency |
||||
|
{ |
||||
|
private readonly IBackgroundJobManager _backgroundJobManager; |
||||
|
|
||||
|
public OrderAutoCancelOnCreatedHandler( |
||||
|
IBackgroundJobManager backgroundJobManager) |
||||
|
{ |
||||
|
_backgroundJobManager = backgroundJobManager; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task HandleEventAsync(EntityCreatedEto<OrderEto> eventData) |
||||
|
{ |
||||
|
if (!eventData.Entity.PaymentExpiration.HasValue) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var args = new UnpaidOrderAutoCancelArgs |
||||
|
{ |
||||
|
TenantId = eventData.Entity.TenantId, |
||||
|
OrderId = eventData.Entity.Id |
||||
|
}; |
||||
|
|
||||
|
await _backgroundJobManager.EnqueueAsync( |
||||
|
args: args, |
||||
|
delay: eventData.Entity.PaymentExpiration.Value.Subtract(eventData.Entity.CreationTime) // Todo: use a absolute time.
|
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Entities.Events; |
||||
|
using Volo.Abp.EventBus; |
||||
|
using Volo.Abp.Timing; |
||||
|
using Volo.Abp.Uow; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Orders.Orders |
||||
|
{ |
||||
|
public class OrderAutoCancelOnUpdatedHandler : |
||||
|
ILocalEventHandler<EntityUpdatedEventData<Order>>, |
||||
|
ITransientDependency |
||||
|
{ |
||||
|
private readonly IClock _clock; |
||||
|
private readonly IOrderManager _orderManager; |
||||
|
|
||||
|
public OrderAutoCancelOnUpdatedHandler( |
||||
|
IClock clock, |
||||
|
IOrderManager orderManager) |
||||
|
{ |
||||
|
_clock = clock; |
||||
|
_orderManager = orderManager; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork(true)] |
||||
|
public virtual async Task HandleEventAsync(EntityUpdatedEventData<Order> eventData) |
||||
|
{ |
||||
|
if (!eventData.Entity.PaymentExpiration.HasValue || eventData.Entity.PaymentId.HasValue) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (_clock.Now > eventData.Entity.PaymentExpiration.Value && !eventData.Entity.CanceledTime.HasValue) |
||||
|
{ |
||||
|
await _orderManager.CancelAsync(eventData.Entity, OrdersConsts.CancellationReason); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,25 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.MultiTenancy; |
|
||||
|
|
||||
namespace EasyAbp.EShop.Orders.Orders |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class OrderPaymentIdChangedEto : IMultiTenant |
|
||||
{ |
|
||||
public Guid? TenantId { get; set; } |
|
||||
|
|
||||
public Order Order { get; set; } |
|
||||
|
|
||||
public Guid? FromPaymentId { get; set; } |
|
||||
|
|
||||
public Guid? ToPaymentId { get; set; } |
|
||||
|
|
||||
public OrderPaymentIdChangedEto(Guid? tenantId, Order order, Guid? fromPaymentId, Guid? toPaymentId) |
|
||||
{ |
|
||||
TenantId = tenantId; |
|
||||
Order = order; |
|
||||
FromPaymentId = fromPaymentId; |
|
||||
ToPaymentId = toPaymentId; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,16 +1,14 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\..\..\common.props" /> |
|
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net5.0</TargetFramework> |
<TargetFramework>net6.0</TargetFramework> |
||||
<RootNamespace /> |
<RootNamespace /> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\..\src\EasyAbp.EShop.Orders.Application\EasyAbp.EShop.Orders.Application.csproj" /> |
<ProjectReference Include="..\..\src\EasyAbp.EShop.Orders.Application\EasyAbp.EShop.Orders.Application.csproj" /> |
||||
<ProjectReference Include="..\EasyAbp.EShop.Orders.Domain.Tests\EasyAbp.EShop.Orders.Domain.Tests.csproj" /> |
<ProjectReference Include="..\EasyAbp.EShop.Orders.Domain.Tests\EasyAbp.EShop.Orders.Domain.Tests.csproj" /> |
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,8 @@ |
|||||
|
namespace EasyAbp.EShop.Payments; |
||||
|
|
||||
|
public class EShopPaymentsRemoteServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "EasyAbpEShopPayments"; |
||||
|
|
||||
|
public const string ModuleName = "easyAbpEShopPayments"; |
||||
|
} |
||||
@ -1,16 +1,14 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\..\..\common.props" /> |
|
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net5.0</TargetFramework> |
<TargetFramework>net6.0</TargetFramework> |
||||
<RootNamespace /> |
<RootNamespace>EasyAbp.EShop.Payments</RootNamespace> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\..\src\EasyAbp.EShop.Payments.Application\EasyAbp.EShop.Payments.Application.csproj" /> |
<ProjectReference Include="..\..\src\EasyAbp.EShop.Payments.Application\EasyAbp.EShop.Payments.Application.csproj" /> |
||||
<ProjectReference Include="..\EasyAbp.EShop.Payments.Domain.Tests\EasyAbp.EShop.Payments.Domain.Tests.csproj" /> |
<ProjectReference Include="..\EasyAbp.EShop.Payments.Domain.Tests\EasyAbp.EShop.Payments.Domain.Tests.csproj" /> |
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,8 @@ |
|||||
|
namespace EasyAbp.EShop.Plugins; |
||||
|
|
||||
|
public class EShopPluginsRemoteServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "EasyAbpEShopPlugins"; |
||||
|
|
||||
|
public const string ModuleName = "easyAbpEShopPlugins"; |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue