Commit 0b3a431c authored by 吴春's avatar 吴春

提交代码

parent d70ddbd1
......@@ -59,6 +59,8 @@ namespace Mall.Model.Extend.Product
/// 商品id
/// </summary>
public int? GoodsId { get; set; }
public int PayMemerNum { get; set; }
/// <summary>
/// 分销用户id
/// </summary>
......
......@@ -287,7 +287,7 @@ namespace Mall.Module.MarketingCenter
{
model.OrderPay = List.Count();
model.PayMoney = List.Sum(x => x.Income ?? 0);
model.PayMemerNum = List.GroupBy(x => x.UserId).Count();
model.PayMemerNum = List.Sum(x => x.PayMemerNum ); //List.GroupBy(x => x.UserId).Count();
model.BuyNum = List.Sum(x => x.GoodsTotalNum);
model.OrderLineList = new List<OrderLine>();
if (dmodel.IsYesterday == 1)//同一天
......
......@@ -795,18 +795,23 @@ SELECT 0 as Total,0 as MemberNum, 0 as GoodsNum,0 as OrderNum,
public List<RB_Goods_Order_Extend> GetWeeklyOrder(DataStatistics_Query dmodel)
{
string where = $" where 1=1 and a.OrderStatus in(2,3,4,6,5)";
string payMemerNumWhere = "";
string orderTypeWhere = "";
string sql = "";
if (dmodel.TenantId > 0)
{
where += $@" and a.{nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}";
payMemerNumWhere += $@" and {nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and a.{nameof(RB_Goods_Order.MallBaseId)}={dmodel.MallBaseId}";
payMemerNumWhere += $@" and {nameof(RB_Goods_Order.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.PlatformType > 0)
{
where += $@" and a.{nameof(RB_Goods_Order.OrderSource)}={(int)dmodel.PlatformType}";
payMemerNumWhere += $@" and {nameof(RB_Goods_Order.OrderSource)}={(int)dmodel.PlatformType}";
}
if (dmodel.OrderType > 0)
{
......@@ -815,13 +820,19 @@ SELECT 0 as Total,0 as MemberNum, 0 as GoodsNum,0 as OrderNum,
if (!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
where += $" AND DATE_FORMAT(a.{nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_OrderAfterSale.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
}
if (!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
where += $" AND DATE_FORMAT(a.{nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_OrderAfterSale.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
}
string sql = $@" select a.*,b.GoodsTotalNum from rb_goods_order as a LEFT JOIN (SELECT OrderId,COUNT(*) as GoodsTotalNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b
on a.OrderId=b.OrderId {where}";
sql = $@"SELECT t.CreateDate,SUM(t.GoodsNum)as GoodsTotalNum ,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.GoodsTotalNum,a.UserId,a.Income,a.OrderId,c.PayMemerNum 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} )
as t GROUP BY t.CreateDate desc ";
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
......
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