mirror of https://github.com/EasyAbp/EShop.git
63 changed files with 9557 additions and 23 deletions
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Orders.Orders |
||||
|
{ |
||||
|
[Serializable] |
||||
|
public class OrderCanceledEto |
||||
|
{ |
||||
|
public OrderEto Order { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Orders.Orders |
||||
|
{ |
||||
|
[Serializable] |
||||
|
public class OrderCompletedEto |
||||
|
{ |
||||
|
public OrderEto Order { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
|
} |
||||
@ -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> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
namespace EasyAbp.EShop.Stores |
||||
|
{ |
||||
|
public static class StoresConsts |
||||
|
{ |
||||
|
public const string TransactionOrderCompletedActionName = "OrderCompleted"; |
||||
|
|
||||
|
public const string TransactionOrderRefundedActionName = "OrderRefunded"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Stores.Transactions |
||||
|
{ |
||||
|
[Flags] |
||||
|
public enum TransactionType |
||||
|
{ |
||||
|
Debit = 1, |
||||
|
Credit = 2 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Stores.Transactions |
||||
|
{ |
||||
|
public interface ITransactionRepository : IRepository<Transaction, Guid> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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> |
||||
@ -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(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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> |
||||
@ -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(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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> |
||||
@ -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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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,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(); |
||||
|
}); |
||||
|
}); |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
@ -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"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
@ -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)"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue