Commit 5eeec128 authored by 黄奎's avatar 黄奎

新增统计

parent 343743aa
......@@ -39,5 +39,10 @@ namespace Edu.Model.ViewModel.Customer
/// 有效数据量 (第一次跟进且不等于流失)
/// </summary>
public int FollowCount { get; set; }
/// <summary>
/// 单资源回访平均数~~~就是一条资源跟进了几次 【平均】
/// </summary>
public decimal AgFollow { get; set; }
}
}
......@@ -76,6 +76,11 @@ namespace Edu.Model.ViewModel.Customer
/// </summary>
public int VisitCount { get; set; }
/// <summary>
/// 订单数量
/// </summary>
public int OrderCount { get; set; }
/// <summary>
/// 创建人【查询使用】
/// </summary>
......
......@@ -309,5 +309,10 @@ namespace Edu.Model.ViewModel.Sell
/// 业务员
/// </summary>
public string QEnterIds { get; set; }
/// <summary>
/// 订单条数
/// </summary>
public int OrderCount { get; set; }
}
}
\ No newline at end of file
......@@ -170,7 +170,216 @@ SELECT A.CreateBy,COUNT(1) AS FollowCount
FROM rb_student_follow AS A INNER JOIN(SELECT StuId,CreateBy,MIN(Id) AS Id FROM rb_student_follow WHERE `Status`=0 GROUP BY StuId,CreateBy) AS B ON A.Id=B.Id
INNER JOIN RB_student AS C ON A.StuId=C.StuId
WHERE A.Status=0 AND C.Status=0 AND C.StuStage<>7 {0}
GROUP BY A.CreateBy
";
if (query.CreateBy > 0)
{
sql += string.Format(" AND A.CreateBy={0} ", query.CreateBy);
}
sql += " GROUP BY A.CreateBy ";
string todayWhere = "";
if (!string.IsNullOrEmpty(query.STime))
{
todayWhere += string.Format(" AND to_days(A.CreateTime)=to_days('{0}') ", query.STime);
}
else
{
todayWhere += string.Format(" AND to_days(A.CreateTime)=to_days(now()) ");
}
//今日
var todayList = Get<RB_Student_Follow_Extend>(string.Format(sql.ToString(), todayWhere)).ToList();
dicList.Add("today", todayList);
//昨日
string yesWhere = "";
if (!string.IsNullOrEmpty(query.STime))
{
yesWhere += string.Format(" AND TO_DAYS('{0}')-TO_DAYS(A.CreateTime)=1 ", query.STime);
}
else
{
yesWhere += string.Format(" AND TO_DAYS(now())-TO_DAYS(A.CreateTime)=1 ");
}
var yesList = Get<RB_Student_Follow_Extend>(string.Format(sql, yesWhere)).ToList();
dicList.Add("yestoday", yesList);
//本周
string curWeek = "";
if (!string.IsNullOrEmpty(query.STime))
{
curWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d' )) = YEARWEEK('{0}') ", query.STime);
}
else
{
curWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d')) = YEARWEEK(now()) ");
}
var curWeekList = Get<RB_Student_Follow_Extend>(string.Format(sql, curWeek)).ToList();
dicList.Add("currentWeek", curWeekList);
//上周
string lastWeek = "";
if (!string.IsNullOrEmpty(query.STime))
{
lastWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d')) = YEARWEEK('{0}')-1 ", query.STime);
}
else
{
lastWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d')) = YEARWEEK(now())-1 ");
}
var lastWeekList = Get<RB_Student_Follow_Extend>(string.Format(sql, lastWeek)).ToList();
dicList.Add("lastWeek", lastWeekList);
//本月
string curMonth = "";
if (!string.IsNullOrEmpty(query.STime))
{
curMonth += string.Format(" AND DATE_FORMAT(A.CreateTime,'%Y%m')=DATE_FORMAT('{0}','%Y%m') ", query.STime);
}
else
{
curMonth += string.Format(" AND DATE_FORMAT(A.CreateTime,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') ");
}
var curMonthList = Get<RB_Student_Follow_Extend>(string.Format(sql, curMonth)).ToList();
dicList.Add("curMonth", curMonthList);
//上月
string lastMonth = "";
if (!string.IsNullOrEmpty(query.STime))
{
lastMonth += string.Format(" AND PERIOD_DIFF(date_format('{0}','%Y%m'),date_format(A.CreateTime,'%Y%m')) =1 ", query.STime);
}
else
{
lastMonth += string.Format(" AND PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(A.CreateTime,'%Y%m')) =1 ");
}
var lastMonthList = Get<RB_Student_Follow_Extend>(string.Format(sql, lastMonth)).ToList();
dicList.Add("lastMonth", lastMonthList);
return dicList;
}
/// <summary>
/// 课程顾问部有效回访总量
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public Dictionary<string, List<RB_Student_Follow_Extend>> GetConsultantFollowStaticRepository(RB_Student_Follow_Extend query)
{
Dictionary<string, List<RB_Student_Follow_Extend>> dicList = new Dictionary<string, List<RB_Student_Follow_Extend>>();
string sql = @"
SELECT A.CreateBy,COUNT(1) AS FollowCount
FROM rb_student_follow AS A
WHERE A.Status=0 {0}
";
if (query.CreateBy > 0)
{
sql += string.Format(" AND A.CreateBy={0} ", query.CreateBy);
}
sql += " GROUP BY A.CreateBy ";
string todayWhere = "";
if (!string.IsNullOrEmpty(query.STime))
{
todayWhere += string.Format(" AND to_days(A.CreateTime)=to_days('{0}') ", query.STime);
}
else
{
todayWhere += string.Format(" AND to_days(A.CreateTime)=to_days(now()) ");
}
//今日
var todayList = Get<RB_Student_Follow_Extend>(string.Format(sql.ToString(), todayWhere)).ToList();
dicList.Add("today", todayList);
//昨日
string yesWhere = "";
if (!string.IsNullOrEmpty(query.STime))
{
yesWhere += string.Format(" AND TO_DAYS('{0}')-TO_DAYS(A.CreateTime)=1 ", query.STime);
}
else
{
yesWhere += string.Format(" AND TO_DAYS(now())-TO_DAYS(A.CreateTime)=1 ");
}
var yesList = Get<RB_Student_Follow_Extend>(string.Format(sql, yesWhere)).ToList();
dicList.Add("yestoday", yesList);
//本周
string curWeek = "";
if (!string.IsNullOrEmpty(query.STime))
{
curWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d' )) = YEARWEEK('{0}') ", query.STime);
}
else
{
curWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d')) = YEARWEEK(now()) ");
}
var curWeekList = Get<RB_Student_Follow_Extend>(string.Format(sql, curWeek)).ToList();
dicList.Add("currentWeek", curWeekList);
//上周
string lastWeek = "";
if (!string.IsNullOrEmpty(query.STime))
{
lastWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d')) = YEARWEEK('{0}')-1 ", query.STime);
}
else
{
lastWeek += string.Format(" AND YEARWEEK(date_format(A.CreateTime,'%Y-%m-%d')) = YEARWEEK(now())-1 ");
}
var lastWeekList = Get<RB_Student_Follow_Extend>(string.Format(sql, lastWeek)).ToList();
dicList.Add("lastWeek", lastWeekList);
//本月
string curMonth = "";
if (!string.IsNullOrEmpty(query.STime))
{
curMonth += string.Format(" AND DATE_FORMAT(A.CreateTime,'%Y%m')=DATE_FORMAT('{0}','%Y%m') ", query.STime);
}
else
{
curMonth += string.Format(" AND DATE_FORMAT(A.CreateTime,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') ");
}
var curMonthList = Get<RB_Student_Follow_Extend>(string.Format(sql, curMonth)).ToList();
dicList.Add("curMonth", curMonthList);
//上月
string lastMonth = "";
if (!string.IsNullOrEmpty(query.STime))
{
lastMonth += string.Format(" AND PERIOD_DIFF(date_format('{0}','%Y%m'),date_format(A.CreateTime,'%Y%m')) =1 ", query.STime);
}
else
{
lastMonth += string.Format(" AND PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(A.CreateTime,'%Y%m')) =1 ");
}
var lastMonthList = Get<RB_Student_Follow_Extend>(string.Format(sql, lastMonth)).ToList();
dicList.Add("lastMonth", lastMonthList);
return dicList;
}
/// <summary>
/// 单资源回访平均数~~~就是一条资源跟进了几次 【平均】
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public Dictionary<string, List<RB_Student_Follow_Extend>> GetConsultantAvgFollowStaticRepository(RB_Student_Follow_Extend query)
{
Dictionary<string, List<RB_Student_Follow_Extend>> dicList = new Dictionary<string, List<RB_Student_Follow_Extend>>();
string whereStr = "";
if (query.CreateBy > 0)
{
whereStr += string.Format(" AND CreateBy={0} ", query.CreateBy);
}
string sql = @"
SELECT Avg(FollowCount) AS AgFollow FROM
(
SELECT A.StuId,COUNT(1) AS FollowCount
FROM rb_student_follow AS A
WHERE A.Status=0 " + whereStr + @" {0}
GROUP BY A.StuId
) AS A
";
string todayWhere = "";
......
......@@ -143,11 +143,21 @@ WHERE 1=1
{
Dictionary<string, List<RB_Student_Visit_Extend>> dicList = new Dictionary<string, List<RB_Student_Visit_Extend>>();
string sql = @"
SELECT A.CreateBy,Count(1) AS VisitCount
SELECT A.CreateBy,Count(1) AS VisitCount,IFNULL(C.OrderCount,0) AS OrderCount
FROM RB_Student_Visit AS A INNER JOIN rb_student AS B ON A.StuId=B.StuId
LEFT JOIN (
SELECT sog.Student_Id,COUNT(1) AS OrderCount
FROM rb_student_orderguest AS sog INNER JOIN rb_order AS o ON sog.OrderId=o.OrderId
WHERE o.OrderState IN(1,2)
GROUP BY sog.Student_Id
) AS C ON A.StuId=C.Student_Id
WHERE 1=1 AND B.Status=0 {0}
GROUP BY A.CreateBy
";
if (query.CreateBy > 0)
{
sql += string.Format(" AND A.CreateBy={0} ", query.CreateBy);
}
sql += " GROUP BY A.CreateBy ";
string todayWhere = "";
if (!string.IsNullOrEmpty(query.StartDate))
{
......
......@@ -65,26 +65,46 @@ WHERE 1=1
var newModel = new RB_Consultant_Data_Extend()
{
Date = model.Date,
//ClueCount = model.ClueCount,
//YestodayClue = model.YestodayClue,
//LastWeekClue = model.LastWeekClue,
//LastMonthClue = model.LastMonthClue,
VisitCount = model.VisitCount,
YestodayVisit = model.YestodayVisit,
LastWeekVisit = model.LastWeekVisit,
LastMonthVisit = model.LastMonthVisit,
TrialLessonCount = model.TrialLessonCount,
YestodayTrialLesson = model.YestodayTrialLesson,
CurWeekTrialLesson = model.CurWeekTrialLesson,
LastWeekTrialLesson = model.LastWeekTrialLesson,
CurMonthTrialLesson = model.CurMonthTrialLesson,
LastMonthTrialLesson = model.LastMonthTrialLesson,
VisitCount = model.VisitCount,
YestodayVisit = model.YestodayVisit,
CurWeekVisit = model.CurWeekVisit,
LastWeekVisit = model.LastWeekVisit,
CurMonthVisit = model.CurMonthVisit,
LastMonthVisit = model.LastMonthVisit,
Rates = model.Rates,
YestodayRates = model.YestodayRates,
CurWeekRates = model.CurWeekRates,
LastWeekRates = model.LastWeekRates,
CurMonthRates = model.CurMonthRates,
LastMonthRates = model.LastMonthRates,
FollowCount = model.FollowCount,
YestodayFollow = model.YestodayFollow,
CurWeekFollow = model.CurWeekFollow,
LastWeekFollow = model.LastWeekFollow,
CurMonthFollow = model.CurMonthFollow,
LastMonthFollow = model.LastMonthFollow,
//SaleMoney = model.SaleMoney,
//YestodaySale = model.YestodaySale,
//LastWeekSale = model.LastWeekSale,
//LastMonthSale = model.LastMonthSale,
AgFollow = model.AgFollow,
YestodayAgFollow = model.YestodayAgFollow,
CurWeekAgFollow = model.CurWeekAgFollow,
LastWeekAgFollow=model.LastWeekAgFollow,
CurMonthAgFollow=model.CurMonthAgFollow,
LastMonthAgFollow=model.LastMonthAgFollow,
CurWeekOrderNum=model.CurWeekOrderNum,
LastWeekOrderNum=model.LastWeekOrderNum,
CurWeekOrderSale=model.CurWeekOrderSale,
LastWeekOrderSale=model.LastWeekOrderSale,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
DeptId = model.DeptId,
......
......@@ -65,26 +65,42 @@ WHERE 1=1
var newModel = new RB_Market_Data_Extend()
{
Date = model.Date,
ClueCount = model.ClueCount,
YestodayClue = model.YestodayClue,
CurWeekClue=model.CurWeekClue,
LastWeekClue = model.LastWeekClue,
CurMonthClue=model.CurMonthClue,
LastMonthClue = model.LastMonthClue,
VisitCount = model.VisitCount,
YestodayVisit = model.YestodayVisit,
CurWeekVisit=model.CurWeekVisit,
LastWeekVisit = model.LastWeekVisit,
CurMonthVisit=model.CurMonthVisit,
LastMonthVisit = model.LastMonthVisit,
TrialLessonCount = model.TrialLessonCount,
YestodayTrialLesson = model.YestodayTrialLesson,
CurWeekTrialLesson=model.CurWeekTrialLesson,
LastWeekTrialLesson = model.LastWeekTrialLesson,
CurMonthTrialLesson=model.CurMonthTrialLesson,
LastMonthTrialLesson = model.LastMonthTrialLesson,
FollowCount = model.FollowCount,
YestodayFollow = model.YestodayFollow,
CurWeekFollow=model.CurWeekFollow,
LastWeekFollow = model.LastWeekFollow,
CurMonthFollow=model.CurMonthFollow,
LastMonthFollow = model.LastMonthFollow,
SaleMoney = model.SaleMoney,
YestodaySale = model.YestodaySale,
CurWeekSale=model.CurWeekSale,
LastWeekSale = model.LastWeekSale,
CurMonrhSale=model.CurMonrhSale,
LastMonthSale = model.LastMonthSale,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
DeptId = model.DeptId,
......
......@@ -318,8 +318,12 @@ WHERE 1=1
SELECT A.CreateBy,COUNT(1) AS TrialLessonCount
FROM RB_Visitor_Reserve AS A
WHERE 1=1 AND A.Status=0 {0}
GROUP BY A.CreateBy
";
if (query.CreateBy > 0)
{
sql += string.Format(@" AND A.CreateBy={0} ", query.CreateBy);
}
sql += " GROUP BY A.CreateBy ";
string todayWhere = "";
if (!string.IsNullOrEmpty(query.StartClassDate))
{
......
......@@ -1218,16 +1218,39 @@ WHERE 1=1
/// 市场部和课程顾问部销售额统计
/// </summary>
/// <param name="query"></param>
/// <param name="qType">1-市场部,2-课程顾问部</param>
/// <returns></returns>
public Dictionary<string, List<RB_Order_ViewModel>> GetMarketMarketConsultantStaticRepository(RB_Order_ViewModel query)
public Dictionary<string, List<RB_Order_ViewModel>> GetMarketConsultantStaticRepository(RB_Order_ViewModel query,int qType=1)
{
Dictionary<string, List<RB_Order_ViewModel>> dicList = new Dictionary<string, List<RB_Order_ViewModel>>();
string sql = @"
SELECT A.EnterID,A.CourseConsultantId,SUM(A.Income) AS Income
string sql = "";
if (qType == 1)
{
sql = @"
SELECT A.EnterID,SUM(A.Income) AS Income
FROM RB_Order AS A
WHERE 1=1 AND A.OrderState IN(1,2) {0}
GROUP BY A.EnterID,A.CourseConsultantId
";
if (query.EnterID > 0)
{
sql += string.Format(" AND A.EnterID={0} ", query.EnterID);
}
sql += " GROUP BY A.EnterID ";
}
else
{
sql = @"
SELECT A.CourseConsultantId,Count(1) AS OrderCount, SUM(A.Income) AS Income
FROM RB_Order AS A
WHERE 1=1 AND A.OrderState IN(1,2) {0}
";
if (query.CourseConsultantId > 0)
{
sql += string.Format(" AND A.CourseConsultantId={0} ", query.CourseConsultantId);
}
sql += " GROUP BY A.CourseConsultantId ";
}
string todayWhere = "";
if (!string.IsNullOrEmpty(query.StartTime))
{
......
......@@ -832,14 +832,23 @@ WHERE 1=1
public Dictionary<string,List<RB_Student_ViewModel>> GetStudentClueRepository(RB_Student_ViewModel query)
{
Dictionary<string, List<RB_Student_ViewModel>> dicList = new Dictionary<string, List<RB_Student_ViewModel>>();
string whereStr = "";
if (query.CreateBy > 0)
{
whereStr += string.Format(" AND CreateBy={0} ", query.CreateBy);
}
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT Count(1) AS ClueCount,CreateBy
FROM RB_Student
WHERE Status=0 {0}
GROUP BY CreateBy
");
if (!string.IsNullOrEmpty(whereStr))
{
builder.Append(whereStr);
}
builder.Append(" GROUP BY CreateBy ");
string todayWhere = "";
if (!string.IsNullOrEmpty(query.StartTime))
{
......
......@@ -2538,7 +2538,7 @@ namespace Edu.WebApi.Controllers.User
marketConsultantModule.ClearData();
Task.Run(() =>
{
for (var i = 0; i < days; i++)
for (var i = 0; i <= days; i++)
{
marketConsultantModule.CreateMarketDataModule(start.AddDays(i));
marketConsultantModule.CreateConsultantDataModule(start.AddDays(i));
......
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