Commit 27e6dbe3 authored by 黄奎's avatar 黄奎

统计修改

parent 482452b2
...@@ -92,6 +92,11 @@ namespace Mall.Model.Extend.Statistics ...@@ -92,6 +92,11 @@ namespace Mall.Model.Extend.Statistics
/// 购买商品件数 /// 购买商品件数
/// </summary> /// </summary>
public int GoodCount { get; set; } public int GoodCount { get; set; }
/// <summary>
/// 用户编号
/// </summary>
public int UserId { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -2012,14 +2012,14 @@ namespace Mall.Module.User ...@@ -2012,14 +2012,14 @@ namespace Mall.Module.User
{ {
for (var i = 0; i <= 23; i++) for (var i = 0; i <= 23; i++)
{ {
var subModel = list?.Where(qitem => qitem.TimeStr == i.ToString())?.FirstOrDefault(); var tempSubList = list?.Where(qitem => qitem.TimeStr == i.ToString())?.ToList();
subList.Add(new MallSalesStatistics() subList.Add(new MallSalesStatistics()
{ {
TimeStr = i.ToString(), TimeStr = i.ToString(),
GoodCount = subModel?.GoodCount ?? 0, GoodCount = tempSubList?.Sum(qitem=>qitem.GoodCount) ?? 0,
Income = subModel?.Income ?? 0, Income = tempSubList?.Sum(qitem => qitem.Income) ?? 0,
OrderCount = subModel?.OrderCount ?? 0, OrderCount = tempSubList?.Sum(qitem => qitem.OrderCount) ?? 0,
UserCount = subModel?.UserCount ?? 0, UserCount = tempSubList?.GroupBy(qitem => new { qitem.UserId }).Count() ?? 0,
}); });
} }
} }
...@@ -2028,14 +2028,14 @@ namespace Mall.Module.User ...@@ -2028,14 +2028,14 @@ namespace Mall.Module.User
var startDate = DateTime.Now.AddDays(-7); var startDate = DateTime.Now.AddDays(-7);
for (var i = 0; i <= 7; i++) for (var i = 0; i <= 7; i++)
{ {
var subModel = list?.Where(qitem => qitem.TimeStr == startDate.AddDays(i).ToString("yyyy-MM-dd"))?.FirstOrDefault(); var tempSubList = list?.Where(qitem => qitem.TimeStr == startDate.AddDays(i).ToString("yyyy-MM-dd"))?.ToList();
subList.Add(new MallSalesStatistics() subList.Add(new MallSalesStatistics()
{ {
TimeStr = startDate.AddDays(i).ToString("yyyy-MM-dd"), TimeStr = startDate.AddDays(i).ToString("yyyy-MM-dd"),
GoodCount = subModel?.GoodCount ?? 0, GoodCount = tempSubList?.Sum(qitem => qitem.GoodCount) ?? 0,
Income = subModel?.Income ?? 0, Income = tempSubList?.Sum(qitem => qitem.Income) ?? 0,
OrderCount = subModel?.OrderCount ?? 0, OrderCount = tempSubList?.Sum(qitem => qitem.OrderCount) ?? 0,
UserCount = subModel?.UserCount ?? 0, UserCount = tempSubList?.GroupBy(qitem=>new { qitem.UserId}).Count() ?? 0,
}); });
} }
} }
...@@ -2047,7 +2047,7 @@ namespace Mall.Module.User ...@@ -2047,7 +2047,7 @@ namespace Mall.Module.User
Income = list?.Sum(qitem => qitem.Income) ?? 0, Income = list?.Sum(qitem => qitem.Income) ?? 0,
//支付人数 //支付人数
UserCount = list?.Sum(qitem => qitem.UserCount) ?? 0, UserCount = list?.GroupBy(qitem=>new { qitem.UserId}).Count() ?? 0,
//支付件数 //支付件数
GoodCount = list?.Sum(qitem => qitem.GoodCount) ?? 0, GoodCount = list?.Sum(qitem => qitem.GoodCount) ?? 0,
subList, subList,
......
...@@ -173,17 +173,17 @@ WHERE 1=1 AND A.ReOrderStatus IN(2,3,4) "); ...@@ -173,17 +173,17 @@ WHERE 1=1 AND A.ReOrderStatus IN(2,3,4) ");
if (query.SalesTimeType == 1 || query.SalesTimeType == 0) if (query.SalesTimeType == 1 || query.SalesTimeType == 0)
{ {
selectFileds = " SUBSTR(DATE_FORMAT(CreateDate,'%Y%m%d%H'),9,2) AS TimeStr, "; selectFileds = " SUBSTR(DATE_FORMAT(CreateDate,'%Y%m%d%H'),9,2) AS TimeStr, ";
groupFileds = " GROUP BY DATE_FORMAT(CreateDate,'%Y%m%d%H') "; groupFileds = " GROUP BY DATE_FORMAT(CreateDate,'%Y%m%d%H'),A.UserId ";
} }
else else
{ {
selectFileds = " DATE_FORMAT(CreateDate,'%Y-%m-%d') AS TimeStr, "; selectFileds = " DATE_FORMAT(CreateDate,'%Y-%m-%d') AS TimeStr, ";
groupFileds = " GROUP BY DATE_FORMAT(CreateDate,'%Y%m%d') "; groupFileds = " GROUP BY DATE_FORMAT(CreateDate,'%Y%m%d'),A.UserId ";
} }
builder.AppendFormat(@" builder.AppendFormat(@"
SELECT {0} COUNT(1) AS OrderCount,SUM(A.Income) AS Income,COUNT(DISTINCT A.UserId) AS UserCount,SUM(B.GoodCount) AS GoodCount SELECT {0} COUNT(1) AS OrderCount,SUM(A.Income) AS Income,A.UserId,SUM(B.GoodCount) AS GoodCount
FROM rb_goods_order A LEFT JOIN (SELECT OrderId,COUNT(1) AS GoodCount FROM rb_goods_orderdetail GROUP BY OrderId) AS B ON A.OrderId=B.OrderId FROM rb_goods_order A LEFT JOIN (SELECT OrderId,SUM(Number) AS GoodCount FROM rb_goods_orderdetail GROUP BY OrderId) AS B ON A.OrderId=B.OrderId
WHERE 1=1 AND OrderStatus>=2 AND OrderStatus<=5 WHERE 1=1 AND OrderStatus>=2 AND OrderStatus<=5
", selectFileds); ", selectFileds);
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Goods_Order_Extend.TenantId), query.TenantId); builder.AppendFormat(" AND {0}={1} ", nameof(RB_Goods_Order_Extend.TenantId), query.TenantId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment