Merge branch '4.80' of https://git.aycode.com/Adam/Mango.Nop.Plugins into 4.80
This commit is contained in:
commit
e1851c3329
|
|
@ -2,6 +2,8 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using AyCode.Services.Server.SignalRs;
|
||||
using AyCode.Services.SignalRs;
|
||||
using AyCode.Utils.Extensions;
|
||||
using FluentMigrator.Runner.Generators.Base;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
|
|
@ -225,10 +227,15 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
OrderStatusIds = orderStatuses,
|
||||
PaymentStatusIds = paymentStatuses,
|
||||
ShippingStatusIds = shippingStatuses,
|
||||
Length = 50,
|
||||
AvailablePageSizes = "20,50,100,500",
|
||||
SortColumn = "Id",
|
||||
SortColumnDirection = "desc",
|
||||
});
|
||||
|
||||
model.SetGridSort("Id", "desc");
|
||||
model.SetGridPageSize(50, "20,50,100,500");
|
||||
|
||||
return View("~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/List.cshtml", model);
|
||||
}
|
||||
|
||||
|
|
@ -237,6 +244,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
public async Task<IActionResult> OrderList(OrderSearchModelExtended searchModel)
|
||||
{
|
||||
//prepare model
|
||||
//if (searchModel.SortColumn.IsNullOrWhiteSpace())
|
||||
//{
|
||||
// searchModel.SortColumn = "Id";
|
||||
// searchModel.SortColumnDirection = "desc";
|
||||
//}
|
||||
|
||||
var orderListModel = await GetOrderListModelByFilter(searchModel);
|
||||
//var orderListModel = new OrderListModel();
|
||||
|
||||
|
|
@ -294,19 +307,29 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
|
||||
public async Task<OrderListModelExtended> GetOrderListModelByFilter(OrderSearchModelExtended searchModel)
|
||||
{
|
||||
|
||||
var sortColumnIndex = Request.Form["order[0][column]"].FirstOrDefault();
|
||||
var sortDirection = Request.Form["order[0][dir]"].FirstOrDefault();
|
||||
|
||||
if (!string.IsNullOrEmpty(sortColumnIndex))
|
||||
//if (searchModel.SortColumn.IsNullOrWhiteSpace())
|
||||
{
|
||||
// Get the column name from the column index
|
||||
var columnName = Request.Form[$"columns[{sortColumnIndex}][data]"].FirstOrDefault();
|
||||
var sortColumnIndex = Request.Form["order[0][column]"].FirstOrDefault();
|
||||
var sortDirection = Request.Form["order[0][dir]"].FirstOrDefault();
|
||||
|
||||
searchModel.SortColumn = columnName;
|
||||
searchModel.SortColumnDirection = sortDirection; // "asc" or "desc"
|
||||
if (!string.IsNullOrEmpty(sortColumnIndex))
|
||||
{
|
||||
// Get the column name from the column index
|
||||
var columnName = Request.Form[$"columns[{sortColumnIndex}][data]"].FirstOrDefault();
|
||||
|
||||
searchModel.SortColumn = columnName;
|
||||
|
||||
if(int.Parse(sortColumnIndex) > 0) searchModel.SortColumnDirection = sortDirection; // "asc" or "desc"
|
||||
else searchModel.SortColumnDirection = "desc";
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// searchModel.SortColumn = "Id";
|
||||
// searchModel.SortColumnDirection = "desc";
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// Get the paginated data
|
||||
var orderListModel = await _orderModelFactory.PrepareOrderListModelExtendedAsync(searchModel);
|
||||
|
||||
|
|
@ -526,16 +549,28 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
throw new Exception($"{errorText}");
|
||||
}
|
||||
|
||||
var valami = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: true);
|
||||
var unitPrice = valami.finalPrice;
|
||||
|
||||
// Calculate tax
|
||||
var (unitPriceInclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, true, customer);
|
||||
var (unitPriceExclTaxValue, _) = await _taxService.GetProductPriceAsync(product, unitPrice, false, customer);
|
||||
|
||||
|
||||
var orderItem = new OrderItem
|
||||
{
|
||||
OrderId = order.Id,
|
||||
ProductId = item.Id,
|
||||
Quantity = item.Quantity,
|
||||
UnitPriceInclTax = item.Price,
|
||||
UnitPriceExclTax = item.Price,
|
||||
PriceInclTax = isMeasurable ? 0 : item.Price * item.Quantity,
|
||||
PriceExclTax = isMeasurable ? 0 : item.Price * item.Quantity,
|
||||
OriginalProductCost = product.ProductCost,
|
||||
|
||||
UnitPriceInclTax = unitPriceInclTaxValue,
|
||||
UnitPriceExclTax = unitPriceExclTaxValue,
|
||||
|
||||
PriceInclTax = isMeasurable ? 0 : unitPriceInclTaxValue * item.Quantity,
|
||||
PriceExclTax = isMeasurable ? 0 : unitPriceExclTaxValue * item.Quantity,
|
||||
|
||||
OriginalProductCost = await _priceCalculationService.GetProductCostAsync(product, null),
|
||||
|
||||
AttributeDescription = string.Empty,
|
||||
AttributesXml = string.Empty,
|
||||
DiscountAmountInclTax = 0,
|
||||
|
|
@ -1194,6 +1229,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
}
|
||||
|
||||
var productDtosByOrderItemId = await _dbContext.ProductDtos.GetAllByIds(products.Select(x => x.Id).ToArray()).ToDictionaryAsync(k => k.Id, v => v);
|
||||
|
||||
var customer = await _customerService.GetCustomerByIdAsync(order.CustomerId);
|
||||
var store = await _storeContext.GetCurrentStoreAsync();
|
||||
var admin = await _workContext.GetCurrentCustomerAsync();
|
||||
|
|
@ -1201,8 +1237,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
|
||||
var transactionSuccess = await _dbContext.TransactionSafeAsync(async _ =>
|
||||
{
|
||||
|
||||
|
||||
// Add each product to the order
|
||||
foreach (var productModel in products)
|
||||
{
|
||||
|
|
@ -1214,7 +1248,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
}
|
||||
|
||||
// Validate stock
|
||||
var stockQuantity = await _productService.GetTotalStockQuantityAsync(product);
|
||||
//var stockQuantity = await _productService.GetTotalStockQuantityAsync(product);
|
||||
var productDto = productDtosByOrderItemId[productModel.Id];
|
||||
var isMeasurable = productDto.IsMeasurable;
|
||||
|
||||
|
|
@ -1243,9 +1277,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
|
||||
|
||||
var valami = await _priceCalculationService.GetFinalPriceAsync(product, customer, store, includeDiscounts: true);
|
||||
var originalPrice = valami.priceWithoutDiscounts;
|
||||
var discountAmount = valami.appliedDiscountAmount;
|
||||
var discountedPrice = valami.appliedDiscounts;
|
||||
var unitPrice = valami.finalPrice;
|
||||
|
||||
// Calculate tax
|
||||
|
|
@ -1258,12 +1289,22 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
OrderItemGuid = Guid.NewGuid(),
|
||||
OrderId = order.Id,
|
||||
ProductId = product.Id,
|
||||
Quantity = productModel.Quantity,
|
||||
|
||||
UnitPriceInclTax = unitPriceInclTaxValue,
|
||||
UnitPriceExclTax = unitPriceExclTaxValue,
|
||||
PriceInclTax = unitPriceInclTaxValue * productModel.Quantity,
|
||||
PriceExclTax = unitPriceExclTaxValue * productModel.Quantity,
|
||||
|
||||
PriceInclTax = isMeasurable ? 0 : unitPriceInclTaxValue * productModel.Quantity,
|
||||
PriceExclTax = isMeasurable ? 0 : unitPriceExclTaxValue * productModel.Quantity,
|
||||
|
||||
OriginalProductCost = await _priceCalculationService.GetProductCostAsync(product, null),
|
||||
Quantity = productModel.Quantity,
|
||||
|
||||
//UnitPriceInclTax = unitPriceInclTaxValue,
|
||||
//UnitPriceExclTax = unitPriceExclTaxValue,
|
||||
//PriceInclTax = unitPriceInclTaxValue * productModel.Quantity,
|
||||
//PriceExclTax = unitPriceExclTaxValue * productModel.Quantity,
|
||||
//OriginalProductCost = await _priceCalculationService.GetProductCostAsync(product, null),
|
||||
|
||||
DiscountAmountInclTax = decimal.Zero,
|
||||
DiscountAmountExclTax = decimal.Zero,
|
||||
DownloadCount = 0,
|
||||
|
|
|
|||
|
|
@ -18,5 +18,11 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.Order
|
|||
public string SortColumn { get; set; }
|
||||
public string SortColumnDirection { get; set; }
|
||||
|
||||
public void SetGridSort(string columnName, string columnDirection = "asc")
|
||||
{
|
||||
SortColumn = "Id";
|
||||
SortColumnDirection = columnDirection;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,14 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
return await ctx.ShippingItems.GetAll(true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItemsByDocumentId)]
|
||||
public async Task<List<ShippingItem>> GetShippingItemsByDocumentId(int shippingDocumentId)
|
||||
{
|
||||
_logger.Detail($"GetShippingItemsByDocumentId invoked");
|
||||
|
||||
return await ctx.ShippingItems.GetAllByShippingDocumentIdAsync(shippingDocumentId, true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItemById)]
|
||||
public async Task<ShippingItem> GetShippingItemById(int id)
|
||||
{
|
||||
|
|
@ -151,7 +159,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
_logger.Detail($"AddShippingItem invoked; id: {shippingItem.Id}");
|
||||
|
||||
if (!await ctx.AddShippingItemAsync(shippingItem)) return null;
|
||||
return await ctx.ShippingItems.GetByIdAsync(shippingItem.Id, shippingItem.ShippingDocument != null);
|
||||
return await ctx.ShippingItems.GetByIdAsync(shippingItem.Id, true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShippingItem)]
|
||||
|
|
|
|||
|
|
@ -227,10 +227,19 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
|
||||
if (productId > 0)
|
||||
{
|
||||
var productDto = await ProductDtos.GetByIdAsync(productId);
|
||||
shippingItem.IsMeasurable = productDto?.IsMeasurable ?? false;
|
||||
var productDto = await ProductDtos.GetByIdAsync(productId, true);
|
||||
|
||||
if (productDto != null)
|
||||
{
|
||||
shippingItem.IsMeasurable = productDto.IsMeasurable;
|
||||
shippingItem.Name = productDto.Name;
|
||||
}
|
||||
}
|
||||
|
||||
//IDEIGLENES, AMÍG NEM VEZETJÜK KI A shippingItem.Name-et!
|
||||
if (shippingItem.Name.IsNullOrEmpty() && !shippingItem.NameOnDocument.IsNullOrEmpty()) shippingItem.Name = shippingItem.NameOnDocument;
|
||||
else if (shippingItem.Name.IsNullOrEmpty()) shippingItem.Name = string.Empty;
|
||||
|
||||
await ShippingItems.InsertAsync(shippingItem);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -256,6 +265,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
throw new Exception($"shippingItem.ProductId > 0 && product == null; shippingItem.ProductId: {shippingItem.ProductId}");
|
||||
|
||||
productIsMeasurable = productDto.IsMeasurable;
|
||||
shippingItem.Name = productDto.Name;
|
||||
}
|
||||
|
||||
shippingItem.IsMeasurable = productIsMeasurable;
|
||||
|
|
@ -315,7 +325,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
//await _fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(productDto.Id, weightToChange, shippingItem.IsMeasurable, true);
|
||||
}
|
||||
|
||||
await UpdateStockQuantityAndWeightAsync(productDto, quantityInc, $"Bejövő mérés, shippingItem: #{shippingItem.Id}", weightToChange);
|
||||
await UpdateStockQuantityAndWeightAsync(productDto, quantityInc, $"Áru bevételezés, shippingItem: #{shippingItem.Id}", weightToChange);
|
||||
//productDto!.StockQuantity += quantityInc;
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +356,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
//}
|
||||
|
||||
await UpdateStockQuantityAndWeightAsync(productDto, -dbShippingItem.MeasuredQuantity,
|
||||
$"Bejövő mérés, ShippingItem.Id: #{shippingItem.Id}. Product.Id megváltozott, #{productDto.Id}->#{shippingItem.ProductId}!",
|
||||
$"Áru bevételezés, ShippingItem.Id: #{shippingItem.Id}. Product.Id megváltozott, #{productDto.Id}->#{shippingItem.ProductId}!",
|
||||
-dbShippingItem.MeasuredNetWeight);
|
||||
|
||||
//productDto!.StockQuantity -= dbShippingItem.MeasuredQuantity;
|
||||
|
|
@ -515,7 +525,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
//await _fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(orderItemDto.ProductId, productWeightToChange, orderItemDto.IsMeasurable, true);
|
||||
|
||||
await UpdateStockQuantityAndWeightAsync(orderItemDto.ProductId, 0,
|
||||
$"Kimenő mérés, OrderStatus set to complete. Rendelés: #{orderDto.Id}, rendelés tétel: #{orderItemDto.Id}",
|
||||
$"Áru kiadás, OrderStatus set to complete. Rendelés: #{orderDto.Id}, rendelés tétel: #{orderItemDto.Id}",
|
||||
productWeightToChange);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue