Browse Source

增加百分比指标

GOIAggregation
sanji 2 years ago
parent
commit
950ba65e71
  1. 14
      SiNan.Business/GOIBusiness.cs
  2. 21
      SiNan.Model/Dto/Response/JDXX/JDXXHistogramResponse.cs

14
SiNan.Business/GOIBusiness.cs

@ -506,6 +506,20 @@ namespace SiNan.Business
Profit = g.Sum(g.Value.Profits), Profit = g.Sum(g.Value.Profits),
TotalCost = g.Sum(g.Value.TotalCost) 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; return datas;
} }

21
SiNan.Model/Dto/Response/JDXX/JDXXHistogramResponse.cs

@ -7,20 +7,41 @@
/// </summary> /// </summary>
public decimal? UV { get; set; } public decimal? UV { get; set; }
/// <summary>
/// UV百分比
/// </summary>
public decimal? UVPercent { get; set; }
/// <summary> /// <summary>
/// 销量 /// 销量
/// </summary> /// </summary>
public decimal? Sales { get; set; } public decimal? Sales { get; set; }
/// <summary>
/// 销量百分比
/// </summary>
public decimal? SalesPercent { get; set; }
/// <summary> /// <summary>
/// 花费 /// 花费
/// </summary> /// </summary>
public decimal? TotalCost { get; set; } public decimal? TotalCost { get; set; }
/// <summary>
/// 花费百分比
/// </summary>
public decimal? TotalCostPercent { get; set; }
/// <summary> /// <summary>
/// 利润 /// 利润
/// </summary> /// </summary>
public decimal? Profit { get; set; } public decimal? Profit { get; set; }
/// <summary>
/// 利润百分比
/// </summary>
public decimal? ProfitPercent { get; set; }
public string Sku { get; set; } public string Sku { get; set; }
} }
} }

Loading…
Cancel
Save