|
|
@ -26,7 +26,7 @@ namespace EasyAbp.EShop.Payments.Payments |
|
|
private readonly IDistributedEventBus _distributedEventBus; |
|
|
private readonly IDistributedEventBus _distributedEventBus; |
|
|
private readonly IOrderAppService _orderAppService; |
|
|
private readonly IOrderAppService _orderAppService; |
|
|
private readonly IPaymentRepository _repository; |
|
|
private readonly IPaymentRepository _repository; |
|
|
|
|
|
|
|
|
public PaymentAppService( |
|
|
public PaymentAppService( |
|
|
IDistributedEventBus distributedEventBus, |
|
|
IDistributedEventBus distributedEventBus, |
|
|
IOrderAppService orderAppService, |
|
|
IOrderAppService orderAppService, |
|
|
@ -49,7 +49,7 @@ namespace EasyAbp.EShop.Payments.Payments |
|
|
|
|
|
|
|
|
return payment; |
|
|
return payment; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override IQueryable<Payment> CreateFilteredQuery(GetPaymentListDto input) |
|
|
protected override IQueryable<Payment> CreateFilteredQuery(GetPaymentListDto input) |
|
|
{ |
|
|
{ |
|
|
var query = base.CreateFilteredQuery(input); |
|
|
var query = base.CreateFilteredQuery(input); |
|
|
@ -73,19 +73,19 @@ namespace EasyAbp.EShop.Payments.Payments |
|
|
|
|
|
|
|
|
return await base.GetListAsync(input); |
|
|
return await base.GetListAsync(input); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Authorize(PaymentsPermissions.Payments.Create)] |
|
|
[Authorize(PaymentsPermissions.Payments.Create)] |
|
|
public virtual async Task CreateAsync(CreatePaymentDto input) |
|
|
public virtual async Task CreateAsync(CreatePaymentDto input) |
|
|
{ |
|
|
{ |
|
|
// Todo: should avoid duplicate creations. (concurrent lock)
|
|
|
// Todo: should avoid duplicate creations. (concurrent lock)
|
|
|
|
|
|
|
|
|
var orders = new List<OrderDto>(); |
|
|
var orders = new List<OrderDto>(); |
|
|
|
|
|
|
|
|
foreach (var orderId in input.OrderIds) |
|
|
foreach (var orderId in input.OrderIds) |
|
|
{ |
|
|
{ |
|
|
orders.Add(await _orderAppService.GetAsync(orderId)); |
|
|
orders.Add(await _orderAppService.GetAsync(orderId)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await AuthorizationService.CheckAsync( |
|
|
await AuthorizationService.CheckAsync( |
|
|
new PaymentCreationResource |
|
|
new PaymentCreationResource |
|
|
{ |
|
|
{ |
|
|
@ -95,20 +95,18 @@ namespace EasyAbp.EShop.Payments.Payments |
|
|
new PaymentOperationAuthorizationRequirement(PaymentOperation.Creation) |
|
|
new PaymentOperationAuthorizationRequirement(PaymentOperation.Creation) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
var createPaymentEto = new CreatePaymentEto |
|
|
var createPaymentEto = new CreatePaymentEto( |
|
|
{ |
|
|
tenantId: CurrentTenant.Id, |
|
|
TenantId = CurrentTenant.Id, |
|
|
userId: CurrentUser.GetId(), paymentMethod: input.PaymentMethod, currency: orders.First().Currency, |
|
|
UserId = CurrentUser.GetId(), |
|
|
paymentItems: orders.Select(order => new CreatePaymentItemEto |
|
|
PaymentMethod = input.PaymentMethod, |
|
|
|
|
|
Currency = orders.First().Currency, |
|
|
|
|
|
ExtraProperties = new ExtraPropertyDictionary(), |
|
|
|
|
|
PaymentItems = orders.Select(order => new CreatePaymentItemEto |
|
|
|
|
|
{ |
|
|
{ |
|
|
ItemType = PaymentsConsts.PaymentItemType, |
|
|
ItemType = PaymentsConsts.PaymentItemType, |
|
|
ItemKey = order.Id.ToString(), |
|
|
ItemKey = order.Id.ToString(), |
|
|
OriginalPaymentAmount = order.ActualTotalPrice, |
|
|
OriginalPaymentAmount = order.ActualTotalPrice, |
|
|
ExtraProperties = new ExtraPropertyDictionary {{"StoreId", order.StoreId.ToString()}} |
|
|
ExtraProperties = new ExtraPropertyDictionary { { "StoreId", order.StoreId.ToString() } } |
|
|
}).ToList() |
|
|
}).ToList()) |
|
|
|
|
|
{ |
|
|
|
|
|
ExtraProperties = new ExtraPropertyDictionary() |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
await _distributedEventBus.PublishAsync(createPaymentEto); |
|
|
await _distributedEventBus.PublishAsync(createPaymentEto); |
|
|
|