Commit 49cec62c authored by 吴春's avatar 吴春

提交销售统计

parent e433c54d
......@@ -61,6 +61,8 @@ namespace Mall.Model.Extend.Product
public int? GoodsId { get; set; }
public int PayMemerNum { get; set; }
public int TotalPayMemerNum { get; set; }
/// <summary>
/// 分销用户id
/// </summary>
......
......@@ -285,9 +285,14 @@ namespace Mall.Module.MarketingCenter
DataStatistics_Query model = new DataStatistics_Query();
if (List != null && List.Any())
{
model.OrderPay = List.Count();
model.OrderNum = List.Sum(x => x.OrderNum ?? 0); //List.Count();
model.PayMoney = List.Sum(x => x.Income ?? 0);
model.PayMemerNum = List.Sum(x => x.PayMemerNum ); //List.GroupBy(x => x.UserId).Count();
model.PayMemerNum = List.Sum(x => x.PayMemerNum); // List.GroupBy(x => x.UserId).Count();
model.GoodsNum = List.Sum(x => x.GoodsTotalNum);
model.MemberNum = List.Max(x => x.TotalPayMemerNum);
model.OrderPay = List.Count();
//model.PayMoney = List.Sum(x => x.Income ?? 0);
//model.PayMemerNum = List.Sum(x => x.PayMemerNum );
model.BuyNum = List.Sum(x => x.GoodsTotalNum);
model.OrderLineList = new List<OrderLine>();
if (dmodel.IsYesterday == 1)//同一天
......@@ -417,6 +422,7 @@ namespace Mall.Module.MarketingCenter
model.PayMoney = List.Sum(x => x.Income ?? 0);
model.PayMemerNum = List.Sum(x => x.PayMemerNum); // List.GroupBy(x => x.UserId).Count();
model.GoodsNum = List.Sum(x => x.GoodsTotalNum);
model.MemberNum = List.Max(x => x.TotalPayMemerNum);
}
return model;
}
......
......@@ -830,11 +830,12 @@ SELECT 0 as Total,0 as MemberNum, 0 as GoodsNum,0 as OrderNum,
payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_OrderAfterSale.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
}
sql = $@"SELECT t.CreateDate,SUM(t.GoodsTotalNum)as GoodsTotalNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as Income,MAX(t.PayMemerNum) as PayMemerNum,GROUP_CONCAT(DISTINCT t.UserId) as UserIds
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsTotalNum,a.UserId,a.Income,a.OrderId,c.PayMemerNum from rb_goods_order as a
sql = $@"SELECT t.CreateDate,SUM(t.GoodsTotalNum)as GoodsTotalNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as Income,
(SELECT COUNT(DISTINCT UserId) from rb_goods_order where 1=1 {payMemerNumWhere} ) as TotalPayMemerNum,
COUNT(DISTINCT t.UserId) as PayMemerNum,GROUP_CONCAT(DISTINCT t.UserId) as UserIds
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsTotalNum,a.UserId,a.Income,a.OrderId from rb_goods_order as a
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsTotalNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from rb_goods_order where 1=1 {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
{where} )
as t GROUP BY t.CreateDate desc";
// sql = $@"SELECT t.CreateDate,SUM(t.GoodsTotalNum)as GoodsTotalNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as Income,MAX(t.PayMemerNum) as PayMemerNum,GROUP_CONCAT(DISTINCT t.UserId) as UserIds
//from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsTotalNum,a.UserId,a.Income,a.OrderId,c.PayMemerNum from rb_goods_order as a
......@@ -842,7 +843,6 @@ as t GROUP BY t.CreateDate desc";
//LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from rb_goods_order where 1=1 {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
//as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
//as t GROUP BY t.CreateDate desc";
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
......@@ -980,14 +980,17 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
}
if (dmodel.OrderStatus == 0 || dmodel.OrderStatus == 1 || dmodel.OrderStatus == 2 || dmodel.OrderStatus == 3)
{
sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum,GROUP_CONCAT(DISTINCT t.UserId) as UserIds
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId,c.PayMemerNum from rb_goods_order as a
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from rb_goods_order where 1=1 {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
// sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum,GROUP_CONCAT(DISTINCT t.UserId) as UserIds
//from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId,c.PayMemerNum from rb_goods_order as a
// LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId
//LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from rb_goods_order where 1=1 {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
//as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
//as t GROUP BY t.CreateDate desc";
sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsNum ,COUNT(t.OrderId)as OrderNum ,SUM(t.Income)as PayMoney,COUNT(DISTINCT t.UserId) as PayMemerNum,GROUP_CONCAT(DISTINCT t.UserId) as UserIds
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId from rb_goods_order as a
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId {where} )
as t GROUP BY t.CreateDate desc";
}
else
{
......
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