From d9d3211804a48fc465968c4a4819c2e92a60c593 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Thu, 21 Sep 2023 17:06:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=A2=E5=8D=95=E7=9F=AB?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BillCorrection/BillCorrectionBusiness.cs | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs b/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs index 00b4f497..c7808e19 100644 --- a/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs +++ b/BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs @@ -36,31 +36,55 @@ namespace BBWY.Server.Business var orderIds = orderList.Select(o => o.OrderId).ToList(); var sdOrderIds = orderList.Where(o => o.StorageType == Model.Enums.StorageType.SD).Select(o => o.OrderId).ToArray(); - var orderCostDetailList = fsql.Select() - .Where(ocd => orderIds.Contains(ocd.OrderId) && ocd.IsEnabled == true) - .GroupBy(ocd => ocd.OrderId) - .ToList(g => new - { - OrderId = g.Key, - DeliveryExpressFreight = g.Sum(g.Value.DeliveryExpressFreight), - SkuAmount = g.Sum(g.Value.SkuAmount), - PurchaseFreight = g.Sum(g.Value.PurchaseFreight), - FirstFreight = g.Sum(g.Value.FirstFreight), - InStorageAmount = g.Sum(g.Value.InStorageAmount), - OutStorageAmount = g.Sum(g.Value.OutStorageAmount), - ConsumableAmount = g.Sum(g.Value.ConsumableAmount), - StorageAmount = g.Sum(g.Value.StorageAmount) - }); + //var orderCostDetailList = fsql.Select() + // .Where(ocd => orderIds.Contains(ocd.OrderId) && ocd.IsEnabled == true) + // .GroupBy(ocd => ocd.OrderId) + // .ToList(g => new + // { + // OrderId = g.Key, + // DeliveryExpressFreight = g.Sum(g.Value.DeliveryExpressFreight), + // SkuAmount = g.Sum(g.Value.SkuAmount), + // PurchaseFreight = g.Sum(g.Value.PurchaseFreight), + // FirstFreight = g.Sum(g.Value.FirstFreight), + // InStorageAmount = g.Sum(g.Value.InStorageAmount), + // OutStorageAmount = g.Sum(g.Value.OutStorageAmount), + // ConsumableAmount = g.Sum(g.Value.ConsumableAmount), + // StorageAmount = g.Sum(g.Value.StorageAmount) + // }); + var orderCostDetailList = fsql.Select().InnerJoin((ocd, o) => ocd.OrderId == o.Id) + .Where((ocd, o) => ocd.IsEnabled == true) + .Where((ocd, o) => request.ShopIds.Contains(o.ShopId) && + o.StartTime >= request.StartTime && + o.StartTime <= request.EndTime && + o.IsGift == false) + .GroupBy((ocd, o) => ocd.OrderId) + .ToList(g => new + { + OrderId = g.Key, + DeliveryExpressFreight = g.Sum(g.Value.Item1.DeliveryExpressFreight), + SkuAmount = g.Sum(g.Value.Item1.SkuAmount), + PurchaseFreight = g.Sum(g.Value.Item1.PurchaseFreight), + FirstFreight = g.Sum(g.Value.Item1.FirstFreight), + InStorageAmount = g.Sum(g.Value.Item1.InStorageAmount), + OutStorageAmount = g.Sum(g.Value.Item1.OutStorageAmount), + ConsumableAmount = g.Sum(g.Value.Item1.ConsumableAmount), + StorageAmount = g.Sum(g.Value.Item1.StorageAmount) + }); + var sdOrderCostList = fsql.Select(sdOrderIds).ToList(); - var afterOrderList = fsql.Select() - .Where(aso => orderIds.Contains(aso.OrderId)) - .GroupBy(aso => aso.OrderId) + var afterOrderList = fsql.Select() + .InnerJoin((aso, o) => aso.OrderId == o.Id) + .Where((aso, o) => request.ShopIds.Contains(o.ShopId) && + o.StartTime >= request.StartTime && + o.StartTime <= request.EndTime && + o.IsGift == false) + .GroupBy((aso, o) => aso.OrderId) .ToList(g => new { OrderId = g.Key, - AfterTotalCost = g.Sum(g.Value.AfterTotalCost) + AfterTotalCost = g.Sum(g.Value.Item1.AfterTotalCost) }); foreach (var order in orderList)