From 950ba65e71d4e5e27dfda0818b09c5d78b343b58 Mon Sep 17 00:00:00 2001 From: sanji Date: Fri, 10 Nov 2023 17:33:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=99=BE=E5=88=86=E6=AF=94?= =?UTF-8?q?=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SiNan.Business/GOIBusiness.cs | 14 +++++++++++++ .../Response/JDXX/JDXXHistogramResponse.cs | 21 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/SiNan.Business/GOIBusiness.cs b/SiNan.Business/GOIBusiness.cs index 59b16ad..ae7e853 100644 --- a/SiNan.Business/GOIBusiness.cs +++ b/SiNan.Business/GOIBusiness.cs @@ -506,6 +506,20 @@ namespace SiNan.Business Profit = g.Sum(g.Value.Profits), TotalCost = g.Sum(g.Value.TotalCost) }); + + var totalUV = datas.Sum(x => x.UV); + var totalSales = datas.Sum(x => x.Sales); + var totalProfit = datas.Sum(x => x.Profit); + var totalCost = datas.Sum(x => x.TotalCost); + + foreach (var data in datas) + { + data.UVPercent = totalUV == 0 ? 0 : Math.Round((data.UV / totalUV) ?? 0, 2); + data.SalesPercent = totalSales == 0 ? 0 : Math.Round((data.Sales / totalSales) ?? 0, 2); + data.ProfitPercent = totalProfit == 0 ? 0 : Math.Round((data.Profit / totalProfit) ?? 0, 2); + data.TotalCostPercent = totalCost == 0 ? 0 : Math.Round((data.TotalCost / totalCost) ?? 0, 2); + } + return datas; } diff --git a/SiNan.Model/Dto/Response/JDXX/JDXXHistogramResponse.cs b/SiNan.Model/Dto/Response/JDXX/JDXXHistogramResponse.cs index ee266d5..d8ea9bd 100644 --- a/SiNan.Model/Dto/Response/JDXX/JDXXHistogramResponse.cs +++ b/SiNan.Model/Dto/Response/JDXX/JDXXHistogramResponse.cs @@ -7,20 +7,41 @@ /// public decimal? UV { get; set; } + /// + /// UV百分比 + /// + public decimal? UVPercent { get; set; } + /// /// 销量 /// public decimal? Sales { get; set; } + /// + /// 销量百分比 + /// + public decimal? SalesPercent { get; set; } + /// /// 花费 /// public decimal? TotalCost { get; set; } + /// + /// 花费百分比 + /// + public decimal? TotalCostPercent { get; set; } + /// /// 利润 /// public decimal? Profit { get; set; } + + /// + /// 利润百分比 + /// + public decimal? ProfitPercent { get; set; } + public string Sku { get; set; } } }