jkhklhkl
This commit is contained in:
parent
5a0031f9a4
commit
9f9399eb1b
|
|
@ -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<MyProductModelFactory>();
|
||||
services.AddScoped<SignalRMessageHandler>();
|
||||
services.AddScoped<IOrderService, OrderService>();
|
||||
services.AddScoped<IOrderProcessingService, OrderProcessingService>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,4 +58,6 @@ public interface IAuctionService
|
|||
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);
|
||||
Task<ProductToAuctionMapping> GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId);
|
||||
Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping);
|
||||
|
||||
Task CreateOrderForWinner(ProductToAuctionMapping productToAuctionMapping);
|
||||
}
|
||||
|
|
@ -9,93 +9,93 @@
|
|||
@{
|
||||
if (!Model.IsGuest)
|
||||
{
|
||||
<div id="publicProductBidBox" class="p-3 bg-primary text-white">
|
||||
<h4>This item is under auction!</h4>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<strong>Base Price:</strong>
|
||||
<span class="value">
|
||||
@($"{Model.BasePrice:c}")
|
||||
@* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>Bid Step:</strong>
|
||||
<span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
||||
</div>
|
||||
<div>
|
||||
<button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button" disabled="@(!Model.IsItemActive)">
|
||||
Bid @($"{Model.NextBidPrice:c}")
|
||||
</button>
|
||||
@* <button id="bidButton" class="btn btn-success">
|
||||
<div id="publicProductBidBox" class="p-3 bg-primary text-white">
|
||||
<h4>This item is under auction!</h4>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<strong>Base Price:</strong>
|
||||
<span class="value">
|
||||
@($"{Model.BasePrice:c}")
|
||||
@* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>Bid Step:</strong>
|
||||
<span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
||||
</div>
|
||||
<div>
|
||||
<button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button" disabled="@(!Model.IsItemActive)">
|
||||
Bid @($"{Model.NextBidPrice:c}")
|
||||
</button>
|
||||
@* <button id="bidButton" class="btn btn-success">
|
||||
|
||||
Bid @String.Format("{0:c}", Model.NextBidPrice)
|
||||
</button> *@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@* <button id="testButton" class="btn btn-success">
|
||||
@* <button id="testButton" class="btn btn-success">
|
||||
TestButton
|
||||
</button> *@
|
||||
|
||||
<div id="bidFeedback" class="mt-3"></div>
|
||||
</div>
|
||||
<div id="bidFeedback" class="mt-3"></div>
|
||||
</div>
|
||||
|
||||
|
||||
if (Model.IsAdmin)
|
||||
{
|
||||
<div id="publicProductBidBoxAdmin" class="p-3 bg-secondary text-white">
|
||||
<h4>Manage auction!</h4>
|
||||
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
||||
|
||||
<div>
|
||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Active ? "disabled" : string.Empty)>
|
||||
First warning
|
||||
</button>
|
||||
<button id="signalRSecondWarningButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.FirstWarning ? "disabled" : string.Empty)>
|
||||
Second warning
|
||||
</button>
|
||||
<button id="signalRCloseItemButton" class="btn btn-success" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.SecondWarning ? "disabled" : string.Empty)>
|
||||
Finished
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button id="signalROpenItemButton" class="btn btn-primary" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.None || Model.AuctionStatus == AuctionStatus.Pause ? string.Empty : "disabled")>
|
||||
Open item
|
||||
</button>
|
||||
<button id="signalRPauseItemButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.Active || Model.AuctionStatus == AuctionStatus.FirstWarning || Model.AuctionStatus == AuctionStatus.SecondWarning ? string.Empty : "disabled")>
|
||||
Pause auction
|
||||
</button>
|
||||
<button id="signalRRevertBidButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled" : string.Empty)>
|
||||
Revert bid
|
||||
</button>
|
||||
<button id="signalRResetItemButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled" : string.Empty)>
|
||||
Reset auction
|
||||
</button>
|
||||
</div>
|
||||
<div id="publicProductBidBoxAdmin" class="p-3 bg-secondary text-white">
|
||||
<h4>Manage auction!</h4>
|
||||
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<button id="signalROpenItemButton" class="btn btn-primary" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.None || Model.AuctionStatus == AuctionStatus.Pause ? string.Empty : "disabled")>
|
||||
Open item
|
||||
</button>
|
||||
<button id="signalRPauseItemButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus == AuctionStatus.Active || Model.AuctionStatus == AuctionStatus.FirstWarning || Model.AuctionStatus == AuctionStatus.SecondWarning ? string.Empty : "disabled")>
|
||||
Pause auction
|
||||
</button>
|
||||
<button id="signalRRevertBidButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled" : string.Empty)>
|
||||
Revert bid
|
||||
</button>
|
||||
<button id="signalRResetItemButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Pause ? "disabled" : string.Empty)>
|
||||
Reset auction
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.Active ? "disabled" : string.Empty)>
|
||||
First warning
|
||||
</button>
|
||||
<button id="signalRSecondWarningButton" class="btn btn-danger" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.FirstWarning ? "disabled" : string.Empty)>
|
||||
Second warning
|
||||
</button>
|
||||
<button id="signalRCloseItemButton" class="btn btn-success" style="text-transform: uppercase;" type="button" @(Model.AuctionStatus != AuctionStatus.SecondWarning ? "disabled" : string.Empty)>
|
||||
Finished
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No access to admin level buttons</p>
|
||||
<p>No access to admin level buttons</p>
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<div id="publicProductBidBoxGuest" class="p-3 bg-primary text-white">
|
||||
<h4>This item is under auction!</h4>
|
||||
<div id="bidBoxGuestMessage" class="d-flex justify-content-between mb-3">
|
||||
<div id="publicProductBidBoxGuest" class="p-3 bg-primary text-white">
|
||||
<h4>This item is under auction!</h4>
|
||||
<div id="bidBoxGuestMessage" class="d-flex justify-content-between mb-3">
|
||||
|
||||
<p>Please log in or register to participate!</p>
|
||||
</div>
|
||||
</div>
|
||||
<p>Please log in or register to participate!</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
@ -400,8 +353,8 @@
|
|||
signalROpenItemButton: false,
|
||||
signalRCloseItemButton: true,
|
||||
signalRPauseItemButton: true,
|
||||
signalRRevertBidButton: true,
|
||||
signalRResetItemButton: 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.`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue