Commit 6d1f50b5 authored by 吴春's avatar 吴春

Merge branch 'master' of http://gitlab.oytour.com/Kui2/mall.oytour.com into sdzq

parents f861459f d8241e0c
......@@ -187,4 +187,38 @@ namespace Mall.Model.Extend.Statistics
/// </summary>
public DateTime TimeStr { get; set; }
}
/// <summary>
/// 分销每日用户统计
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class MallDistributorDay
{
/// <summary>
/// 时间
/// </summary>
public DateTime TimeStr { get; set; }
/// <summary>
/// 普通会员
/// </summary>
public decimal Pink { get; set; }
/// <summary>
/// VIP
/// </summary>
public decimal VIP { get; set; }
/// <summary>
/// 分享家
/// </summary>
public decimal Silver { get; set; }
/// <summary>
/// 金象【优享家】
/// </summary>
public decimal Gold { get; set; }
}
}
......@@ -423,29 +423,36 @@ GROUP By B.FXGradeId,C.GradeName ", where, DateTime.Now.ToString("yyyy-MM-dd"));
}
StringBuilder build = new StringBuilder();
build.AppendFormat(@"
SELECT TabA.TimeStr
,MAX(CASE TabA.FXGradeId WHEN 1 THEN TabA.UserCount ELSE 0 END ) AS 'Pink'
,MAX(CASE TabA.FXGradeId WHEN 2 THEN TabA.UserCount ELSE 0 END ) AS 'VIP'
,MAX(CASE TabA.FXGradeId WHEN 3 THEN TabA.UserCount ELSE 0 END ) AS 'Silver'
,MAX(CASE TabA.FXGradeId WHEN 4 THEN TabA.UserCount ELSE 0 END ) AS 'Gold'
FROM
(
SELECT B.FXGradeId,C.GradeName,COUNT(1) AS UserCount,DATE_FORMAT(A.CreateDate,'%Y-%m-%d') AS TimeStr
FROM rb_member_user AS A LEFT JOIN rb_distributor_info AS B ON A.Id=B.UserId
LEFT JOIN rb_distributor_fxgrade AS C ON B.FXGradeId=C.Grade
WHERE A.Id>19 AND B.`Status`=0 {0}
GROUP By B.FXGradeId,C.GradeName,DATE_FORMAT(A.CreateDate,'%Y%m%d')
ORDER BY DATE_FORMAT(A.CreateDate,'%Y%m%d') DESC
", where);
) AS TabA
GROUP BY TabA.TimeStr
ORDER BY TabA.TimeStr DESC", where);
List<object> resultList = new List<object>();
var list = GetPage<MallDistributorTotal>(pageIndex,pageSize,out rowsCount,build.ToString()).ToList();
var list = GetPage<MallDistributorDay>(pageIndex,pageSize,out rowsCount,build.ToString()).ToList();
if (list != null && list.Count > 0)
{
var dayList = list.GroupBy(qitem => new { qitem.TimeStr }).Select(qitem => new { qitem.Key.TimeStr });
foreach (var dayItem in dayList)
foreach (var item in list)
{
resultList.Add(new
{
TimeStr = Convert.ToDateTime(dayItem.TimeStr).ToString("yyyy-MM-dd"),
Pink = list.Where(qitem => qitem.TimeStr == dayItem.TimeStr && qitem.FXGradeId == 1)?.FirstOrDefault()?.UserCount ?? 0,
VIP = list.Where(qitem => qitem.TimeStr == dayItem.TimeStr && qitem.FXGradeId == 2)?.FirstOrDefault()?.UserCount ?? 0,
Silver = list.Where(qitem => qitem.TimeStr == dayItem.TimeStr && qitem.FXGradeId == 3)?.FirstOrDefault()?.UserCount ?? 0,
Gold = list.Where(qitem => qitem.TimeStr == dayItem.TimeStr && qitem.FXGradeId == 4)?.FirstOrDefault()?.UserCount ?? 0,
TimeStr=Convert.ToDateTime(item.TimeStr).ToString("yyyy-MM-dd"),
item.Pink,
item.VIP,
item.Silver,
item.Gold
});
};
}
}
return resultList;
}
......
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