From 46e80f481ee2102d243dbf9f142c029685b49da3 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Mon, 18 Apr 2022 23:30:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=9F=E8=B1=A1=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StatisticsController.cs | 2 +- .../Statistics/StatisticsBusiness.cs | 43 +++++++++++++------ .../Response/Order/XingXinagSearchResponse.cs | 27 +++++++++++- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/BBWY.Server.API/Controllers/StatisticsController.cs b/BBWY.Server.API/Controllers/StatisticsController.cs index 0f22f7c7..626512ea 100644 --- a/BBWY.Server.API/Controllers/StatisticsController.cs +++ b/BBWY.Server.API/Controllers/StatisticsController.cs @@ -33,7 +33,7 @@ namespace BBWY.Server.API.Controllers /// /// [HttpPost] - public IList XingXiangStatistics([FromBody] XingXiangSearchOrderRequest xingXiangSearchOrderRequest) + public XingXinagSearchResponse XingXiangStatistics([FromBody] XingXiangSearchOrderRequest xingXiangSearchOrderRequest) { return statisticsBusiness.XingXiangStatistics(xingXiangSearchOrderRequest); } diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs index 9549e86b..2ff5f4c2 100644 --- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs +++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs @@ -40,11 +40,11 @@ namespace BBWY.Server.Business } - public IList XingXiangStatistics(XingXiangSearchOrderRequest xingXiangSearchOrderRequest) + public XingXinagSearchResponse XingXiangStatistics(XingXiangSearchOrderRequest xingXiangSearchOrderRequest) { var beginTime = xingXiangSearchOrderRequest.SearchDate.Date; var endTime = xingXiangSearchOrderRequest.SearchDate.Date.AddDays(1).AddSeconds(-1); - IList list = null; + IList detailList = null; //查询订单 var orderList = fsql.Select().Where(o => o.ShopId == xingXiangSearchOrderRequest.ShopId) @@ -61,8 +61,8 @@ namespace BBWY.Server.Business //查询成本明细 var orderCostDetailList = fsql.Select().Where(ocd => orderIdList.Contains(ocd.OrderId)).ToList(); - list = new List(); - + detailList = new List(); + var totalSDOrderCost = 0M; foreach (var order in orderList) { var skuCount = orderSkuList.Count(osku => osku.OrderId == order.Id); @@ -73,33 +73,48 @@ namespace BBWY.Server.Business foreach (var group in currentOrderSkuGroups) { var spuId = group.Key; - var procutAmount = group.Sum(osku => osku.Price * osku.ItemTotal) ?? 0; //货款 - var commissionAmount = procutAmount * 0.05M; //该SPU的平台扣点金额 + var prodcutAmount = group.Sum(osku => osku.Price * osku.ItemTotal) ?? 0; //货款 + var commissionAmount = prodcutAmount * 0.05M; //该SPU的平台扣点金额 var freightPriceByUser = order.FreightPrice == 0 ? 0 : order.FreightPrice / skuCount * group.Count(); //该SPU分配的用户承担运费 var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == spuId).ToList(); var purchaseAmount = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.TotalCost) : 0; var deliveryFreight = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.DeliveryExpressFreight) : 0; - var profit = procutAmount + freightPriceByUser - purchaseAmount - deliveryFreight - commissionAmount; - var xxRespose = list.FirstOrDefault(xx => xx.Spu == spuId); + var profit = 0M; + if (order.StorageType != Enums.StorageType.SD) + profit = prodcutAmount + freightPriceByUser - purchaseAmount - deliveryFreight - commissionAmount; + else + { + var sdCommissionAmount = order.SDCommissionAmount.Value / skuCount * group.Count(); + profit = 0 - sdCommissionAmount - commissionAmount - deliveryFreight; + totalSDOrderCost += Math.Abs(profit); + } + var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId); if (xxRespose == null) { - xxRespose = new XingXinagSearchResponse() { Spu = spuId, Profit = 0M }; - list.Add(xxRespose); + xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M }; + detailList.Add(xxRespose); } xxRespose.Profit += profit; if (order.StorageType == Enums.StorageType.SD) { - var sdCommissionAmount = order.SDCommissionAmount.Value / skuCount * group.Count(); xxRespose.SDOrderCount++; - xxRespose.SDOrderAmount += procutAmount; - xxRespose.SDOrderCost += purchaseAmount + deliveryFreight + commissionAmount + sdCommissionAmount; + xxRespose.SDOrderAmount += prodcutAmount; + xxRespose.SDOrderCost += Math.Abs(profit); } } } - return list; + var sdOrderList = orderList.Where(o => o.StorageType == Enums.StorageType.SD); + + return new XingXinagSearchResponse() + { + ItemList = detailList, + TotalSDOrderAmount = sdOrderList.Count() > 0 ? sdOrderList.Sum(o => o.OrderSellerPrice) : 0M, + TotalSDOrderCount = sdOrderList.Count(), + TotalSDOrderCost = totalSDOrderCost + }; } } diff --git a/BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs b/BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs index 34cf9afb..a4359793 100644 --- a/BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs @@ -1,6 +1,31 @@ -namespace BBWY.Server.Model.Dto +using System.Collections.Generic; + +namespace BBWY.Server.Model.Dto { public class XingXinagSearchResponse + { + /// + /// 汇总刷单量 + /// + public decimal TotalSDOrderCount { get; set; } + + /// + /// 汇总刷单成本 + /// + public decimal TotalSDOrderCost { get; set; } + + /// + /// 汇总刷单成交额 + /// + public decimal TotalSDOrderAmount { get; set; } + + /// + /// Spu刷单明细 + /// + public IList ItemList { get; set; } + } + + public class XingXiangItemResponse { public string Spu { get; set; }