Commit 238a463d authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents ac946d9e 6745d148
......@@ -105,6 +105,10 @@ namespace Edu.Cache.User
/// 账号仓储层对象
/// </summary>
private static readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary>
/// 部门仓储层对象
/// </summary>
private static readonly RB_DepartmentRepository departmentRepository = new RB_DepartmentRepository();
/// <summary>
/// 获取用户登录信息
......@@ -138,12 +142,18 @@ namespace Edu.Cache.User
})?.FirstOrDefault();
if (model != null)
{
var deptList = departmentRepository.GetDepartmentListRepository(new Model.ViewModel.User.RB_Department_ViewModel()
{
DeptId = model.Dept_Id,
Group_Id = model.Group_Id,
ManagerIds = model.Id.ToString()
});
userInfo = new UserInfo
{
Id = model.Id,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
AccountType=model.AccountType,
AccountType = model.AccountType,
AccountName = model.AccountName,
GroupName = model.GroupName,
SchoolName = model.SchoolName,
......@@ -165,6 +175,7 @@ namespace Edu.Cache.User
IsTenCccUser = model.IsTenCccUser,
IsCourseConsultant = (model != null && model.UserRole == UserRoleEnum.CourseConsultant) ? 1 : 0,
IsMarket = (model != null && model.UserRole == UserRoleEnum.MarketPersion) ? 1 : 0,
IsManager = (deptList?.Count ?? 0) > 0 ? 1 : 0,
};
UserInfoSet(Cache.CacheKey.User_Login_Key + Id.ToString(), userInfo, Common.Config.JwtExpirTime);
}
......
......@@ -177,6 +177,11 @@ namespace Edu.Model.CacheModel
/// 是否是市场(1-是)
/// </summary>
public int IsMarket { get; set; }
/// <summary>
/// 部门负责人(1-是)
/// </summary>
public int IsManager { get; set; }
}
/// <summary>
......
......@@ -209,5 +209,30 @@ namespace Edu.Model.Entity.DataStatistics
/// 所属部门编号
/// </summary>
public int DeptId { get; set; }
/// <summary>
/// 当月完成订单累计金额
/// </summary>
public decimal CurMonthOrderSale { get; set; }
/// <summary>
/// 当月效能目标金额
/// </summary>
public decimal CurMonthOrderGoal { get; set; }
/// <summary>
/// 当月新签累计 [订单数量累计】
/// </summary>
public int CurMonthOrderNum { get; set; }
/// <summary>
/// 上月新签累计 [订单数量累计】
/// </summary>
public int LastMonthOrderNum { get; set; }
/// <summary>
/// 上月累计金额
/// </summary>
public decimal LastMonthOrderSale { get; set; }
}
}
using Edu.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Edu.Model.Entity.DataStatistics
{
/// <summary>
/// 课程顾问部月目标实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Consultant_Goal
{
/// <summary>
/// 主键
/// </summary>
public int Id { get; set; }
/// <summary>
/// 年份
/// </summary>
public int YearStr { get; set; }
/// <summary>
/// 月份
/// </summary>
public int MonthStr { get; set; }
/// <summary>
/// 目标金额
/// </summary>
public decimal GoalMoney { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 校区编号
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 部门编号
/// </summary>
public int Dept_Id { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public DateStateEnum Status { get; set; }
}
}
......@@ -39,5 +39,15 @@ namespace Edu.Model.ViewModel.Customer
/// 有效数据量 (第一次跟进且不等于流失)
/// </summary>
public int FollowCount { get; set; }
/// <summary>
/// 单资源回访平均数
/// </summary>
public decimal FollowEffectiveCount { 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>
......
using Edu.Model.Entity.DataStatistics;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.DataStatistics
{
/// <summary>
/// 课程顾问部月目标扩展实体类
/// </summary>
public class RB_Consultant_Goal_Extend : RB_Consultant_Goal
{
/// <summary>
/// 部门名称
/// </summary>
public string DeptName { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 创建时间字符串
/// </summary>
public string CreateTimeStr { get { return Common.ConvertHelper.FormatTime(this.CreateTime); } }
}
}
......@@ -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
......@@ -11,6 +11,8 @@ using Edu.Repository.DataStatistics;
using Edu.Model.ViewModel.User;
using Edu.Model.ViewModel.DataStatistics;
using Edu.Model.ViewModel.Reserve;
using VT.FW.DB;
using Edu.Common.Enum;
namespace Edu.Module.Customer
{
......@@ -59,6 +61,16 @@ namespace Edu.Module.Customer
/// </summary>
private readonly RB_Consultant_DataRepository consultant_DataRepository = new RB_Consultant_DataRepository();
/// <summary>
/// 课程顾问部目标仓储层对象
/// </summary>
private readonly RB_Consultant_GoalRepository consultant_GoalRepository = new RB_Consultant_GoalRepository();
/// <summary>
/// 部门仓储层对象
/// </summary>
private readonly RB_DepartmentRepository departmentRepository = new RB_DepartmentRepository();
/// <summary>
/// 清除数据
/// </summary>
......@@ -95,7 +107,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 +139,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 +179,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 +216,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 +251,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)
......@@ -293,6 +309,7 @@ namespace Edu.Module.Customer
});
if (empList != null && empList.Count > 0)
{
var consultantGoal = GetConsultantGoalListModule(new RB_Consultant_Goal_Extend() { Group_Id = 100000, Dept_Id = 13, YearStr = StartTime.Year, MonthStr = StartTime.Month })?.FirstOrDefault();
foreach (var item in empList)
{
RB_Consultant_Data_Extend model = new RB_Consultant_Data_Extend()
......@@ -303,126 +320,209 @@ namespace Edu.Module.Customer
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
});
if (avgFollowList != null && avgFollowList.Count > 0)
{
foreach (var sItem in avgFollowList)
{
if (sItem.Key == "today")
{
model.AgFollow = sItem.Value?.FirstOrDefault()?.FollowEffectiveCount ?? 0;
}
else if (sItem.Key == "yestoday")
{
model.YestodayAgFollow = sItem.Value?.FirstOrDefault()?.FollowEffectiveCount ?? 0;
}
else if (sItem.Key == "currentWeek")
{
model.CurWeekAgFollow = sItem.Value?.FirstOrDefault()?.FollowEffectiveCount ?? 0;
}
else if (sItem.Key == "lastWeek")
{
model.LastWeekAgFollow = sItem.Value?.FirstOrDefault()?.FollowEffectiveCount ?? 0;
}
else if (sItem.Key == "curMonth")
{
model.CurMonthAgFollow = sItem.Value?.FirstOrDefault()?.FollowEffectiveCount ?? 0;
}
else if (sItem.Key == "lastMonth")
{
model.LastMonthAgFollow = sItem.Value?.FirstOrDefault()?.FollowEffectiveCount ?? 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;
}
if (sItem.Key == "curMonth")
{
model.CurMonthOrderNum = orderCount;
model.CurMonthOrderSale = Income;
model.CurMonthOrderGoal = consultantGoal?.GoalMoney ?? 0;
}
if (sItem.Key == "lastMonth")
{
model.LastMonthOrderNum = orderCount;
model.LastMonthOrderSale = Income;
}
}
consultant_DataRepository.InsertConsultantRepository(model);
}
}
}
}
/// <summary>
/// 市场人员统计
/// </summary>
......@@ -509,6 +609,7 @@ namespace Edu.Module.Customer
YesDataObj = new
{
DayStr = Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)),
WeekStr = Common.Plugin.StringHelper.GetWeek(end.AddDays(-1)),
ClueCount = yesDataList?.Sum(qitem => qitem.ClueCount) ?? 0,
YestodayClue = yesDataList?.Sum(qitem => qitem.YestodayClue) ?? 0,
......@@ -565,102 +666,199 @@ 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()
var consultantGoal = GetConsultantGoalListModule(new RB_Consultant_Goal_Extend() { Group_Id = 100000, Dept_Id = 13, YearStr = end.Year, MonthStr = end.Month })?.FirstOrDefault();
var yesDataList = lastList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.Date) == Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)))?.ToList();
obj = new
{
QCreateByIds = EmpIds,
StartClassDate = StartTime,
EndClassDate = EndTime
});
DayStr = Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)),
WeekStr=Common.Plugin.StringHelper.GetWeek(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,
//到访列表
var visitList = student_VisitRepository.GetStudentVisitStaticRepository(new RB_Student_Visit_Extend()
{
QCreateByIds = EmpIds,
StartDate = StartTime,
EndDate = EndTime
});
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,
//订单列表
var orderList = orderRepository.GetOrderListRepository(new RB_Order_ViewModel()
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?.Average(qitem => qitem.AgFollow) ?? 0,
YestodayAgFollow = yesDataList?.Average(qitem => qitem.YestodayAgFollow) ?? 0,
CurWeekAgFollow = yesDataList?.Average(qitem => qitem.CurWeekAgFollow) ?? 0,
LastWeekAgFollow = yesDataList?.Average(qitem => qitem.LastWeekAgFollow) ?? 0,
CurMonthAgFollow = yesDataList?.Average(qitem => qitem.CurMonthAgFollow) ?? 0,
LastMonthAgFollow = yesDataList?.Average(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,
CurMonthOrderSale = yesDataList?.Sum(qitem => qitem.CurMonthOrderSale) ?? 0,
LastMonthOrderSale= yesDataList?.Sum(qitem => qitem.LastMonthOrderSale) ?? 0,
CurMonthOrderGoal = consultantGoal?.GoalMoney??0,
CurMonthOrderNum = yesDataList?.Sum(qitem => qitem.CurMonthOrderNum) ?? 0,
LastMonthOrderNum = yesDataList?.Sum(qitem => qitem.LastMonthOrderNum) ?? 0,
};
return obj;
}
#region 课程顾问部目标设置
/// <summary>
/// 获取课程顾问部目标分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Consultant_Goal_Extend> GetConsultantGoalPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Consultant_Goal_Extend query)
{
QEnterIds = EmpIds,
StartTime = StartTime,
EndTime = EndTime,
});
List<object> dayList = new List<object>();
for (var i = 0; i <= days; i++)
var list = consultant_GoalRepository.GetConsultantGoalPageRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
DateTime newDate = start.AddDays(i);
object tempObj = new object();
if (Common.ConvertHelper.FormatDate(newDate) == Common.ConvertHelper.FormatDate(DateTime.Now))
var deptList = new List<RB_Department_ViewModel>();
string deptIds = string.Join(",", list.Select(qitem => qitem.Dept_Id));
if (!string.IsNullOrEmpty(deptIds))
{
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
deptList= departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel()
{
DayStr = Common.ConvertHelper.FormatMonthDay(newDate),
//新增线索条数
ClueCount = tempStuList?.FirstOrDefault()?.ClueCount ?? 0,
//试听人数
TrialLessonCount = tempTrialLessonList?.Sum(qitem => qitem.TrialLessonCount) ?? 0,
//到访人数
VisitCount = tempVisitList?.Sum(qitem => qitem.VisitCount) ?? 0,
};
QDeptIds = deptIds
});
}
else
foreach (var item in list)
{
var tempLast = lastList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.Date) == Common.ConvertHelper.FormatMonthDay(newDate))?.ToList();
tempObj = new
item.DeptName = deptList?.FirstOrDefault(qitem => qitem.DeptId == item.Dept_Id)?.DeptName ?? "";
}
}
return list;
}
/// <summary>
/// 获取课程顾问部目标列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Consultant_Goal_Extend> GetConsultantGoalListModule(RB_Consultant_Goal_Extend query)
{
DayStr = Common.ConvertHelper.FormatMonthDay(newDate),
var list = consultant_GoalRepository.GetConsultantGoalListRepository(query);
return list;
}
//试听人数
TrialLessonCount = tempLast?.Sum(qitem => qitem.TrialLessonCount) ?? 0,
//到访人数
VisitCount = tempLast?.Sum(qitem => qitem.VisitCount) ?? 0,
/// <summary>
/// 修改课程顾问部目标
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetConsultantGoalModule(RB_Consultant_Goal_Extend model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Consultant_Goal_Extend.YearStr),model.YearStr},
{ nameof(RB_Consultant_Goal_Extend.MonthStr),model.MonthStr},
{ nameof(RB_Consultant_Goal_Extend.GoalMoney),model.GoalMoney},
{ nameof(RB_Consultant_Goal_Extend.Dept_Id),model.Dept_Id},
};
flag = consultant_GoalRepository.Update(fileds, new WhereHelper(nameof(RB_Consultant_Goal_Extend.Id), model.Id));
}
dayList.Add(tempObj);
return flag;
}
var yesDataList = lastList?.Where(qitem => Common.ConvertHelper.FormatMonthDay(qitem.Date) == Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)))?.ToList();
obj = new
/// <summary>
/// 批量添加课程顾问部目标
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool AddConsultantGoalModule(List<RB_Consultant_Goal_Extend> list)
{
dayList,
YesDataObj = new
bool flag = true;
if (list != null && list.Count > 0)
{
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,
foreach (var item in list)
{
var oldModel = consultant_GoalRepository.GetConsultantGoalListRepository(new RB_Consultant_Goal_Extend()
{
YearStr = item.YearStr,
MonthStr = item.MonthStr,
Dept_Id = item.Dept_Id
})?.FirstOrDefault();
item.Id = oldModel?.Id ?? 0;
if (flag)
{
if (item.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Consultant_Goal_Extend.YearStr),item.YearStr},
{ nameof(RB_Consultant_Goal_Extend.MonthStr),item.MonthStr},
{ nameof(RB_Consultant_Goal_Extend.GoalMoney),item.GoalMoney},
{ nameof(RB_Consultant_Goal_Extend.Dept_Id),item.Dept_Id},
};
flag = consultant_GoalRepository.Update(fileds, new WhereHelper(nameof(RB_Consultant_Goal_Extend.Id), item.Id));
}
else
{
var newId = consultant_GoalRepository.Insert(item);
item.Id = newId;
flag = newId > 0;
}
}
}
}
return flag;
}
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,
/// <summary>
/// 根据编号获取课程顾问部目标
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Consultant_Goal_Extend GetConsultantGoalModule(object Id)
{
var extModel = consultant_GoalRepository.GetEntity<RB_Consultant_Goal_Extend>(Id);
return extModel;
}
}
/// <summary>
/// 根据编号删除课程顾问部目标
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public bool RemoveConsultantGoalModule(object Id)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Consultant_Goal_Extend.Status) ,(int)DateStateEnum.Delete}
};
return obj;
bool flag = consultant_GoalRepository.Update(fileds, new WhereHelper(nameof(RB_Consultant_Goal_Extend.Id), Id));
return flag;
}
#endregion
}
}
\ No newline at end of file
......@@ -569,11 +569,13 @@ namespace Edu.Module.Duty
};
var flag = reserve_ClassRepository.Update(fileds, new WhereHelper(nameof(RB_Reserve_Class_Extend.ReserveClassId), ReserveClassId));
var model = GetReserveClassModule(ReserveClassId);
var teacherModel = accountRepository.GetAccountListRepository(new Model.ViewModel.User.RB_Account_ViewModel()
if (model != null)
{
var teacherModel = accountRepository.GetAccountListRepository(new RB_Account_ViewModel()
{
Group_Id = model.Group_Id,
AccountId = model.TeacherId,
AccountType= Common.Enum.User.AccountTypeEnum.Teacher
AccountType = Common.Enum.User.AccountTypeEnum.Teacher
})?.FirstOrDefault();
Common.Message.PushMessageModel pushModel = new Common.Message.PushMessageModel()
{
......@@ -586,12 +588,13 @@ namespace Edu.Module.Duty
SendType = 0,
Title = "试听课",
Platform = 2,
ReceiveId = (teacherModel?.Id??0).ToString(),
ReceiveId = (teacherModel?.Id ?? 0).ToString(),
};
if (flag)
{
Common.Message.MessageHelper.SendMessage(pushModel);
}
}
return flag;
}
}
......
......@@ -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 FollowEffectiveCount 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,52 @@ 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,
CurMonthOrderGoal=model.CurMonthOrderGoal,
LastMonthOrderSale=model.LastMonthOrderSale,
CurMonthOrderSale=model.CurMonthOrderSale,
CurMonthOrderNum=model.CurMonthOrderNum,
LastMonthOrderNum=model.LastMonthOrderNum,
CreateBy = model.CreateBy,
CreateTime = DateTime.Now,
DeptId = model.DeptId,
......
using Edu.Common.Enum;
using Edu.Model.Entity.DataStatistics;
using Edu.Model.ViewModel.DataStatistics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.DataStatistics
{
/// <summary>
/// 课程顾问部月目标仓储层
/// </summary>
public class RB_Consultant_GoalRepository : BaseRepository<RB_Consultant_Goal>
{
/// <summary>
/// 获取课程顾问部目标分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Consultant_Goal_Extend> GetConsultantGoalPageRepository(int pageIndex, int pageSize, out long rowsCount, RB_Consultant_Goal_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Consultant_Goal AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.Group_Id), query.Group_Id);
}
if (query.YearStr > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.YearStr), query.YearStr);
}
if (query.MonthStr > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.MonthStr), query.MonthStr);
}
}
builder.Append(" ORDER BY A.YearStr,A.MonthStr ");
return GetPage<RB_Consultant_Goal_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取课程顾问部目标列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Consultant_Goal_Extend> GetConsultantGoalListRepository(RB_Consultant_Goal_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@"
SELECT A.*
FROM RB_Consultant_Goal AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.Group_Id), query.Group_Id);
}
if (query.YearStr > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.YearStr), query.YearStr);
}
if (query.MonthStr > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.MonthStr), query.MonthStr);
}
if (query.Dept_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Consultant_Goal_Extend.Dept_Id), query.Dept_Id);
}
}
return Get<RB_Consultant_Goal_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -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))
{
......
......@@ -51,15 +51,16 @@ namespace Edu.WebApi.Controllers.User
/// </summary>
private readonly TeacherModule teacherModule = new TeacherModule();
private readonly StudentModule studentModule = new StudentModule();
/// <summary>
/// 部门处理类对象
/// </summary>
private readonly DepartmentModule departmentModule = new DepartmentModule();
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult Test()
{
studentModule.UpdateTel();
return ApiResult.Success();
}
......@@ -153,10 +154,6 @@ namespace Edu.WebApi.Controllers.User
string erpToken = WebApiTokenHelper.CreateToken(Common.GlobalKey.JWT_ERP_User_Key, erpUserInfo);
#region 获取甲鹤教育Token
string JHTenantId = Config.JHTenantId;
string JHMallBaseId = Config.JHMallBaseId;
......@@ -190,6 +187,7 @@ namespace Edu.WebApi.Controllers.User
#endregion
var treeList = menuModule.GetPostMenuTreeModule(new Model.ViewModel.System.RB_Menu_ViewModel()
{
MenuType = accountType
......@@ -198,6 +196,7 @@ namespace Edu.WebApi.Controllers.User
var actionList = menuModule.GetPostMenuFunctionListModule(model.Post_Id.ToString());
//上传配置
var uploadConfig = publicModule.GetFileStoreList(new Model.Public.RB_File_Store() { Group_Id = model.Group_Id, IsDefault = 1 })?.FirstOrDefault();
var deptList= departmentModule.GetDepartmentListModule(new RB_Department_ViewModel() { DeptId = model.Dept_Id, Group_Id = model.Group_Id, ManagerIds = model.Id.ToString() });
UserInfo obj = new UserInfo
{
......@@ -225,6 +224,7 @@ namespace Edu.WebApi.Controllers.User
PostId = model.Post_Id,
PostName = model.PostName,
Email = model.Email,
IsManager=(deptList?.Count??0)>0?1:0,
IsTenCccUser = model.IsTenCccUser,
IsCourseConsultant = (model != null && model.UserRole == UserRoleEnum.CourseConsultant) ? 1 : 0,
IsMarket= (model != null && model.UserRole == UserRoleEnum.MarketPersion) ? 1 : 0,
......@@ -255,6 +255,28 @@ namespace Edu.WebApi.Controllers.User
}
}
/// <summary>
/// 获取最新token
/// </summary>
/// <returns></returns>
public ApiResult GetSeatNewToken()
{
if (!string.IsNullOrEmpty(this.UserInfo.Email))
{
var tObj = new TenCloudCCCHelper().GetTenCccUserToken(this.UserInfo.Email).Result;
var tenCccToken = new TenCccTokenItem()
{
SdkURL = tObj.SdkURL,
Token = tObj.Token
};
return ApiResult.Success(data: tenCccToken);
}
else
{
return ApiResult.Failed("用户信息不合法,无法获取信息");
}
}
/// <summary>
/// 根据Token获取用户信息
/// </summary>
......
......@@ -13,6 +13,7 @@ using Edu.Common.Enum.User;
using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.Public;
using Edu.Model.ViewModel.DataStatistics;
using Edu.Model.ViewModel.User;
using Edu.Module.Course;
using Edu.Module.Customer;
......@@ -2538,7 +2539,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));
......@@ -2552,6 +2553,7 @@ namespace Edu.WebApi.Controllers.User
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowRepeatAttribute]
public ApiResult MarketStatic()
{
string startTime = base.ParmJObj.GetStringValue("startTime");
......@@ -2584,6 +2586,7 @@ namespace Edu.WebApi.Controllers.User
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowRepeatAttribute]
public ApiResult ConsultantStatic()
{
string startTime = base.ParmJObj.GetStringValue("startTime");
......@@ -2611,5 +2614,148 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success(data: obj);
}
#endregion
#region 课程顾问部目标
/// <summary>
/// 获取课程顾问部目标分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetConsultantGoalPage()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Consultant_Goal_Extend()
{
YearStr=base.ParmJObj.GetInt("YearStr"),
MonthStr=base.ParmJObj.GetInt("MonthStr"),
};
query.Group_Id = base.UserInfo.Group_Id;
List<object> list = new List<object>();
var data= marketConsultantModule.GetConsultantGoalPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
if (data != null && data.Count > 0)
{
foreach (var item in data)
{
string CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
list.Add(new
{
item.Id,
item.YearStr,
item.MonthStr,
item.GoalMoney,
CreateByName,
item.CreateTimeStr,
item.Dept_Id,
item.DeptName,
});
}
}
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 修改课程顾问部目标
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult UpdateConsultantGoal()
{
var model = new RB_Consultant_Goal_Extend()
{
Id=base.ParmJObj.GetInt("Id"),
YearStr=base.ParmJObj.GetInt("YearStr"),
MonthStr=base.ParmJObj.GetInt("MonthStr"),
GoalMoney=base.ParmJObj.GetDecimal("GoalMoney"),
Dept_Id=base.ParmJObj.GetInt("Dept_Id"),
};
model.CreateBy = base.UserInfo.Id;
model.CreateTime = DateTime.Now;
model.Group_Id = base.UserInfo.Group_Id;
model.School_Id = base.UserInfo.School_Id;
model.Status = Common.Enum.DateStateEnum.Normal;
bool flag = marketConsultantModule.SetConsultantGoalModule(model);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 新增课程顾问部目标
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult AddConsultantGoal()
{
List<RB_Consultant_Goal_Extend> list = new List<RB_Consultant_Goal_Extend>();
var timeListStr = base.ParmJObj.GetStringValue("TimeList");
if (!string.IsNullOrEmpty(timeListStr))
{
List<string> timeList = Common.Plugin.JsonHelper.DeserializeObject<List<string>>(timeListStr);
if (timeList != null && timeList.Count > 0)
{
foreach (var item in timeList)
{
var tempArray = item.Split('-');
if (tempArray != null && tempArray.Length == 2)
{
Int32.TryParse(tempArray[0], out int YearStr);
Int32.TryParse(tempArray[1], out int MonthStr);
var model = new RB_Consultant_Goal_Extend()
{
Id = 0,
YearStr = YearStr,
MonthStr = MonthStr,
GoalMoney = base.ParmJObj.GetDecimal("GoalMoney"),
Dept_Id = base.ParmJObj.GetInt("Dept_Id"),
};
model.CreateBy = base.UserInfo.Id;
model.CreateTime = DateTime.Now;
model.Group_Id = base.UserInfo.Group_Id;
model.School_Id = base.UserInfo.School_Id;
model.Status = Common.Enum.DateStateEnum.Normal;
if (YearStr > 0 && MonthStr > 0)
{
list.Add(model);
}
}
}
}
}
bool flag = marketConsultantModule.AddConsultantGoalModule(list);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 根据编号获取目标
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetConsultantGoal()
{
var Id = base.ParmJObj.GetInt("Id");
var extModel = marketConsultantModule.GetConsultantGoalModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 根据编号删除目标
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveConsultantGoal()
{
var Id = base.ParmJObj.GetInt("Id");
var extModel = marketConsultantModule.RemoveConsultantGoalModule(Id);
return ApiResult.Success(data: extModel);
}
#endregion
}
}
\ No newline at end of file
......@@ -1273,7 +1273,6 @@ namespace Edu.WebApi.Controllers.User
var customer = base.AppletCustomerInfo;
var query = new RB_Student_ViewModel()
{
QQ = base.ParmJObj.GetStringValue("QQ"),
WeChatNo = base.ParmJObj.GetStringValue("WeChatNo")
};
......@@ -1293,7 +1292,6 @@ namespace Edu.WebApi.Controllers.User
extModel.CreateByName = UserReidsCache.GetUserLoginInfo(extModel.CreateBy)?.AccountName ?? "";
if (customer != null)
{
Common.Plugin.LogHelper.Write("查重推送消息");
studentModule.PushMessageModule(extModel,1);
}
}
......
using Edu.Common.Plugin;
using Edu.Module.Course;
using Edu.Module.Customer;
using Edu.Module.Duty;
using Edu.Module.EduTask;
using Edu.Module.Exam;
......@@ -39,6 +40,11 @@ namespace Edu.WebApi.Timers
/// </summary>
private static readonly PaperModule paperModule = new PaperModule();
/// <summary>
/// 课程顾问部和市场部数据统计
/// </summary>
private static readonly MarketConsultantModule marketConsultantModule = new MarketConsultantModule();
static System.Timers.Timer timer1;//计时器
static System.Timers.Timer timer2;//定期处理未值班数据
......@@ -53,6 +59,8 @@ namespace Edu.WebApi.Timers
static System.Timers.Timer finishGuest;//处理学生毕业状态
static System.Timers.Timer marketTimer;//处理市场部和课程顾问部数据统计
public static void RunTimer()
{
timer1 = new System.Timers.Timer
......@@ -104,6 +112,13 @@ namespace Edu.WebApi.Timers
};
finishGuest.Elapsed += new System.Timers.ElapsedEventHandler(DealGuestFinish);
finishGuest.Enabled = true;
marketTimer= new System.Timers.Timer()
{
Interval = (1000) * (1) //1秒检测一次 00:30:00 每天执行一次
};
marketTimer.Elapsed += new System.Timers.ElapsedEventHandler(DealMarketConsultantData);
marketTimer.Enabled = true;
}
public static void RunStop()
......@@ -115,6 +130,7 @@ namespace Edu.WebApi.Timers
changeOrder.Enabled = false;
examTimer.Enabled = false;
finishGuest.Enabled = false;
marketTimer.Enabled = false;
}
/// <summary>
......@@ -127,6 +143,34 @@ namespace Edu.WebApi.Timers
private static int changeOrder_Timer = 0;
private static int examPublish_Timer = 0;
private static int guestfinish_Timer = 0;
private static int marketconsultant_Timer = 0;
/// <summary>
/// 定时生成市场部和课程顾问部数据统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void DealMarketConsultantData(object sender, System.Timers.ElapsedEventArgs e)
{
if (Interlocked.Exchange(ref marketconsultant_Timer, 1) == 0)
{
int intHour = e.SignalTime.Hour;
int intMinute = e.SignalTime.Minute;
int intSecond = e.SignalTime.Second;
// 定制时间;比如 在00:30:00 的时候执行某个函数
int iHour = 00;
int iMinute = 30;
int iSecond = 00;
// 设置每天的
if (intHour == iHour && intMinute == iMinute && intSecond == iSecond)
{
marketConsultantModule.CreateConsultantDataModule(DateTime.Now);
marketConsultantModule.CreateMarketDataModule(DateTime.Now);
}
Interlocked.Exchange(ref marketconsultant_Timer, 0);
}
}
/// <summary>
/// 处理学员毕业状态
......
{
"ConnectionStrings": {
"DefaultConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=test_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_finance;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient",
......
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