Compare commits
7 Commits
816eb7f378
...
a2a6f2def3
| Author | SHA1 | Date |
|---|---|---|
|
|
a2a6f2def3 | |
|
|
54619b93f7 | |
|
|
c56d9a7931 | |
|
|
7683d63d90 | |
|
|
d9146a2a62 | |
|
|
b28443c6c4 | |
|
|
d9b4a7ffdd |
|
|
@ -1,10 +1,7 @@
|
||||||
using ExCSS;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
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.Enums;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
|
|
@ -15,194 +12,198 @@ using Nop.Web.Framework.Components;
|
||||||
using Nop.Web.Framework.Infrastructure;
|
using Nop.Web.Framework.Infrastructure;
|
||||||
using Nop.Web.Models.Catalog;
|
using Nop.Web.Models.Catalog;
|
||||||
using Nop.Web.Framework.Mvc.Routing;
|
using Nop.Web.Framework.Mvc.Routing;
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Components;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Components;
|
||||||
|
|
||||||
public class AuctionPublicViewComponent : NopViewComponent
|
public class AuctionPublicViewComponent : NopViewComponent
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
protected readonly IAddressService _addressService;
|
//private readonly IAddressService _addressService;
|
||||||
protected readonly IGenericAttributeService _genericAttributeService;
|
//private readonly IGenericAttributeService _genericAttributeService;
|
||||||
protected readonly IWidgetPluginManager _widgetPluginManager;
|
private readonly IWidgetPluginManager _widgetPluginManager;
|
||||||
protected readonly IWorkContext _workContext;
|
private readonly IWorkContext _workContext;
|
||||||
protected readonly AuctionService _auctionService;
|
private readonly AuctionService _auctionService;
|
||||||
protected readonly AuctionSettings _auctionSettings;
|
//private readonly AuctionSettings _auctionSettings;
|
||||||
protected readonly ICustomerService _customerService;
|
private readonly ICustomerService _customerService;
|
||||||
protected readonly IWebHelper _webHelper;
|
private readonly IWebHelper _webHelper;
|
||||||
protected readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
protected readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
protected readonly MyProductModelFactory _myProductModelFactory;
|
private readonly MyProductModelFactory _myProductModelFactory;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Ctor
|
#region Ctor
|
||||||
|
|
||||||
public AuctionPublicViewComponent(IAddressService addressService,
|
public AuctionPublicViewComponent(
|
||||||
IGenericAttributeService genericAttributeService,
|
//IAddressService addressService,
|
||||||
IWidgetPluginManager widgetPluginManager,
|
//IGenericAttributeService genericAttributeService,
|
||||||
IWorkContext workContext,
|
IWidgetPluginManager widgetPluginManager,
|
||||||
AuctionService auctionService,
|
IWorkContext workContext,
|
||||||
AuctionSettings auctionSettings,
|
AuctionService auctionService,
|
||||||
ICustomerService customerService,
|
//AuctionSettings auctionSettings,
|
||||||
IWebHelper webHelper,
|
ICustomerService customerService,
|
||||||
IProductService productService,
|
IWebHelper webHelper,
|
||||||
MyProductModelFactory myProductModelFactory,
|
IProductService productService,
|
||||||
ILogger logger)
|
MyProductModelFactory myProductModelFactory,
|
||||||
{
|
ILogger logger)
|
||||||
_addressService = addressService;
|
{
|
||||||
_genericAttributeService = genericAttributeService;
|
//_addressService = addressService;
|
||||||
_widgetPluginManager = widgetPluginManager;
|
//_genericAttributeService = genericAttributeService;
|
||||||
_workContext = workContext;
|
_widgetPluginManager = widgetPluginManager;
|
||||||
_auctionService = auctionService;
|
_workContext = workContext;
|
||||||
_auctionSettings = auctionSettings;
|
_auctionService = auctionService;
|
||||||
_customerService = customerService;
|
//_auctionSettings = auctionSettings;
|
||||||
_webHelper = webHelper;
|
_customerService = customerService;
|
||||||
_productService = productService;
|
_webHelper = webHelper;
|
||||||
_myProductModelFactory = myProductModelFactory;
|
_productService = productService;
|
||||||
_logger = logger;
|
_myProductModelFactory = myProductModelFactory;
|
||||||
}
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoke the widget view component
|
/// Invoke the widget view component
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="widgetZone">Widget zone</param>
|
/// <param name="widgetZone">Widget zone</param>
|
||||||
/// <param name="additionalData">Additional parameters</param>
|
/// <param name="additionalData">Additional parameters</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A task that represents the asynchronous operation
|
/// A task that represents the asynchronous operation
|
||||||
/// The task result contains the view component result
|
/// The task result contains the view component result
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
await _logger.InformationAsync("WidgetViewComponent called");
|
await _logger.InformationAsync("WidgetViewComponent called");
|
||||||
|
|
||||||
//ensure that widget is active and enabled
|
//ensure that widget is active and enabled
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||||
await _logger.InformationAsync($"WidgetViewComponent customer: {customer.Email}");
|
await _logger.InformationAsync($"WidgetViewComponent customer: {customer.Email}");
|
||||||
|
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
||||||
await _logger.InformationAsync("WidgetViewComponent widget active");
|
await _logger.InformationAsync("WidgetViewComponent widget active");
|
||||||
|
|
||||||
//if (!_auctionSettings.Enabled)
|
//if (!_auctionSettings.Enabled)
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
|
|
||||||
var productDetailsModel = additionalData as ProductDetailsModel;
|
var productDetailsModel = (additionalData as ProductDetailsModel)!;
|
||||||
|
|
||||||
await _logger.InformationAsync($"WidgetViewComponent product: {productDetailsModel.Name}");
|
await _logger.InformationAsync($"WidgetViewComponent product: {productDetailsModel.Name}");
|
||||||
|
|
||||||
//if (productDetailsModel is null)
|
//if (productDetailsModel is null)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
// await _logger.InformationAsync("WidgetViewComponent productdetailsmodel is null");
|
// await _logger.InformationAsync("WidgetViewComponent productdetailsmodel is null");
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
||||||
{
|
{
|
||||||
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _logger.InformationAsync("WidgetViewComponent called II");
|
await _logger.InformationAsync("WidgetViewComponent called II");
|
||||||
|
|
||||||
//is it under Auction?
|
//is it under Auction?
|
||||||
|
|
||||||
var productId = productDetailsModel.Id;
|
var productId = productDetailsModel.Id;
|
||||||
|
|
||||||
var productToAuction = (await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId)).FirstOrDefault();
|
var productToAuction = (await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId)).FirstOrDefault();
|
||||||
|
|
||||||
if (productToAuction == null)
|
if (productToAuction == null)
|
||||||
{
|
{
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuction.AuctionId, false, false));
|
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuction.AuctionId, false, false));
|
||||||
auctionDto.ProductToAuctionDtos.Add(productToAuction);
|
auctionDto.ProductToAuctionDtos.Add(productToAuction);
|
||||||
|
|
||||||
var productBidBoxViewModel = new ProductBidBoxViewModel(auctionDto);
|
var productBidBoxViewModel = new ProductBidBoxViewModel(auctionDto);
|
||||||
//List<ProductToAuctionMapping> productToAuctionId = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productDetailsModel.Id);
|
//List<ProductToAuctionMapping> productToAuctionId = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productDetailsModel.Id);
|
||||||
|
|
||||||
AuctionStatus status = productToAuction.AuctionStatus;
|
var status = productToAuction.AuctionStatus;
|
||||||
//bool isActive = status == AuctionStatus.Active || status == AuctionStatus.FirstWarning || status == AuctionStatus.SecondWarning;
|
//bool isActive = status == AuctionStatus.Active || status == AuctionStatus.FirstWarning || status == AuctionStatus.SecondWarning;
|
||||||
//bool isFirstWarning = status == AuctionStatus.FirstWarning;
|
//bool isFirstWarning = status == AuctionStatus.FirstWarning;
|
||||||
|
|
||||||
var detailedAuctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuction.AuctionId, true, false));
|
var detailedAuctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuction.AuctionId, true, false));
|
||||||
|
|
||||||
ProductToAuctionDto nextProductToAuction;
|
ProductToAuctionDto nextProductToAuction;
|
||||||
ProductToAuctionDto lastProductToAuction;
|
ProductToAuctionDto lastProductToAuction;
|
||||||
string nextUrl = "";
|
var nextUrl = "";
|
||||||
string lastUrl = "";
|
var lastUrl = "";
|
||||||
string nextImageUrl = "";
|
var nextImageUrl = "";
|
||||||
string lastImageUrl = "";
|
var lastImageUrl = "";
|
||||||
string nextProductName = "";
|
var nextProductName = "";
|
||||||
string lastProductName = "";
|
var lastProductName = "";
|
||||||
|
|
||||||
if (productToAuction.SortIndex < detailedAuctionDto.ProductToAuctionDtos.Count)
|
if (productToAuction.SortIndex < detailedAuctionDto.ProductToAuctionDtos.Count)
|
||||||
{
|
{
|
||||||
nextProductToAuction = detailedAuctionDto.ProductToAuctionDtos.Where(x => x.SortIndex == productToAuction.SortIndex + 1).FirstOrDefault();
|
nextProductToAuction = detailedAuctionDto.ProductToAuctionDtos.FirstOrDefault(x => x.SortIndex == productToAuction.SortIndex + 1);
|
||||||
var nextProductId = nextProductToAuction.ProductId;
|
if (nextProductToAuction != null)
|
||||||
var nextProduct = await _productService.GetProductByIdAsync(nextProductId);
|
{
|
||||||
var nextDetails = await _myProductModelFactory.PrepareProductDetailsModelAsync(nextProduct);
|
var nextProductId = nextProductToAuction.ProductId;
|
||||||
nextUrl = Url.RouteUrl<Product>(new { nextDetails.SeName }, _webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
|
var nextProduct = await _productService.GetProductByIdAsync(nextProductId);
|
||||||
nextImageUrl = nextDetails.DefaultPictureModel.FullSizeImageUrl;
|
var nextDetails = await _myProductModelFactory.PrepareProductDetailsModelAsync(nextProduct);
|
||||||
nextProductName = nextDetails.SeName;
|
nextUrl = Url.RouteUrl<Product>(new { nextDetails.SeName }, _webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
|
||||||
|
nextImageUrl = nextDetails.DefaultPictureModel.FullSizeImageUrl;
|
||||||
|
nextProductName = nextDetails.SeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextProductToAuction = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (productToAuction.SortIndex > 1)
|
||||||
else
|
{
|
||||||
{
|
lastProductToAuction = detailedAuctionDto.ProductToAuctionDtos.FirstOrDefault(x => x.SortIndex == productToAuction.SortIndex - 1);
|
||||||
nextProductToAuction = null;
|
if (lastProductToAuction != null)
|
||||||
}
|
{
|
||||||
|
var lastProductId = lastProductToAuction.ProductId;
|
||||||
|
var lastProduct = await _productService.GetProductByIdAsync(lastProductId);
|
||||||
|
var lastDetails = await _myProductModelFactory.PrepareProductDetailsModelAsync(lastProduct);
|
||||||
|
lastUrl = Url.RouteUrl<Product>(new { lastDetails.SeName }, _webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
|
||||||
|
lastImageUrl = lastDetails.DefaultPictureModel.FullSizeImageUrl;
|
||||||
|
lastProductName = lastDetails.SeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastProductToAuction = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (productToAuction.SortIndex > 1)
|
productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer);
|
||||||
{
|
productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer);
|
||||||
lastProductToAuction = detailedAuctionDto.ProductToAuctionDtos.Where(x => x.SortIndex == productToAuction.SortIndex - 1).FirstOrDefault();
|
productBidBoxViewModel.AuctionClosed = auctionDto.Closed;
|
||||||
var lastProductId = lastProductToAuction.ProductId;
|
productBidBoxViewModel.AuctionStatus = status;
|
||||||
var lastProduct = await _productService.GetProductByIdAsync(lastProductId);
|
productBidBoxViewModel.WidgetZone = widgetZone;
|
||||||
var lastDetails = await _myProductModelFactory.PrepareProductDetailsModelAsync(lastProduct);
|
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
||||||
lastUrl = Url.RouteUrl<Product>(new { lastDetails.SeName }, _webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
|
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
||||||
lastImageUrl = lastDetails.DefaultPictureModel.FullSizeImageUrl;
|
//productBidBoxViewModel.ProductToAuctionId = productToAuctionId.FirstOrDefault().Id;
|
||||||
lastProductName = lastDetails.SeName;
|
//productBidBoxViewModel.AuctionId = auctionId;
|
||||||
}
|
productBidBoxViewModel.CustomerId = customer.Id;
|
||||||
else
|
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
||||||
{
|
//productBidBoxViewModel.NextProductUrl = Url.RouteUrl("Product", productDetailsModel.SeName);
|
||||||
lastProductToAuction = null;
|
productBidBoxViewModel.NextProductUrl = nextUrl;
|
||||||
}
|
productBidBoxViewModel.LastProductUrl = lastUrl;
|
||||||
|
productBidBoxViewModel.LastProductImageUrl = lastImageUrl;
|
||||||
|
productBidBoxViewModel.NextProductImageUrl = nextImageUrl;
|
||||||
|
productBidBoxViewModel.LastProductName = lastProductName;
|
||||||
|
productBidBoxViewModel.NextProductName = nextProductName;
|
||||||
|
productBidBoxViewModel.LicitStep = AuctionService.GetStepAmount(productToAuction.CurrentPrice); //add calculation
|
||||||
|
productBidBoxViewModel.NextBidPrice = AuctionService.GetNextBidPrice(productToAuction.CurrentPrice, productBidBoxViewModel.LicitStep);
|
||||||
|
|
||||||
|
|
||||||
productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml", productBidBoxViewModel);
|
||||||
productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer);
|
}
|
||||||
productBidBoxViewModel.AuctionClosed = auctionDto.Closed;
|
|
||||||
productBidBoxViewModel.AuctionStatus = status;
|
|
||||||
productBidBoxViewModel.WidgetZone = widgetZone;
|
|
||||||
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
|
||||||
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
|
||||||
//productBidBoxViewModel.ProductToAuctionId = productToAuctionId.FirstOrDefault().Id;
|
|
||||||
//productBidBoxViewModel.AuctionId = auctionId;
|
|
||||||
productBidBoxViewModel.CustomerId = customer.Id;
|
|
||||||
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
|
||||||
//productBidBoxViewModel.NextProductUrl = Url.RouteUrl("Product", productDetailsModel.SeName);
|
|
||||||
productBidBoxViewModel.NextProductUrl = nextUrl;
|
|
||||||
productBidBoxViewModel.LastProductUrl = lastUrl;
|
|
||||||
productBidBoxViewModel.LastProductImageUrl = lastImageUrl;
|
|
||||||
productBidBoxViewModel.NextProductImageUrl = nextImageUrl;
|
|
||||||
productBidBoxViewModel.LastProductName = lastProductName;
|
|
||||||
productBidBoxViewModel.NextProductName = nextProductName;
|
|
||||||
productBidBoxViewModel.LicitStep = AuctionService.GetStepAmount(productToAuction.CurrentPrice); //add calculation
|
|
||||||
productBidBoxViewModel.NextBidPrice = productToAuction.CurrentPrice + productBidBoxViewModel.LicitStep;
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml", productBidBoxViewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
var MessageHandler = (function () {
|
var MessageHandler = (function () {
|
||||||
// Handlers for each message type
|
// Handlers for each message type
|
||||||
let animation = "slideDown";
|
var animation = "slideDown";
|
||||||
const handlers = {
|
var handlers = {
|
||||||
announcement: function (data) {
|
announcement: function (data) {
|
||||||
var myObject = JSON.parse(data);
|
var myObject = JSON.parse(data);
|
||||||
|
|
||||||
|
|
@ -31,20 +31,30 @@
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
var myObject = JSON.parse(data);
|
var myObject = JSON.parse(data);
|
||||||
//console.log(myObject);
|
//console.log(myObject);
|
||||||
var productAuctionMappingId = myObject.auctionDto.productToAuctionDtos[0].id;
|
|
||||||
|
var auctionDto = myObject.auctionDto;
|
||||||
|
var productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
||||||
|
|
||||||
|
//var productAuctionMappingId = productToAuctionDto.id;
|
||||||
//console.log(productAuctionMappingId);
|
//console.log(productAuctionMappingId);
|
||||||
|
|
||||||
var publicProductBidBox = document.getElementById("publicProductBidBox");
|
var publicProductBidBox = document.getElementById("publicProductBidBox");
|
||||||
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
||||||
|
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
||||||
|
|
||||||
if (publicProductBidBox)
|
if (publicProductBidBox)
|
||||||
{
|
{
|
||||||
refreshPublicBidBox(myObject);
|
refreshPublicBidBox(myObject);
|
||||||
}
|
}
|
||||||
|
if (publicInfo) {
|
||||||
|
var functionName = "refreshPublicInfo" + productToAuctionDto.productId;
|
||||||
|
window[functionName](auctionDto);
|
||||||
|
}
|
||||||
if (liveScreen)
|
if (liveScreen)
|
||||||
{
|
{
|
||||||
reloadOnUpdate();
|
reloadOnUpdate();
|
||||||
}
|
}
|
||||||
if (!liveScreen) {
|
else {
|
||||||
toastr.success(`<div class="item bidToast"><p>${myObject.currentPrice}</p><p>${myObject.productName}</p></div>`, "New bid arrived", {
|
toastr.success(`<div class="item bidToast"><p>${myObject.currentPrice}</p><p>${myObject.productName}</p></div>`, "New bid arrived", {
|
||||||
"closeButton": true,
|
"closeButton": true,
|
||||||
"positionClass": "toast-bottom-left",
|
"positionClass": "toast-bottom-left",
|
||||||
|
|
@ -66,12 +76,14 @@
|
||||||
},
|
},
|
||||||
ProductToAuctionStatusNotification: function (data) {
|
ProductToAuctionStatusNotification: function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
var myObject = JSON.parse(data);
|
var myObject = JSON.parse(data);
|
||||||
var auctionDto = myObject.auctionDto;
|
var auctionDto = myObject.auctionDto;
|
||||||
var productToAuctionDto = myObject.auctionDto.productToAuctionDtos[0];
|
var productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
||||||
var publicProductBidBox = document.getElementById("publicProductBidBox");
|
var publicProductBidBox = document.getElementById("publicProductBidBox");
|
||||||
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
|
||||||
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
var publicInfo = document.getElementById("publicInfoOverlay" + productToAuctionDto.productId);
|
||||||
|
|
||||||
if (!liveScreen) {
|
if (!liveScreen) {
|
||||||
var messageTitle = "";
|
var messageTitle = "";
|
||||||
var messageText = "";
|
var messageText = "";
|
||||||
|
|
@ -143,11 +155,7 @@
|
||||||
}
|
}
|
||||||
if (publicInfo) {
|
if (publicInfo) {
|
||||||
var functionName = "refreshPublicInfo" + productToAuctionDto.productId;
|
var functionName = "refreshPublicInfo" + productToAuctionDto.productId;
|
||||||
/*if (typeof window[functionName] === "function" + productToAuctionDto.productId) {*/
|
window[functionName](auctionDto);
|
||||||
window[functionName](myObject); // Dynamically call the function
|
|
||||||
//} else {
|
|
||||||
//console.error("Function " + functionName + " does not exist.");
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// var publicProductBidBox = document.getElementById("publicProductBidBox");
|
// var publicProductBidBox = document.getElementById("publicProductBidBox");
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,19 @@
|
||||||
using AyCode.Core.Extensions;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
using Nop.Data;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
using Nop.Web.Areas.Admin.Factories;
|
|
||||||
using Nop.Web.Framework.Controllers;
|
using Nop.Web.Framework.Controllers;
|
||||||
using Nop.Web.Models.Catalog;
|
using Nop.Web.Models.Catalog;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Controllers;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Controllers;
|
||||||
|
|
||||||
public class AuctionController : BasePluginController
|
public class AuctionController(AuctionService auctionService, ILogger logger, IProductService productService, MyProductModelFactory productModelFactory)
|
||||||
|
: BasePluginController
|
||||||
{
|
{
|
||||||
|
// GET
|
||||||
protected readonly AuctionService _auctionService;
|
|
||||||
protected readonly ILogger _logger;
|
|
||||||
protected readonly IProductService _productService;
|
|
||||||
protected readonly MyProductModelFactory _productModelFactory;
|
|
||||||
|
|
||||||
public AuctionController(AuctionService auctionService, ILogger logger, IProductService productService, MyProductModelFactory productModelFactory)
|
|
||||||
{
|
|
||||||
_auctionService = auctionService;
|
|
||||||
_logger = logger;
|
|
||||||
_productService = productService;
|
|
||||||
_productModelFactory = productModelFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
//var a = new Auction();
|
//var a = new Auction();
|
||||||
|
|
@ -43,7 +24,7 @@ public class AuctionController : BasePluginController
|
||||||
public async Task<IActionResult> PlaceBid([FromBody] AuctionBid model)
|
public async Task<IActionResult> PlaceBid([FromBody] AuctionBid model)
|
||||||
{
|
{
|
||||||
|
|
||||||
await _logger.InformationAsync("PlaceBid called");
|
await logger.InformationAsync("PlaceBid called");
|
||||||
|
|
||||||
//if (model.BidPrice < CurrentPrice + LicitStep)
|
//if (model.BidPrice < CurrentPrice + LicitStep)
|
||||||
//{
|
//{
|
||||||
|
|
@ -51,8 +32,8 @@ public class AuctionController : BasePluginController
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// kéne valami visszajelzés
|
// kéne valami visszajelzés
|
||||||
await _auctionService.InsertBidAsync(model);
|
await auctionService.InsertBidAsync(model);
|
||||||
bool bidSuccess = true;
|
var bidSuccess = true;
|
||||||
if (bidSuccess)
|
if (bidSuccess)
|
||||||
{
|
{
|
||||||
return Ok(new { message = "Your bid was successfully placed!" });
|
return Ok(new { message = "Your bid was successfully placed!" });
|
||||||
|
|
@ -66,17 +47,17 @@ public class AuctionController : BasePluginController
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> RefreshAuctionWidget([FromBody] RefreshWidgetRequest request)
|
public async Task<IActionResult> RefreshAuctionWidget([FromBody] RefreshWidgetRequest request)
|
||||||
{
|
{
|
||||||
await _logger.InformationAsync($"Refresh auction widget called from {request.WidgetZone} with data of {request.ProductId}");
|
await logger.InformationAsync($"Refresh auction widget called from {request.WidgetZone} with data of {request.ProductId}");
|
||||||
|
|
||||||
var product = await _productService.GetProductByIdAsync(request.ProductId);
|
var product = await productService.GetProductByIdAsync(request.ProductId);
|
||||||
ProductDetailsModel detailsModel = await _productModelFactory.PrepareProductDetailsModelAsync(product);
|
var detailsModel = await productModelFactory.PrepareProductDetailsModelAsync(product);
|
||||||
|
|
||||||
return ViewComponent("AuctionPublic", new { widgetZone = request.WidgetZone, additionalData = detailsModel });
|
return ViewComponent("AuctionPublic", new { widgetZone = request.WidgetZone, additionalData = detailsModel });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> LiveScreen(int auctionId)
|
public async Task<IActionResult> LiveScreen(int auctionId)
|
||||||
{
|
{
|
||||||
var auctionDto = await _auctionService.GetAuctionDtoWithAuctionBids(auctionId, true, 5);
|
var auctionDto = await auctionService.GetAuctionDtoWithAuctionBids(auctionId, true, 5); //A javascript-ben az első 6-ot vágod le, melyik a valid? - J.
|
||||||
var activeMapping = auctionDto?.ProductToAuctionDtos.MinBy(x => x.SortIndex);
|
var activeMapping = auctionDto?.ProductToAuctionDtos.MinBy(x => x.SortIndex);
|
||||||
var isAnyItemLive = activeMapping != null;
|
var isAnyItemLive = activeMapping != null;
|
||||||
if (auctionDto == null)
|
if (auctionDto == null)
|
||||||
|
|
@ -88,18 +69,18 @@ public class AuctionController : BasePluginController
|
||||||
Product product;
|
Product product;
|
||||||
ProductDetailsModel productDetailsModel;
|
ProductDetailsModel productDetailsModel;
|
||||||
|
|
||||||
int activeProductId = 0;
|
int activeProductId;
|
||||||
int activeProductToAuctionId = 0;
|
int activeProductToAuctionId;
|
||||||
decimal basePrice = 0;
|
decimal basePrice = 0;
|
||||||
decimal currentPrice = 0;
|
decimal currentPrice = 0;
|
||||||
decimal nextStep = 0;
|
decimal nextStep = 0;
|
||||||
|
|
||||||
if (isAnyItemLive)
|
if (isAnyItemLive)
|
||||||
{
|
{
|
||||||
product = await _productService.GetProductByIdAsync(activeMapping.ProductId);
|
product = await productService.GetProductByIdAsync(activeMapping.ProductId);
|
||||||
activeProductId = activeMapping.ProductId;
|
activeProductId = activeMapping.ProductId;
|
||||||
activeProductToAuctionId = activeMapping.Id;
|
activeProductToAuctionId = activeMapping.Id;
|
||||||
productDetailsModel = await _productModelFactory.PrepareProductDetailsModelAsync(product);
|
productDetailsModel = await productModelFactory.PrepareProductDetailsModelAsync(product);
|
||||||
basePrice = activeMapping.StartingPrice;
|
basePrice = activeMapping.StartingPrice;
|
||||||
currentPrice = activeMapping.CurrentPrice;
|
currentPrice = activeMapping.CurrentPrice;
|
||||||
nextStep = AuctionService.GetStepAmount(currentPrice);
|
nextStep = AuctionService.GetStepAmount(currentPrice);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using AyCode.Core.Extensions;
|
using AyCode.Core.Extensions;
|
||||||
using AyCode.Utils.Extensions;
|
using AyCode.Utils.Extensions;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
|
|
@ -12,10 +11,6 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
using Nop.Core.Domain.Customers;
|
using Nop.Core.Domain.Customers;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Services.Customers;
|
using Nop.Services.Customers;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
using Mango.Nop.Core.Repositories;
|
|
||||||
using Nop.Core.Caching;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
|
|
@ -162,6 +157,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
switch (auctionProductStatusRequest.AuctionStatus)
|
switch (auctionProductStatusRequest.AuctionStatus)
|
||||||
{
|
{
|
||||||
|
case AuctionStatus.None:
|
||||||
|
return; //ez sosem futhat le a fenti if miatt... - J.
|
||||||
|
|
||||||
case AuctionStatus.Pause:
|
case AuctionStatus.Pause:
|
||||||
productToAuction.AuctionStatus = AuctionStatus.Pause;
|
productToAuction.AuctionStatus = AuctionStatus.Pause;
|
||||||
break;
|
break;
|
||||||
|
|
@ -179,7 +177,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
productToAuction.WinnerCustomerId = lastAuctionBid.CustomerId;
|
productToAuction.WinnerCustomerId = lastAuctionBid.CustomerId;
|
||||||
|
|
||||||
var placeOrderResult = await auctionService.CreateOrderForWinnerAsync(productToAuction);
|
var placeOrderResult = await auctionService.CreateOrderForWinnerAsync(productToAuction);
|
||||||
if (placeOrderResult is not { Success: true }) return;
|
if (placeOrderResult is not { Success: true })
|
||||||
|
{
|
||||||
|
logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); (placeOrderResult is not {{ Success: true }})", null, customer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -323,11 +325,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
}
|
}
|
||||||
|
|
||||||
private static decimal GetStepAmount(decimal currentBidPrice) => AuctionService.GetStepAmount(currentBidPrice);
|
private static decimal GetStepAmount(decimal currentBidPrice) => AuctionService.GetStepAmount(currentBidPrice);
|
||||||
private static decimal GetNextBidPrice(decimal currentBidPrice) => GetNextBidPrice(currentBidPrice, GetStepAmount(currentBidPrice));
|
private static decimal GetNextBidPrice(decimal currentBidPrice) => AuctionService.GetNextBidPrice(currentBidPrice, GetStepAmount(currentBidPrice));
|
||||||
private static decimal GetNextBidPrice(decimal currentBidPrice, decimal stepAmount)
|
private static decimal GetNextBidPrice(decimal currentBidPrice, decimal stepAmount) => AuctionService.GetNextBidPrice(currentBidPrice, stepAmount);
|
||||||
{
|
|
||||||
return currentBidPrice + stepAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsValidRequestAuctionStatus(AuctionStatus newStatus, AuctionStatus oldStatus)
|
private static bool IsValidRequestAuctionStatus(AuctionStatus newStatus, AuctionStatus oldStatus)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,41 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
using Nop.Web.Framework.Models;
|
using Nop.Web.Framework.Models;
|
||||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
{
|
{
|
||||||
public record AuctionPublicInfoModel : BaseNopModel
|
public record AuctionPublicInfoModel : BaseNopModel
|
||||||
{
|
{
|
||||||
[JsonIgnore]
|
//[JsonIgnore]
|
||||||
[System.Text.Json.Serialization.JsonIgnore]
|
//[System.Text.Json.Serialization.JsonIgnore]
|
||||||
public AuctionDto AuctionDto { get; set; }
|
public AuctionDto AuctionDto { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[System.Text.Json.Serialization.JsonIgnore]
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
public ProductToAuctionDto FirstProductToAuction { get; set; }
|
public ProductToAuctionDto FirstProductToAuction { get; set; }
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
public int ProductId => FirstProductToAuction?.ProductId ?? 0;
|
||||||
|
public int ProductToAuctionMappingId => FirstProductToAuction?.ProductId ?? 0;
|
||||||
public int ProductToAuctionMappingId { get; set; }
|
public DateTime StartDate => AuctionDto?.StartDateUtc ?? DateTime.MinValue;
|
||||||
|
public bool IsActive => FirstProductToAuction?.IsActiveItem ?? false;
|
||||||
public DateTime StartDate { get; set; }
|
|
||||||
|
|
||||||
public bool IsActive { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public AuctionPublicInfoModel() {}
|
public AuctionPublicInfoModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public AuctionPublicInfoModel(AuctionDto auctionDto) : this()
|
public AuctionPublicInfoModel(AuctionDto auctionDto) : this()
|
||||||
{
|
{
|
||||||
AuctionDto = auctionDto;
|
AuctionDto = auctionDto;
|
||||||
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.First();
|
|
||||||
|
|
||||||
ProductId = FirstProductToAuction.ProductId;
|
//StartDate = AuctionDto.StartDateUtc;
|
||||||
ProductToAuctionMappingId = FirstProductToAuction.Id;
|
|
||||||
StartDate = AuctionDto.StartDateUtc;
|
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.FirstOrDefault();
|
||||||
IsActive = FirstProductToAuction.IsActiveItem;
|
if (FirstProductToAuction == null) return;
|
||||||
|
|
||||||
|
//ProductId = FirstProductToAuction.ProductId;
|
||||||
|
//ProductToAuctionMappingId = FirstProductToAuction.Id;
|
||||||
|
//IsActive = FirstProductToAuction.IsActiveItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
public bool AuctionClosed { get; set; }
|
public bool AuctionClosed { get; set; }
|
||||||
public bool IsItemActive => FirstProductToAuction.IsActiveItem;
|
public bool IsItemActive => FirstProductToAuction?.IsActiveItem ?? false;
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
|
|
@ -62,9 +62,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
public ProductBidBoxViewModel(AuctionDto auctionDto) : this()
|
public ProductBidBoxViewModel(AuctionDto auctionDto) : this()
|
||||||
{
|
{
|
||||||
AuctionDto = auctionDto;
|
AuctionDto = auctionDto;
|
||||||
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.First();
|
|
||||||
|
|
||||||
AuctionId = auctionDto.Id;
|
AuctionId = auctionDto.Id;
|
||||||
|
|
||||||
|
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.FirstOrDefault();
|
||||||
|
if (FirstProductToAuction == null) return;
|
||||||
|
|
||||||
ProductId = FirstProductToAuction.ProductId;
|
ProductId = FirstProductToAuction.ProductId;
|
||||||
ProductToAuctionId = FirstProductToAuction.Id;
|
ProductToAuctionId = FirstProductToAuction.Id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,14 @@
|
||||||
using AyCode.Core.Extensions;
|
using Nop.Core;
|
||||||
using Nop.Core;
|
|
||||||
using Nop.Core.Caching;
|
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
using Nop.Core.Domain.Customers;
|
|
||||||
using Nop.Core.Domain.Orders;
|
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;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
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.Orders;
|
||||||
using Nop.Services.Payments;
|
using Nop.Services.Payments;
|
||||||
using Org.BouncyCastle.Crypto;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
||||||
|
|
@ -27,6 +22,7 @@ public class AuctionService : IAuctionService
|
||||||
private readonly AuctionDbContext _ctx;
|
private readonly AuctionDbContext _ctx;
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly IWorkContext _workContext;
|
private readonly IWorkContext _workContext;
|
||||||
|
private readonly IPaymentService _paymentService;
|
||||||
private readonly IOrderProcessingService _orderProcessingService;
|
private readonly IOrderProcessingService _orderProcessingService;
|
||||||
private readonly IShoppingCartService _shoppingCartService;
|
private readonly IShoppingCartService _shoppingCartService;
|
||||||
private readonly IStoreContext _storeContext;
|
private readonly IStoreContext _storeContext;
|
||||||
|
|
@ -41,6 +37,7 @@ public class AuctionService : IAuctionService
|
||||||
/// <param name="ctx"></param>
|
/// <param name="ctx"></param>
|
||||||
/// <param name="productService"></param>
|
/// <param name="productService"></param>
|
||||||
/// <param name="workContext"></param>
|
/// <param name="workContext"></param>
|
||||||
|
/// <param name="paymentService"></param>
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
public AuctionService(
|
public AuctionService(
|
||||||
AuctionDbContext ctx,
|
AuctionDbContext ctx,
|
||||||
|
|
@ -49,6 +46,7 @@ public class AuctionService : IAuctionService
|
||||||
IOrderProcessingService orderProcessingService,
|
IOrderProcessingService orderProcessingService,
|
||||||
IShoppingCartService shoppingCartService,
|
IShoppingCartService shoppingCartService,
|
||||||
IStoreContext storeContext,
|
IStoreContext storeContext,
|
||||||
|
IPaymentService paymentService,
|
||||||
ILogger logger)
|
ILogger logger)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
|
@ -57,6 +55,7 @@ public class AuctionService : IAuctionService
|
||||||
_orderProcessingService = orderProcessingService;
|
_orderProcessingService = orderProcessingService;
|
||||||
_shoppingCartService = shoppingCartService;
|
_shoppingCartService = shoppingCartService;
|
||||||
_storeContext = storeContext;
|
_storeContext = storeContext;
|
||||||
|
_paymentService = paymentService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,6 +105,12 @@ public class AuctionService : IAuctionService
|
||||||
//200 000 000 Ft fölött 20 000 000 Ft-tal
|
//200 000 000 Ft fölött 20 000 000 Ft-tal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static decimal GetNextBidPrice(decimal currentBidPrice) => GetNextBidPrice(currentBidPrice, GetStepAmount(currentBidPrice));
|
||||||
|
public static decimal GetNextBidPrice(decimal currentBidPrice, decimal stepAmount)
|
||||||
|
{
|
||||||
|
return currentBidPrice + stepAmount;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task ResetProductToAuctionByProductId(int productId)
|
public async Task ResetProductToAuctionByProductId(int productId)
|
||||||
=> await ResetProductToAuctionAsync(await _ctx.ProductToAuctions.GetByProductId(productId).FirstOrDefaultAsync());
|
=> await ResetProductToAuctionAsync(await _ctx.ProductToAuctions.GetByProductId(productId).FirstOrDefaultAsync());
|
||||||
|
|
||||||
|
|
@ -207,12 +212,15 @@ public class AuctionService : IAuctionService
|
||||||
PaymentMethodSystemName = "Payments.CheckMoneyOrder",
|
PaymentMethodSystemName = "Payments.CheckMoneyOrder",
|
||||||
CustomerId = auctionItem.WinnerCustomerId,
|
CustomerId = auctionItem.WinnerCustomerId,
|
||||||
OrderTotal = auctionItem.CurrentPrice,
|
OrderTotal = auctionItem.CurrentPrice,
|
||||||
OrderGuid = auctionItem.OrderGuid.IsNullOrEmpty() ? Guid.NewGuid() : auctionItem.OrderGuid.Value
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentCustomer = await _workContext.GetCurrentCustomerAsync();
|
var currentCustomer = await _workContext.GetCurrentCustomerAsync();
|
||||||
var product = await _productService.GetProductByIdAsync(auctionItem.ProductId);
|
var product = await _productService.GetProductByIdAsync(auctionItem.ProductId);
|
||||||
var currentStore = await _storeContext.GetCurrentStoreAsync();
|
var currentStore = await _storeContext.GetCurrentStoreAsync();
|
||||||
|
|
||||||
|
//TODO: valszeg a GenerateOrderGuidAsync-ot kell használni, de nemtom egy példában láttam... - J.
|
||||||
|
await _paymentService.GenerateOrderGuidAsync(processPaymentRequest);
|
||||||
|
|
||||||
processPaymentRequest.CustomValues.Add("ProductToAuctionMappingId", auctionItem.Id);
|
processPaymentRequest.CustomValues.Add("ProductToAuctionMappingId", auctionItem.Id);
|
||||||
|
|
||||||
product.DisableBuyButton = false;
|
product.DisableBuyButton = false;
|
||||||
|
|
@ -223,8 +231,6 @@ public class AuctionService : IAuctionService
|
||||||
|
|
||||||
if (!placeOrderResult.Success) return null;
|
if (!placeOrderResult.Success) return null;
|
||||||
|
|
||||||
//placeOrderResult.PlacedOrder //TODO:... - J.
|
|
||||||
|
|
||||||
auctionItem.OrderId = placeOrderResult.PlacedOrder.Id;
|
auctionItem.OrderId = placeOrderResult.PlacedOrder.Id;
|
||||||
auctionItem.OrderGuid = placeOrderResult.PlacedOrder.OrderGuid;
|
auctionItem.OrderGuid = placeOrderResult.PlacedOrder.OrderGuid;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
@{
|
@{
|
||||||
if (Model.IsAnyItemActive)
|
if (Model.IsAnyItemActive)
|
||||||
{
|
{
|
||||||
|
|
||||||
<div class="row py-3">
|
<div class="row py-3">
|
||||||
<!-- Item Image -->
|
<!-- Item Image -->
|
||||||
<div class="col-lg-4 col-md-6 mb-4" style="height: calc(100vh - 100px);">
|
<div class="col-lg-4 col-md-6 mb-4" style="height: calc(100vh - 100px);">
|
||||||
|
|
@ -65,11 +64,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Base price</span>
|
<span>Base price</span>
|
||||||
<span>@(String.Format("{0:c}", Model.BasePrice))</span>
|
<span>@($"{Model.BasePrice:c}")</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Actual licit step</span>
|
<span>Actual licit step</span>
|
||||||
<span>@(String.Format("{0:c}", Model.LicitStep))</span>
|
<span>@($"{Model.LicitStep:c}")</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
@ -84,7 +83,7 @@
|
||||||
<div class="card-footer h-50 border-0 align-items-center text-center bg-transparent">
|
<div class="card-footer h-50 border-0 align-items-center text-center bg-transparent">
|
||||||
<span>Current state price</span>
|
<span>Current state price</span>
|
||||||
<h3 style="font-size: 72px;">
|
<h3 style="font-size: 72px;">
|
||||||
@(String.Format("{0:c}", Model.CurrentPrice))
|
@($"{Model.CurrentPrice:c}")
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -115,7 +114,7 @@
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
liveScreenPageViewModel = @Html.Raw(Json.Serialize(Model));
|
var liveScreenPageViewModel = @Html.Raw(Json.Serialize(Model));
|
||||||
console.log("ViewModel:", liveScreenPageViewModel);
|
console.log("ViewModel:", liveScreenPageViewModel);
|
||||||
|
|
||||||
// Extract and preprocess table data
|
// Extract and preprocess table data
|
||||||
|
|
@ -126,6 +125,7 @@
|
||||||
BidPrice: item.BidPrice,
|
BidPrice: item.BidPrice,
|
||||||
CustomerId: item.CustomerId
|
CustomerId: item.CustomerId
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log("Table Data:", tableData);
|
console.log("Table Data:", tableData);
|
||||||
|
|
||||||
tableData.forEach((element) => console.log(element));
|
tableData.forEach((element) => console.log(element));
|
||||||
|
|
@ -147,22 +147,22 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
function addRowToTable(tableRow) {
|
function addRowToTable(tableRow) {
|
||||||
const table = document.getElementById("bidHistoryTable");
|
var table = document.getElementById("bidHistoryTable");
|
||||||
const row = table.insertRow();
|
var row = table.insertRow();
|
||||||
|
|
||||||
const cell1 = row.insertCell();
|
var cell1 = row.insertCell();
|
||||||
cell1.textContent = tableRow.Id;
|
cell1.textContent = tableRow.Id;
|
||||||
|
|
||||||
const cell2 = row.insertCell();
|
var cell2 = row.insertCell();
|
||||||
cell2.textContent = tableRow.BidPrice;
|
cell2.textContent = tableRow.BidPrice;
|
||||||
|
|
||||||
const cell3 = row.insertCell();
|
var cell3 = row.insertCell();
|
||||||
cell3.textContent = tableRow.CustomerId;
|
cell3.textContent = tableRow.CustomerId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadOnUpdate() {
|
function reloadOnUpdate() {
|
||||||
location.reload()
|
location.reload();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,72 +1,85 @@
|
||||||
@model AuctionPublicInfoModel
|
@using AyCode.Core.Extensions
|
||||||
|
@model AuctionPublicInfoModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script asp-location="Footer">
|
<script asp-location="Footer">
|
||||||
var pageViewModel;
|
|
||||||
var isActive;
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// Deserialize the server-side model
|
|
||||||
pageViewModel = @Html.Raw(Json.Serialize(Model));
|
console.log("PublicInfo ready enter; ProductId: " + @Model.ProductId);
|
||||||
console.log("Page View Model:", pageViewModel);
|
let auctionDto = @Html.Raw(Model.AuctionDto.ToJson());
|
||||||
console.log(pageViewModel.ProductId);
|
|
||||||
console.log(pageViewModel.ProductToAuctionMappingId);
|
initialize@(Model.ProductId)(auctionDto);
|
||||||
// Get the element with data-productid
|
|
||||||
isActive = pageViewModel.IsActive;
|
|
||||||
initialize@(Model.ProductId)(@Model.ProductId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function initialize@(Model.ProductId)(thisProductId) {
|
function initialize@(Model.ProductId)(auctionDto) {
|
||||||
console.log("isActive = " + isActive);
|
console.log("PublicInfo initialize" + @Model.ProductId + " enter; auctionDto: " + auctionDto);
|
||||||
console.log("productId:" + thisProductId);
|
|
||||||
var productItem = $('.product-item[data-productid="' + thisProductId + '"]');
|
|
||||||
|
|
||||||
var existingOverlay = document.getElementById(`publicInfoOverlay${thisProductId}`);
|
if (!auctionDto) {
|
||||||
if (existingOverlay) {
|
console.error("auctionDto == null");
|
||||||
console.log("remove because it exists");
|
return;
|
||||||
existingOverlay.remove();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Check if element exists
|
let productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
||||||
if (productItem.length > 0 && pageViewModel.ProductToAuctionMappingId > 0) {
|
let productId = productToAuctionDto.productId;
|
||||||
console.log("Product item length:", productItem.length);
|
let isActive = productToAuctionDto.isActiveItem;
|
||||||
// Add a new div as the first child
|
|
||||||
if (isActive) {
|
|
||||||
console.log("isActive: " + isActive);
|
|
||||||
productItem.prepend(`<div id="publicInfoOverlay${thisProductId}" class="bg-success p-1 text-white fs-6 text-center" style="position: absolute; width: calc(100% - 1rem); height: 40px; z-index: 1;"><i class="fa-solid fa-gavel"> `
|
|
||||||
+ 'LIVE RIGTH NOW' +
|
|
||||||
'</i></div>');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log("isActive: " + isActive);
|
|
||||||
productItem.prepend(`<div id="publicInfoOverlay${thisProductId}" class="bg-primary p-1 text-white fs-6 text-center" style="position: absolute; width: calc(100% - 1rem); height: 40px; z-index: 1;"><i class="fa-solid fa-gavel"> `
|
|
||||||
+ pageViewModel.StartDate +
|
|
||||||
'</i></div>');
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
console.log("isActiveItem: " + isActive + "; productId:" + productId + "; productToAuctionId: " + productToAuctionDto.id);
|
||||||
console.error("Product item not found with productId:", pageViewModel.ProductId);
|
|
||||||
}
|
let productItem = $('.product-item[data-productid="' + productId + '"]');
|
||||||
|
let publicInfoOverlayId = "publicInfoOverlay" + productId;
|
||||||
|
|
||||||
|
console.log("publicInfoOverlayId: " + publicInfoOverlayId + "; productItem:" + productItem);
|
||||||
|
|
||||||
|
var existingOverlay = document.getElementById(publicInfoOverlayId);
|
||||||
|
if (existingOverlay) {
|
||||||
|
console.log("remove because it exists");
|
||||||
|
existingOverlay.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if element exists
|
||||||
|
if (productItem.length > 0 && productToAuctionDto.id > 0) {
|
||||||
|
console.log("Product item length:", productItem.length);
|
||||||
|
|
||||||
|
var widgetPriceElements = productItem.find('.actual-price');
|
||||||
|
//console.log("widgetPriceElements:", widgetPriceElements);
|
||||||
|
|
||||||
|
if (widgetPriceElements && widgetPriceElements.length > 0) {
|
||||||
|
widgetPriceElements[0].textContent = HUFFormatter.format(productToAuctionDto.currentPrice); // Update the price
|
||||||
|
}
|
||||||
|
// Add a new div as the first child
|
||||||
|
if (isActive) {
|
||||||
|
console.log("isActive: " + isActive);
|
||||||
|
productItem.prepend('<div id="' +
|
||||||
|
publicInfoOverlayId +
|
||||||
|
'" class="bg-success p-1 text-white fs-6 text-center" style="position: absolute; width: calc(100% - 1rem); height: 40px; z-index: 1;"><i class="fa-solid fa-gavel"> ' +
|
||||||
|
'LIVE RIGTH NOW' +
|
||||||
|
'</i></div>');
|
||||||
|
} else {
|
||||||
|
console.log("isActive: " + isActive);
|
||||||
|
productItem.prepend('<div id="' +
|
||||||
|
publicInfoOverlayId +
|
||||||
|
'" class="bg-primary p-1 text-white fs-6 text-center" style="position: absolute; width: calc(100% - 1rem); height: 40px; z-index: 1;"><i class="fa-solid fa-gavel"> ' +
|
||||||
|
auctionDto.startDateUtc +
|
||||||
|
'</i></div>');
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.error("Product item not found with productId:", productId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window[`refreshPublicInfo${@Model.ProductId}`] = function(auctionDto) {
|
||||||
|
|
||||||
window[`refreshPublicInfo${@Model.ProductId}`] = function (data) {
|
let productToAuctionDto = auctionDto.productToAuctionDtos[0];
|
||||||
|
|
||||||
var status = data.auctionDto.productToAuctionDtos[0].auctionStatus;
|
console.log(auctionDto);
|
||||||
if (status == AuctionStatus.Active) {
|
console.log("setting active to " + productToAuctionDto.isActiveItem);
|
||||||
console.log(data.auctionDto);
|
|
||||||
isActive = true;
|
|
||||||
console.log("setting active to " + isActive);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
isActive = false;
|
|
||||||
console.log("setting active to " + isActive);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize@(Model.ProductId)(data.auctionDto.productToAuctionDtos[0].productId);
|
initialize@(Model.ProductId)(auctionDto);
|
||||||
console.log('Function called: refreshPublicInfo' + @Model.ProductId);
|
console.log('Function called: refreshPublicInfo' + productToAuctionDto.productId);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(`Function refreshPublicInfo${@Model.ProductId} added to DOM:`, window[`refreshPublicInfo${@Model.ProductId}`]);
|
console.log(`Function refreshPublicInfo${@Model.ProductId} added to DOM:`, window[`refreshPublicInfo${@Model.ProductId}`]);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue