This commit is contained in:
Adam 2024-11-30 16:44:30 +01:00
commit a157ebe311
1 changed files with 37 additions and 36 deletions

View File

@ -157,21 +157,21 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
{ {
switch (auctionProductStatusRequest.AuctionStatus) switch (auctionProductStatusRequest.AuctionStatus)
{ {
case AuctionStatus.None: case AuctionStatus.Active:
return; //ez sosem futhat le a fenti if miatt... - J. productToAuction.AuctionStatus = AuctionStatus.Active;
await UpdateProductCategoryIsFeaturedAsync(productToAuction.ProductId, auction.CategoryId, true);
break;
case AuctionStatus.Pause: case AuctionStatus.FirstWarning:
productToAuction.AuctionStatus = AuctionStatus.Pause; case AuctionStatus.SecondWarning:
productToAuction.AuctionStatus = auctionProductStatusRequest.AuctionStatus;
break; break;
case AuctionStatus.Sold: case AuctionStatus.Sold:
var lastAuctionBid = await auctionService.GetLastAuctionBidByProductToAuctionIdAsync(productToAuction.Id); var lastAuctionBid = await auctionService.GetLastAuctionBidByProductToAuctionIdAsync(productToAuction.Id);
if (lastAuctionBid == null) if (lastAuctionBid == null) productToAuction.AuctionStatus = AuctionStatus.NotSold;
else
{ {
productToAuction.AuctionStatus = AuctionStatus.NotSold;
break;
}
productToAuction.AuctionStatus = AuctionStatus.Sold; productToAuction.AuctionStatus = AuctionStatus.Sold;
productToAuction.CurrentPrice = lastAuctionBid.BidPrice; productToAuction.CurrentPrice = lastAuctionBid.BidPrice;
productToAuction.WinnerCustomerId = lastAuctionBid.CustomerId; productToAuction.WinnerCustomerId = lastAuctionBid.CustomerId;
@ -182,19 +182,18 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); (placeOrderResult == null || placeOrderResult.Id == 0)", null, customer); logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); (placeOrderResult == null || placeOrderResult.Id == 0)", null, customer);
//return; //TODO: EGYELŐRE HAGYJUK LEZÁRNI AKKOR IS, HA NEM SIKERÜLT AZ ORDERPLACE()! - J. //return; //TODO: EGYELŐRE HAGYJUK LEZÁRNI AKKOR IS, HA NEM SIKERÜLT AZ ORDERPLACE()! - J.
} }
}
await UpdateProductCategoryIsFeaturedAsync(productToAuction.ProductId, auction.CategoryId, false);
break; break;
case AuctionStatus.NotSold: case AuctionStatus.Pause:
logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); (auctionProductStatusRequest.AuctionStatus == AuctionStatus.NotSold)", null, customer); productToAuction.AuctionStatus = AuctionStatus.Pause;
break; break;
case AuctionStatus.FirstWarning:
case AuctionStatus.SecondWarning:
case AuctionStatus.Active:
default: default:
productToAuction.AuctionStatus = auctionProductStatusRequest.AuctionStatus; logger.Error($"SignalRMessageHandler.HandleProductToAuctionStatusChangedRequest(); AuctionStatus not found; (auctionProductStatusRequest.AuctionStatus == {auctionProductStatusRequest.AuctionStatus})", null, customer);
break; return;
} }
await auctionService.UpdateProductToAuctionMappingAsync(productToAuction); await auctionService.UpdateProductToAuctionMappingAsync(productToAuction);
@ -210,8 +209,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
await hubContext.Clients.All.SendAsync("send", productToauctionChangedNotification.ToJson()); await hubContext.Clients.All.SendAsync("send", productToauctionChangedNotification.ToJson());
var isFeaturedProduct = productToAuction.IsActiveItem || productToAuction.AuctionStatus == AuctionStatus.Pause; //if (productToAuction.AuctionStatus is AuctionStatus.FirstWarning or AuctionStatus.SecondWarning or AuctionStatus.Pause) return;
await UpdateProductCategoryIsFeaturedAsync(isFeaturedProduct, auction.CategoryId, productToAuction.ProductId);
//var isFeaturedProduct = productToAuction.IsActiveItem || productToAuction.AuctionStatus == AuctionStatus.Pause;
//await UpdateProductCategoryIsFeaturedAsync(isFeaturedProduct, auction.CategoryId, productToAuction.ProductId);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -316,10 +317,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
await auctionService.ResetProductToAuctionAsync(productToAuction, productToAuction.StartingPrice); await auctionService.ResetProductToAuctionAsync(productToAuction, productToAuction.StartingPrice);
categoryId ??= (await auctionService.GetAuctionByIdAsync(productToAuction.AuctionId))?.CategoryId; categoryId ??= (await auctionService.GetAuctionByIdAsync(productToAuction.AuctionId))?.CategoryId;
await UpdateProductCategoryIsFeaturedAsync(false, categoryId, productToAuction.ProductId); await UpdateProductCategoryIsFeaturedAsync(productToAuction.ProductId, categoryId, false);
} }
private async Task UpdateProductCategoryIsFeaturedAsync(bool isFeatured, int? categoryId, int productId) private async Task UpdateProductCategoryIsFeaturedAsync(int productId, int? categoryId, bool isFeatured)
{ {
//Leszarjuk ha elszáll, az aukció menjen tovább... - J. //Leszarjuk ha elszáll, az aukció menjen tovább... - J.
try try