From f7bc19be7e5bace770b4d78807f83961a76d7bde Mon Sep 17 00:00:00 2001 From: Huei Feng <695979933@qq.com> Date: Sun, 7 Feb 2021 22:37:08 +0800 Subject: [PATCH] fix error code --- .../Payments/Payments/PaymentAppService.cs | 28 +++++++++---------- .../Payments/Refunds/RefundAppService.cs | 18 +++++------- .../Properties/launchSettings.json | 27 ++++++++++++++++++ 3 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Properties/launchSettings.json diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/PaymentAppService.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/PaymentAppService.cs index fc4801b3..a77c12a3 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/PaymentAppService.cs +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/PaymentAppService.cs @@ -26,7 +26,7 @@ namespace EasyAbp.EShop.Payments.Payments private readonly IDistributedEventBus _distributedEventBus; private readonly IOrderAppService _orderAppService; private readonly IPaymentRepository _repository; - + public PaymentAppService( IDistributedEventBus distributedEventBus, IOrderAppService orderAppService, @@ -49,7 +49,7 @@ namespace EasyAbp.EShop.Payments.Payments return payment; } - + protected override IQueryable CreateFilteredQuery(GetPaymentListDto input) { var query = base.CreateFilteredQuery(input); @@ -73,19 +73,19 @@ namespace EasyAbp.EShop.Payments.Payments return await base.GetListAsync(input); } - + [Authorize(PaymentsPermissions.Payments.Create)] public virtual async Task CreateAsync(CreatePaymentDto input) { // Todo: should avoid duplicate creations. (concurrent lock) var orders = new List(); - + foreach (var orderId in input.OrderIds) { orders.Add(await _orderAppService.GetAsync(orderId)); } - + await AuthorizationService.CheckAsync( new PaymentCreationResource { @@ -95,20 +95,18 @@ namespace EasyAbp.EShop.Payments.Payments new PaymentOperationAuthorizationRequirement(PaymentOperation.Creation) ); - var createPaymentEto = new CreatePaymentEto - { - TenantId = CurrentTenant.Id, - UserId = CurrentUser.GetId(), - PaymentMethod = input.PaymentMethod, - Currency = orders.First().Currency, - ExtraProperties = new ExtraPropertyDictionary(), - PaymentItems = orders.Select(order => new CreatePaymentItemEto + var createPaymentEto = new CreatePaymentEto( + tenantId: CurrentTenant.Id, + userId: CurrentUser.GetId(), paymentMethod: input.PaymentMethod, currency: orders.First().Currency, + paymentItems: orders.Select(order => new CreatePaymentItemEto { ItemType = PaymentsConsts.PaymentItemType, ItemKey = order.Id.ToString(), OriginalPaymentAmount = order.ActualTotalPrice, - ExtraProperties = new ExtraPropertyDictionary {{"StoreId", order.StoreId.ToString()}} - }).ToList() + ExtraProperties = new ExtraPropertyDictionary { { "StoreId", order.StoreId.ToString() } } + }).ToList()) + { + ExtraProperties = new ExtraPropertyDictionary() }; await _distributedEventBus.PublishAsync(createPaymentEto); diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs index e42589f1..a49c2d1c 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs @@ -31,7 +31,7 @@ namespace EasyAbp.EShop.Payments.Refunds private readonly IPaymentRepository _paymentRepository; private readonly IJsonSerializer _jsonSerializer; private readonly IRefundRepository _repository; - + public RefundAppService( IOrderAppService orderAppService, IDistributedEventBus distributedEventBus, @@ -52,7 +52,7 @@ namespace EasyAbp.EShop.Payments.Refunds var refund = await base.GetAsync(id); var payment = await _paymentRepository.GetAsync(refund.PaymentId); - + if (payment.UserId != CurrentUser.GetId()) { await CheckPolicyAsync(GetPolicyName); @@ -60,7 +60,7 @@ namespace EasyAbp.EShop.Payments.Refunds return refund; } - + protected override IQueryable CreateFilteredQuery(GetRefundListDto input) { var query = input.UserId.HasValue ? _repository.GetQueryableByUserId(input.UserId.Value) : _repository; @@ -85,7 +85,7 @@ namespace EasyAbp.EShop.Payments.Refunds await AuthorizationService.CheckAsync(PaymentsPermissions.Refunds.Manage); var payment = await _paymentRepository.GetAsync(input.PaymentId); - + var createRefundInput = new CreateRefundInput { PaymentId = input.PaymentId, @@ -93,7 +93,7 @@ namespace EasyAbp.EShop.Payments.Refunds CustomerRemark = input.CustomerRemark, StaffRemark = input.StaffRemark }; - + foreach (var refundItem in input.RefundItems) { var order = await _orderAppService.GetAsync(refundItem.OrderId); @@ -110,7 +110,7 @@ namespace EasyAbp.EShop.Payments.Refunds foreach (var orderLineRefundInfoModel in refundItem.OrderLines) { var orderLine = order.OrderLines.Single(x => x.Id == orderLineRefundInfoModel.OrderLineId); - + if (orderLine.RefundedQuantity + orderLineRefundInfoModel.Quantity > orderLine.Quantity) { throw new InvalidRefundQuantityException(orderLineRefundInfoModel.Quantity); @@ -132,11 +132,7 @@ namespace EasyAbp.EShop.Payments.Refunds }); } - await _distributedEventBus.PublishAsync(new RefundPaymentEto - { - TenantId = CurrentTenant.Id, - CreateRefundInput = createRefundInput - }); + await _distributedEventBus.PublishAsync(new RefundPaymentEto(tenantId: CurrentTenant.Id, createRefundInput)); } } } \ No newline at end of file diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Properties/launchSettings.json b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Properties/launchSettings.json new file mode 100644 index 00000000..729d257e --- /dev/null +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54581/", + "sslPort": 44336 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "EasyAbp.EShop.Plugins.Coupons.Web": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file