improvements

This commit is contained in:
Loretta 2024-11-22 06:42:59 +01:00
parent d9f95dd8e1
commit f583cbe51f
5 changed files with 68 additions and 19 deletions

View File

@ -120,8 +120,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
{
//AuctionDto = TODO: ??? - J.
ProductName = viewModel.ProductName,
BidPrice = viewModel.BidPrice.ToString(),
NextStepAmount = viewModel.NextStepAmount.ToString()
BidPrice = viewModel.BidPrice,
NextStepAmount = viewModel.NextStepAmount
}.ToJson()
};
var jsonMessage = JsonConvert.SerializeObject(bid, Formatting.Indented,

View File

@ -12,8 +12,8 @@ public partial class Auction: MgEntityBase, IAuction
{
public string AuctionName { get; set; }
[NotMapped]
[NotColumn]
//[NotMapped]
//[NotColumn]
public AuctionType AuctionType{ get; set; }
public DateTime StartDateUtc { get; set; }

View File

@ -14,8 +14,8 @@ public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMa
public int AuctionId { get; set; }
public int WinnerCustomerId { get; set; }
[NotMapped]
[NotColumn]
//[NotMapped]
//[NotColumn]
public AuctionStatus AuctionStatus { get; set; }
public decimal StartingPrice { get; set; }

View File

@ -15,8 +15,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages
public class BidNotificationMessage : AuctionNotificationBase
{
public string ProductName { get; set; }
public string BidPrice { get; set; }
public string NextStepAmount { get; set; }
public decimal BidPrice { get; set; }
public decimal NextBidPrice { get; set; }
public decimal NextStepAmount { get; set; }
public BidNotificationMessage() { }
public BidNotificationMessage(AuctionDto auctionDto):base(auctionDto) { }

View File

@ -11,6 +11,9 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
{
//- FirstWarning, SecondWarning,
//- ProductToAuctionDto ne lista legyen
//- GetFullAuctionDto
//- SortIndex
//- Rátettem egy unique-ot az AuctionId és a ProductId-ra!!!
//- Új field-ek a db-be! pl.: WinnerCustomerId, stb...
@ -128,7 +131,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
SenderId = senderId,
Data = new ProductToAuctionStatusNotification(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuction.Id, true))
{
ToasterMessage = string.Empty, //TODO: - J.
ToasterMessage = "string.Empty", //TODO: - J.
}.ToJson()
};
@ -203,7 +206,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
activeProductAuction.BidPrice = product.Price;
await _auctionService.UpdateProductToAuctionMappingAsync(activeProductAuction);
// Optionally broadcast to all clients
var stepAmount = GetStepAmount(auctionBid.BidPrice);
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
{
MessageType = "bidNotification",
@ -211,9 +217,9 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
Data = new BidNotificationMessage(await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(activeProductAuction.Id, true))
{
ProductName = auctionBid.ProductId.ToString(),
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
NextStepAmount = "50000", //TODO: - J.
BidPrice = auctionBid.BidPrice,
NextStepAmount = stepAmount,
NextBidPrice = nextBidPrice,
ToasterMessage = string.Empty, //TODO: - J.
}.ToJson()
};
@ -225,5 +231,47 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
_logger.Error($"SignalRMessageHandler.HandleBidRequest(); MessageHandling error: {ex}");
}
}
private static decimal GetStepAmount(decimal currentPrice)
{
return currentPrice switch
{
>= 0 and < 100000 => 1000, //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
}
}
}