Browse Source

Introduce Transaction aggregate root in Stores module.

Close #90
pull/96/head
gdlcf88 6 years ago
parent
commit
cdd29205f5
  1. 5
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs
  2. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp.EShop.Orders.Domain.Shared.csproj
  3. 4
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/EShopOrdersDomainSharedModule.cs
  4. 10
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderCanceledEto.cs
  5. 10
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderCompletedEto.cs
  6. 1
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderPaidEto.cs
  7. 13
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderRefundedEto.cs
  8. 24
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderManager.cs
  9. 17
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/RefundCompletedEventHandler.cs
  10. 4
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Pages/EShop/Orders/Orders/Order/Index.cshtml
  11. 4
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Pages/EShop/Orders/Orders/Order/index.js
  12. 13
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Permissions/StoresPermissionDefinitionProvider.cs
  13. 12
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Permissions/StoresPermissions.cs
  14. 20
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/Dtos/CreateUpdateTransactionDto.cs
  15. 10
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/Dtos/GetTransactionListInput.cs
  16. 21
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/Dtos/TransactionDto.cs
  17. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/ITransactionAppService.cs
  18. 4
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs
  19. 31
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs
  20. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/cs.json
  21. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/en.json
  22. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pl.json
  23. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pt-BR.json
  24. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/sl.json
  25. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/tr.json
  26. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/vi.json
  27. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hans.json
  28. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hant.json
  29. 9
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/StoresConsts.cs
  30. 11
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Transactions/TransactionType.cs
  31. 1
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp.EShop.Stores.Domain.csproj
  32. 8
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/EShopStoresDomainModule.cs
  33. 9
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/ITransactionRepository.cs
  34. 41
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/OrderCompletedEventHandler.cs
  35. 42
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/OrderRefundedEventHandler.cs
  36. 48
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs
  37. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/EShopStoresEntityFrameworkCoreModule.cs
  38. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/IStoresDbContext.cs
  39. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/StoresDbContext.cs
  40. 10
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/StoresDbContextModelCreatingExtensions.cs
  41. 14
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/Transactions/TransactionRepository.cs
  42. 54
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.HttpApi/EasyAbp/EShop/Stores/Transactions/TransactionController.cs
  43. 12
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs
  44. 2
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenus.cs
  45. 18
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/CreateModal.cshtml
  46. 28
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/CreateModal.cshtml.cs
  47. 19
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/EditModal.cshtml
  48. 39
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/EditModal.cshtml.cs
  49. 63
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/Index.cshtml
  50. 17
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/Index.cshtml.cs
  51. 27
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/ViewModels/CreateEditTransactionViewModel.cs
  52. 0
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/index.css
  53. 70
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/index.js
  54. 6
      modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs
  55. 26
      modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Transactions/TransactionAppServiceTests.cs
  56. 23
      modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Domain.Tests/Transactions/TransactionDomainTests.cs
  57. 31
      modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.EntityFrameworkCore.Tests/EntityFrameworkCore/Transactions/TransactionRepositoryTests.cs
  58. 3
      samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/appsettings.json
  59. 4225
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831094628_AddedTransactionEntityToStoresModule.Designer.cs
  60. 39
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831094628_AddedTransactionEntityToStoresModule.cs
  61. 4225
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831101341_ConfiguredHasColumnTypeForTransaction.Designer.cs
  62. 29
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831101341_ConfiguredHasColumnTypeForTransaction.cs
  63. 51
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/EShopSampleMigrationsDbContextModelSnapshot.cs

5
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs

@ -48,6 +48,9 @@ namespace EasyAbp.EShop.Orders.Orders
}
var productTotalPrice = orderLines.Select(x => x.TotalPrice).Sum();
// Todo: totalPrice may contain other fee.
var totalPrice = productTotalPrice;
var order = new Order(
id: _guidGenerator.Create(),
@ -57,7 +60,7 @@ namespace EasyAbp.EShop.Orders.Orders
currency: await GetStoreCurrencyAsync(input.StoreId),
productTotalPrice: productTotalPrice,
totalDiscount: orderLines.Select(x => x.TotalDiscount).Sum(),
totalPrice: productTotalPrice,
totalPrice: totalPrice,
customerRemark: input.CustomerRemark);
foreach (var orderExtraProperty in orderExtraProperties)

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp.EShop.Orders.Domain.Shared.csproj

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Volo.Abp.Validation" Version="3.0.4" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Payments\src\EasyAbp.EShop.Payments.Domain.Shared\EasyAbp.EShop.Payments.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Stores\src\EasyAbp.EShop.Stores.Domain.Shared\EasyAbp.EShop.Stores.Domain.Shared.csproj" />
</ItemGroup>

4
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/EShopOrdersDomainSharedModule.cs

@ -1,6 +1,7 @@
using Volo.Abp.Modularity;
using Volo.Abp.Localization;
using EasyAbp.EShop.Orders.Localization;
using EasyAbp.EShop.Payments;
using EasyAbp.EShop.Stores;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Validation;
@ -11,7 +12,8 @@ namespace EasyAbp.EShop.Orders
{
[DependsOn(
typeof(AbpValidationModule),
typeof(EShopStoresDomainSharedModule)
typeof(EShopStoresDomainSharedModule),
typeof(EShopPaymentsDomainSharedModule)
)]
public class EShopOrdersDomainSharedModule : AbpModule
{

10
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderCanceledEto.cs

@ -0,0 +1,10 @@
using System;
namespace EasyAbp.EShop.Orders.Orders
{
[Serializable]
public class OrderCanceledEto
{
public OrderEto Order { get; set; }
}
}

10
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderCompletedEto.cs

@ -0,0 +1,10 @@
using System;
namespace EasyAbp.EShop.Orders.Orders
{
[Serializable]
public class OrderCompletedEto
{
public OrderEto Order { get; set; }
}
}

1
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderPaidEto.cs

@ -2,6 +2,7 @@
namespace EasyAbp.EShop.Orders.Orders
{
[Serializable]
public class OrderPaidEto
{
public OrderEto Order { get; set; }

13
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderRefundedEto.cs

@ -0,0 +1,13 @@
using System;
using EasyAbp.EShop.Payments.Refunds;
namespace EasyAbp.EShop.Orders.Orders
{
[Serializable]
public class OrderRefundedEto
{
public OrderEto Order { get; set; }
public EShopRefundEto Refund { get; set; }
}
}

24
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderManager.cs

@ -2,20 +2,32 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Timing;
using Volo.Abp.Uow;
namespace EasyAbp.EShop.Orders.Orders
{
public class OrderManager : DomainService, IOrderManager
{
private readonly IClock _clock;
private readonly IObjectMapper _objectMapper;
private readonly IDistributedEventBus _distributedEventBus;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IOrderRepository _orderRepository;
public OrderManager(
IClock clock,
IObjectMapper objectMapper,
IDistributedEventBus distributedEventBus,
IUnitOfWorkManager unitOfWorkManager,
IOrderRepository orderRepository)
{
_clock = clock;
_objectMapper = objectMapper;
_distributedEventBus = distributedEventBus;
_unitOfWorkManager = unitOfWorkManager;
_orderRepository = orderRepository;
}
@ -46,6 +58,12 @@ namespace EasyAbp.EShop.Orders.Orders
order.SetCompletionTime(_clock.Now);
order.SetOrderStatus(OrderStatus.Completed);
_unitOfWorkManager.Current.OnCompleted(async () => await _distributedEventBus.PublishAsync(
new OrderCompletedEto
{
Order = _objectMapper.Map<Order, OrderEto>(order)
}));
return await _orderRepository.UpdateAsync(order, true);
}
@ -63,6 +81,12 @@ namespace EasyAbp.EShop.Orders.Orders
order.SetCanceled(_clock.Now, cancellationReason);
order.SetOrderStatus(OrderStatus.Canceled);
_unitOfWorkManager.Current.OnCompleted(async () => await _distributedEventBus.PublishAsync(
new OrderCanceledEto
{
Order = _objectMapper.Map<Order, OrderEto>(order)
}));
return await _orderRepository.UpdateAsync(order, true);
}

17
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/RefundCompletedEventHandler.cs

@ -4,6 +4,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
namespace EasyAbp.EShop.Orders.Orders
@ -11,13 +12,22 @@ namespace EasyAbp.EShop.Orders.Orders
public class RefundCompletedEventHandler : IDistributedEventHandler<EShopRefundCompletedEto>, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
private readonly IObjectMapper _objectMapper;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IDistributedEventBus _distributedEventBus;
private readonly IOrderRepository _orderRepository;
public RefundCompletedEventHandler(
ICurrentTenant currentTenant,
IObjectMapper objectMapper,
IUnitOfWorkManager unitOfWorkManager,
IDistributedEventBus distributedEventBus,
IOrderRepository orderRepository)
{
_currentTenant = currentTenant;
_objectMapper = objectMapper;
_unitOfWorkManager = unitOfWorkManager;
_distributedEventBus = distributedEventBus;
_orderRepository = orderRepository;
}
@ -36,6 +46,13 @@ namespace EasyAbp.EShop.Orders.Orders
}
await _orderRepository.UpdateAsync(order, true);
_unitOfWorkManager.Current.OnCompleted(async () => await _distributedEventBus.PublishAsync(
new OrderRefundedEto
{
Order = _objectMapper.Map<Order, OrderEto>(order),
Refund = eventData.Refund
}));
}
}
}

4
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Pages/EShop/Orders/Orders/Order/Index.cshtml

@ -34,6 +34,10 @@
<abp-style src="/Pages/EShop/Orders/Orders/Order/index.css"/>
}
<script>
let storeId = '@Model.StoreId';
</script>
<abp-card>
<abp-card-header>
<abp-row>

4
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Pages/EShop/Orders/Orders/Order/index.js

@ -12,7 +12,9 @@ $(function () {
autoWidth: false,
scrollCollapse: true,
order: [[1, "asc"]],
ajax: abp.libs.datatables.createAjax(service.getList),
ajax: abp.libs.datatables.createAjax(service.getList, function () {
return { storeId: storeId }
}),
columnDefs: [
{
rowAction: {

13
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Permissions/StoresPermissionDefinitionProvider.cs

@ -1,4 +1,4 @@
using EasyAbp.EShop.Stores.Localization;
using EasyAbp.EShop.Stores.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
@ -9,12 +9,17 @@ namespace EasyAbp.EShop.Stores.Permissions
{
public override void Define(IPermissionDefinitionContext context)
{
var moduleGroup = context.AddGroup(StoresPermissions.GroupName, L("Permission:Stores"));
var myGroup = context.AddGroup(StoresPermissions.GroupName, L("Permission:Stores"));
var stores = moduleGroup.AddPermission(StoresPermissions.Stores.Default, L("Permission:Store"));
var stores = myGroup.AddPermission(StoresPermissions.Stores.Default, L("Permission:Store"));
stores.AddChild(StoresPermissions.Stores.Create, L("Permission:Create"));
stores.AddChild(StoresPermissions.Stores.Update, L("Permission:Update"));
stores.AddChild(StoresPermissions.Stores.Delete, L("Permission:Delete"), MultiTenancySides.Host);
var transactionPermission = myGroup.AddPermission(StoresPermissions.Transaction.Default, L("Permission:Transaction"));
transactionPermission.AddChild(StoresPermissions.Transaction.Create, L("Permission:Create"));
transactionPermission.AddChild(StoresPermissions.Transaction.Update, L("Permission:Update"));
transactionPermission.AddChild(StoresPermissions.Transaction.Delete, L("Permission:Delete"));
}
private static LocalizableString L(string name)
@ -22,4 +27,4 @@ namespace EasyAbp.EShop.Stores.Permissions
return LocalizableString.Create<StoresResource>(name);
}
}
}
}

12
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Permissions/StoresPermissions.cs

@ -1,4 +1,4 @@
using Volo.Abp.Reflection;
using Volo.Abp.Reflection;
namespace EasyAbp.EShop.Stores.Permissions
{
@ -18,5 +18,13 @@ namespace EasyAbp.EShop.Stores.Permissions
public const string Update = Default + ".Update";
public const string Create = Default + ".Create";
}
public class Transaction
{
public const string Default = GroupName + ".Transaction";
public const string Update = Default + ".Update";
public const string Create = Default + ".Create";
public const string Delete = Default + ".Delete";
}
}
}
}

20
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/Dtos/CreateUpdateTransactionDto.cs

@ -0,0 +1,20 @@
using System;
using System.ComponentModel;
namespace EasyAbp.EShop.Stores.Transactions.Dtos
{
[Serializable]
public class CreateUpdateTransactionDto
{
public Guid StoreId { get; set; }
public Guid? OrderId { get; set; }
public TransactionType TransactionType { get; set; }
public string ActionName { get; set; }
public string Currency { get; set; }
public decimal Amount { get; set; }
}
}

10
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/Dtos/GetTransactionListInput.cs

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Stores.Transactions.Dtos
{
public class GetTransactionListInput : PagedAndSortedResultRequestDto
{
public Guid StoreId { get; set; }
}
}

21
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/Dtos/TransactionDto.cs

@ -0,0 +1,21 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Stores.Transactions.Dtos
{
[Serializable]
public class TransactionDto : CreationAuditedEntityDto<Guid>
{
public Guid StoreId { get; set; }
public Guid? OrderId { get; set; }
public TransactionType TransactionType { get; set; }
public string ActionName { get; set; }
public string Currency { get; set; }
public decimal Amount { get; set; }
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp/EShop/Stores/Transactions/ITransactionAppService.cs

@ -0,0 +1,17 @@
using System;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Stores.Transactions
{
public interface ITransactionAppService :
ICrudAppService<
TransactionDto,
Guid,
GetTransactionListInput,
CreateUpdateTransactionDto,
CreateUpdateTransactionDto>
{
}
}

4
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/StoresApplicationAutoMapperProfile.cs

@ -1,5 +1,7 @@
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Stores.Dtos;
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using AutoMapper;
namespace EasyAbp.EShop.Stores
@ -13,6 +15,8 @@ namespace EasyAbp.EShop.Stores
* into multiple profile classes for a better organization. */
CreateMap<Store, StoreDto>();
CreateMap<CreateUpdateStoreDto, Store>(MemberList.Source);
CreateMap<Transaction, TransactionDto>();
CreateMap<CreateUpdateTransactionDto, Transaction>(MemberList.Source);
}
}
}

31
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp/EShop/Stores/Transactions/TransactionAppService.cs

@ -0,0 +1,31 @@
using System;
using System.Linq;
using EasyAbp.EShop.Stores.Permissions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace EasyAbp.EShop.Stores.Transactions
{
public class TransactionAppService : CrudAppService<Transaction, TransactionDto, Guid, GetTransactionListInput, CreateUpdateTransactionDto, CreateUpdateTransactionDto>,
ITransactionAppService
{
protected override string GetPolicyName { get; set; } = StoresPermissions.Transaction.Default;
protected override string GetListPolicyName { get; set; } = StoresPermissions.Transaction.Default;
protected override string CreatePolicyName { get; set; } = StoresPermissions.Transaction.Create;
protected override string UpdatePolicyName { get; set; } = StoresPermissions.Transaction.Update;
protected override string DeletePolicyName { get; set; } = StoresPermissions.Transaction.Delete;
private readonly ITransactionRepository _repository;
public TransactionAppService(ITransactionRepository repository) : base(repository)
{
_repository = repository;
}
protected override IQueryable<Transaction> CreateFilteredQuery(GetTransactionListInput input)
{
return base.CreateFilteredQuery(input).Where(x => x.StoreId == input.StoreId);
}
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/cs.json

@ -7,6 +7,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/en.json

@ -8,6 +8,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pl.json

@ -7,6 +7,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/pt-BR.json

@ -7,6 +7,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/sl.json

@ -8,6 +8,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/tr.json

@ -8,6 +8,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/vi.json

@ -7,6 +7,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hans.json

@ -8,6 +8,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Localization/Stores/zh-Hant.json

@ -8,6 +8,21 @@
"CreateStore": "CreateStore",
"EditStore": "EditStore",
"StoreDeletionConfirmationMessage": "Are you sure to delete the store {0}?",
"SuccessfullyDeleted": "Successfully deleted"
"SuccessfullyDeleted": "Successfully deleted",
"Permission:Transaction": "Transaction",
"Permission:Create": "Create",
"Permission:Update": "Update",
"Permission:Delete": "Delete",
"Menu:Transaction": "MenuTransaction",
"Transaction": "Transaction",
"TransactionStoreId": "TransactionStoreId",
"TransactionOrderId": "TransactionOrderId",
"TransactionTransactionType": "TransactionTransactionType",
"TransactionActionName": "TransactionActionName",
"TransactionCurrency": "TransactionCurrency",
"TransactionAmount": "TransactionAmount",
"CreateTransaction": "CreateTransaction",
"EditTransaction": "EditTransaction",
"TransactionDeletionConfirmationMessage": "Are you sure to delete the transaction {0}?"
}
}

9
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/StoresConsts.cs

@ -0,0 +1,9 @@
namespace EasyAbp.EShop.Stores
{
public static class StoresConsts
{
public const string TransactionOrderCompletedActionName = "OrderCompleted";
public const string TransactionOrderRefundedActionName = "OrderRefunded";
}
}

11
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp/EShop/Stores/Transactions/TransactionType.cs

@ -0,0 +1,11 @@
using System;
namespace EasyAbp.EShop.Stores.Transactions
{
[Flags]
public enum TransactionType
{
Debit = 1,
Credit = 2
}
}

1
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp.EShop.Stores.Domain.csproj

@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="3.0.4" />
<ProjectReference Include="..\..\..\EasyAbp.EShop.Orders\src\EasyAbp.EShop.Orders.Domain.Shared\EasyAbp.EShop.Orders.Domain.Shared.csproj" />
<ProjectReference Include="..\EasyAbp.EShop.Stores.Domain.Shared\EasyAbp.EShop.Stores.Domain.Shared.csproj" />
</ItemGroup>

8
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/EShopStoresDomainModule.cs

@ -1,10 +1,12 @@
using Volo.Abp.Modularity;
using EasyAbp.EShop.Orders;
using Volo.Abp.Modularity;
namespace EasyAbp.EShop.Stores
{
[DependsOn(
typeof(EShopStoresDomainSharedModule)
)]
typeof(EShopStoresDomainSharedModule),
typeof(EShopOrdersDomainSharedModule)
)]
public class EShopStoresDomainModule : AbpModule
{

9
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/ITransactionRepository.cs

@ -0,0 +1,9 @@
using System;
using Volo.Abp.Domain.Repositories;
namespace EasyAbp.EShop.Stores.Transactions
{
public interface ITransactionRepository : IRepository<Transaction, Guid>
{
}
}

41
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/OrderCompletedEventHandler.cs

@ -0,0 +1,41 @@
using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
namespace EasyAbp.EShop.Stores.Transactions
{
public class OrderCompletedEventHandler : IDistributedEventHandler<OrderCompletedEto>, ITransientDependency
{
private readonly IGuidGenerator _guidGenerator;
private readonly ICurrentTenant _currentTenant;
private readonly ITransactionRepository _transactionRepository;
public OrderCompletedEventHandler(
IGuidGenerator guidGenerator,
ICurrentTenant currentTenant,
ITransactionRepository transactionRepository)
{
_guidGenerator = guidGenerator;
_currentTenant = currentTenant;
_transactionRepository = transactionRepository;
}
[UnitOfWork(true)]
public virtual async Task HandleEventAsync(OrderCompletedEto eventData)
{
var order = eventData.Order;
using var changeTenant = _currentTenant.Change(order.TenantId);
var transaction = new Transaction(_guidGenerator.Create(), order.TenantId, order.StoreId, order.Id,
TransactionType.Debit, StoresConsts.TransactionOrderCompletedActionName, order.Currency,
order.TotalPrice);
await _transactionRepository.InsertAsync(transaction, true);
}
}
}

42
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/OrderRefundedEventHandler.cs

@ -0,0 +1,42 @@
using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
namespace EasyAbp.EShop.Stores.Transactions
{
public class OrderRefundedEventHandler : IDistributedEventHandler<OrderRefundedEto>, ITransientDependency
{
private readonly IGuidGenerator _guidGenerator;
private readonly ICurrentTenant _currentTenant;
private readonly ITransactionRepository _transactionRepository;
public OrderRefundedEventHandler(
IGuidGenerator guidGenerator,
ICurrentTenant currentTenant,
ITransactionRepository transactionRepository)
{
_guidGenerator = guidGenerator;
_currentTenant = currentTenant;
_transactionRepository = transactionRepository;
}
[UnitOfWork(true)]
public virtual async Task HandleEventAsync(OrderRefundedEto eventData)
{
var order = eventData.Order;
var refund = eventData.Refund;
using var changeTenant = _currentTenant.Change(order.TenantId);
var transaction = new Transaction(_guidGenerator.Create(), order.TenantId, order.StoreId, order.Id,
TransactionType.Credit, StoresConsts.TransactionOrderRefundedActionName, refund.Currency,
-refund.RefundAmount);
await _transactionRepository.InsertAsync(transaction, true);
}
}
}

48
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp/EShop/Stores/Transactions/Transaction.cs

@ -0,0 +1,48 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace EasyAbp.EShop.Stores.Transactions
{
public class Transaction : CreationAuditedAggregateRoot<Guid>, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }
public virtual Guid StoreId { get; protected set; }
public virtual Guid? OrderId { get; protected set; }
public virtual TransactionType TransactionType { get; protected set; }
[NotNull]
public virtual string ActionName { get; protected set; }
[NotNull]
public virtual string Currency { get; protected set; }
public virtual decimal Amount { get; protected set; }
protected Transaction()
{
}
public Transaction(Guid id,
Guid? tenantId,
Guid storeId,
Guid? orderId,
TransactionType transactionType,
[NotNull] string actionName,
[NotNull] string currency,
decimal amount) : base(id)
{
TenantId = tenantId;
StoreId = storeId;
OrderId = orderId;
TransactionType = transactionType;
ActionName = actionName;
Currency = currency;
Amount = amount;
}
}
}

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/EShopStoresEntityFrameworkCoreModule.cs

@ -1,3 +1,4 @@
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
@ -19,6 +20,7 @@ namespace EasyAbp.EShop.Stores.EntityFrameworkCore
* options.AddRepository<Question, EfCoreQuestionRepository>();
*/
options.AddRepository<Store, StoreRepository>();
options.AddRepository<Transaction, TransactionRepository>();
});
}
}

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/IStoresDbContext.cs

@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Transactions;
namespace EasyAbp.EShop.Stores.EntityFrameworkCore
{
@ -12,5 +13,6 @@ namespace EasyAbp.EShop.Stores.EntityFrameworkCore
* DbSet<Question> Questions { get; }
*/
DbSet<Store> Stores { get; set; }
DbSet<Transaction> Transactions { get; set; }
}
}

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/StoresDbContext.cs

@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using EasyAbp.EShop.Stores.Stores;
using EasyAbp.EShop.Stores.Transactions;
namespace EasyAbp.EShop.Stores.EntityFrameworkCore
{
@ -12,6 +13,7 @@ namespace EasyAbp.EShop.Stores.EntityFrameworkCore
* public DbSet<Question> Questions { get; set; }
*/
public DbSet<Store> Stores { get; set; }
public DbSet<Transaction> Transactions { get; set; }
public StoresDbContext(DbContextOptions<StoresDbContext> options)
: base(options)

10
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/EntityFrameworkCore/StoresDbContextModelCreatingExtensions.cs

@ -1,3 +1,4 @@
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Stores;
using System;
using Microsoft.EntityFrameworkCore;
@ -47,6 +48,15 @@ namespace EasyAbp.EShop.Stores.EntityFrameworkCore
b.ConfigureByConvention();
/* Configure more properties here */
});
builder.Entity<Transaction>(b =>
{
b.ToTable(options.TablePrefix + "Transactions", options.Schema);
b.ConfigureByConvention();
/* Configure more properties here */
b.Property(x => x.Amount).HasColumnType("decimal(20,8)");
});
}
}
}

14
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp/EShop/Stores/Transactions/TransactionRepository.cs

@ -0,0 +1,14 @@
using System;
using EasyAbp.EShop.Stores.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace EasyAbp.EShop.Stores.Transactions
{
public class TransactionRepository : EfCoreRepository<StoresDbContext, Transaction, Guid>, ITransactionRepository
{
public TransactionRepository(IDbContextProvider<StoresDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
}

54
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.HttpApi/EasyAbp/EShop/Stores/Transactions/TransactionController.cs

@ -0,0 +1,54 @@
using System;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace EasyAbp.EShop.Stores.Transactions
{
[RemoteService(Name = "TransactionService")]
[Route("/api/stores/transaction")]
public class TransactionController : StoresController, ITransactionAppService
{
private readonly ITransactionAppService _service;
public TransactionController(ITransactionAppService service)
{
_service = service;
}
[HttpGet]
[Route("{id}")]
public Task<TransactionDto> GetAsync(Guid id)
{
return _service.GetAsync(id);
}
[HttpGet]
public Task<PagedResultDto<TransactionDto>> GetListAsync(GetTransactionListInput input)
{
return _service.GetListAsync(input);
}
[HttpPost]
public Task<TransactionDto> CreateAsync(CreateUpdateTransactionDto input)
{
return _service.CreateAsync(input);
}
[HttpPut]
[Route("{id}")]
public Task<TransactionDto> UpdateAsync(Guid id, CreateUpdateTransactionDto input)
{
return _service.UpdateAsync(id, input);
}
[HttpDelete]
[Route("{id}")]
public Task DeleteAsync(Guid id)
{
return _service.DeleteAsync(id);
}
}
}

12
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs

@ -2,6 +2,8 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.Localization;
using EasyAbp.EShop.Stores.Permissions;
using EasyAbp.EShop.Stores.Stores;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.UI.Navigation;
namespace EasyAbp.EShop.Stores.Web.Menus
@ -29,6 +31,16 @@ namespace EasyAbp.EShop.Stores.Web.Menus
);
}
if (await context.IsGrantedAsync(StoresPermissions.Transaction.Default))
{
var storeAppService = context.ServiceProvider.GetRequiredService<IStoreAppService>();
var defaultStore = (await storeAppService.GetDefaultAsync())?.Id;
storeManagementMenuItem.AddItem(
new ApplicationMenuItem(StoresMenus.Transaction, l["Menu:Transaction"], "/EShop/Stores/Transactions/Transaction?storeId=" + defaultStore));
}
if (!storeManagementMenuItem.Items.IsNullOrEmpty())
{
var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == StoresMenus.ModuleGroupPrefix,

2
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenus.cs

@ -7,6 +7,8 @@
public const string Prefix = ModuleGroupPrefix + ".Stores";
public const string Store = Prefix + ".Store";
public const string Transaction = Prefix + ".Transaction";
//Add your menu items here...
//public const string Home = Prefix + ".MyNewMenuItem";

18
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/CreateModal.cshtml

@ -0,0 +1,18 @@
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal;
@using EasyAbp.EShop.Stores.Localization
@inject IHtmlLocalizer<StoresResource> L
@model EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.CreateModalModel
@{
Layout = null;
}
<abp-dynamic-form abp-model="ViewModel" data-ajaxForm="true" asp-page="CreateModal">
<abp-modal>
<abp-modal-header title="@L["CreateTransaction"].Value"></abp-modal-header>
<abp-modal-body>
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>

28
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/CreateModal.cshtml.cs

@ -0,0 +1,28 @@
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction
{
public class CreateModalModel : StoresPageModel
{
[BindProperty]
public CreateEditTransactionViewModel ViewModel { get; set; }
private readonly ITransactionAppService _service;
public CreateModalModel(ITransactionAppService service)
{
_service = service;
}
public virtual async Task<IActionResult> OnPostAsync()
{
var dto = ObjectMapper.Map<CreateEditTransactionViewModel, CreateUpdateTransactionDto>(ViewModel);
await _service.CreateAsync(dto);
return NoContent();
}
}
}

19
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/EditModal.cshtml

@ -0,0 +1,19 @@
@page
@using EasyAbp.EShop.Stores.Localization
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal;
@inject IHtmlLocalizer<StoresResource> L
@model EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.EditModalModel
@{
Layout = null;
}
<abp-dynamic-form abp-model="ViewModel" data-ajaxForm="true" asp-page="EditModal">
<abp-modal>
<abp-modal-header title="@L["EditTransaction"].Value"></abp-modal-header>
<abp-modal-body>
<abp-input asp-for="Id" />
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>

39
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/EditModal.cshtml.cs

@ -0,0 +1,39 @@
using System;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.Transactions;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction
{
public class EditModalModel : StoresPageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public Guid Id { get; set; }
[BindProperty]
public CreateEditTransactionViewModel ViewModel { get; set; }
private readonly ITransactionAppService _service;
public EditModalModel(ITransactionAppService service)
{
_service = service;
}
public virtual async Task OnGetAsync()
{
var dto = await _service.GetAsync(Id);
ViewModel = ObjectMapper.Map<TransactionDto, CreateEditTransactionViewModel>(dto);
}
public virtual async Task<IActionResult> OnPostAsync()
{
var dto = ObjectMapper.Map<CreateEditTransactionViewModel, CreateUpdateTransactionDto>(ViewModel);
await _service.UpdateAsync(Id, dto);
return NoContent();
}
}
}

63
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/Index.cshtml

@ -0,0 +1,63 @@
@page
@using EasyAbp.EShop.Stores.Permissions
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using EasyAbp.EShop.Stores.Localization
@using EasyAbp.EShop.Stores.Web.Menus
@model EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.IndexModel
@inject IPageLayout PageLayout
@inject IHtmlLocalizer<StoresResource> L
@inject IAuthorizationService Authorization
@{
PageLayout.Content.Title = L["Transaction"].Value;
PageLayout.Content.BreadCrumb.Add(L["Menu:Transaction"].Value);
PageLayout.Content.MenuItemName = StoresMenus.Transaction;
}
@section scripts
{
<abp-script src="/Pages/EShop/Stores/Transactions/Transaction/index.js" />
}
@section styles
{
<abp-style src="/Pages/EShop/Stores/Transactions/Transaction/index.css"/>
}
<script>
var storeId = '@Model.StoreId';
</script>
<abp-card>
<abp-card-header>
<abp-row>
<abp-column size-md="_6">
<abp-card-title>@L["Transaction"]</abp-card-title>
</abp-column>
<abp-column size-md="_6" class="text-right">
@if (await Authorization.IsGrantedAsync(StoresPermissions.Transaction.Create))
{
<abp-button id="NewTransactionButton"
text="@L["CreateTransaction"].Value"
icon="plus"
button-type="Primary" />
}
</abp-column>
</abp-row>
</abp-card-header>
<abp-card-body>
<abp-table striped-rows="true" id="TransactionTable" class="nowrap">
<thead>
<tr>
<th>@L["Actions"]</th>
<th>@L["TransactionStoreId"]</th>
<th>@L["TransactionOrderId"]</th>
<th>@L["TransactionTransactionType"]</th>
<th>@L["TransactionActionName"]</th>
<th>@L["TransactionCurrency"]</th>
<th>@L["TransactionAmount"]</th>
</tr>
</thead>
</abp-table>
</abp-card-body>
</abp-card>

17
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/Index.cshtml.cs

@ -0,0 +1,17 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction
{
public class IndexModel : StoresPageModel
{
[BindProperty(SupportsGet = true)]
public Guid StoreId { get; set; }
public virtual async Task OnGetAsync()
{
await Task.CompletedTask;
}
}
}

27
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/ViewModels/CreateEditTransactionViewModel.cs

@ -0,0 +1,27 @@
using System;
using System.ComponentModel.DataAnnotations;
using EasyAbp.EShop.Stores.Transactions;
namespace EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.ViewModels
{
public class CreateEditTransactionViewModel
{
[Display(Name = "TransactionStoreId")]
public Guid StoreId { get; set; }
[Display(Name = "TransactionOrderId")]
public Guid? OrderId { get; set; }
[Display(Name = "TransactionTransactionType")]
public TransactionType TransactionType { get; set; }
[Display(Name = "TransactionActionName")]
public string ActionName { get; set; }
[Display(Name = "TransactionCurrency")]
public string Currency { get; set; }
[Display(Name = "TransactionAmount")]
public decimal Amount { get; set; }
}
}

0
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/index.css

70
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Pages/EShop/Stores/Transactions/Transaction/index.js

@ -0,0 +1,70 @@
$(function () {
var l = abp.localization.getResource('EasyAbpEShopStores');
var service = easyAbp.eShop.stores.transactions.transaction;
var createModal = new abp.ModalManager(abp.appPath + 'EShop/Stores/Transactions/Transaction/CreateModal');
var editModal = new abp.ModalManager(abp.appPath + 'EShop/Stores/Transactions/Transaction/EditModal');
var dataTable = $('#TransactionTable').DataTable(abp.libs.datatables.normalizeConfiguration({
processing: true,
serverSide: true,
paging: true,
searching: false,
autoWidth: false,
scrollCollapse: true,
order: [[1, "asc"]],
ajax: abp.libs.datatables.createAjax(service.getList, function () {
return { storeId: storeId }
}),
columnDefs: [
{
rowAction: {
items:
[
{
text: l('Edit'),
visible: abp.auth.isGranted('Stores.Transaction.Update'),
action: function (data) {
editModal.open({ id: data.record.id });
}
},
{
text: l('Delete'),
visible: abp.auth.isGranted('Stores.Transaction.Delete'),
confirmMessage: function (data) {
return l('TransactionDeletionConfirmationMessage', data.record.id);
},
action: function (data) {
service.delete(data.record.id)
.then(function () {
abp.notify.info(l('SuccessfullyDeleted'));
dataTable.ajax.reload();
});
}
}
]
}
},
{ data: "storeId" },
{ data: "orderId" },
{ data: "transactionType" },
{ data: "actionName" },
{ data: "currency" },
{ data: "amount" },
]
}));
createModal.onResult(function () {
dataTable.ajax.reload();
});
editModal.onResult(function () {
dataTable.ajax.reload();
});
$('#NewTransactionButton').click(function (e) {
e.preventDefault();
createModal.open();
});
});

6
modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/StoresWebAutoMapperProfile.cs

@ -1,6 +1,9 @@
using EasyAbp.EShop.Stores.Stores.Dtos;
using AutoMapper;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using EasyAbp.EShop.Stores.Transactions.Dtos;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Stores.Store.ViewModels;
using EasyAbp.EShop.Stores.Web.Pages.EShop.Stores.Transactions.Transaction.ViewModels;
namespace EasyAbp.EShop.Stores.Web
{
@ -13,6 +16,9 @@ namespace EasyAbp.EShop.Stores.Web
* into multiple profile classes for a better organization. */
CreateMap<StoreDto, CreateEditStoreViewModel>();
CreateMap<CreateEditStoreViewModel, CreateUpdateStoreDto>();
CreateMap<TransactionDto, CreateUpdateTransactionDto>();
CreateMap<TransactionDto, CreateEditTransactionViewModel>();
CreateMap<CreateEditTransactionViewModel, CreateUpdateTransactionDto>();
}
}
}

26
modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Application.Tests/Transactions/TransactionAppServiceTests.cs

@ -0,0 +1,26 @@
using Shouldly;
using System.Threading.Tasks;
using Xunit;
namespace EasyAbp.EShop.Stores.Transactions
{
public class TransactionAppServiceTests : StoresApplicationTestBase
{
private readonly ITransactionAppService _transactionAppService;
public TransactionAppServiceTests()
{
_transactionAppService = GetRequiredService<ITransactionAppService>();
}
[Fact]
public async Task Test1()
{
// Arrange
// Act
// Assert
}
}
}

23
modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.Domain.Tests/Transactions/TransactionDomainTests.cs

@ -0,0 +1,23 @@
using System.Threading.Tasks;
using Shouldly;
using Xunit;
namespace EasyAbp.EShop.Stores.Transactions
{
public class TransactionDomainTests : StoresDomainTestBase
{
public TransactionDomainTests()
{
}
[Fact]
public async Task Test1()
{
// Arrange
// Assert
// Assert
}
}
}

31
modules/EasyAbp.EShop.Stores/test/EasyAbp.EShop.Stores.EntityFrameworkCore.Tests/EntityFrameworkCore/Transactions/TransactionRepositoryTests.cs

@ -0,0 +1,31 @@
using System;
using System.Threading.Tasks;
using EasyAbp.EShop.Stores.Transactions;
using Volo.Abp.Domain.Repositories;
using Xunit;
namespace EasyAbp.EShop.Stores.EntityFrameworkCore.Transactions
{
public class TransactionRepositoryTests : StoresEntityFrameworkCoreTestBase
{
private readonly ITransactionRepository _transactionRepository;
public TransactionRepositoryTests()
{
_transactionRepository = GetRequiredService<ITransactionRepository>();
}
[Fact]
public async Task Test1()
{
await WithUnitOfWorkAsync(async () =>
{
// Arrange
// Act
//Assert
});
}
}
}

3
samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/appsettings.json

@ -1,7 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=60.208.32.153;Database=fenghui01test;User Id=fenghui01test;Password=WYSytJdMORYnhTYmvf;Trusted_Connection=True;Integrated Security=false"
"Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=EShopSample;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"IdentityServer": {
"Clients": {

4225
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831094628_AddedTransactionEntityToStoresModule.Designer.cs

File diff suppressed because it is too large

39
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831094628_AddedTransactionEntityToStoresModule.cs

@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace EShopSample.Migrations
{
public partial class AddedTransactionEntityToStoresModule : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "EasyAbpEShopStoresTransactions",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
StoreId = table.Column<Guid>(nullable: false),
OrderId = table.Column<Guid>(nullable: true),
TransactionType = table.Column<int>(nullable: false),
ActionName = table.Column<string>(nullable: true),
Currency = table.Column<string>(nullable: true),
Amount = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EasyAbpEShopStoresTransactions", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EasyAbpEShopStoresTransactions");
}
}
}

4225
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831101341_ConfiguredHasColumnTypeForTransaction.Designer.cs

File diff suppressed because it is too large

29
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200831101341_ConfiguredHasColumnTypeForTransaction.cs

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace EShopSample.Migrations
{
public partial class ConfiguredHasColumnTypeForTransaction : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<decimal>(
name: "Amount",
table: "EasyAbpEShopStoresTransactions",
type: "decimal(20,8)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "decimal(18,2)");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<decimal>(
name: "Amount",
table: "EasyAbpEShopStoresTransactions",
type: "decimal(18,2)",
nullable: false,
oldClrType: typeof(decimal),
oldType: "decimal(20,8)");
}
}
}

51
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/EShopSampleMigrationsDbContextModelSnapshot.cs

@ -1498,6 +1498,57 @@ namespace EShopSample.Migrations
b.ToTable("EasyAbpEShopStoresStores");
});
modelBuilder.Entity("EasyAbp.EShop.Stores.Transactions.Transaction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ActionName")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Amount")
.HasColumnType("decimal(20,8)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(40)")
.HasMaxLength(40);
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Currency")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("OrderId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("StoreId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<int>("TransactionType")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("EasyAbpEShopStoresTransactions");
});
modelBuilder.Entity("EasyAbp.PaymentService.Payments.Payment", b =>
{
b.Property<Guid>("Id")

Loading…
Cancel
Save