improvements
This commit is contained in:
parent
d9f95dd8e1
commit
f583cbe51f
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ 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) { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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...
|
||||
|
|
@ -76,7 +79,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
|
||||
private async Task HandleProductToAuctionStatusChangedRequest(int senderId, AuctionProductStatusRequest auctionProductStatusRequest)
|
||||
{
|
||||
if (auctionProductStatusRequest == null)
|
||||
if (auctionProductStatusRequest == null)
|
||||
{
|
||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); auctionProductStatusRequest == null");
|
||||
return;
|
||||
|
|
@ -85,7 +88,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
try
|
||||
{
|
||||
await _logger.InformationAsync($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); ProductToAuctionMappingId: {auctionProductStatusRequest.ProductToAuctionId}; Status: {auctionProductStatusRequest.AuctionStatus}({(int)auctionProductStatusRequest.AuctionStatus})");
|
||||
|
||||
|
||||
//TODO: if IsAdmin.. - J.
|
||||
//TODO: if nincs aktív item.. - J.
|
||||
|
||||
|
|
@ -128,17 +131,17 @@ 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()
|
||||
};
|
||||
|
||||
await _hubContext.Clients.All.SendAsync("send", productToauctionChangedNotification.ToJson());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); Error {ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task HandleBidRequest(int senderId, AuctionBidRequest bidRequestMessage)
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue