This commit is contained in:
Loretta 2024-11-28 06:51:08 +01:00
commit 7683d63d90
2 changed files with 24 additions and 3 deletions

View File

@ -71,6 +71,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
services.AddScoped<SignalRMessageHandler>();
services.AddScoped<IOrderService, OrderService>();
services.AddScoped<IOrderProcessingService, OrderProcessingService>();
services.AddScoped<IShoppingCartService, ShoppingCartService>();
services.AddScoped<IStoreContext, WebStoreContext>();
}
/// <summary>

View File

@ -23,6 +23,8 @@ public class AuctionService : IAuctionService
private readonly IWorkContext _workContext;
private readonly IPaymentService _paymentService;
private readonly IOrderProcessingService _orderProcessingService;
private readonly IShoppingCartService _shoppingCartService;
private readonly IStoreContext _storeContext;
private readonly ILogger _logger;
#endregion
@ -36,13 +38,21 @@ public class AuctionService : IAuctionService
/// <param name="workContext"></param>
/// <param name="paymentService"></param>
/// <param name="logger"></param>
/// <param name="orderProcessingService"></param>
public AuctionService(AuctionDbContext ctx, IProductService productService, IWorkContext workContext, IOrderProcessingService orderProcessingService, IPaymentService paymentService, ILogger logger)
public AuctionService(
AuctionDbContext ctx,
IProductService productService,
IWorkContext workContext,
IOrderProcessingService orderProcessingService,
IShoppingCartService shoppingCartService,
IStoreContext storeContext,
ILogger logger)
{
_ctx = ctx;
_productService = productService;
_workContext = workContext;
_orderProcessingService = orderProcessingService;
_shoppingCartService = shoppingCartService;
_storeContext = storeContext;
_paymentService = paymentService;
_logger = logger;
}
@ -197,12 +207,21 @@ public class AuctionService : IAuctionService
{
var processPaymentRequest = new ProcessPaymentRequest
{
PaymentMethodSystemName = "Payments.CheckMoneyOrder",
CustomerId = auctionItem.WinnerCustomerId,
OrderTotal = auctionItem.CurrentPrice,
};
var currentCustomer = await _workContext.GetCurrentCustomerAsync();
var product = await _productService.GetProductByIdAsync(auctionItem.ProductId);
var currentStore = await _storeContext.GetCurrentStoreAsync();
processPaymentRequest.CustomValues.Add("ProductToAuctionMappingId", auctionItem.Id);
product.DisableBuyButton = false;
var cartResult = await _shoppingCartService.AddToCartAsync(currentCustomer, product, ShoppingCartType.ShoppingCart, currentStore.Id);
//TODO: valszeg a GenerateOrderGuidAsync-ot kell használni, de nemtom egy példában láttam... - J.
await _paymentService.GenerateOrderGuidAsync(processPaymentRequest);