Compare commits
No commits in common. "69a6cd5053908470370fbcdd88b746485d4f4a79" and "0e08842f95dccd6c503a85501da42974fe02ec78" have entirely different histories.
69a6cd5053
...
0e08842f95
|
|
@ -120,9 +120,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
//AuctionDto = TODO: ??? - J.
|
//AuctionDto = TODO: ??? - J.
|
||||||
ProductName = viewModel.ProductName,
|
ProductName = viewModel.ProductName,
|
||||||
CurrentPrice = viewModel.BidPrice,
|
BidPrice = viewModel.BidPrice.ToString(),
|
||||||
NextStepAmount = viewModel.NextStepAmount,
|
NextStepAmount = viewModel.NextStepAmount.ToString()
|
||||||
NextBidPrice = viewModel.BidPrice + viewModel.NextStepAmount
|
|
||||||
}.ToJson()
|
}.ToJson()
|
||||||
};
|
};
|
||||||
var jsonMessage = JsonConvert.SerializeObject(bid, Formatting.Indented,
|
var jsonMessage = JsonConvert.SerializeObject(bid, Formatting.Indented,
|
||||||
|
|
|
||||||
|
|
@ -105,27 +105,28 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
|
|
||||||
var productId = productDetailsModel.Id;
|
var productId = productDetailsModel.Id;
|
||||||
|
|
||||||
var productToAuction = (await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId)).FirstOrDefault();
|
var productToAuctionDtoMappings = await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId);
|
||||||
if (productToAuction == null)
|
if (productToAuctionDtoMappings.Count == 0)
|
||||||
{
|
{
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuction.AuctionId));
|
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuctionDtoMappings.FirstOrDefault()!.AuctionId));
|
||||||
auctionDto.ProductToAuctionDtos.Add(productToAuction);
|
auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||||
|
|
||||||
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;
|
AuctionStatus status = productToAuctionDtoMappings.FirstOrDefault()!.AuctionStatus;
|
||||||
//bool isActive = status == AuctionStatus.Active || status == AuctionStatus.FirstWarning || status == AuctionStatus.SecondWarning;
|
bool isActive = status.HasFlag(AuctionStatus.Active);
|
||||||
//bool isFirstWarning = status == AuctionStatus.FirstWarning;
|
bool isFirstWarning = status.HasFlag(AuctionStatus.FirstWarning);
|
||||||
|
|
||||||
|
|
||||||
productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer);
|
productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer);
|
||||||
productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer);
|
productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer);
|
||||||
productBidBoxViewModel.AuctionClosed = auctionDto.Closed;
|
//productBidBoxViewModel.AuctionClosed = auction.Closed;
|
||||||
productBidBoxViewModel.AuctionStatus = status;
|
|
||||||
|
//productBidBoxViewModel.IsItemActive = isActive;
|
||||||
productBidBoxViewModel.WidgetZone = widgetZone;
|
productBidBoxViewModel.WidgetZone = widgetZone;
|
||||||
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
||||||
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
||||||
|
|
@ -133,8 +134,8 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
//productBidBoxViewModel.AuctionId = auctionId;
|
//productBidBoxViewModel.AuctionId = auctionId;
|
||||||
productBidBoxViewModel.CustomerId = customer.Id;
|
productBidBoxViewModel.CustomerId = customer.Id;
|
||||||
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
||||||
productBidBoxViewModel.LicitStep = AuctionService.GetStepAmount(productToAuction.CurrentPrice); //add calculation
|
productBidBoxViewModel.LicitStep = 50000; //add calculation
|
||||||
productBidBoxViewModel.NextBidPrice = productToAuction.CurrentPrice + productBidBoxViewModel.LicitStep;
|
productBidBoxViewModel.BidPrice = productDetailsModel.ProductPrice.PriceValue + productBidBoxViewModel.LicitStep;
|
||||||
|
|
||||||
|
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml", productBidBoxViewModel);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml", productBidBoxViewModel);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
Active: 1,
|
Active: 1,
|
||||||
FirstWarning: 2,
|
FirstWarning: 2,
|
||||||
SecondWarning: 4,
|
SecondWarning: 4,
|
||||||
Sold: 8,
|
SoldOut: 8,
|
||||||
NotSold: 16
|
NotSold: 16
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
bidNotification: function (data) {
|
bidNotification: function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
var myObject = JSON.parse(data);
|
var myObject = JSON.parse(data);
|
||||||
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.bidPrice}</p><p>${myObject.productName}</p></div>`, "New bid arrived", {
|
||||||
"closeButton": true,
|
"closeButton": true,
|
||||||
"positionClass": "toast-bottom-right",
|
"positionClass": "toast-bottom-right",
|
||||||
"newestOnTop": true,
|
"newestOnTop": true,
|
||||||
|
|
@ -48,40 +48,11 @@
|
||||||
{
|
{
|
||||||
refreshPublicBidBox(myObject);
|
refreshPublicBidBox(myObject);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
ProductToAuctionStatusNotification: function (data) {
|
|
||||||
console.log(data);
|
|
||||||
var myObject = JSON.parse(data);
|
|
||||||
var auctionDto = myObject.auctionDto;
|
|
||||||
var productToAuctionDto = myObject.auctionDto.productToAuctionDtos[0];
|
|
||||||
|
|
||||||
toastr.success(`<div class="item bidToast"><p>${productToAuctionDto.auctionStatus}</p><p>${productToAuctionDto.id}</p></div>`, "Status changed", {
|
|
||||||
"closeButton": true,
|
|
||||||
"positionClass": "toast-bottom-right",
|
|
||||||
"newestOnTop": true,
|
|
||||||
"progressBar": true,
|
|
||||||
"preventDuplicates": false,
|
|
||||||
"onclick": null,
|
|
||||||
"showDuration": "30000",
|
|
||||||
"hideDuration": "1000",
|
|
||||||
"timeOut": "5000",
|
|
||||||
"extendedTimeOut": "1000",
|
|
||||||
"showEasing": "swing",
|
|
||||||
"hideEasing": "linear",
|
|
||||||
"showMethod": animation,
|
|
||||||
"hideMethod": "fadeOut"
|
|
||||||
});
|
|
||||||
$('.toast-success').css("background-color", "#4caf50");
|
|
||||||
|
|
||||||
// var publicProductBidBox = document.getElementById("publicProductBidBox");
|
|
||||||
// if (publicProductBidBox)
|
|
||||||
// {
|
|
||||||
// refreshPublicBidBox(myObject);
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
openItemMessage: function (data) {
|
openItemMessage: function (data) {
|
||||||
var myObject = JSON.parse(data);
|
var myObject = JSON.parse(data);
|
||||||
toastr.success(`<div class="item bidToast"><p>${myObject.nextBidPrice}</p><p>${myObject.productName}</p></div>`, "Item auction is OPENED!", {
|
toastr.success(`<div class="item bidToast"><p>${myObject.bidPrice}</p><p>${myObject.productName}</p></div>`, "Item auction is OPENED!", {
|
||||||
"closeButton": true,
|
"closeButton": true,
|
||||||
"positionClass": "toast-bottom-right",
|
"positionClass": "toast-bottom-right",
|
||||||
"newestOnTop": true,
|
"newestOnTop": true,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public interface IProductToAuctionDtoBase : IMgModelDtoBase
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
|
|
||||||
public decimal StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public decimal CurrentPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
public int ProductAmount { get; set; }
|
public int ProductAmount { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos.Interfaces;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Interfaces;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
|
||||||
|
|
@ -14,40 +12,28 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
public int WinnerCustomerId { get; set; }
|
public int WinnerCustomerId { get; set; }
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
public decimal StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public decimal CurrentPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
public int ProductAmount { get; set; }
|
public int ProductAmount { get; set; }
|
||||||
public int SortIndex { get; set; }
|
public int SortIndex { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// EGYELŐRE NE HASZNÁLD!!! - J.
|
|
||||||
/// </summary>
|
|
||||||
public decimal StepAmount { get; set; }
|
|
||||||
public List<AuctionBidDto> AuctionBidDtos { get; } = [];
|
public List<AuctionBidDto> AuctionBidDtos { get; } = [];
|
||||||
|
|
||||||
public bool IsActiveItem => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;
|
public bool IsActiveItem => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;
|
||||||
|
|
||||||
public ProductToAuctionDto() { }
|
public ProductToAuctionDto()
|
||||||
public ProductToAuctionDto(ProductToAuctionMapping productToAuction) : this(productToAuction, 0/*AuctionService.GetStepAmount(productToAuction.BidPrice)*/) { }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
public ProductToAuctionDto(ProductToAuctionMapping productToAuction)
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="productToAuction"></param>
|
|
||||||
/// <param name="stepAmount">EGYELŐRE NE HASZNÁLD!!! - J.</param>
|
|
||||||
public ProductToAuctionDto(ProductToAuctionMapping productToAuction, decimal stepAmount) : this()
|
|
||||||
{
|
{
|
||||||
if (productToAuction == null) return;
|
if (productToAuction == null) return;
|
||||||
|
|
||||||
if (stepAmount > 0) StepAmount = stepAmount;
|
|
||||||
//else StepAmount = AuctionService.GetStepAmount(productToAuction.BidPrice);
|
|
||||||
|
|
||||||
|
|
||||||
Id = productToAuction.Id;
|
Id = productToAuction.Id;
|
||||||
ProductId = productToAuction.ProductId;
|
ProductId = productToAuction.ProductId;
|
||||||
AuctionId = productToAuction.AuctionId;
|
AuctionId = productToAuction.AuctionId;
|
||||||
AuctionStatus = productToAuction.AuctionStatus;
|
AuctionStatus = productToAuction.AuctionStatus;
|
||||||
StartingPrice = productToAuction.StartingPrice;
|
StartingPrice = productToAuction.StartingPrice;
|
||||||
CurrentPrice = productToAuction.CurrentPrice;
|
BidPrice = productToAuction.BidPrice;
|
||||||
ProductAmount = productToAuction.ProductAmount;
|
ProductAmount = productToAuction.ProductAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,7 +46,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
mainEntity.AuctionId = AuctionId;
|
mainEntity.AuctionId = AuctionId;
|
||||||
mainEntity.AuctionStatus = AuctionStatus;
|
mainEntity.AuctionStatus = AuctionStatus;
|
||||||
mainEntity.StartingPrice = StartingPrice;
|
mainEntity.StartingPrice = StartingPrice;
|
||||||
mainEntity.CurrentPrice = CurrentPrice;
|
mainEntity.BidPrice = BidPrice;
|
||||||
mainEntity.ProductAmount = ProductAmount;
|
mainEntity.ProductAmount = ProductAmount;
|
||||||
|
|
||||||
return mainEntity;
|
return mainEntity;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ public partial class Auction: MgEntityBase, IAuction
|
||||||
{
|
{
|
||||||
public string AuctionName { get; set; }
|
public string AuctionName { get; set; }
|
||||||
|
|
||||||
//[NotMapped]
|
[NotMapped]
|
||||||
//[NotColumn]
|
[NotColumn]
|
||||||
public AuctionType AuctionType{ get; set; }
|
public AuctionType AuctionType{ get; set; }
|
||||||
|
|
||||||
public DateTime StartDateUtc { get; set; }
|
public DateTime StartDateUtc { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMa
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
public int WinnerCustomerId { get; set; }
|
public int WinnerCustomerId { get; set; }
|
||||||
|
|
||||||
//[NotMapped]
|
[NotMapped]
|
||||||
//[NotColumn]
|
[NotColumn]
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
|
|
||||||
public decimal StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public decimal CurrentPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
public int ProductAmount { get; set; } = 1;
|
public int ProductAmount { get; set; } = 1;
|
||||||
public int SortIndex { get; set; }
|
public int SortIndex { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ public enum AuctionStatus : byte
|
||||||
Active = 1,
|
Active = 1,
|
||||||
FirstWarning = 2,
|
FirstWarning = 2,
|
||||||
SecondWarning = 4,
|
SecondWarning = 4,
|
||||||
Sold = 8,
|
SoldOut = 8,
|
||||||
NotSold = 16
|
NotSold = 16
|
||||||
}
|
}
|
||||||
|
|
@ -15,9 +15,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
|
||||||
public class BidNotificationMessage : AuctionNotificationBase
|
public class BidNotificationMessage : AuctionNotificationBase
|
||||||
{
|
{
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; set; }
|
||||||
public decimal CurrentPrice { get; set; }
|
public string BidPrice { get; set; }
|
||||||
public decimal NextBidPrice { get; set; }
|
public string NextStepAmount { get; set; }
|
||||||
public decimal NextStepAmount { get; set; }
|
|
||||||
|
|
||||||
public BidNotificationMessage() { }
|
public BidNotificationMessage() { }
|
||||||
public BidNotificationMessage(AuctionDto auctionDto):base(auctionDto) { }
|
public BidNotificationMessage(AuctionDto auctionDto):base(auctionDto) { }
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,6 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
{
|
{
|
||||||
//- FirstWarning, SecondWarning,
|
|
||||||
//- ProductToAuctionDto ne lista legyen
|
|
||||||
//- GetFullAuctionDto
|
|
||||||
//- SortIndex
|
//- SortIndex
|
||||||
//- Rátettem egy unique-ot az AuctionId és a ProductId-ra!!!
|
//- Rátettem egy unique-ot az AuctionId és a ProductId-ra!!!
|
||||||
//- Új field-ek a db-be! pl.: WinnerCustomerId, stb...
|
//- Új field-ek a db-be! pl.: WinnerCustomerId, stb...
|
||||||
|
|
@ -53,11 +50,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _logger.InformationAsync($"SignalRMessageHandler.HandleMessage(); jsonData: {message.Data}");
|
|
||||||
|
|
||||||
if (message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
if (message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
||||||
{
|
{
|
||||||
_logger.Error($"SignalRMessageHandler.HandleMessage(); message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id; SenderId: {message.SenderId}");
|
_logger.Error($"SignalRMessageHandler.HandleMessage(); message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,13 +63,13 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
await HandleBidRequest(message.SenderId, message.Data.JsonTo<AuctionBidRequest>());
|
await HandleBidRequest(message.SenderId, message.Data.JsonTo<AuctionBidRequest>());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "AuctionProductStatusRequest":
|
case "OpenItemRequestMessage":
|
||||||
await HandleProductToAuctionStatusChangedRequest(message.SenderId, message.Data.JsonTo<AuctionProductStatusRequest>());
|
await HandleProductToAuctionStatusChangedRequest(message.SenderId, message.Data.JsonTo<AuctionProductStatusRequest>());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Add other message types here
|
// Add other message types here
|
||||||
default:
|
default:
|
||||||
await _logger.ErrorAsync($"SignalRMessageHandler.HandleMessage(); Unknown message type; MessageType: {message.MessageType}");
|
await _logger.ErrorAsync("SignalRMessageHandler.HandleMessage(); Unknown message type");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +92,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(auctionProductStatusRequest.ProductToAuctionId);
|
var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(auctionProductStatusRequest.ProductToAuctionId);
|
||||||
if (auction == null || auction.Closed)
|
if (auction == null || auction.Closed)
|
||||||
{
|
{
|
||||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auction == null || auction.Closed;");
|
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auction == null || auction.Closed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,18 +105,18 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
|
|
||||||
switch (auctionProductStatusRequest.AuctionStatus)
|
switch (auctionProductStatusRequest.AuctionStatus)
|
||||||
{
|
{
|
||||||
case AuctionStatus.Sold:
|
|
||||||
productToAuction.AuctionStatus = productToAuction.CurrentPrice == productToAuction.StartingPrice ? AuctionStatus.NotSold : AuctionStatus.Sold;
|
|
||||||
break;
|
|
||||||
case AuctionStatus.NotSold:
|
|
||||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auctionProductStatusRequest.AuctionStatus == AuctionStatus.NotSold");
|
|
||||||
break;
|
|
||||||
case AuctionStatus.FirstWarning:
|
case AuctionStatus.FirstWarning:
|
||||||
|
productToAuction.AuctionStatus = AuctionStatus.FirstWarning; //AuctionStatus.Active | AuctionStatus.FirstWarning;
|
||||||
|
break;
|
||||||
case AuctionStatus.SecondWarning:
|
case AuctionStatus.SecondWarning:
|
||||||
|
productToAuction.AuctionStatus = AuctionStatus.SecondWarning; //AuctionStatus.Active | AuctionStatus.SecondWarning;
|
||||||
|
break;
|
||||||
case AuctionStatus.None:
|
case AuctionStatus.None:
|
||||||
case AuctionStatus.Active:
|
case AuctionStatus.Active:
|
||||||
|
case AuctionStatus.SoldOut:
|
||||||
|
case AuctionStatus.NotSold:
|
||||||
default:
|
default:
|
||||||
productToAuction.AuctionStatus = auctionProductStatusRequest.AuctionStatus;
|
auctionProductStatusRequest.AuctionStatus = auctionProductStatusRequest.AuctionStatus;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +128,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
SenderId = senderId,
|
SenderId = senderId,
|
||||||
Data = new ProductToAuctionStatusNotification(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true))
|
Data = new ProductToAuctionStatusNotification(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true))
|
||||||
{
|
{
|
||||||
ToasterMessage = "string.Empty", //TODO: - J.
|
ToasterMessage = string.Empty, //TODO: - J.
|
||||||
}.ToJson()
|
}.ToJson()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -205,13 +200,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
await _productService.UpdateProductAsync(product);
|
await _productService.UpdateProductAsync(product);
|
||||||
|
|
||||||
activeProductAuction.StartingPrice = product.OldPrice;
|
activeProductAuction.StartingPrice = product.OldPrice;
|
||||||
activeProductAuction.CurrentPrice = product.Price;
|
activeProductAuction.BidPrice = product.Price;
|
||||||
await _auctionService.UpdateProductToAuctionMappingAsync(activeProductAuction);
|
await _auctionService.UpdateProductToAuctionMappingAsync(activeProductAuction);
|
||||||
|
|
||||||
var stepAmount = AuctionService.GetStepAmount(auctionBid.BidPrice);
|
// Optionally broadcast to all clients
|
||||||
var nextBidPrice = auctionBid.BidPrice + stepAmount;
|
|
||||||
//stepAmount = GetStepAmount(nextBidPrice); //Direkt van 2x, különben a sávváltásoknál lehet gond! - J.
|
|
||||||
|
|
||||||
var bid = new MessageWrapper
|
var bid = new MessageWrapper
|
||||||
{
|
{
|
||||||
MessageType = "bidNotification",
|
MessageType = "bidNotification",
|
||||||
|
|
@ -219,9 +211,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(activeProductAuction.Id, true))
|
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(activeProductAuction.Id, true))
|
||||||
{
|
{
|
||||||
ProductName = auctionBid.ProductId.ToString(),
|
ProductName = auctionBid.ProductId.ToString(),
|
||||||
CurrentPrice = auctionBid.BidPrice,
|
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
||||||
NextStepAmount = stepAmount,
|
NextStepAmount = "50000", //TODO: - J.
|
||||||
NextBidPrice = nextBidPrice,
|
|
||||||
ToasterMessage = string.Empty, //TODO: - J.
|
ToasterMessage = string.Empty, //TODO: - J.
|
||||||
}.ToJson()
|
}.ToJson()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class ProductToAuctionMappingBuilder : NopEntityBuilder<ProductToAuctionM
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() //enum??? - J.
|
.WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() //enum??? - J.
|
||||||
|
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.StartingPrice)).AsInt32().NotNullable()
|
.WithColumn(nameof(ProductToAuctionMapping.StartingPrice)).AsInt32().NotNullable()
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.CurrentPrice)).AsInt32().NotNullable()
|
.WithColumn(nameof(ProductToAuctionMapping.BidPrice)).AsInt32().NotNullable()
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.ProductAmount)).AsInt32().NotNullable().WithDefaultValue(1)
|
.WithColumn(nameof(ProductToAuctionMapping.ProductAmount)).AsInt32().NotNullable().WithDefaultValue(1)
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.SortIndex)).AsInt32().NotNullable().WithDefaultValue(0)
|
.WithColumn(nameof(ProductToAuctionMapping.SortIndex)).AsInt32().NotNullable().WithDefaultValue(0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
[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 ProductToAuctionId { get; set; }
|
public int ProductToAuctionId { get; set; }
|
||||||
public bool IsAdmin { get; set; }
|
public bool IsAdmin { get; set; }
|
||||||
public bool IsGuest { get; set; }
|
public bool IsGuest { get; set; }
|
||||||
|
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
public bool AuctionClosed { get; set; }
|
public bool IsItemActive { get; set; }
|
||||||
public bool IsItemActive => FirstProductToAuction.IsActiveItem;
|
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int CustomerId { get; set; }
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
public string WidgetZone { get; set; }
|
public string WidgetZone { get; set; }
|
||||||
|
|
@ -43,7 +42,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
#region visible
|
#region visible
|
||||||
public decimal LicitStep { get; set; }
|
public decimal LicitStep { get; set; }
|
||||||
public decimal? CurrentPrice { get; set; }
|
public decimal? CurrentPrice { get; set; }
|
||||||
public decimal NextBidPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
#endregion visible
|
#endregion visible
|
||||||
|
|
||||||
|
|
@ -57,6 +56,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
AuctionId = auctionDto.Id;
|
AuctionId = auctionDto.Id;
|
||||||
ProductId = FirstProductToAuction.ProductId;
|
ProductId = FirstProductToAuction.ProductId;
|
||||||
ProductToAuctionId = FirstProductToAuction.Id;
|
ProductToAuctionId = FirstProductToAuction.Id;
|
||||||
}
|
IsItemActive = FirstProductToAuction.IsActiveItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ 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.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
using Org.BouncyCastle.Crypto;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
||||||
|
|
@ -69,48 +68,6 @@ public class AuctionService : IAuctionService
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public static decimal GetStepAmount(decimal currentPrice)
|
|
||||||
{
|
|
||||||
return currentPrice switch
|
|
||||||
{
|
|
||||||
>= 0 and < 100000 => 10000, //Ezt csak hasraütésszerűen adtam meg!!! - J.
|
|
||||||
|
|
||||||
//100 000 - 1 000 000
|
|
||||||
>= 100000 and < 200000 => 10000,
|
|
||||||
>= 200000 and < 500000 => 20000,
|
|
||||||
>= 500000 and < 1000000 => 50000,
|
|
||||||
|
|
||||||
//1 000 000 - 10 000 000
|
|
||||||
>= 1000000 and < 2000000 => 100000,
|
|
||||||
>= 2000000 and < 5000000 => 200000,
|
|
||||||
>= 5000000 and < 10000000 => 500000,
|
|
||||||
|
|
||||||
//10 000 000 - 100 000 000
|
|
||||||
>= 10000000 and < 20000000 => 1000000,
|
|
||||||
>= 20000000 and < 50000000 => 2000000,
|
|
||||||
>= 50000000 and < 100000000 => 5000000,
|
|
||||||
|
|
||||||
//100 000 000 - ~
|
|
||||||
>= 100000000 and < 200000000 => 10000000,
|
|
||||||
_ => 20000000
|
|
||||||
};
|
|
||||||
|
|
||||||
//100 000 Ft – 200 000 Ft között 10 000 Ft-tal
|
|
||||||
//200 000 Ft – 500 000 Ft között 20 000 Ft-tal
|
|
||||||
//500 000 Ft – 1 000 000 Ft között 50 000 Ft-tal
|
|
||||||
|
|
||||||
//1 000 000 Ft – 2 000 000 Ft között 100 000 Ft-tal
|
|
||||||
//2 000 000 Ft – 5 000 000 Ft között 200 000 Ft-tal
|
|
||||||
//5 000 000 Ft – 10 000 000 Ft között 500 000 Ft-tal
|
|
||||||
|
|
||||||
//10 000 000 Ft – 20 000 000 Ft között 1 000 000 Ft-tal
|
|
||||||
//20 000 000 Ft – 50 000 000 Ft között 2 000 000 Ft-tal
|
|
||||||
//50 000 000 Ft – 100 000 000 Ft között 5 000 000 Ft-tal
|
|
||||||
|
|
||||||
//100 000 000 Ft – 200 000 000 Ft között 10 000 000 Ft-tal
|
|
||||||
//200 000 000 Ft fölött 20 000 000 Ft-tal
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<bool> ValidateAuctionBid(AuctionBid auctionBid)
|
private async Task<bool> ValidateAuctionBid(AuctionBid auctionBid)
|
||||||
{
|
{
|
||||||
//auctionBid.CustomerId = (await _workContext.GetCurrentCustomerAsync()).Id; //elvileg megnézi cache-ben, csak utána DB-zik! - J.
|
//auctionBid.CustomerId = (await _workContext.GetCurrentCustomerAsync()).Id; //elvileg megnézi cache-ben, csak utána DB-zik! - J.
|
||||||
|
|
@ -206,25 +163,10 @@ public class AuctionService : IAuctionService
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Dtots
|
#region Dtots
|
||||||
|
public async Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId)
|
||||||
public async Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId, bool widthProducts = false)
|
|
||||||
{
|
{
|
||||||
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
||||||
if (auction == null) return null;
|
return auction == null ? null : new AuctionDto(auction);
|
||||||
|
|
||||||
var auctionDto = new AuctionDto(auction);
|
|
||||||
|
|
||||||
if (widthProducts)
|
|
||||||
{
|
|
||||||
auctionDto.ProductToAuctionDtos.AddRange((await GetProductToAuctionDtosByAuctionId(auctionId)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return auctionDto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<ProductToAuctionDto>> GetProductToAuctionDtosByAuctionId(int auctionId)
|
|
||||||
{
|
|
||||||
return (await GetProductToAuctionsByAuctionIdAsync(auctionId)).Select(x => new ProductToAuctionDto(x)).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly = false)
|
public async Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly = false)
|
||||||
|
|
@ -290,7 +232,7 @@ public class AuctionService : IAuctionService
|
||||||
{
|
{
|
||||||
ProductId = productId,
|
ProductId = productId,
|
||||||
StartingPrice = startingPrice,
|
StartingPrice = startingPrice,
|
||||||
CurrentPrice = bidPrice,
|
BidPrice = bidPrice,
|
||||||
ProductAmount = 1,
|
ProductAmount = 1,
|
||||||
AuctionStatus = AuctionStatus.None,
|
AuctionStatus = AuctionStatus.None,
|
||||||
AuctionId = auctionId
|
AuctionId = auctionId
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAuctionService
|
public interface IAuctionService
|
||||||
{
|
{
|
||||||
//decimal GetStepAmount(decimal currentPrice);
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all bids
|
/// Gets all bids
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -41,8 +38,7 @@ public interface IAuctionService
|
||||||
|
|
||||||
Task<List<ProductToAuctionMapping>> GetProductToAuctionsByAuctionIdAsync(int auctionId, bool onlyActiveItems = false);
|
Task<List<ProductToAuctionMapping>> GetProductToAuctionsByAuctionIdAsync(int auctionId, bool onlyActiveItems = false);
|
||||||
|
|
||||||
Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId, bool widthProducts = false);
|
Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId);
|
||||||
Task<List<ProductToAuctionDto>> GetProductToAuctionDtosByAuctionId(int auctionId);
|
|
||||||
|
|
||||||
|
|
||||||
Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly);
|
Task<AuctionDto> GetAuctionDtoWithProductByIdAsync(int auctionId, int productId, bool activeProductOnly);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
@using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums
|
@model ProductBidBoxViewModel
|
||||||
@using Nop.Web.Framework.TagHelpers.Shared
|
|
||||||
@model ProductBidBoxViewModel
|
|
||||||
@* @inject IJsonHelper JsonHelper; *@
|
@* @inject IJsonHelper JsonHelper; *@
|
||||||
|
|
||||||
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
||||||
|
|
@ -24,12 +22,12 @@
|
||||||
<span id="licitStepText" class="value">@String.Format("{0:c}", Model.LicitStep)</span>
|
<span id="licitStepText" class="value">@String.Format("{0:c}", Model.LicitStep)</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">
|
||||||
Bid @String.Format("{0:c}", Model.NextBidPrice)
|
Bid @String.Format("{0:c}", Model.BidPrice)
|
||||||
</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.BidPrice)
|
||||||
</button> *@
|
</button> *@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -51,11 +49,11 @@
|
||||||
@{
|
@{
|
||||||
if(Model.IsItemActive)
|
if(Model.IsItemActive)
|
||||||
{
|
{
|
||||||
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" disabled="@((byte)Model.AuctionStatus >= (byte)AuctionStatus.FirstWarning))">
|
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
||||||
First warning
|
First warning
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRSecondWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button" disabled="@((byte)Model.AuctionStatus >= (byte)AuctionStatus.SecondWarning))">
|
<button id="signalRFirstWarningButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
||||||
Second warning
|
First warning
|
||||||
</button>
|
</button>
|
||||||
<button id="signalRCloseItemButton" class="btn btn-secondary" style="text-transform: uppercase;" type="button">
|
<button id="signalRCloseItemButton" class="btn btn-secondary" style="text-transform: uppercase;" type="button">
|
||||||
Deactivate item
|
Deactivate item
|
||||||
|
|
@ -123,7 +121,7 @@
|
||||||
var bidMessage = {
|
var bidMessage = {
|
||||||
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
ProductAuctionMappingId: bidBoxPageViewModel.ProductToAuctionId,
|
||||||
AuctionId: bidBoxPageViewModel.AuctionId,
|
AuctionId: bidBoxPageViewModel.AuctionId,
|
||||||
BidPrice: bidBoxPageViewModel.NextBidPrice,
|
BidPrice: bidBoxPageViewModel.BidPrice,
|
||||||
ProductId: bidBoxPageViewModel.ProductId,
|
ProductId: bidBoxPageViewModel.ProductId,
|
||||||
CustomerId: bidBoxPageViewModel.CustomerId
|
CustomerId: bidBoxPageViewModel.CustomerId
|
||||||
};
|
};
|
||||||
|
|
@ -177,7 +175,7 @@
|
||||||
|
|
||||||
// Create the message object
|
// Create the message object
|
||||||
var auctionMessage = {
|
var auctionMessage = {
|
||||||
ProductToAuctionId: bidBoxPageViewModel.ProductToAuctionId,
|
ProductAuctionId: bidBoxPageViewModel.ProductToAuctionId,
|
||||||
AuctionStatus: auctionStatus
|
AuctionStatus: auctionStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -205,18 +203,18 @@
|
||||||
var licitStepElement = document.getElementById("licitStepText");
|
var licitStepElement = document.getElementById("licitStepText");
|
||||||
|
|
||||||
if (widgetPriceElement) {
|
if (widgetPriceElement) {
|
||||||
widgetPriceElement.textContent = HUFFormatter.format(data.currentPrice); // Update the price
|
widgetPriceElement.textContent = HUFFormatter.format(data.bidPrice); // Update the price
|
||||||
licitStepElement.textContent = HUFFormatter.format(data.nextStepAmount);
|
licitStepElement.textContent = HUFFormatter.format(data.nextStepAmount);
|
||||||
bidBoxPageViewModel.NextBidPrice = Number(data.nextBidPrice);
|
bidBoxPageViewModel.BidPrice = Number(data.bidPrice) + Number(data.nextStepAmount);
|
||||||
|
|
||||||
budButtonElement.textContent = "Bid " + HUFFormatter.format(bidBoxPageViewModel.NextBidPrice);
|
budButtonElement.textContent = "Bid " + HUFFormatter.format(bidBoxPageViewModel.BidPrice);
|
||||||
|
|
||||||
|
|
||||||
// if (bidBoxPageViewModel.CustomerId == data.CustomerId) {
|
// if (bidBoxPageViewModel.CustomerId == data.CustomerId) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
console.log(`WidgetPrice updated to: ${data.currentPrice}, next bid is ${bidBoxPageViewModel.NextBidPrice}`);
|
console.log(`WidgetPrice updated to: ${data.bidPrice}, next bid is ${bidBoxPageViewModel.BidPrice}`);
|
||||||
budButtonElement.disabled = false;
|
budButtonElement.disabled = false;
|
||||||
} else {
|
} else {
|
||||||
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue