SignalR improvements; etc...
This commit is contained in:
parent
9a94bc6c06
commit
946748134c
|
|
@ -4,11 +4,13 @@ using FruitBank.Common.Dtos;
|
||||||
using FruitBank.Common.Entities;
|
using FruitBank.Common.Entities;
|
||||||
using FruitBank.Common.Interfaces;
|
using FruitBank.Common.Interfaces;
|
||||||
using FruitBank.Common.Server.Interfaces;
|
using FruitBank.Common.Server.Interfaces;
|
||||||
|
using FruitBank.Common.Server.Services.SignalRs;
|
||||||
using FruitBank.Common.SignalRs;
|
using FruitBank.Common.SignalRs;
|
||||||
using Mango.Nop.Core.Extensions;
|
using Mango.Nop.Core.Extensions;
|
||||||
using Mango.Nop.Core.Loggers;
|
using Mango.Nop.Core.Loggers;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Core.Domain.Customers;
|
using Nop.Core.Domain.Customers;
|
||||||
|
|
@ -42,6 +44,9 @@ using System.Text;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using AyCode.Services.Server.SignalRs;
|
||||||
|
using AyCode.Core.Extensions;
|
||||||
|
using MessagePack.Resolvers;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -50,6 +55,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
public class CustomOrderController : BaseAdminController, ICustomOrderSignalREndpointServer
|
public class CustomOrderController : BaseAdminController, ICustomOrderSignalREndpointServer
|
||||||
{
|
{
|
||||||
private readonly FruitBankDbContext _dbContext;
|
private readonly FruitBankDbContext _dbContext;
|
||||||
|
private readonly SignalRSendToClientService _sendToClient;
|
||||||
|
|
||||||
private readonly IOrderService _orderService;
|
private readonly IOrderService _orderService;
|
||||||
private readonly CustomOrderModelFactory _orderModelFactory;
|
private readonly CustomOrderModelFactory _orderModelFactory;
|
||||||
|
|
@ -95,7 +101,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
return hasVendorProducts;
|
return hasVendorProducts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomOrderController(FruitBankDbContext fruitBankDbContext,
|
public CustomOrderController(FruitBankDbContext fruitBankDbContext, SignalRSendToClientService sendToClient,
|
||||||
IOrderService orderService,
|
IOrderService orderService,
|
||||||
IPriceCalculationService priceCalculationService,
|
IPriceCalculationService priceCalculationService,
|
||||||
IOrderModelFactory orderModelFactory,
|
IOrderModelFactory orderModelFactory,
|
||||||
|
|
@ -119,6 +125,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
||||||
|
|
||||||
_dbContext = fruitBankDbContext;
|
_dbContext = fruitBankDbContext;
|
||||||
|
_sendToClient = sendToClient;
|
||||||
|
|
||||||
_orderService = orderService;
|
_orderService = orderService;
|
||||||
_orderModelFactory = orderModelFactory as CustomOrderModelFactory;
|
_orderModelFactory = orderModelFactory as CustomOrderModelFactory;
|
||||||
_customOrderSignalREndpoint = customOrderSignalREndpoint;
|
_customOrderSignalREndpoint = customOrderSignalREndpoint;
|
||||||
|
|
@ -143,14 +151,26 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
#region CustomOrderSignalREndpoint
|
#region CustomOrderSignalREndpoint
|
||||||
|
|
||||||
[NonAction] public Task<List<OrderDto>> GetAllOrderDtos() => _customOrderSignalREndpoint.GetAllOrderDtos();
|
[NonAction] public Task<List<OrderDto>> GetAllOrderDtos() => _customOrderSignalREndpoint.GetAllOrderDtos();
|
||||||
[NonAction]public Task<OrderDto> GetOrderDtoById(int orderId) => _customOrderSignalREndpoint.GetOrderDtoById(orderId);
|
[NonAction] public Task<OrderDto> GetOrderDtoById(int orderId) => _customOrderSignalREndpoint.GetOrderDtoById(orderId);
|
||||||
[NonAction]public Task<List<OrderDto>> GetPendingOrderDtos() => _customOrderSignalREndpoint.GetPendingOrderDtos();
|
[NonAction] public Task<List<OrderDto>> GetPendingOrderDtos() => _customOrderSignalREndpoint.GetPendingOrderDtos();
|
||||||
[NonAction]public Task<List<OrderDto>> GetPendingOrderDtosForMeasuring() => _customOrderSignalREndpoint.GetPendingOrderDtosForMeasuring();
|
[NonAction] public Task<List<OrderDto>> GetPendingOrderDtosForMeasuring() => _customOrderSignalREndpoint.GetPendingOrderDtosForMeasuring();
|
||||||
[NonAction] public Task<OrderDto> StartMeasuring(int orderId, int userId) => _customOrderSignalREndpoint.StartMeasuring(orderId, userId);
|
[NonAction] public Task<OrderDto> StartMeasuring(int orderId, int userId) => _customOrderSignalREndpoint.StartMeasuring(orderId, userId);
|
||||||
[NonAction]public Task<OrderDto> SetOrderStatusToComplete(int orderId, int revisorId) => _customOrderSignalREndpoint.SetOrderStatusToComplete(orderId, revisorId);
|
[NonAction] public Task<OrderDto> SetOrderStatusToComplete(int orderId, int revisorId) => _customOrderSignalREndpoint.SetOrderStatusToComplete(orderId, revisorId);
|
||||||
[NonAction] public Task<List<OrderDto>> GetAllOrderDtoByIds(int[] orderIds) => _customOrderSignalREndpoint.GetAllOrderDtoByIds(orderIds);
|
[NonAction] public Task<List<OrderDto>> GetAllOrderDtoByIds(int[] orderIds) => _customOrderSignalREndpoint.GetAllOrderDtoByIds(orderIds);
|
||||||
[NonAction] public Task<OrderItemPallet> AddOrUpdateMeasuredOrderItemPallet(OrderItemPallet orderItemPallet) => _customOrderSignalREndpoint.AddOrUpdateMeasuredOrderItemPallet(orderItemPallet);
|
[NonAction] public Task<List<OrderItemDto>> GetAllOrderItemDtos() => _customOrderSignalREndpoint.GetAllOrderItemDtos();
|
||||||
|
[NonAction]public Task<List<OrderDto>> GetAllOrderDtoByProductId(int productId) => _customOrderSignalREndpoint.GetAllOrderDtoByProductId(productId);
|
||||||
|
[NonAction]public Task<OrderItemDto> GetOrderItemDtoById(int orderItemId) => _customOrderSignalREndpoint.GetOrderItemDtoById(orderItemId);
|
||||||
|
[NonAction]public Task<List<OrderItemDto>> GetAllOrderItemDtoByOrderId(int orderId) => _customOrderSignalREndpoint.GetAllOrderItemDtoByOrderId(orderId);
|
||||||
|
[NonAction]public Task<List<OrderItemDto>> GetAllOrderItemDtoByProductId(int productId) => _customOrderSignalREndpoint.GetAllOrderItemDtoByProductId(productId);
|
||||||
|
[NonAction] public Task<List<OrderItemPallet>> GetAllOrderItemPallets() => _customOrderSignalREndpoint.GetAllOrderItemPallets();
|
||||||
|
[NonAction] public Task<OrderItemPallet> GetOrderItemPalletById(int orderItemPalletId) => _customOrderSignalREndpoint.GetOrderItemPalletById(orderItemPalletId);
|
||||||
|
[NonAction] public Task<List<OrderItemPallet>> GetAllOrderItemPalletByOrderItemId(int orderItemId) => _customOrderSignalREndpoint.GetAllOrderItemPalletByOrderItemId(orderItemId);
|
||||||
|
[NonAction] public Task<List<OrderItemPallet>> GetAllOrderItemPalletByOrderId(int orderId) => _customOrderSignalREndpoint.GetAllOrderItemPalletByOrderId(orderId);
|
||||||
|
[NonAction] public Task<List<OrderItemPallet>> GetAllOrderItemPalletByProductId(int productId) => _customOrderSignalREndpoint.GetAllOrderItemPalletByProductId(productId);
|
||||||
|
[NonAction]public Task<OrderItemPallet> AddOrUpdateMeasuredOrderItemPallet(OrderItemPallet orderItemPallet) => _customOrderSignalREndpoint.AddOrUpdateMeasuredOrderItemPallet(orderItemPallet);
|
||||||
|
|
||||||
#endregion CustomOrderSignalREndpoint
|
#endregion CustomOrderSignalREndpoint
|
||||||
|
|
||||||
[CheckPermission(StandardPermission.Orders.ORDERS_VIEW)]
|
[CheckPermission(StandardPermission.Orders.ORDERS_VIEW)]
|
||||||
|
|
@ -258,12 +278,16 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
if (order == null)
|
if (order == null)
|
||||||
return RedirectToAction("List", "Order");
|
return RedirectToAction("List", "Order");
|
||||||
|
|
||||||
|
//TODO: A FruitBankAttributeService-t használjuk és akkor az OrderDto lehet lekérni és beadni a SaveAttribute-ba! - J.
|
||||||
|
|
||||||
// store attributes in GenericAttribute table
|
// store attributes in GenericAttribute table
|
||||||
//await _genericAttributeService.SaveAttributeAsync(order, nameof(IMeasurable.IsMeasurable), model.IsMeasurable, _storeContext.GetCurrentStore().Id);
|
//await _genericAttributeService.SaveAttributeAsync(order, nameof(IMeasurable.IsMeasurable), model.IsMeasurable, _storeContext.GetCurrentStore().Id);
|
||||||
await _genericAttributeService.SaveAttributeAsync(order, nameof(IOrderDto.DateOfReceipt), model.DateOfReceipt, _storeContext.GetCurrentStore().Id);
|
await _genericAttributeService.SaveAttributeAsync(order, nameof(IOrderDto.DateOfReceipt), model.DateOfReceipt, _storeContext.GetCurrentStore().Id);
|
||||||
|
|
||||||
_notificationService.SuccessNotification("Custom attributes saved successfully.");
|
var orderDto = await _dbContext.OrderDtos.GetByIdAsync(model.OrderId, true);
|
||||||
|
await _sendToClient.SendOrderChanged(orderDto);
|
||||||
|
|
||||||
|
_notificationService.SuccessNotification("Custom attributes saved successfully.");
|
||||||
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
|
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,11 +303,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
if (customer == null) return RedirectToAction("List");
|
if (customer == null) return RedirectToAction("List");
|
||||||
|
|
||||||
var billingAddress = await _customerService.GetCustomerBillingAddressAsync(customer);
|
var billingAddress = await _customerService.GetCustomerBillingAddressAsync(customer);
|
||||||
if(billingAddress == null)
|
if (billingAddress == null)
|
||||||
{
|
{
|
||||||
//let's see if he has any address at all
|
//let's see if he has any address at all
|
||||||
var addresses = await _customerService.GetAddressesByCustomerIdAsync(customer.Id);
|
var addresses = await _customerService.GetAddressesByCustomerIdAsync(customer.Id);
|
||||||
if(addresses != null && addresses.Count > 0)
|
if (addresses != null && addresses.Count > 0)
|
||||||
{
|
{
|
||||||
//set the first one as billing
|
//set the first one as billing
|
||||||
billingAddress = addresses[0];
|
billingAddress = addresses[0];
|
||||||
|
|
@ -388,6 +412,9 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
|
|
||||||
await _orderService.UpdateOrderAsync(order);
|
await _orderService.UpdateOrderAsync(order);
|
||||||
|
|
||||||
|
var orderDto = await _dbContext.OrderDtos.GetByIdAsync(order.Id, true);
|
||||||
|
await _sendToClient.SendMeasuringNotification("Módosult a rendelés, mérjétek újra!", orderDto);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -534,7 +561,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(fullName))
|
if (string.IsNullOrEmpty(fullName))
|
||||||
fullName = "[No name]";
|
fullName = "[No name]";
|
||||||
if(string.IsNullOrEmpty(company))
|
if (string.IsNullOrEmpty(company))
|
||||||
company = "[No company]";
|
company = "[No company]";
|
||||||
|
|
||||||
string fullText = $"{company} ({fullName}), {customer.Email}";
|
string fullText = $"{company} ({fullName}), {customer.Email}";
|
||||||
|
|
@ -738,10 +765,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
[CheckPermission(StandardPermission.Orders.ORDERS_IMPORT_EXPORT)]
|
[CheckPermission(StandardPermission.Orders.ORDERS_IMPORT_EXPORT)]
|
||||||
public virtual async Task<IActionResult> ExportXmlAll(OrderSearchModel model)
|
public virtual async Task<IActionResult> ExportXmlAll(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var startDateValue = model.StartDate == null ? null
|
var startDateValue = model.StartDate == null
|
||||||
|
? null
|
||||||
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync());
|
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync());
|
||||||
|
|
||||||
var endDateValue = model.EndDate == null ? null
|
var endDateValue = model.EndDate == null
|
||||||
|
? null
|
||||||
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1);
|
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1);
|
||||||
|
|
||||||
//a vendor should have access only to his products
|
//a vendor should have access only to his products
|
||||||
|
|
@ -834,10 +863,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
[CheckPermission(StandardPermission.Orders.ORDERS_IMPORT_EXPORT)]
|
[CheckPermission(StandardPermission.Orders.ORDERS_IMPORT_EXPORT)]
|
||||||
public virtual async Task<IActionResult> ExportExcelAll(OrderSearchModel model)
|
public virtual async Task<IActionResult> ExportExcelAll(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var startDateValue = model.StartDate == null ? null
|
var startDateValue = model.StartDate == null
|
||||||
|
? null
|
||||||
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync());
|
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync());
|
||||||
|
|
||||||
var endDateValue = model.EndDate == null ? null
|
var endDateValue = model.EndDate == null
|
||||||
|
? null
|
||||||
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1);
|
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1);
|
||||||
|
|
||||||
//a vendor should have access only to his products
|
//a vendor should have access only to his products
|
||||||
|
|
@ -954,9 +985,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
return RedirectToAction("List");
|
return RedirectToAction("List");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using FruitBank.Common.Dtos;
|
||||||
using FruitBank.Common.Entities;
|
using FruitBank.Common.Entities;
|
||||||
using FruitBank.Common.Interfaces;
|
using FruitBank.Common.Interfaces;
|
||||||
using FruitBank.Common.Server.Interfaces;
|
using FruitBank.Common.Server.Interfaces;
|
||||||
|
using FruitBank.Common.Server.Services.SignalRs;
|
||||||
using FruitBank.Common.SignalRs;
|
using FruitBank.Common.SignalRs;
|
||||||
using Mango.Nop.Core.Loggers;
|
using Mango.Nop.Core.Loggers;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
|
|
@ -13,11 +14,11 @@ using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using static Nop.Services.Security.StandardPermission;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
|
||||||
|
|
||||||
public class CustomOrderSignalREndpoint(FruitBankDbContext ctx, IPriceCalculationService customPriceCalculationService,IEventPublisher eventPublisher, IWorkContext workContext, IEnumerable<IAcLogWriterBase> logWriters) : ICustomOrderSignalREndpointServer
|
public class CustomOrderSignalREndpoint(FruitBankDbContext ctx, SignalRSendToClientService sendToClient, IPriceCalculationService customPriceCalculationService,IEventPublisher eventPublisher, IWorkContext workContext, IEnumerable<IAcLogWriterBase> logWriters)
|
||||||
|
: ICustomOrderSignalREndpointServer
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger = new Logger<CustomOrderSignalREndpoint>(logWriters.ToArray());
|
private readonly ILogger _logger = new Logger<CustomOrderSignalREndpoint>(logWriters.ToArray());
|
||||||
|
|
||||||
|
|
@ -51,7 +52,67 @@ public class CustomOrderSignalREndpoint(FruitBankDbContext ctx, IPriceCalculatio
|
||||||
return await ctx.OrderDtos.GetAllByIds(orderIds).ToListAsync();
|
return await ctx.OrderDtos.GetAllByIds(orderIds).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.StartMeasuring)]
|
[SignalR(SignalRTags.GetAllOrderDtoByProductId)]
|
||||||
|
public async Task<List<OrderDto>> GetAllOrderDtoByProductId(int productId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderDtos.GetAllByProductId(productId, true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetOrderItemDtoById)]
|
||||||
|
public async Task<OrderItemDto> GetOrderItemDtoById(int orderItemId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemDtos.GetByIdAsync(orderItemId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemDtos)]
|
||||||
|
public async Task<List<OrderItemDto>> GetAllOrderItemDtos()
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemDtos.GetAll(true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemDtoByOrderId)]
|
||||||
|
public async Task<List<OrderItemDto>> GetAllOrderItemDtoByOrderId(int orderId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemDtos.GetAllByOrderId(orderId, true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemDtoByProductId)]
|
||||||
|
public async Task<List<OrderItemDto>> GetAllOrderItemDtoByProductId(int productId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemDtos.GetAllByProductId(productId, true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetOrderItemPalletById)]
|
||||||
|
public async Task<OrderItemPallet> GetOrderItemPalletById(int orderItemPalletId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemPallets.GetByIdAsync(orderItemPalletId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemPallets)]
|
||||||
|
public async Task<List<OrderItemPallet>> GetAllOrderItemPallets()
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemPallets.GetAll(true).ToListAsync();
|
||||||
|
}
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemPalletByOrderItemId)]
|
||||||
|
public async Task<List<OrderItemPallet>> GetAllOrderItemPalletByOrderItemId(int orderItemId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemPallets.GetAllByOrderItemId(orderItemId, true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemPalletByOrderId)]
|
||||||
|
public async Task<List<OrderItemPallet>> GetAllOrderItemPalletByOrderId(int orderId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemPallets.GetAllByOrderId(orderId).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetAllOrderItemPalletByProductId)]
|
||||||
|
public async Task<List<OrderItemPallet>> GetAllOrderItemPalletByProductId(int productId)
|
||||||
|
{
|
||||||
|
return await ctx.OrderItemPallets.GetAllByProductId(productId).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.StartMeasuring, SignalRTags.SendOrderChanged, SendToClientType.Others)]
|
||||||
public async Task<OrderDto> StartMeasuring(int orderId, int userId)
|
public async Task<OrderDto> StartMeasuring(int orderId, int userId)
|
||||||
{
|
{
|
||||||
_logger.Detail($"StartMeasuring invoked; orderId: {orderId}; userId: {userId}");
|
_logger.Detail($"StartMeasuring invoked; orderId: {orderId}; userId: {userId}");
|
||||||
|
|
@ -60,7 +121,7 @@ public class CustomOrderSignalREndpoint(FruitBankDbContext ctx, IPriceCalculatio
|
||||||
return await ctx.OrderDtos.GetByIdAsync(orderId, true);
|
return await ctx.OrderDtos.GetByIdAsync(orderId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.SetOrderStatusToComplete)]
|
[SignalR(SignalRTags.SetOrderStatusToComplete, SignalRTags.SendOrderChanged, SendToClientType.Others)]
|
||||||
public async Task<OrderDto> SetOrderStatusToComplete(int orderId, int revisorId)
|
public async Task<OrderDto> SetOrderStatusToComplete(int orderId, int revisorId)
|
||||||
{
|
{
|
||||||
_logger.Detail($"SetOrderStatusToComplete invoked; orderId: {orderId}; revisorId: {revisorId}");
|
_logger.Detail($"SetOrderStatusToComplete invoked; orderId: {orderId}; revisorId: {revisorId}");
|
||||||
|
|
@ -79,7 +140,7 @@ public class CustomOrderSignalREndpoint(FruitBankDbContext ctx, IPriceCalculatio
|
||||||
return await ctx.OrderDtos.GetByIdAsync(orderId, true);
|
return await ctx.OrderDtos.GetByIdAsync(orderId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.AddOrUpdateMeasuredOrderItemPallet)]
|
[SignalR(SignalRTags.AddOrUpdateMeasuredOrderItemPallet, SignalRTags.SendOrderItemPalletChanged, SendToClientType.Others)]
|
||||||
public async Task<OrderItemPallet> AddOrUpdateMeasuredOrderItemPallet(OrderItemPallet orderItemPallet)
|
public async Task<OrderItemPallet> AddOrUpdateMeasuredOrderItemPallet(OrderItemPallet orderItemPallet)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(orderItemPallet);
|
ArgumentNullException.ThrowIfNull(orderItemPallet);
|
||||||
|
|
@ -87,6 +148,21 @@ public class CustomOrderSignalREndpoint(FruitBankDbContext ctx, IPriceCalculatio
|
||||||
_logger.Detail($"AddOrUpdateMeasuredOrderItemPallet invoked; {orderItemPallet}");
|
_logger.Detail($"AddOrUpdateMeasuredOrderItemPallet invoked; {orderItemPallet}");
|
||||||
|
|
||||||
if (!await ctx.AddOrUpdateOrderItemPalletSafeAsync(orderItemPallet)) return null;
|
if (!await ctx.AddOrUpdateOrderItemPalletSafeAsync(orderItemPallet)) return null;
|
||||||
|
|
||||||
|
var isMeasurable = orderItemPallet.GrossWeight > 0;
|
||||||
|
if (isMeasurable)
|
||||||
|
{
|
||||||
|
var orderItemDto = await ctx.OrderItemDtos.GetByIdAsync(orderItemPallet.OrderItemId, true);
|
||||||
|
|
||||||
|
if (orderItemDto.IsAudited && orderItemDto.IsMeasurable)
|
||||||
|
{
|
||||||
|
var orderItem = ctx.OrderItems.GetById(orderItemDto.Id);
|
||||||
|
|
||||||
|
await ((CustomPriceCalculationService)customPriceCalculationService).CheckAndUpdateOrderItemFinalPricesAsync
|
||||||
|
(orderItem, orderItemDto.IsMeasurable, orderItemDto.NetWeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await ctx.OrderItemPallets.GetByIdAsync(orderItemPallet.Id, false);
|
return await ctx.OrderItemPallets.GetByIdAsync(orderItemPallet.Id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -361,14 +361,22 @@
|
||||||
ClassName = NopColumnClassDefaults.CenterAll
|
ClassName = NopColumnClassDefaults.CenterAll
|
||||||
});
|
});
|
||||||
|
|
||||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModelExtended.IsMeasured))
|
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModelExtended.MeasuringStatusString))
|
||||||
{
|
{
|
||||||
Title = T($"FruitBank.{nameof(OrderModelExtended.IsMeasured)}").Text,
|
Title = "Mérés állapota", //T($"FruitBank.{nameof(OrderModelExtended.MeasuringStatus)}").Text,
|
||||||
Width = "80",
|
Width = "100",
|
||||||
Render = new RenderCustom("renderColumnIsMeasurable"),
|
Render = new RenderCustom("renderColumnMeasuringStatus"),
|
||||||
ClassName = NopColumnClassDefaults.CenterAll
|
ClassName = NopColumnClassDefaults.CenterAll
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModelExtended.IsMeasured))
|
||||||
|
// {
|
||||||
|
// Title = T($"FruitBank.{nameof(OrderModelExtended.IsMeasured)}").Text,
|
||||||
|
// Width = "80",
|
||||||
|
// Render = new RenderCustom("renderColumnIsMeasurable"),
|
||||||
|
// ClassName = NopColumnClassDefaults.CenterAll
|
||||||
|
// });
|
||||||
|
|
||||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(IOrderDto.DateOfReceipt))
|
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(IOrderDto.DateOfReceipt))
|
||||||
{
|
{
|
||||||
Title = T($"FruitBank.{nameof(IOrderDto.DateOfReceipt)}").Text,
|
Title = T($"FruitBank.{nameof(IOrderDto.DateOfReceipt)}").Text,
|
||||||
|
|
@ -384,13 +392,15 @@
|
||||||
{
|
{
|
||||||
Title = T("Admin.Orders.Fields.OrderStatus").Text,
|
Title = T("Admin.Orders.Fields.OrderStatus").Text,
|
||||||
Width = "100",
|
Width = "100",
|
||||||
Render = new RenderCustom("renderColumnOrderStatus")
|
Render = new RenderCustom("renderColumnOrderStatus"),
|
||||||
|
ClassName = NopColumnClassDefaults.CenterAll
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModel.PaymentStatus))
|
gridModel.ColumnCollection.Add(new ColumnProperty(nameof(OrderModel.PaymentStatus))
|
||||||
{
|
{
|
||||||
Title = T("Admin.Orders.Fields.PaymentStatus").Text,
|
Title = T("Admin.Orders.Fields.PaymentStatus").Text,
|
||||||
Width = "130"
|
Width = "130",
|
||||||
|
ClassName = NopColumnClassDefaults.CenterAll
|
||||||
});
|
});
|
||||||
//a vendor does not have access to this functionality
|
//a vendor does not have access to this functionality
|
||||||
if (!Model.IsLoggedInAsVendor)
|
if (!Model.IsLoggedInAsVendor)
|
||||||
|
|
@ -458,6 +468,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderColumnMeasuringStatus(data, type, row, meta) {
|
||||||
|
var color;
|
||||||
|
switch (row.MeasuringStatus) {
|
||||||
|
case 10: color = 'yellow'; break;
|
||||||
|
case 20: color = 'blue'; break;
|
||||||
|
case 30: color = 'green'; break;
|
||||||
|
case 40: color = 'red'; break;
|
||||||
|
default: color = 'gray';
|
||||||
|
}
|
||||||
|
return '<span class="grid-report-item ' + color + '">' + data + '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
function renderColumnCustomer(data, type, row, meta) {
|
function renderColumnCustomer(data, type, row, meta) {
|
||||||
console.log("Hello World 2");
|
console.log("Hello World 2");
|
||||||
var link = '@Url.Content("~/Admin/Customer/Edit/")' + row.CustomerId;
|
var link = '@Url.Content("~/Admin/Customer/Edit/")' + row.CustomerId;
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,10 @@
|
||||||
<th>
|
<th>
|
||||||
@T("FruitBank.IsMeasurable")
|
@T("FruitBank.IsMeasurable")
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
Mérés állapota
|
||||||
|
</th>
|
||||||
|
|
||||||
@* <th>
|
@* <th>
|
||||||
@T("Admin.Orders.Products.Discount")
|
@T("Admin.Orders.Products.Discount")
|
||||||
</th> *@
|
</th> *@
|
||||||
|
|
@ -324,6 +328,12 @@
|
||||||
<input type="hidden" name="pvIsMeasurable@(item.Id)" id="pvIsMeasurable@(item.Id)" value="@(item.IsMeasurable.ToString())" disabled />
|
<input type="hidden" name="pvIsMeasurable@(item.Id)" id="pvIsMeasurable@(item.Id)" value="@(item.IsMeasurable.ToString())" disabled />
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td style="width: 100px;" class="text-center">
|
||||||
|
<div>
|
||||||
|
<span>@($"{item.MeasuringStatusString}")</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
@* <td style="width: 15%;" class="text-center">
|
@* <td style="width: 15%;" class="text-center">
|
||||||
@if (Model.AllowCustomersToSelectTaxDisplayType)
|
@if (Model.AllowCustomersToSelectTaxDisplayType)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -428,18 +428,22 @@ public class FruitBankDbContext : MgDbContextBase,
|
||||||
{
|
{
|
||||||
if (orderItemDto.TrayQuantity != orderItemDto.Quantity) return null;
|
if (orderItemDto.TrayQuantity != orderItemDto.Quantity) return null;
|
||||||
|
|
||||||
//orderItemDto.ProductDto!.StockQuantity -= orderItemDto.TrayQuantity;
|
foreach (var orderItemPallet in orderItemDto.OrderItemPallets.Where(oip => oip.RevisorId <= 0))
|
||||||
//await ProductDtos.UpdateAsync(orderItemDto.ProductDto);
|
{
|
||||||
|
orderItemPallet.RevisorId = revisorId;
|
||||||
|
await OrderItemPallets.UpdateAsync(orderItemPallet, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (!orderItemDto.IsMeasurable) continue;
|
if (!orderItemDto.IsMeasurable) continue;
|
||||||
|
|
||||||
var gaNetWeight = CommonHelper.To<double>(orderItemDto.GenericAttributes.FirstOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))?.Value ?? "0");
|
var prevNetWeightFromGa = orderItemDto.GenericAttributes.GetValueOrDefault(nameof(IMeasuringNetWeight.NetWeight), 0);
|
||||||
|
//var gaNetWeight = CommonHelper.To<double>(orderItemDto.GenericAttributes.FirstOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))?.Value ?? "0");
|
||||||
|
|
||||||
await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<OrderItem, double>
|
await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<OrderItem, double>
|
||||||
(orderItemDto.Id, nameof(IMeasuringNetWeight.NetWeight), orderItemDto.NetWeight);
|
(orderItemDto.Id, nameof(IMeasuringNetWeight.NetWeight), orderItemDto.NetWeight);
|
||||||
|
|
||||||
await _fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>
|
await _fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>
|
||||||
(orderItemDto.ProductId, -(orderItemDto.NetWeight-gaNetWeight), orderItemDto.IsMeasurable, true);
|
(orderItemDto.ProductId, -(orderItemDto.NetWeight - prevNetWeightFromGa), orderItemDto.IsMeasurable, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//await _eventPublisher.PublishAsync(new OrderStatusChangedEvent(order, prevOrderStatus));
|
//await _eventPublisher.PublishAsync(new OrderStatusChangedEvent(order, prevOrderStatus));
|
||||||
|
|
@ -483,10 +487,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
||||||
|
|
||||||
private async Task<bool> SetupOrderItemPalletMeauringValues(OrderItemPallet orderItemPallet)
|
private async Task<bool> SetupOrderItemPalletMeauringValues(OrderItemPallet orderItemPallet)
|
||||||
{
|
{
|
||||||
OrderItemDto orderItemDto;
|
var orderItemDto = await OrderItemDtos.GetByIdAsync(orderItemPallet.OrderItemId, true);
|
||||||
|
|
||||||
if (orderItemPallet.OrderItemDto?.ProductDto == null) orderItemDto = await OrderItemDtos.GetByIdAsync(orderItemPallet.OrderItemId, true);
|
|
||||||
else orderItemDto = orderItemPallet.OrderItemDto;
|
|
||||||
|
|
||||||
if (orderItemDto == null || orderItemPallet.OrderItemId != orderItemDto.Id || //orderItemDto.IsOtherMeasuringInProgress(orderItemPallet.CreatorId) ||
|
if (orderItemDto == null || orderItemPallet.OrderItemId != orderItemDto.Id || //orderItemDto.IsOtherMeasuringInProgress(orderItemPallet.CreatorId) ||
|
||||||
orderItemPallet.TrayQuantity > orderItemDto.Quantity || !orderItemPallet.IsValidSafeMeasuringValues()) return false;
|
orderItemPallet.TrayQuantity > orderItemDto.Quantity || !orderItemPallet.IsValidSafeMeasuringValues()) return false;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using Nop.Core.Domain.Orders;
|
||||||
using Nop.Core.Events;
|
using Nop.Core.Events;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
using Mango.Nop.Core.Loggers;
|
using Mango.Nop.Core.Loggers;
|
||||||
|
using Nop.Core.Domain.Payments;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
|
|
@ -34,7 +35,10 @@ public class OrderDtoDbTable : MgDtoDbTableBase<OrderDto, Order>
|
||||||
=> GetAll(loadRelations).Where(o => o.OrderStatusId == (int)orderStatus);
|
=> GetAll(loadRelations).Where(o => o.OrderStatusId == (int)orderStatus);
|
||||||
|
|
||||||
public IQueryable<OrderDto> GetAllForMeasuring(bool loadRelations = true)
|
public IQueryable<OrderDto> GetAllForMeasuring(bool loadRelations = true)
|
||||||
=> GetAllByOrderStatus(OrderStatus.Pending, loadRelations).Where(o => o.GenericAttributes.Any(ga => ga.Key == nameof(OrderDto.DateOfReceipt)));
|
=> GetAll(loadRelations).Where(o => o.PaymentStatusId < (int)PaymentStatus.Paid && o.GenericAttributes.Any(ga => ga.Key == nameof(OrderDto.DateOfReceipt)));
|
||||||
|
//=> GetAllByOrderStatus(OrderStatus.Pending, loadRelations).Where(o => o.GenericAttributes.Any(ga => ga.Key == nameof(OrderDto.DateOfReceipt)));
|
||||||
|
|
||||||
|
public IQueryable<OrderDto> GetAllByProductId(int productId, bool loadRelations = true) => GetAll(loadRelations).Where(o => o.OrderItemDtos.Any(oi => oi.ProductId == productId));
|
||||||
|
|
||||||
public IQueryable<OrderDto> GetAllByIds(IEnumerable<int> orderIds, bool loadRelations = true) => GetAll(loadRelations).Where(o => orderIds.Contains(o.Id));
|
public IQueryable<OrderDto> GetAllByIds(IEnumerable<int> orderIds, bool loadRelations = true) => GetAll(loadRelations).Where(o => orderIds.Contains(o.Id));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,17 @@ public class OrderItemDtoDbTable : MgDtoDbTableBase<OrderItemDto, OrderItem>
|
||||||
public IQueryable<OrderItemDto> GetAll(bool loadRelations)
|
public IQueryable<OrderItemDto> GetAll(bool loadRelations)
|
||||||
{
|
{
|
||||||
return GetAll()
|
return GetAll()
|
||||||
.LoadWith(oi => oi.OrderDto)
|
|
||||||
.LoadWith(oi => oi.OrderItemPallets)
|
|
||||||
.LoadWith(oi => oi.GenericAttributes)
|
.LoadWith(oi => oi.GenericAttributes)
|
||||||
|
.LoadWith(oi => oi.OrderDto).ThenLoad(prod => prod.GenericAttributes)
|
||||||
|
.LoadWith(oi => oi.OrderItemPallets).ThenLoad(oip => oip.OrderItemDto).ThenLoad(oi => oi.GenericAttributes)
|
||||||
.LoadWith(oi => oi.ProductDto).ThenLoad(prod => prod.GenericAttributes);
|
.LoadWith(oi => oi.ProductDto).ThenLoad(prod => prod.GenericAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<OrderItemDto> GetByIdAsync(int orderItemId, bool loadRelations) => GetAll(loadRelations).Where(oi => oi.Id == orderItemId).FirstOrDefaultAsync(null);
|
public Task<OrderItemDto> GetByIdAsync(int orderItemId, bool loadRelations) => GetAll(loadRelations).Where(oi => oi.Id == orderItemId).FirstOrDefaultAsync(null);
|
||||||
|
|
||||||
public IQueryable<OrderItemDto> GetAllByOrderId(int orderId, bool loadRelations = true)=> GetAll(loadRelations).Where(oi => oi.OrderId == orderId);
|
public IQueryable<OrderItemDto> GetAllByOrderId(int orderId, bool loadRelations = true)=> GetAll(loadRelations).Where(oi => oi.OrderId == orderId);
|
||||||
|
public IQueryable<OrderItemDto> GetAllByProductId(int productId, bool loadRelations = true)=> GetAll(loadRelations).Where(oi => oi.ProductId == productId);
|
||||||
|
|
||||||
public IQueryable<OrderItemDto> GetAllByIds(IEnumerable<int> orderItemIds, bool loadRelations = true) => GetAll(loadRelations).Where(oi => orderItemIds.Contains(oi.Id));
|
public IQueryable<OrderItemDto> GetAllByIds(IEnumerable<int> orderItemIds, bool loadRelations = true) => GetAll(loadRelations).Where(oi => orderItemIds.Contains(oi.Id));
|
||||||
|
public IQueryable<OrderItemDto> GetAllByOrderIds(IEnumerable<int> orderIds, bool loadRelations = true) => GetAll(loadRelations).Where(oi => orderIds.Contains(oi.OrderId));
|
||||||
}
|
}
|
||||||
|
|
@ -21,13 +21,21 @@ public class OrderItemPalletDbTable : MeasuringItemPalletBaseDbTable<OrderItemPa
|
||||||
{
|
{
|
||||||
return loadRelations
|
return loadRelations
|
||||||
? GetAll()
|
? GetAll()
|
||||||
.LoadWith(oip => oip.OrderItemDto).ThenLoad(oi => oi.ProductDto).ThenLoad(oip => oip.GenericAttributes)
|
.LoadWith(oip => oip.OrderItemDto).ThenLoad(oi => oi.OrderDto).ThenLoad(o => o.GenericAttributes)
|
||||||
|
.LoadWith(oip => oip.OrderItemDto).ThenLoad(oi => oi.ProductDto).ThenLoad(p => p.GenericAttributes)
|
||||||
: GetAll();
|
: GetAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<OrderItemPallet> GetByIdAsync(int id, bool loadRelations)
|
public Task<OrderItemPallet> GetByIdAsync(int id, bool loadRelations)
|
||||||
=> GetAll(loadRelations).FirstOrDefaultAsync(oip => oip.Id == id);
|
=> GetAll(loadRelations).FirstOrDefaultAsync(oip => oip.Id == id);
|
||||||
|
|
||||||
public IQueryable<OrderItemPallet> GetAllByOrderItemIdAsync(int orderItemId, bool loadRelations)
|
public IQueryable<OrderItemPallet> GetAllByOrderItemId(int orderItemId, bool loadRelations)
|
||||||
=> GetAll(loadRelations).Where(oip => oip.OrderItemId == orderItemId);
|
=> GetAll(loadRelations).Where(oip => oip.OrderItemId == orderItemId);
|
||||||
|
|
||||||
|
public IQueryable<OrderItemPallet> GetAllByOrderId(int orderId)
|
||||||
|
=> GetAll(true).Where(oip => oip.OrderItemDto.OrderId == orderId);
|
||||||
|
|
||||||
|
public IQueryable<OrderItemPallet> GetAllByProductId(int productId)
|
||||||
|
=> GetAll(true).Where(oip => oip.OrderItemDto.ProductId == productId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -259,21 +259,19 @@ public class FruitBankEventConsumer :
|
||||||
|
|
||||||
public async Task HandleEventAsync(EntityUpdatedEvent<OrderItem> eventMessage)
|
public async Task HandleEventAsync(EntityUpdatedEvent<OrderItem> eventMessage)
|
||||||
{
|
{
|
||||||
//await _customPriceCalculationService.CheckAndUpdateOrderItemFinalPricesAsync(eventMessage.Entity);
|
await CheckAndUpdateOrderItemFinalPricesAsync(eventMessage.Entity);
|
||||||
if (await _customPriceCalculationService.CheckAndUpdateOrderItemFinalPricesAsync(eventMessage.Entity))
|
|
||||||
{
|
|
||||||
var order = await _ctx.Orders.GetByIdAsync(eventMessage.Entity.OrderId);
|
|
||||||
await _customPriceCalculationService.CheckAndUpdateOrderTotalPrice(order);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task HandleEventAsync(EntityInsertedEvent<OrderItem> eventMessage)
|
public async Task HandleEventAsync(EntityInsertedEvent<OrderItem> eventMessage)
|
||||||
{
|
{
|
||||||
//await _customPriceCalculationService.CheckAndUpdateOrderItemFinalPricesAsync(eventMessage.Entity);
|
await CheckAndUpdateOrderItemFinalPricesAsync(eventMessage.Entity);
|
||||||
if (await _customPriceCalculationService.CheckAndUpdateOrderItemFinalPricesAsync(eventMessage.Entity))
|
}
|
||||||
|
|
||||||
|
private async Task CheckAndUpdateOrderItemFinalPricesAsync(OrderItem orderItem)
|
||||||
{
|
{
|
||||||
var order = await _ctx.Orders.GetByIdAsync(eventMessage.Entity.OrderId);
|
if (await _customPriceCalculationService.CheckAndUpdateOrderItemFinalPricesAsync(orderItem))
|
||||||
|
{
|
||||||
|
var order = await _ctx.Orders.GetByIdAsync(orderItem.OrderId);
|
||||||
await _customPriceCalculationService.CheckAndUpdateOrderTotalPrice(order);
|
await _customPriceCalculationService.CheckAndUpdateOrderTotalPrice(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Factories
|
||||||
private static void PrepareOrderModelExtended(OrderModelExtended orderModelExtended, OrderDto orderDto)
|
private static void PrepareOrderModelExtended(OrderModelExtended orderModelExtended, OrderDto orderDto)
|
||||||
{
|
{
|
||||||
orderModelExtended.IsMeasured = orderDto.IsMeasured;
|
orderModelExtended.IsMeasured = orderDto.IsMeasured;
|
||||||
|
orderModelExtended.MeasuringStatus = orderDto.MeasuringStatus;
|
||||||
orderModelExtended.IsMeasurable = orderDto.IsMeasurable;
|
orderModelExtended.IsMeasurable = orderDto.IsMeasurable;
|
||||||
orderModelExtended.DateOfReceipt = orderDto.DateOfReceipt;
|
orderModelExtended.DateOfReceipt = orderDto.DateOfReceipt;
|
||||||
orderModelExtended.OrderTotal = !orderDto.IsComplete && orderDto.IsMeasurable ? "kalkuláció alatt..." : orderModelExtended.OrderTotal;
|
orderModelExtended.OrderTotal = !orderDto.IsComplete && orderDto.IsMeasurable ? "kalkuláció alatt..." : orderModelExtended.OrderTotal;
|
||||||
|
|
@ -209,11 +210,14 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Factories
|
||||||
|
|
||||||
orderItemModelExtended.IsMeasured = orderItemDto.IsMeasured;
|
orderItemModelExtended.IsMeasured = orderItemDto.IsMeasured;
|
||||||
orderItemModelExtended.IsMeasurable = orderItemDto.IsMeasurable;
|
orderItemModelExtended.IsMeasurable = orderItemDto.IsMeasurable;
|
||||||
|
orderItemModelExtended.MeasuringStatus = orderItemDto.MeasuringStatus;
|
||||||
orderItemModelExtended.NetWeight = (decimal)orderItemDto.NetWeight;
|
orderItemModelExtended.NetWeight = (decimal)orderItemDto.NetWeight;
|
||||||
orderItemModelExtended.ProductStockQuantity = orderItemDto.ProductDto!.StockQuantity;
|
orderItemModelExtended.ProductStockQuantity = orderItemDto.ProductDto!.StockQuantity;
|
||||||
orderItemModelExtended.ProductIncomingQuantity = orderItemDto.ProductDto.IncomingQuantity;
|
orderItemModelExtended.ProductIncomingQuantity = orderItemDto.ProductDto.IncomingQuantity;
|
||||||
orderItemModelExtended.ProductAvailableQuantity = orderItemDto.ProductDto.AvailableQuantity;
|
orderItemModelExtended.ProductAvailableQuantity = orderItemDto.ProductDto.AvailableQuantity;
|
||||||
//orderItemModelExtended.SubTotalInclTax = !orderDto.IsComplete && orderItemDto.IsMeasurable ? "kalkuláció alatt..." : orderItemModelExtended.SubTotalInclTax;
|
|
||||||
|
|
||||||
|
orderItemModelExtended.SubTotalInclTax = orderItemDto.IsMeasurable && !orderItemDto.IsAudited ? "kalkuláció alatt..." : orderItemModelExtended.SubTotalInclTax;
|
||||||
|
|
||||||
orderModelExtended.ItemExtendeds ??= new List<OrderItemModelExtended>();
|
orderModelExtended.ItemExtendeds ??= new List<OrderItemModelExtended>();
|
||||||
orderModelExtended.ItemExtendeds.Add(orderItemModelExtended);
|
orderModelExtended.ItemExtendeds.Add(orderItemModelExtended);
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ public class PluginNopStartup : INopStartup
|
||||||
services.AddScoped<ShippingDocumentToFilesDbTable>();
|
services.AddScoped<ShippingDocumentToFilesDbTable>();
|
||||||
|
|
||||||
services.AddScoped<FruitBankDbContext>();
|
services.AddScoped<FruitBankDbContext>();
|
||||||
|
|
||||||
|
services.AddScoped<SignalRSendToClientService>();
|
||||||
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
||||||
services.AddScoped<ICustomOrderSignalREndpointServer, CustomOrderSignalREndpoint>();
|
services.AddScoped<ICustomOrderSignalREndpointServer, CustomOrderSignalREndpoint>();
|
||||||
|
|
||||||
|
|
@ -84,6 +86,8 @@ public class PluginNopStartup : INopStartup
|
||||||
services.AddScoped<InnVoiceApiService>();
|
services.AddScoped<InnVoiceApiService>();
|
||||||
services.AddScoped<InnVoiceOrderService>();
|
services.AddScoped<InnVoiceOrderService>();
|
||||||
|
|
||||||
|
services.AddScoped<MeasurementService>();
|
||||||
|
|
||||||
//services.AddScoped<OrderListModel, OrderListModelExtended>();
|
//services.AddScoped<OrderListModel, OrderListModelExtended>();
|
||||||
//services.AddScoped<OrderModel, OrderModelExtended>();
|
//services.AddScoped<OrderModel, OrderModelExtended>();
|
||||||
//services.AddScoped<OrderSearchModel, OrderSearchModelExtended>();
|
//services.AddScoped<OrderSearchModel, OrderSearchModelExtended>();
|
||||||
|
|
@ -100,7 +104,13 @@ public class PluginNopStartup : INopStartup
|
||||||
options.Filters.AddService<PendingMeasurementCheckoutFilter>();
|
options.Filters.AddService<PendingMeasurementCheckoutFilter>();
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);
|
services.AddSignalR(hubOptions =>
|
||||||
|
{
|
||||||
|
//hubOptions.EnableDetailedErrors = true;
|
||||||
|
hubOptions.MaximumReceiveMessageSize = 256 * 1024;
|
||||||
|
hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignalRKeepAliveIntervalSecond);
|
||||||
|
hubOptions.ClientTimeoutInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignarlRTimeoutIntervalSecond);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,18 @@ using Nop.Plugin.Misc.FruitBankPlugin.Models.MgBase.OrderModels;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders;
|
||||||
|
|
||||||
public interface IOrderItemModelExtended : /*IMgOrderItemModelExtended,*/ IMeasurable, IMeasured
|
public interface IOrderItemModelExtended : /*IMgOrderItemModelExtended,*/ IMeasurable, IMeasured, IMeasurableStatus
|
||||||
{
|
{
|
||||||
|
string MeasuringStatusString { get; }
|
||||||
decimal NetWeight { get; set; }
|
decimal NetWeight { get; set; }
|
||||||
int ProductStockQuantity { get; set; }
|
int ProductStockQuantity { get; set; }
|
||||||
int ProductIncomingQuantity { get; set; }
|
int ProductIncomingQuantity { get; set; }
|
||||||
int ProductAvailableQuantity { get; set; }
|
int ProductAvailableQuantity { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IOrderModelExtended : IMgOrderModelExtended, IMeasurable, IMeasured
|
public interface IOrderModelExtended : IMgOrderModelExtended, IMeasurable, IMeasured, IMeasurableStatus
|
||||||
{
|
{
|
||||||
|
string MeasuringStatusString { get; }
|
||||||
DateTime? DateOfReceipt { get; set; }
|
DateTime? DateOfReceipt { get; set; }
|
||||||
string CustomerCompany { get; set; }
|
string CustomerCompany { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Models.MgBase.OrderModels;
|
using FruitBank.Common.Enums;
|
||||||
|
using Nop.Plugin.Misc.FruitBankPlugin.Models.MgBase.OrderModels;
|
||||||
using Nop.Web.Areas.Admin.Models.Orders;
|
using Nop.Web.Areas.Admin.Models.Orders;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
||||||
|
|
@ -7,6 +8,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
||||||
{
|
{
|
||||||
public bool IsMeasured { get; set; }
|
public bool IsMeasured { get; set; }
|
||||||
public bool IsMeasurable { get; set; }
|
public bool IsMeasurable { get; set; }
|
||||||
|
public MeasuringStatus MeasuringStatus { get; set; }
|
||||||
|
public string MeasuringStatusString => MeasuringStatus.ToString();
|
||||||
public decimal NetWeight { get; set; }
|
public decimal NetWeight { get; set; }
|
||||||
public int ProductStockQuantity { get; set; }
|
public int ProductStockQuantity { get; set; }
|
||||||
public int ProductIncomingQuantity { get; set; }
|
public int ProductIncomingQuantity { get; set; }
|
||||||
|
|
@ -17,6 +20,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
||||||
{
|
{
|
||||||
public bool IsMeasured { get; set; }
|
public bool IsMeasured { get; set; }
|
||||||
public bool IsMeasurable { get; set; }
|
public bool IsMeasurable { get; set; }
|
||||||
|
public MeasuringStatus MeasuringStatus { get; set; }
|
||||||
|
public string MeasuringStatusString => MeasuringStatus.ToString();
|
||||||
public DateTime? DateOfReceipt { get; set; }
|
public DateTime? DateOfReceipt { get; set; }
|
||||||
|
|
||||||
public string CustomerCompany { get; set; }
|
public string CustomerCompany { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using Mango.Nop.Services;
|
using Mango.Nop.Core.Services;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
using FruitBank.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
|
|
||||||
|
public interface IMeasurementService : IMeasurementServiceBase
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
using FruitBank.Common.Services;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||||
|
|
||||||
|
public class MeasurementService : MeasurementServiceBase, IMeasurementService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue