diff --git a/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs index 69a39c5..7cfb9e9 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs @@ -21,6 +21,7 @@ using Nop.Plugin.Misc.AuctionPlugin.Services; using Nop.Services.Catalog; using Nop.Services.Configuration; using Nop.Services.Localization; +using Nop.Services.Orders; using Nop.Web.Framework; using Nop.Web.Framework.Mvc.Routing; @@ -68,6 +69,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } /// diff --git a/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs b/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs index b87d786..d100a63 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs @@ -2,6 +2,7 @@ using Nop.Core.Caching; using Nop.Core.Domain.Catalog; using Nop.Core.Domain.Customers; +using Nop.Core.Domain.Orders; using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer; using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities; @@ -9,6 +10,8 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums; using Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages; using Nop.Services.Catalog; using Nop.Services.Logging; +using Nop.Services.Orders; +using Nop.Services.Payments; using Org.BouncyCastle.Crypto; namespace Nop.Plugin.Misc.AuctionPlugin.Services; @@ -38,6 +41,7 @@ public class AuctionService : IAuctionService private readonly IShortTermCacheManager _shortTermCacheManager; private readonly IStaticCacheManager _staticCacheManager; private readonly IWorkContext _workContext; + private readonly IOrderProcessingService _orderProcessingService; private readonly ILogger _logger; #endregion @@ -60,6 +64,7 @@ public class AuctionService : IAuctionService IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, IWorkContext workContext, + IOrderProcessingService orderProcessingService, ILogger logger) { _ctx = ctx; @@ -70,6 +75,7 @@ public class AuctionService : IAuctionService _shortTermCacheManager = shortTermCacheManager; _staticCacheManager = staticCacheManager; _workContext = workContext; + _orderProcessingService = orderProcessingService; _logger = logger; } @@ -213,6 +219,13 @@ public class AuctionService : IAuctionService await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY); } + public async Task CreateOrderForWinner(ProductToAuctionMapping auctionItem) + { + var processPaymentRequest = new ProcessPaymentRequest(); + + await _orderProcessingService.PlaceOrderAsync(processPaymentRequest); + } + #region auctions public async Task InsertAuctionAsync(Auction auction) { diff --git a/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs b/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs index 49691a5..2628562 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Services/IAuctionService.cs @@ -58,4 +58,6 @@ public interface IAuctionService Task> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly); Task GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId); Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping); + + Task CreateOrderForWinner(ProductToAuctionMapping productToAuctionMapping); } \ No newline at end of file diff --git a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml index 05a45ef..3ef195b 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml +++ b/Nop.Plugin.Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml @@ -9,93 +9,93 @@ @{ if (!Model.IsGuest) { -
-

This item is under auction!

-
-
- Base Price: - - @($"{Model.BasePrice:c}") - @* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@ - -
-
- Bid Step: - @($"{Model.LicitStep:c}") -
-
- - @* + @* *@ -
-
+
+ - @* *@ -
- +
+ if (Model.IsAdmin) { -
-

Manage auction!

-
- -
- - - -
-
- - - - -
+
+

Manage auction!

+
- -
+
+ + + +
+
+ + + +
+ + +
+
} else { -

No access to admin level buttons

+

No access to admin level buttons

} } else { -
-

This item is under auction!

-
+
+

This item is under auction!

+
-

Please log in or register to participate!

-
-
+

Please log in or register to participate!

+
+
} } @@ -233,7 +233,7 @@ console.log(productAuctionMappingId); var status = data.auctionDto.productToAuctionDtos[0].auctionStatus; //if (status == AuctionStatus.FirstWarning) { - setButtons(status); + setButtons(status); //} // if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) { @@ -299,53 +299,6 @@ } } - // function setButtons(auctionStatus) { - // console.log("SetButtons called" + auctionStatus); - - - // var bidButton = document.getElementById("signalRBidButton"); - // var firstWarningButton = document.getElementById("signalRFirstWarningButton"); - // var secondWarningButton = document.getElementById("signalRSecondWarningButton"); - // var openItemButton = document.getElementById("signalROpenItemButton"); - // var closeItemButton = document.getElementById("signalRCloseItemButton"); - // var pauseItemButton = document.getElementById("signalRPauseItemButton"); - // var revertBidButton = document.getElementById("signalRRevertBidButton"); - // var resetItemButton = document.getElementById("signalRResetItemButton"); - - // switch (auctionStatus) { - // case AuctionStatus.None: - // console.log("SWITCH: 0"); - // bidButton.disabled = true; - // break; - // case AuctionStatus.Active: - // console.log("SWITCH: 1"); - // bidButton.disabled = false; - // firstWarningButton.disabled = false; - // break; - // case AuctionStatus.FirstWarning: - // console.log("SWITCH: 1"); - // bidButton.disabled = false; - // firstWarningButton.disabled = true; - // secondWarningButton.disabled = false; - // break; - // case AuctionStatus.SecondWarning: - // // code block - // break; - // case AuctionStatus.Pause: - // // code block - // break; - // case AuctionStatus.Sold: - // // code block - // break; - // case AuctionStatus.NotSold: - // // code block - // break; - // default: - // // code block - // } - - // } - function setButtons(auctionStatus) { console.log("SetButtons called: " + auctionStatus); @@ -394,14 +347,14 @@ signalRResetItemButton: true, }, [AuctionStatus.Pause]: { - signalRBidButton: true, - signalRFirstWarningButton: true, - signalRSecondWarningButton: true, - signalROpenItemButton: false, - signalRCloseItemButton: true, - signalRPauseItemButton: true, - signalRRevertBidButton: false, - signalRResetItemButton: false, + signalRBidButton: true, + signalRFirstWarningButton: true, + signalRSecondWarningButton: true, + signalROpenItemButton: false, + signalRCloseItemButton: true, + signalRPauseItemButton: true, + signalRRevertBidButton: false, + signalRResetItemButton: false, }, [AuctionStatus.Sold]: { signalRBidButton: true, @@ -437,6 +390,7 @@ const button = document.getElementById(buttonId); if (button) { button.disabled = states[buttonId]; + // button.hidden = states[buttonId]; } else { console.warn(`Button with ID ${buttonId} not found.`); }