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
......@@ -95,7 +95,7 @@ namespace Edu.Module.Customer
DeptId = item.Dept_Id,
};
//1.条数(资源量)
var dicList = studentRepository.GetStudentClueRepository(new RB_Student_ViewModel() { StartTime = start });
var dicList = studentRepository.GetStudentClueRepository(new RB_Student_ViewModel() { StartTime = start, CreateBy = item.Id });
if (dicList != null && dicList.Count > 0)
{
foreach (var sItem in dicList)
......@@ -127,11 +127,12 @@ namespace Edu.Module.Customer
}
}
//2.有效数据量 (第一次跟进且不等于流失)
var followList = student_FollowRepository.GetStudentFollowStaticRepository(new RB_Student_Follow_Extend()
{
STime = start
STime = start,
CreateBy = item.Id
});
//2.有效数据量 (第一次跟进且不等于流失)
if (followList != null && followList.Count > 0)
{
foreach (var sItem in followList)
......@@ -166,7 +167,8 @@ namespace Edu.Module.Customer
//3.上门咨询
var visitList = student_VisitRepository.GetVisitStaticRepository(new RB_Student_Visit_Extend()
{
StartDate = start
StartDate = start,
CreateBy = item.Id,
});
if (visitList != null && visitList.Count > 0)
{
......@@ -202,7 +204,8 @@ namespace Edu.Module.Customer
//4.试听邀约
var trialLessonList = visitor_ReserveRepository.GetVisitorStaticRepository(new RB_Visitor_Reserve_Extend()
{
StartClassDate = start
StartClassDate = start,
CreateBy = item.Id,
});
if (trialLessonList != null && trialLessonList.Count > 0)
{
......@@ -236,10 +239,11 @@ namespace Edu.Module.Customer
}
//5.销售额(签约量)
var orderList = orderRepository.GetMarketMarketConsultantStaticRepository(new RB_Order_ViewModel()
var orderList = orderRepository.GetMarketConsultantStaticRepository(new RB_Order_ViewModel()
{
StartTime = start
});
StartTime = start,
EnterID = item.Id
}, qType: 1);
if (orderList != null && orderList.Count > 0)
{
foreach (var sItem in orderList)
......@@ -302,127 +306,199 @@ namespace Edu.Module.Customer
Date = newTime,
DeptId = item.Dept_Id,
};
var followList = student_FollowRepository.GetStudentFollowStaticRepository(new RB_Student_Follow_Extend()
//1.试听邀约
var trialLessonList = visitor_ReserveRepository.GetVisitorStaticRepository(new RB_Visitor_Reserve_Extend()
{
STime = start
StartClassDate = start,
CreateBy = item.Id
});
//2.有效数据量 (第一次跟进且不等于流失)
if (followList != null && followList.Count > 0)
if (trialLessonList != null && trialLessonList.Count > 0)
{
foreach (var sItem in followList)
foreach (var sItem in trialLessonList)
{
if (sItem.Key == "today")
{
model.FollowCount = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
model.TrialLessonCount = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
}
else if (sItem.Key == "yestoday")
{
model.YestodayFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
model.YestodayTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
}
else if (sItem.Key == "currentWeek")
{
model.CurWeekFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
model.CurWeekTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
}
else if (sItem.Key == "lastWeek")
{
model.LastWeekFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
model.LastWeekTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
}
else if (sItem.Key == "curMonth")
{
model.CurMonthFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
model.CurMonthTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
}
else if (sItem.Key == "lastMonth")
{
model.LastMonthFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
model.LastMonthTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
}
}
}
//3.上门咨询
//2.到访累计 和 3.转化率~~~市场收集的数据(学生信息和电话号码),邀约上门咨询后算有效单,,报名成交之后叫转化成功。这个转化率能看出课程顾问的能力或者市场给到的数据的有效性
var visitList = student_VisitRepository.GetVisitStaticRepository(new RB_Student_Visit_Extend()
{
StartDate = start
StartDate = start,
CreateBy = item.Id,
});
if (visitList != null && visitList.Count > 0)
{
foreach (var sItem in visitList)
{
var visitData = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault();
var VisitCount = visitData?.VisitCount ?? 0;
var OrderCount = visitData?.OrderCount ?? 0;
decimal Rates = 0;
if (VisitCount > 0)
{
Rates = Math.Round(Convert.ToDecimal(OrderCount) / Convert.ToDecimal(VisitCount) * 100, 2);
}
if (sItem.Key == "today")
{
model.VisitCount = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.VisitCount ?? 0;
model.VisitCount = VisitCount;
model.Rates = Rates;
}
else if (sItem.Key == "yestoday")
{
model.YestodayVisit = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.VisitCount ?? 0;
model.YestodayVisit = VisitCount;
model.YestodayRates = Rates;
}
else if (sItem.Key == "currentWeek")
{
model.CurWeekVisit = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.VisitCount ?? 0;
model.CurWeekVisit = VisitCount;
model.CurWeekRates = Rates;
}
else if (sItem.Key == "lastWeek")
{
model.LastWeekVisit = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.VisitCount ?? 0;
model.LastWeekVisit = VisitCount;
model.LastWeekRates = Rates;
}
else if (sItem.Key == "curMonth")
{
model.CurMonthVisit = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.VisitCount ?? 0;
model.CurMonthVisit = VisitCount;
model.CurMonthRates = Rates;
}
else if (sItem.Key == "lastMonth")
{
model.LastMonthVisit = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.VisitCount ?? 0;
model.LastMonthVisit = VisitCount;
model.LastMonthRates = Rates;
}
}
}
//4.试听邀约
var trialLessonList = visitor_ReserveRepository.GetVisitorStaticRepository(new RB_Visitor_Reserve_Extend()
//4.有效回访总量~~~(就是跟客户有实际联系上,不是未接) (有跟进记录)
var followList = student_FollowRepository.GetConsultantFollowStaticRepository(new RB_Student_Follow_Extend()
{
StartClassDate = start
STime = start,
CreateBy = item.Id
});
if (trialLessonList != null && trialLessonList.Count > 0)
if (followList != null && followList.Count > 0)
{
foreach (var sItem in trialLessonList)
foreach (var sItem in followList)
{
if (sItem.Key == "today")
{
model.TrialLessonCount = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
model.FollowCount = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "yestoday")
{
model.YestodayTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
model.YestodayFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "currentWeek")
{
model.CurWeekTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
model.CurWeekFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "lastWeek")
{
model.LastWeekTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
model.LastWeekFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "curMonth")
{
model.CurMonthTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
model.CurMonthFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "lastMonth")
{
model.LastMonthTrialLesson = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.TrialLessonCount ?? 0;
model.LastMonthFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
}
}
//5.销售额(签约量)
var orderList = orderRepository.GetMarketMarketConsultantStaticRepository(new RB_Order_ViewModel()
//5.单资源回访平均数~~~就是一条资源跟进了几次 【平均】
var avgFollowList = student_FollowRepository.GetConsultantAvgFollowStaticRepository(new RB_Student_Follow_Extend()
{
StartTime = start
STime = start,
CreateBy = item.Id
});
consultant_DataRepository.InsertConsultantRepository(model);
if (avgFollowList != null && avgFollowList.Count > 0)
{
foreach (var sItem in avgFollowList)
{
if (sItem.Key == "today")
{
model.AgFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "yestoday")
{
model.YestodayAgFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "currentWeek")
{
model.CurWeekAgFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "lastWeek")
{
model.LastWeekAgFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "curMonth")
{
model.CurMonthAgFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
else if (sItem.Key == "lastMonth")
{
model.LastMonthAgFollow = sItem.Value?.Where(qitem => qitem.CreateBy == item.Id)?.FirstOrDefault()?.FollowCount ?? 0;
}
}
}
//5.销售额(签约量)
var orderList = orderRepository.GetMarketConsultantStaticRepository(new RB_Order_ViewModel()
{
StartTime = start,
CourseConsultantId = item.Id
}, qType: 2);
if (orderList != null && orderList.Count > 0)
{
foreach (var sItem in orderList)
{
var tempOrder = sItem.Value?.FirstOrDefault();
var orderCount = tempOrder?.OrderCount ?? 0;
var Income = tempOrder?.Income ?? 0;
if (sItem.Key == "currentWeek")
{
model.CurWeekOrderNum = orderCount;
model.CurWeekOrderSale = Income;
}
if (sItem.Key == "lastWeek")
{
model.LastWeekOrderNum = orderCount;
model.LastWeekOrderSale = Income;
}
}
consultant_DataRepository.InsertConsultantRepository(model);
}
}
}
}
}
/// <summary>
/// 市场人员统计
/// </summary>
......@@ -565,100 +641,51 @@ namespace Edu.Module.Customer
EndTime = EndTime,
QCreateByIds = EmpIds
});
//线索列表
var studentList = studentRepository.GetStudentStaticRepository(EmpIds, StartTime, EndTime);
//试听列表
var trialLessonList = visitor_ReserveRepository.GetVisitorReserveStaticRepository(new Model.ViewModel.Reserve.RB_Visitor_Reserve_Extend()
{
QCreateByIds = EmpIds,
StartClassDate = StartTime,
EndClassDate = EndTime
});
//到访列表
var visitList = student_VisitRepository.GetStudentVisitStaticRepository(new RB_Student_Visit_Extend()
{
QCreateByIds = EmpIds,
StartDate = StartTime,
EndDate = EndTime
});
//订单列表
var orderList = orderRepository.GetOrderListRepository(new RB_Order_ViewModel()
{
QEnterIds = EmpIds,
StartTime = StartTime,
EndTime = EndTime,
});
List<object> dayList = new List<object>();
for (var i = 0; i <= days; i++)
{
DateTime newDate = start.AddDays(i);
object tempObj = new object();
if (Common.ConvertHelper.FormatDate(newDate) == Common.ConvertHelper.FormatDate(DateTime.Now))
{
var tempStuList = studentList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.CreateTime) == Common.ConvertHelper.FormatMonthDay(newDate))?.ToList();
var tempTrialLessonList = trialLessonList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.CreateTime) == Common.ConvertHelper.FormatMonthDay(newDate))?.ToList();
var tempVisitList = visitList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.CreateTime) == Common.ConvertHelper.FormatMonthDay(newDate))?.ToList();
tempObj = new
{
DayStr = Common.ConvertHelper.FormatMonthDay(newDate),
//新增线索条数
ClueCount = tempStuList?.FirstOrDefault()?.ClueCount ?? 0,
//试听人数
TrialLessonCount = tempTrialLessonList?.Sum(qitem => qitem.TrialLessonCount) ?? 0,
//到访人数
VisitCount = tempVisitList?.Sum(qitem => qitem.VisitCount) ?? 0,
};
}
else
{
var tempLast = lastList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.Date) == Common.ConvertHelper.FormatMonthDay(newDate))?.ToList();
tempObj = new
{
DayStr = Common.ConvertHelper.FormatMonthDay(newDate),
//试听人数
TrialLessonCount = tempLast?.Sum(qitem => qitem.TrialLessonCount) ?? 0,
//到访人数
VisitCount = tempLast?.Sum(qitem => qitem.VisitCount) ?? 0,
};
}
dayList.Add(tempObj);
}
var yesDataList = lastList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.Date) == Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)))?.ToList();
obj = new
{
dayList,
YesDataObj = new
{
DayStr = Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)),
FollowCount = yesDataList?.Sum(qitem => qitem.FollowCount) ?? 0,
YestodayFollow = yesDataList?.Sum(qitem => qitem.YestodayFollow) ?? 0,
CurWeekFollow = yesDataList?.Sum(qitem => qitem.CurWeekFollow) ?? 0,
LastWeekFollow = yesDataList?.Sum(qitem => qitem.LastWeekFollow) ?? 0,
CurMonthFollow = yesDataList?.Sum(qitem => qitem.CurMonthFollow) ?? 0,
LastMonthFollow = yesDataList?.Sum(qitem => qitem.LastMonthFollow) ?? 0,
VisitCount = yesDataList?.Sum(qitem => qitem.VisitCount) ?? 0,
YestodayVisit = yesDataList?.Sum(qitem => qitem.YestodayVisit) ?? 0,
CurWeekVisit = yesDataList?.Sum(qitem => qitem.CurWeekVisit) ?? 0,
LastWeekVisit = yesDataList?.Sum(qitem => qitem.LastWeekVisit) ?? 0,
CurMonthVisit = yesDataList?.Sum(qitem => qitem.CurMonthVisit) ?? 0,
LastMonthVisit = yesDataList?.Sum(qitem => qitem.LastMonthVisit) ?? 0,
TrialLessonCount = yesDataList?.Sum(qitem => qitem.TrialLessonCount) ?? 0,
YestodayTrialLesson = yesDataList?.Sum(qitem => qitem.YestodayTrialLesson) ?? 0,
CurWeekTrialLesson = yesDataList?.Sum(qitem => qitem.CurWeekTrialLesson) ?? 0,
LastWeekTrialLesson = yesDataList?.Sum(qitem => qitem.LastWeekTrialLesson) ?? 0,
CurMonthTrialLesson = yesDataList?.Sum(qitem => qitem.CurMonthTrialLesson) ?? 0,
LastMonthTrialLesson = yesDataList?.Sum(qitem => qitem.LastMonthTrialLesson) ?? 0,
}
DayStr = Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)),
TrialLessonCount = yesDataList?.Sum(qitem => qitem.TrialLessonCount) ?? 0,
YestodayTrialLesson = yesDataList?.Sum(qitem => qitem.YestodayTrialLesson) ?? 0,
CurWeekTrialLesson = yesDataList?.Sum(qitem => qitem.CurWeekTrialLesson) ?? 0,
LastWeekTrialLesson = yesDataList?.Sum(qitem => qitem.LastWeekTrialLesson) ?? 0,
CurMonthTrialLesson = yesDataList?.Sum(qitem => qitem.CurMonthTrialLesson) ?? 0,
LastMonthTrialLesson = yesDataList?.Sum(qitem => qitem.LastMonthTrialLesson) ?? 0,
VisitCount = yesDataList?.Sum(qitem => qitem.VisitCount) ?? 0,
YestodayVisit = yesDataList?.Sum(qitem => qitem.YestodayVisit) ?? 0,
CurWeekVisit = yesDataList?.Sum(qitem => qitem.CurWeekVisit) ?? 0,
LastWeekVisit = yesDataList?.Sum(qitem => qitem.LastWeekVisit) ?? 0,
CurMonthVisit = yesDataList?.Sum(qitem => qitem.CurMonthVisit) ?? 0,
LastMonthVisit = yesDataList?.Sum(qitem => qitem.LastMonthVisit) ?? 0,
Rates = yesDataList?.Sum(qitem => qitem.Rates) ?? 0,
YestodayRates = yesDataList?.Sum(qitem => qitem.YestodayRates) ?? 0,
CurWeekRates = yesDataList?.Sum(qitem => qitem.CurWeekRates) ?? 0,
LastWeekRates = yesDataList?.Sum(qitem => qitem.LastWeekRates) ?? 0,
CurMonthRates = yesDataList?.Sum(qitem => qitem.CurMonthRates) ?? 0,
LastMonthRates= yesDataList?.Sum(qitem => qitem.LastMonthRates) ?? 0,
FollowCount = yesDataList?.Sum(qitem => qitem.FollowCount) ?? 0,
YestodayFollow = yesDataList?.Sum(qitem => qitem.YestodayFollow) ?? 0,
CurWeekFollow = yesDataList?.Sum(qitem => qitem.CurWeekFollow) ?? 0,
LastWeekFollow = yesDataList?.Sum(qitem => qitem.LastWeekFollow) ?? 0,
CurMonthFollow = yesDataList?.Sum(qitem => qitem.CurMonthFollow) ?? 0,
LastMonthFollow = yesDataList?.Sum(qitem => qitem.LastMonthFollow) ?? 0,
AgFollow = yesDataList?.Sum(qitem => qitem.AgFollow) ?? 0,
YestodayAgFollow = yesDataList?.Sum(qitem => qitem.YestodayAgFollow) ?? 0,
CurWeekAgFollow = yesDataList?.Sum(qitem => qitem.CurWeekAgFollow) ?? 0,
LastWeekAgFollow = yesDataList?.Sum(qitem => qitem.LastWeekAgFollow) ?? 0,
CurMonthAgFollow = yesDataList?.Sum(qitem => qitem.CurMonthAgFollow) ?? 0,
LastMonthAgFollow = yesDataList?.Sum(qitem => qitem.LastMonthAgFollow) ?? 0,
CurWeekOrderNum = yesDataList?.Sum(qitem => qitem.CurWeekOrderNum) ?? 0,
LastWeekOrderNum = yesDataList?.Sum(qitem => qitem.LastWeekOrderNum) ?? 0,
CurWeekOrderSale = yesDataList?.Sum(qitem => qitem.CurWeekOrderSale) ?? 0,
LastWeekOrderSale = yesDataList?.Sum(qitem => qitem.LastWeekOrderSale) ?? 0,
};
return obj;
}
......
......@@ -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