order müxik
This commit is contained in:
parent
c8ebc1b5e2
commit
e795abfa20
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public class AuctionService : IAuctionService
|
|||
private readonly IProductService _productService;
|
||||
private readonly IWorkContext _workContext;
|
||||
private readonly IOrderProcessingService _orderProcessingService;
|
||||
private readonly IShoppingCartService _shoppingCartService;
|
||||
private readonly IStoreContext _storeContext;
|
||||
private readonly ILogger _logger;
|
||||
#endregion
|
||||
|
||||
|
|
@ -40,12 +42,21 @@ public class AuctionService : IAuctionService
|
|||
/// <param name="productService"></param>
|
||||
/// <param name="workContext"></param>
|
||||
/// <param name="logger"></param>
|
||||
public AuctionService(AuctionDbContext ctx, IProductService productService, IWorkContext workContext, IOrderProcessingService orderProcessingService, 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;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
|
@ -193,12 +204,21 @@ public class AuctionService : IAuctionService
|
|||
{
|
||||
var processPaymentRequest = new ProcessPaymentRequest
|
||||
{
|
||||
PaymentMethodSystemName = "Payments.CheckMoneyOrder",
|
||||
CustomerId = auctionItem.WinnerCustomerId,
|
||||
OrderTotal = auctionItem.CurrentPrice,
|
||||
OrderGuid = auctionItem.OrderGuid.IsNullOrEmpty() ? Guid.NewGuid() : auctionItem.OrderGuid.Value
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
|
||||
var placeOrderResult = await _orderProcessingService.PlaceOrderAsync(processPaymentRequest);
|
||||
|
||||
if (!placeOrderResult.Success) return null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue