From a8e1556f8aad7661bfef8619d167493a3f9cd970 Mon Sep 17 00:00:00 2001
From: shanji <18996038927@163.com>
Date: Tue, 9 Aug 2022 16:12:28 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E7=BB=9F=E8=AE=A1=E6=8C=89?=
=?UTF-8?q?=E5=BA=97=E5=88=86=E7=BB=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/StatisticsController.cs | 13 +++++-
.../Statistics/StatisticsBusiness.cs | 46 ++++++++++++++++++-
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/BBWY.Server.API/Controllers/StatisticsController.cs b/BBWY.Server.API/Controllers/StatisticsController.cs
index 626512ea..1d999daa 100644
--- a/BBWY.Server.API/Controllers/StatisticsController.cs
+++ b/BBWY.Server.API/Controllers/StatisticsController.cs
@@ -17,7 +17,7 @@ namespace BBWY.Server.API.Controllers
}
///
- /// 今日业绩统计
+ /// 业绩统计
///
///
///
@@ -27,6 +27,17 @@ namespace BBWY.Server.API.Controllers
return statisticsBusiness.GetOrderAchievementStatistics(request);
}
+ ///
+ /// 业绩统计(按店分组)
+ ///
+ ///
+ ///
+ [HttpPost]
+ public IList GetOrderAchievementStatisticsList([FromBody] AllShopOrderAchievementRequest request)
+ {
+ return statisticsBusiness.GetOrderAchievementStatisticsList(request);
+ }
+
///
/// 星象SPU查询统计
///
diff --git a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs
index 6bb5f014..a1f6eac0 100644
--- a/BBWY.Server.Business/Statistics/StatisticsBusiness.cs
+++ b/BBWY.Server.Business/Statistics/StatisticsBusiness.cs
@@ -55,9 +55,51 @@ namespace BBWY.Server.Business
return response;
}
- public IList GetOrderAchievementStatistics(AllShopOrderAchievementRequest request)
+ public IList GetOrderAchievementStatisticsList(AllShopOrderAchievementRequest request)
{
- return null;
+ request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
+ var responseList = fsql.Select().LeftJoin((o, oc) => o.Id == oc.OrderId)
+ .Where((o, oc) => o.OrderState != null &&
+ !invalidOrderStateList.Contains(o.OrderState.Value) && //排除待付款和取消
+ o.StartTime >= request.StartTime &&
+ o.StartTime <= request.EndTime)
+ .GroupBy((o, oc) => o.ShopId)
+ .ToList((g) => new OrderAchievementResponse()
+ {
+ ShopId = g.Key,
+ OrderCount = g.Count(g.Value.Item1.Id),
+ Profit = g.Sum(g.Value.Item2.Profit),
+ SaleAmount = g.Sum(g.Value.Item1.OrderPayment),
+ DeliveryExpressFreight = g.Sum(g.Value.Item2.DeliveryExpressFreight),
+ PlatformCommissionAmount = g.Sum(g.Value.Item2.PlatformCommissionAmount),
+ PurchaseAmount = g.Sum(g.Value.Item2.PurchaseAmount)
+ });
+ var mdsShops = freeSqlMultiDBManager.MDSfsql.Select().Where(s => !string.IsNullOrEmpty(s.ShopId)).ToList();
+ var mdsShopIds = mdsShops.Select(s => s.Id);
+ var advCosts = freeSqlMultiDBManager.JDXXfsql.Select().Where(s => mdsShopIds.Contains(s.ShopsId) &&
+ s.CreateTime >= request.StartTime &&
+ s.CreateTime <= request.EndTime)
+ .GroupBy(s => s.ShopsId)
+ .ToList(g => new
+ {
+ ShopId = g.Key,
+ AdvCost = g.Sum(g.Value.ExpressCost + g.Value.ShotgunCost)
+ });
+ foreach (var response in responseList)
+ {
+ string shopId = response.ShopId.ToString();
+ var mdsShop = mdsShops.FirstOrDefault(s => s.ShopId == shopId);
+ if (mdsShop == null)
+ continue;
+
+ var advCostResponse = advCosts.FirstOrDefault(a => a.ShopId == mdsShop.Id);
+ if (advCostResponse == null)
+ continue;
+
+ response.AdvCost = advCostResponse.AdvCost;
+ response.Profit -= advCostResponse.AdvCost;
+ }
+ return responseList;
}
private void XingXiangCumulative(IList detailList, string spuId, bool isSD, decimal profit, decimal sdProductAmount, decimal sdCost)