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.Catalog;
|
||||||
using Nop.Services.Configuration;
|
using Nop.Services.Configuration;
|
||||||
using Nop.Services.Localization;
|
using Nop.Services.Localization;
|
||||||
|
using Nop.Services.Orders;
|
||||||
using Nop.Web.Framework;
|
using Nop.Web.Framework;
|
||||||
using Nop.Web.Framework.Mvc.Routing;
|
using Nop.Web.Framework.Mvc.Routing;
|
||||||
|
|
||||||
|
|
@ -68,6 +69,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||||
|
|
||||||
services.AddScoped<MyProductModelFactory>();
|
services.AddScoped<MyProductModelFactory>();
|
||||||
services.AddScoped<SignalRMessageHandler>();
|
services.AddScoped<SignalRMessageHandler>();
|
||||||
|
services.AddScoped<IOrderService, OrderService>();
|
||||||
|
services.AddScoped<IOrderProcessingService, OrderProcessingService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using Nop.Core.Caching;
|
using Nop.Core.Caching;
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
using Nop.Core.Domain.Customers;
|
using Nop.Core.Domain.Customers;
|
||||||
|
using Nop.Core.Domain.Orders;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
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.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
|
using Nop.Services.Orders;
|
||||||
|
using Nop.Services.Payments;
|
||||||
using Org.BouncyCastle.Crypto;
|
using Org.BouncyCastle.Crypto;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
@ -38,6 +41,7 @@ public class AuctionService : IAuctionService
|
||||||
private readonly IShortTermCacheManager _shortTermCacheManager;
|
private readonly IShortTermCacheManager _shortTermCacheManager;
|
||||||
private readonly IStaticCacheManager _staticCacheManager;
|
private readonly IStaticCacheManager _staticCacheManager;
|
||||||
private readonly IWorkContext _workContext;
|
private readonly IWorkContext _workContext;
|
||||||
|
private readonly IOrderProcessingService _orderProcessingService;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -60,6 +64,7 @@ public class AuctionService : IAuctionService
|
||||||
IShortTermCacheManager shortTermCacheManager,
|
IShortTermCacheManager shortTermCacheManager,
|
||||||
IStaticCacheManager staticCacheManager,
|
IStaticCacheManager staticCacheManager,
|
||||||
IWorkContext workContext,
|
IWorkContext workContext,
|
||||||
|
IOrderProcessingService orderProcessingService,
|
||||||
ILogger logger)
|
ILogger logger)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
|
@ -70,6 +75,7 @@ public class AuctionService : IAuctionService
|
||||||
_shortTermCacheManager = shortTermCacheManager;
|
_shortTermCacheManager = shortTermCacheManager;
|
||||||
_staticCacheManager = staticCacheManager;
|
_staticCacheManager = staticCacheManager;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
|
_orderProcessingService = orderProcessingService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,6 +219,13 @@ public class AuctionService : IAuctionService
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task CreateOrderForWinner(ProductToAuctionMapping auctionItem)
|
||||||
|
{
|
||||||
|
var processPaymentRequest = new ProcessPaymentRequest();
|
||||||
|
|
||||||
|
await _orderProcessingService.PlaceOrderAsync(processPaymentRequest);
|
||||||
|
}
|
||||||
|
|
||||||
#region auctions
|
#region auctions
|
||||||
public async Task InsertAuctionAsync(Auction auction)
|
public async Task InsertAuctionAsync(Auction auction)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,6 @@ public interface IAuctionService
|
||||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);
|
Task<List<ProductToAuctionMapping>> GetProductToAuctionByAuctionIdAndProductIdAsync(int auctionId, int productId, bool activeProductOnly);
|
||||||
Task<ProductToAuctionMapping> GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId);
|
Task<ProductToAuctionMapping> GetProductToAuctionMappingByIdAsync(int productToAuctionMappingId);
|
||||||
Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping);
|
Task UpdateProductToAuctionMappingAsync(ProductToAuctionMapping productToAuctionMapping);
|
||||||
|
|
||||||
|
Task CreateOrderForWinner(ProductToAuctionMapping productToAuctionMapping);
|
||||||
}
|
}
|
||||||
|
|
@ -9,93 +9,93 @@
|
||||||
@{
|
@{
|
||||||
if (!Model.IsGuest)
|
if (!Model.IsGuest)
|
||||||
{
|
{
|
||||||
<div id="publicProductBidBox" class="p-3 bg-primary text-white">
|
<div id="publicProductBidBox" class="p-3 bg-primary text-white">
|
||||||
<h4>This item is under auction!</h4>
|
<h4>This item is under auction!</h4>
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<div>
|
<div>
|
||||||
<strong>Base Price:</strong>
|
<strong>Base Price:</strong>
|
||||||
<span class="value">
|
<span class="value">
|
||||||
@($"{Model.BasePrice:c}")
|
@($"{Model.BasePrice:c}")
|
||||||
@* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@
|
@* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Bid Step:</strong>
|
<strong>Bid Step:</strong>
|
||||||
<span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
<span id="licitStepText" class="value">@($"{Model.LicitStep:c}")</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button" disabled="@(!Model.IsItemActive)">
|
<button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button" disabled="@(!Model.IsItemActive)">
|
||||||
Bid @($"{Model.NextBidPrice:c}")
|
Bid @($"{Model.NextBidPrice:c}")
|
||||||
</button>
|
</button>
|
||||||
@* <button id="bidButton" class="btn btn-success">
|
@* <button id="bidButton" class="btn btn-success">
|
||||||
|
|
||||||
Bid @String.Format("{0:c}", Model.NextBidPrice)
|
Bid @String.Format("{0:c}", Model.NextBidPrice)
|
||||||
</button> *@
|
</button> *@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@* <button id="testButton" class="btn btn-success">
|
@* <button id="testButton" class="btn btn-success">
|
||||||
TestButton
|
TestButton
|
||||||
</button> *@
|
</button> *@
|
||||||
|
|
||||||
<div id="bidFeedback" class="mt-3"></div>
|
<div id="bidFeedback" class="mt-3"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
if (Model.IsAdmin)
|
if (Model.IsAdmin)
|
||||||
{
|
{
|
||||||
<div id="publicProductBidBoxAdmin" class="p-3 bg-secondary text-white">
|
<div id="publicProductBidBoxAdmin" class="p-3 bg-secondary text-white">
|
||||||
<h4>Manage auction!</h4>
|
<h4>Manage auction!</h4>
|
||||||
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
<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>
|
||||||
</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>
|
||||||
|
<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
|
else
|
||||||
{
|
{
|
||||||
<p>No access to admin level buttons</p>
|
<p>No access to admin level buttons</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div id="publicProductBidBoxGuest" class="p-3 bg-primary text-white">
|
<div id="publicProductBidBoxGuest" class="p-3 bg-primary text-white">
|
||||||
<h4>This item is under auction!</h4>
|
<h4>This item is under auction!</h4>
|
||||||
<div id="bidBoxGuestMessage" class="d-flex justify-content-between mb-3">
|
<div id="bidBoxGuestMessage" class="d-flex justify-content-between mb-3">
|
||||||
|
|
||||||
<p>Please log in or register to participate!</p>
|
<p>Please log in or register to participate!</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@
|
||||||
console.log(productAuctionMappingId);
|
console.log(productAuctionMappingId);
|
||||||
var status = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
var status = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
||||||
//if (status == AuctionStatus.FirstWarning) {
|
//if (status == AuctionStatus.FirstWarning) {
|
||||||
setButtons(status);
|
setButtons(status);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// if (productAuctionMappingId == bidBoxPageViewModel.ProductToAuctionId) {
|
// 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) {
|
function setButtons(auctionStatus) {
|
||||||
console.log("SetButtons called: " + auctionStatus);
|
console.log("SetButtons called: " + auctionStatus);
|
||||||
|
|
@ -400,8 +353,8 @@
|
||||||
signalROpenItemButton: false,
|
signalROpenItemButton: false,
|
||||||
signalRCloseItemButton: true,
|
signalRCloseItemButton: true,
|
||||||
signalRPauseItemButton: true,
|
signalRPauseItemButton: true,
|
||||||
signalRRevertBidButton: true,
|
signalRRevertBidButton: false,
|
||||||
signalRResetItemButton: true,
|
signalRResetItemButton: false,
|
||||||
},
|
},
|
||||||
[AuctionStatus.Sold]: {
|
[AuctionStatus.Sold]: {
|
||||||
signalRBidButton: true,
|
signalRBidButton: true,
|
||||||
|
|
@ -437,6 +390,7 @@
|
||||||
const button = document.getElementById(buttonId);
|
const button = document.getElementById(buttonId);
|
||||||
if (button) {
|
if (button) {
|
||||||
button.disabled = states[buttonId];
|
button.disabled = states[buttonId];
|
||||||
|
button.hidden = states[buttonId];
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Button with ID ${buttonId} not found.`);
|
console.warn(`Button with ID ${buttonId} not found.`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue