mirror of https://github.com/EasyAbp/EShop.git
48 changed files with 3670 additions and 122 deletions
@ -1,9 +0,0 @@ |
|||||
using System; |
|
||||
using System.ComponentModel; |
|
||||
namespace EasyAbp.EShop.Payments.Payments.Dtos |
|
||||
{ |
|
||||
public class CreateUpdatePaymentDto |
|
||||
{ |
|
||||
public Guid? StoreId { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Payments.Payments.Dtos |
||||
|
{ |
||||
|
public class GetPaymentListDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public Guid? StoreId { get; set; } |
||||
|
|
||||
|
public Guid? UserId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,10 +0,0 @@ |
|||||
using System; |
|
||||
using System.ComponentModel; |
|
||||
namespace EasyAbp.EShop.Payments.Refunds.Dtos |
|
||||
{ |
|
||||
public class CreateUpdateRefundDto |
|
||||
{ |
|
||||
[DisplayName("RefundStoreId")] |
|
||||
public Guid? StoreId { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Payments.Refunds.Dtos |
||||
|
{ |
||||
|
public class GetRefundListDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public Guid? StoreId { get; set; } |
||||
|
|
||||
|
public Guid? UserId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,25 +1,98 @@ |
|||||
using System; |
using System; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
using EasyAbp.EShop.Payments.Authorization; |
using EasyAbp.EShop.Payments.Authorization; |
||||
|
using EasyAbp.EShop.Payments.Payments; |
||||
using EasyAbp.EShop.Payments.Refunds.Dtos; |
using EasyAbp.EShop.Payments.Refunds.Dtos; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Volo.Abp; |
||||
using Volo.Abp.Application.Dtos; |
using Volo.Abp.Application.Dtos; |
||||
using Volo.Abp.Application.Services; |
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
namespace EasyAbp.EShop.Payments.Refunds |
namespace EasyAbp.EShop.Payments.Refunds |
||||
{ |
{ |
||||
public class RefundAppService : CrudAppService<Refund, RefundDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateRefundDto, CreateUpdateRefundDto>, |
[Authorize] |
||||
|
public class RefundAppService : CrudAppService<Refund, RefundDto, Guid, GetRefundListDto, object, object>, |
||||
IRefundAppService |
IRefundAppService |
||||
{ |
{ |
||||
protected override string GetPolicyName { get; set; } = PaymentsPermissions.Refunds.Default; |
protected override string GetPolicyName { get; set; } = PaymentsPermissions.Refunds.Default; |
||||
protected override string GetListPolicyName { get; set; } = PaymentsPermissions.Refunds.Default; |
protected override string GetListPolicyName { get; set; } = PaymentsPermissions.Refunds.Default; |
||||
protected override string CreatePolicyName { get; set; } = PaymentsPermissions.Refunds.Create; |
|
||||
protected override string UpdatePolicyName { get; set; } = PaymentsPermissions.Refunds.Update; |
|
||||
protected override string DeletePolicyName { get; set; } = PaymentsPermissions.Refunds.Delete; |
|
||||
|
|
||||
|
private readonly IPaymentRepository _paymentRepository; |
||||
private readonly IRefundRepository _repository; |
private readonly IRefundRepository _repository; |
||||
|
|
||||
public RefundAppService(IRefundRepository repository) : base(repository) |
public RefundAppService( |
||||
|
IPaymentRepository paymentRepository, |
||||
|
IRefundRepository repository) : base(repository) |
||||
{ |
{ |
||||
|
_paymentRepository = paymentRepository; |
||||
_repository = repository; |
_repository = repository; |
||||
} |
} |
||||
|
|
||||
|
public override async Task<RefundDto> GetAsync(Guid id) |
||||
|
{ |
||||
|
var refund = await base.GetAsync(id); |
||||
|
|
||||
|
var payment = await _paymentRepository.GetAsync(refund.PaymentId); |
||||
|
|
||||
|
if (payment.UserId != CurrentUser.GetId()) |
||||
|
{ |
||||
|
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.Manage); |
||||
|
|
||||
|
// Todo: Check if current user is an admin of the store.
|
||||
|
} |
||||
|
|
||||
|
return refund; |
||||
|
} |
||||
|
|
||||
|
protected override IQueryable<Refund> CreateFilteredQuery(GetRefundListDto input) |
||||
|
{ |
||||
|
var query = input.UserId.HasValue ? _repository.GetQueryableByUserId(input.UserId.Value) : _repository; |
||||
|
|
||||
|
if (input.StoreId.HasValue) |
||||
|
{ |
||||
|
query = query.Where(x => x.StoreId == input.StoreId.Value); |
||||
|
} |
||||
|
|
||||
|
return query; |
||||
|
} |
||||
|
|
||||
|
public override async Task<PagedResultDto<RefundDto>> GetListAsync(GetRefundListDto input) |
||||
|
{ |
||||
|
if (input.UserId != CurrentUser.GetId()) |
||||
|
{ |
||||
|
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.Manage); |
||||
|
|
||||
|
if (input.StoreId.HasValue) |
||||
|
{ |
||||
|
// Todo: Check if current user is an admin of the store.
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.CrossStore); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return await base.GetListAsync(input); |
||||
|
} |
||||
|
|
||||
|
[RemoteService(false)] |
||||
|
public override Task<RefundDto> CreateAsync(object input) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
[RemoteService(false)] |
||||
|
public override Task<RefundDto> UpdateAsync(Guid id, object input) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
|
||||
|
[RemoteService(false)] |
||||
|
public override Task DeleteAsync(Guid id) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,9 +1,11 @@ |
|||||
using System; |
using System; |
||||
|
using System.Linq; |
||||
using Volo.Abp.Domain.Repositories; |
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
namespace EasyAbp.EShop.Payments.Refunds |
namespace EasyAbp.EShop.Payments.Refunds |
||||
{ |
{ |
||||
public interface IRefundRepository : IRepository<Refund, Guid> |
public interface IRefundRepository : IRepository<Refund, Guid> |
||||
{ |
{ |
||||
|
IQueryable<Refund> GetQueryableByUserId(Guid userId); |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using System; |
||||
|
using EasyAbp.PaymentService.Payments; |
||||
|
using EasyAbp.PaymentService.Refunds; |
||||
|
using Volo.Abp.ObjectExtending; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Payments.EntityFrameworkCore |
||||
|
{ |
||||
|
public static class EShopPaymentsEfCoreEntityExtensionMappings |
||||
|
{ |
||||
|
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
||||
|
|
||||
|
public static void Configure() |
||||
|
{ |
||||
|
OneTimeRunner.Run(() => |
||||
|
{ |
||||
|
ObjectExtensionManager.Instance |
||||
|
.MapEfCoreProperty<Payment, Guid?>( |
||||
|
"StoreId" |
||||
|
); |
||||
|
|
||||
|
ObjectExtensionManager.Instance |
||||
|
.MapEfCoreProperty<Refund, Guid?>( |
||||
|
"StoreId" |
||||
|
); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,12 +1,40 @@ |
|||||
|
using System; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using EasyAbp.EShop.Stores.Stores; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
namespace EasyAbp.EShop.Payments.Web.Pages.EShop.Payments.Payments.Payment |
namespace EasyAbp.EShop.Payments.Web.Pages.EShop.Payments.Payments.Payment |
||||
{ |
{ |
||||
public class IndexModel : PaymentsPageModel |
public class IndexModel : PaymentsPageModel |
||||
{ |
{ |
||||
|
private readonly IStoreAppService _storeAppService; |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid? StoreId { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid? UserId { get; set; } |
||||
|
|
||||
|
public string StoreName { get; set; } |
||||
|
|
||||
|
public string UserName { get; set; } |
||||
|
|
||||
|
public IndexModel(IStoreAppService storeAppService) |
||||
|
{ |
||||
|
_storeAppService = storeAppService; |
||||
|
} |
||||
|
|
||||
public async Task OnGetAsync() |
public async Task OnGetAsync() |
||||
{ |
{ |
||||
await Task.CompletedTask; |
if (StoreId.HasValue) |
||||
|
{ |
||||
|
StoreName = (await _storeAppService.GetAsync(StoreId.Value)).Name; |
||||
|
} |
||||
|
|
||||
|
if (UserId.HasValue) |
||||
|
{ |
||||
|
// Todo: get username
|
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,12 +1,40 @@ |
|||||
|
using System; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using EasyAbp.EShop.Stores.Stores; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
|
||||
namespace EasyAbp.EShop.Payments.Web.Pages.EShop.Payments.Refunds.Refund |
namespace EasyAbp.EShop.Payments.Web.Pages.EShop.Payments.Refunds.Refund |
||||
{ |
{ |
||||
public class IndexModel : PaymentsPageModel |
public class IndexModel : PaymentsPageModel |
||||
{ |
{ |
||||
|
private readonly IStoreAppService _storeAppService; |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid? StoreId { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public Guid? UserId { get; set; } |
||||
|
|
||||
|
public string StoreName { get; set; } |
||||
|
|
||||
|
public string UserName { get; set; } |
||||
|
|
||||
|
public IndexModel(IStoreAppService storeAppService) |
||||
|
{ |
||||
|
_storeAppService = storeAppService; |
||||
|
} |
||||
|
|
||||
public async Task OnGetAsync() |
public async Task OnGetAsync() |
||||
{ |
{ |
||||
await Task.CompletedTask; |
if (StoreId.HasValue) |
||||
|
{ |
||||
|
StoreName = (await _storeAppService.GetAsync(StoreId.Value)).Name; |
||||
|
} |
||||
|
|
||||
|
if (UserId.HasValue) |
||||
|
{ |
||||
|
// Todo: get username
|
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
File diff suppressed because it is too large
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace EShopSample.Migrations |
||||
|
{ |
||||
|
public partial class AddedPaymentAndRefundEntities : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "StoreId", |
||||
|
table: "PaymentServiceRefunds", |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<Guid>( |
||||
|
name: "StoreId", |
||||
|
table: "PaymentServicePayments", |
||||
|
nullable: true); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "StoreId", |
||||
|
table: "PaymentServiceRefunds"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "StoreId", |
||||
|
table: "PaymentServicePayments"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue