Commit b95a8e74 authored by 黄奎's avatar 黄奎

页面修改

parent 9d230eba
......@@ -1262,102 +1262,89 @@ namespace Edu.Module.User
var list = student_AppointmentRepository.GetStudentAppointmentPageRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
//客户阶段列表
var stageList = stageRepository.GetStageListRepostory(new Model.Entity.System.RB_Stage()
{
Group_Id = list[0].Group_Id
});
//学员类型列表
var stuTypeList = student_TypeRepository.GetStudentTypeListRepository(new RB_Student_Type_Extend());
//学习目的
var goalList = learningGoalsRepository.GetLearningGoalsListRepository(new Model.ViewModel.System.RB_LearningGoals_Extend());
//渠道列表
var channelList = channelRepository.GetChannelListRepository(new Model.ViewModel.System.RB_Channel_Extend());
//客户需求
var needList = needsRepository.GetNeedsListRepository(new Model.ViewModel.System.RB_Needs_Extend());
string stuIds = string.Join(",", list.Select(qitem => qitem.StuId));
var stuList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel() { StuIds = stuIds }, isQueryCreateType: true, isQueryAssist: false);
//协助人员列表
var assistList = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
QStuIds = stuIds
});
var stuList = GetStudentPageListModule(1,10000,out _,new RB_Student_ViewModel() { StuIds = stuIds });
List<int> empIds = new List<int>();
//内部介绍人
List<int> stuSourceIdList = Common.ConvertHelper.StringToList(string.Join(",", stuList.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction).Select(qitem => qitem.StuSourceId)));
if (stuSourceIdList != null && stuSourceIdList.Count > 0)
{
empIds.AddRange(stuSourceIdList);
}
//协助人员
List<int> assistIdList = Common.ConvertHelper.StringToList(string.Join(",", assistList.Select(qitem => qitem.AssistId)));
if (assistIdList != null && assistIdList.Count > 0)
{
empIds.AddRange(assistIdList);
}
//跟进人员创建人
List<int> createByIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Select(qitem => qitem.CreateBy)));
if (createByIdList != null && createByIdList.Count > 0)
{
empIds.AddRange(createByIdList);
}
//学员负责人
List<int> stuCreateByList = Common.ConvertHelper.StringToList(string.Join(",", stuList.Select(qitem => qitem.CreateBy)));
if (stuCreateByList != null && stuCreateByList.Count > 0)
{
empIds.AddRange(stuCreateByList);
}
string createIds = string.Join(",", empIds);
var empList = new List<RB_Account_ViewModel>();
if (!string.IsNullOrEmpty(createIds))
{
empList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { QIds = createIds });
}
foreach (var item in list)
foreach (var aItem in list)
{
var tempEmp = empList?.FirstOrDefault(qitem => qitem.Id == item.CreateBy);
var tempStudent = stuList?.FirstOrDefault(qitem => qitem.StuId == item.StuId);
if (tempStudent != null)
{
var tempAssistList = assistList?.Where(qitem => qitem.StuId == item.StuId)?.ToList();
if (tempAssistList != null && tempAssistList.Count > 0)
{
foreach (var subItem in tempAssistList)
{
subItem.AssistName = empList?.FirstOrDefault(qitem => qitem.Id == subItem.AssistId)?.AccountName ?? "";
}
}
tempStudent.AssistList = tempAssistList;
}
var tempEmp = empList?.FirstOrDefault(qitem => qitem.Id == aItem.CreateBy);
var item = stuList?.FirstOrDefault(qitem => qitem.StuId == aItem.StuId);
result.Add(new
{
item.Id,
item.StuId,
item.StuName,
item.CreateBy,
AppointmentTime = Common.ConvertHelper.FormatTime(item.AppointmentTime),
aItem.Id,
aItem.StuId,
aItem.StuName,
aItem.CreateBy,
AppointmentTime = Common.ConvertHelper.FormatTime(aItem.AppointmentTime),
EmployeeName = tempEmp?.AccountName,
CreateTime = Common.ConvertHelper.FormatTime(item.CreateTime),
item.Feedback,
CreateTypeName = tempStudent?.CreateType.ToName() ?? "",
StuSourceId = tempStudent?.StuSourceId ?? 0,
StuSourceIdName = tempStudent?.StuSourceIdName ?? "",
AssistList = tempStudent?.AssistList?.Select(qitem => new
CreateTime = Common.ConvertHelper.FormatTime(aItem.CreateTime),
aItem.Feedback,
item.StuTel,
item.StuIcon,
item.StuSex,
StuSexStr = item.StuSex == 0 ? "男" : "女",
StuBirth = Common.ConvertHelper.FormatDate(item.StuBirth),
item.StuStage,
item.StuStageName,
CreateTimeStr = Common.ConvertHelper.FormatTime(item.CreateTime),
item.CreateByName,
item.CreateType,
CreateTypeStr = item.CreateType.ToName(),
item.StuChannel,
item.StuChannelName,
item.PlatformName,
item.CustomerId,
item.CustomerName,
AssistList = item.AssistList.Select(qitem => new
{
qitem.AssistType,
AssistTypeName = qitem.AssistType.ToName(),
qitem.Id,
qitem.StuId,
qitem.AssistId,
qitem.AssistName,
qitem.AssistType,
AssistTypeName = qitem.AssistType.ToName()
}),
StuStageName = stageList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuStage)?.StageName ?? "",
StuTypeName = stuTypeList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuType)?.Name ?? "",
StuCreateByName = empList?.FirstOrDefault(qitem => qitem.Id == tempStudent.CreateBy)?.AccountName ?? "",
StuChannelName = channelList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuChannel)?.Name ?? "",
StuPurposeName = goalList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuPurpose)?.Name ?? "",
StuNeedsName = needList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuNeeds)?.Name ?? "",
item.JapanBaseInfo,
JapanBaseInfoName = item.JapanBaseInfo.ToName(),
item.StuProfession,
item.StuEducation,
StuEducationName = item.StuEducation.ToName(),
item.StuPurpose,
item.StuPurposeName,
item.VisitCount,
item.TrialLessonCount,
item.StuSourceId,
item.StuSourceIdName,
item.QQ,
item.WeChatNo,
item.StuType,
item.StuTypeName,
item.StuNeeds,
item.StuNeedsName,
item.StuRealMobile,
item.OrderCount,
item.RenewOrderCount,
item.EnterpriseName,
item.AdvisorExpectDate,
item.AdvisorStatus,
item.AdvisorStatusName,
item.AdvisorList,
item.AdvisorWinRate,
});
}
}
......@@ -1380,271 +1367,108 @@ namespace Edu.Module.User
var list = student_AppointmentRepository.GetTodayConnectPageRepository(pageIndex, pageSize, out rowsCount, Common.ConvertHelper.FormatDate(DateTime.Now), CreateBy, UserType: UserType,KeyWords:KeyWords);
if (list != null && list.Count > 0)
{
//客户阶段列表
var stageList = stageRepository.GetStageListRepostory(new Model.Entity.System.RB_Stage()
{
Group_Id = list[0].Group_Id
});
//学员类型列表
var stuTypeList = student_TypeRepository.GetStudentTypeListRepository(new RB_Student_Type_Extend());
//学习目的
var goalList = learningGoalsRepository.GetLearningGoalsListRepository(new Model.ViewModel.System.RB_LearningGoals_Extend());
//渠道列表
var channelList = channelRepository.GetChannelListRepository(new Model.ViewModel.System.RB_Channel_Extend());
//客户需求
var needList = needsRepository.GetNeedsListRepository(new Model.ViewModel.System.RB_Needs_Extend());
string stuIds = string.Join(",", list.Select(qitem => qitem.StuId));
var stuList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel() { StuIds = stuIds }, isQueryCreateType: true, isQueryAssist: false);
//协助人员列表
var assistList = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
QStuIds = stuIds
});
var stuList = GetStudentPageListModule(1, 10000, out _, new RB_Student_ViewModel() { StuIds = stuIds });
List<int> empIds = new List<int>();
//内部介绍人
List<int> stuSourceIdList = Common.ConvertHelper.StringToList(string.Join(",", stuList.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction).Select(qitem => qitem.StuSourceId)));
if (stuSourceIdList != null && stuSourceIdList.Count > 0)
{
empIds.AddRange(stuSourceIdList);
}
//协助人员
List<int> assistIdList = Common.ConvertHelper.StringToList(string.Join(",", assistList.Select(qitem => qitem.AssistId)));
if (assistIdList != null && assistIdList.Count > 0)
{
empIds.AddRange(assistIdList);
}
//跟进人员创建人
List<int> createByIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Select(qitem => qitem.CreateBy)));
if (createByIdList != null && createByIdList.Count > 0)
{
empIds.AddRange(createByIdList);
}
//学员负责人
List<int> stuCreateByList = Common.ConvertHelper.StringToList(string.Join(",", stuList.Select(qitem => qitem.CreateBy)));
if (stuCreateByList != null && stuCreateByList.Count > 0)
{
empIds.AddRange(stuCreateByList);
}
string createIds = string.Join(",", empIds);
var empList = new List<RB_Account_ViewModel>();
if (!string.IsNullOrEmpty(createIds))
{
empList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { QIds = createIds });
}
foreach (var item in list)
foreach (var aItem in list)
{
var tempEmp = empList?.FirstOrDefault(qitem => qitem.Id == item.CreateBy);
var tempStudent = stuList?.FirstOrDefault(qitem => qitem.StuId == item.StuId);
if (tempStudent != null)
{
var tempAssistList = assistList?.Where(qitem => qitem.StuId == item.StuId)?.ToList();
if (tempAssistList != null && tempAssistList.Count > 0)
{
foreach (var subItem in tempAssistList)
{
subItem.AssistName = empList?.FirstOrDefault(qitem => qitem.Id == subItem.AssistId)?.AccountName ?? "";
}
}
tempStudent.AssistList = tempAssistList;
}
var tempEmp = empList?.FirstOrDefault(qitem => qitem.Id == aItem.CreateBy);
var item = stuList?.FirstOrDefault(qitem => qitem.StuId == aItem.StuId);
result.Add(new
{
item.StuId,
item.StuName,
item.CreateBy,
CreateByName = tempEmp?.AccountName,
CreateTime = Common.ConvertHelper.FormatTime(item.CreateTime),
CreateTypeName = tempStudent?.CreateType.ToName() ?? "",
StuSourceId = tempStudent?.StuSourceId ?? 0,
StuSourceIdName = tempStudent?.StuSourceIdName ?? "",
AssistList = tempStudent?.AssistList?.Select(qitem => new
aItem.StuId,
aItem.StuName,
aItem.CreateBy,
AccountName = tempEmp?.AccountName,
CreateTime = Common.ConvertHelper.FormatTime(aItem.CreateTime),
item.StuTel,
item.StuIcon,
item.StuSex,
StuSexStr = item.StuSex == 0 ? "男" : "女",
StuBirth = Common.ConvertHelper.FormatDate(item.StuBirth),
item.StuStage,
item.StuStageName,
CreateTimeStr = Common.ConvertHelper.FormatTime(item.CreateTime),
item.CreateByName,
item.CreateType,
CreateTypeStr = item.CreateType.ToName(),
item.StuChannel,
item.StuChannelName,
item.PlatformName,
item.CustomerId,
item.CustomerName,
AssistList = item.AssistList.Select(qitem => new
{
qitem.AssistType,
AssistTypeName = qitem.AssistType.ToName(),
qitem.Id,
qitem.StuId,
qitem.AssistId,
qitem.AssistName,
}),
StuStageName = stageList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuStage)?.StageName ?? "",
StuTypeName = stuTypeList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuType)?.Name ?? "",
StuCreateByName = empList?.FirstOrDefault(qitem => qitem.Id == tempStudent.CreateBy)?.AccountName ?? "",
StuChannelName = channelList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuChannel)?.Name ?? "",
StuPurposeName = goalList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuPurpose)?.Name ?? "",
StuNeedsName = needList?.FirstOrDefault(qitem => qitem.Id == tempStudent.StuNeeds)?.Name ?? "",
});
}
}
return result;
}
/// <summary>
/// 分配给我的线索 (分配给我,但是没有跟进的线索)
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<object> GetMyClueModule(int pageIndex, int pageSize, out long rowsCount, RB_Student_ViewModel query)
{
rowsCount = 0;
List<object> result = new List<object>();
var list = studentRepository.GetStudentPageListRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
//客户阶段列表
var stageList = stageRepository.GetStageListRepostory(new Model.Entity.System.RB_Stage()
{
Group_Id = list[0].Group_Id
});
//学员类型列表
var stuTypeList = student_TypeRepository.GetStudentTypeListRepository(new RB_Student_Type_Extend());
string stuIds = string.Join(",", list.Select(qitem => qitem.StuId));
//学员跟进
var followList = followRepository.GetStudentFollowListRepository(new RB_Student_Follow_Extend()
{
QStuIds = stuIds
});
//学员订单
var stuOrderList = student_OrderGuestRepository.GetStrOrderGuestListStaticRepository(new RB_Student_OrderGuest_ViewModel()
{
QStudentIds = stuIds
});
//本周新增
var stuList = studentRepository.GetCustomerStuWeekListRepository(new RB_Student_ViewModel()
{
CustomerId = query.CustomerId
});
//协助人员列表
var assistList = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
QStuIds = stuIds
});
//内部介绍人
List<int> empIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction).Select(qitem => qitem.StuSourceId)));
List<int> aIds = Common.ConvertHelper.StringToList(string.Join(",", assistList.Select(qitem => qitem.AssistId)));
List<RB_Account_ViewModel> accountList = new List<RB_Account_ViewModel>();
if (aIds != null && aIds.Count > 0)
{
empIdList.AddRange(aIds);
}
if (empIdList != null && empIdList.Count > 0)
{
accountList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { QIds = string.Join(",", empIdList) });
}
//学员到访统计
var visitList = student_VisitRepository.GetStudentVisitStatic_V2Repository(new RB_Student_Visit_Extend()
{
QStuIds = stuIds,
StartDate = query.StartTime,
EndDate = query.EndTime,
});
//学员试听统计
var stuReserveList = visitor_ReserveRepository.GetStuReserveStaticsListRepository(new Model.ViewModel.Reserve.RB_Visitor_Reserve_Extend()
{
QVisitor_Ids = stuIds
});
//同业录入列表
List<RB_Customer_Extend> customerList = new List<RB_Customer_Extend>();
List<int> customerIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput).Select(qitem => qitem.StuSourceId)));
if (customerIdList != null && customerIdList.Count > 0)
{
customerList = customerRepository.GetCustomerListRepository(new RB_Customer_Extend()
{
CustomerIds = string.Join(",", customerIdList)
});
}
List<RB_Student_ViewModel> transStudentList = new List<RB_Student_ViewModel>();
//转介人列表
List<int> transIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction).Select(qitem => qitem.StuSourceId)));
if (transIdList != null && transIdList.Count > 0)
{
transStudentList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel()
{
StuIds = string.Join(",", transIdList)
});
}
//学习目的
string goalIds = string.Join(",", list.Select(qitem => qitem.StuPurpose));
var goalList = learningGoalsRepository.GetLearningGoalsListRepository(new Model.ViewModel.System.RB_LearningGoals_Extend()
{
QGoalIds = goalIds
});
string channelIds = string.Join(",", list.Select(qitem => qitem.StuChannel));
var channelList = channelRepository.GetChannelListRepository(new Model.ViewModel.System.RB_Channel_Extend()
{
QChannelIds = channelIds
});
var needIds = string.Join(",", list.Select(qitem => qitem.StuNeeds));
var needList = needsRepository.GetNeedsListRepository(new Model.ViewModel.System.RB_Needs_Extend()
{
QNeedsId = needIds
});
//课程顾问跟进信息
List<RB_Student_Advisor_Extend> advisorList = student_AdvisorRepository.GetStudentAdvisorListRepository(new RB_Student_Advisor_Extend() { QStuIds = stuIds });
foreach (var item in list)
{
var tempOrderList = stuOrderList?.Where(qitem => qitem.Student_Id == item.StuId)?.ToList();
var tempFollow = followList?.Where(qitem => qitem.StuId == item.StuId)?.OrderByDescending(qitem => qitem.Id)?.FirstOrDefault();
item.followUpTime = Common.ConvertHelper.FormatTime(tempFollow?.CreateTime);
item.WeekCount = stuList?.Count() ?? 0;
item.TodayCount = stuList?.Where(qitem => Common.ConvertHelper.FormatDate(qitem.CreateTime) == Common.ConvertHelper.FormatDate(DateTime.Now))?.Count() ?? 0;
item.OrderCount = tempOrderList?.Count() ?? 0;
item.RenewOrderCount = tempOrderList?.Where(qitem => qitem.RenewState == 2)?.Count() ?? 0;
item.StuGuestState = tempOrderList?.OrderByDescending(qitem => qitem.OrderId)?.LastOrDefault()?.StuGuestState ?? 0;
var tempAssistList = assistList?.Where(qitem => qitem.StuId == item.StuId)?.ToList();
foreach (var sItem in tempAssistList)
{
sItem.AssistName = accountList?.FirstOrDefault(qitem => qitem.Id == sItem.AssistId)?.AccountName ?? "";
}
item.AssistList = tempAssistList;
item.VisitCount = visitList?.FirstOrDefault(qitem => qitem.StuId == item.StuId)?.VisitCount ?? 0;
item.TrialLessonCount = stuReserveList?.FirstOrDefault(qitem => qitem.Visitor_Id == item.StuId)?.TrialLessonCount ?? 0;
if (item.CreateType == StuCreateTypeEnum.InternalIntroduction)
{
item.StuSourceIdName = accountList?.FirstOrDefault(qitem => qitem.Id == item.StuSourceId)?.AccountName ?? "";
}
else if (item.CreateType == StuCreateTypeEnum.CustomerInput)
{
var tempCustomer = customerList?.FirstOrDefault(qitem => qitem.CustomerId == item.StuSourceId);
item.StuSourceIdName = tempCustomer?.CustomerName ?? "";
if (tempCustomer != null)
{
if (tempCustomer.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.Other)
{
item.EnterpriseName = tempCustomer?.EnterpriseName ?? "";
}
else
{
item.EnterpriseName = tempCustomer?.CategoryName ?? "";
}
}
else
{
item.EnterpriseName = "";
}
}
else if (item.CreateType == StuCreateTypeEnum.TransIntroduction)
{
item.StuSourceIdName = transStudentList?.FirstOrDefault(qitem => qitem.StuId == item.StuSourceId)?.StuName ?? "";
}
item.StuStageName = stageList?.FirstOrDefault(qitem => qitem.Id == item.StuStage)?.StageName ?? "";
item.StuTypeName = stuTypeList?.FirstOrDefault(qitem => qitem.Id == item.StuType)?.Name ?? "";
item.StuChannelName = channelList?.FirstOrDefault(qitem => qitem.Id == item.StuChannel)?.Name ?? "";
item.StuPurposeName = goalList?.FirstOrDefault(qitem => qitem.Id == item.StuPurpose)?.Name ?? "";
item.StuNeedsName = needList?.FirstOrDefault(qitem => qitem.Id == item.StuNeeds)?.Name ?? "";
item.AdvisorList = advisorList?.Where(qitem => qitem.StuId == item.StuId)?.ToList() ?? new List<RB_Student_Advisor_Extend>();
qitem.AssistType,
AssistTypeName = qitem.AssistType.ToName()
}),
item.JapanBaseInfo,
JapanBaseInfoName = item.JapanBaseInfo.ToName(),
item.StuProfession,
item.StuEducation,
StuEducationName = item.StuEducation.ToName(),
item.StuPurpose,
item.StuPurposeName,
item.VisitCount,
item.TrialLessonCount,
item.StuSourceId,
item.StuSourceIdName,
item.QQ,
item.WeChatNo,
item.StuType,
item.StuTypeName,
item.StuNeeds,
item.StuNeedsName,
item.StuRealMobile,
item.OrderCount,
item.RenewOrderCount,
item.EnterpriseName,
item.AdvisorExpectDate,
item.AdvisorStatus,
item.AdvisorStatusName,
item.AdvisorList,
item.AdvisorWinRate,
});
}
}
return result;
}
/// <summary>
/// 分配给我的线索 (分配给我,但是没有跟进的线索)
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<object> GetMyClueModule(int pageIndex, int pageSize, out long rowsCount, RB_Student_ViewModel query)
{
rowsCount = 0;
List<object> result = new List<object>();
var list = GetStudentPageListModule(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
result.Add(new
{
item.StuId,
......@@ -1719,159 +1543,11 @@ namespace Edu.Module.User
{
rowsCount = 0;
List<object> result = new List<object>();
var list = studentRepository.GetStudentPageListRepository(pageIndex, pageSize, out rowsCount, query);
var list = GetStudentPageListModule(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
//客户阶段列表
var stageList = stageRepository.GetStageListRepostory(new Model.Entity.System.RB_Stage()
{
Group_Id = list[0].Group_Id
});
//学员类型列表
var stuTypeList = student_TypeRepository.GetStudentTypeListRepository(new RB_Student_Type_Extend());
string stuIds = string.Join(",", list.Select(qitem => qitem.StuId));
//学员跟进
var followList = followRepository.GetStudentFollowListRepository(new RB_Student_Follow_Extend()
{
QStuIds = stuIds
});
//学员订单
var stuOrderList = student_OrderGuestRepository.GetStrOrderGuestListStaticRepository(new RB_Student_OrderGuest_ViewModel()
{
QStudentIds = stuIds
});
//本周新增
var stuList = studentRepository.GetCustomerStuWeekListRepository(new RB_Student_ViewModel()
{
CustomerId = query.CustomerId
});
//协助人员列表
var assistList = student_AssistRepository.GetStudentAssistListRepository(new RB_Student_Assist_Extend()
{
QStuIds = stuIds
});
//内部介绍人
List<int> empIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction).Select(qitem => qitem.StuSourceId)));
List<int> aIds = Common.ConvertHelper.StringToList(string.Join(",", assistList.Select(qitem => qitem.AssistId)));
List<RB_Account_ViewModel> accountList = new List<RB_Account_ViewModel>();
if (aIds != null && aIds.Count > 0)
{
empIdList.AddRange(aIds);
}
if (empIdList != null && empIdList.Count > 0)
{
accountList = accountModule.GetAccountListExtModule(new RB_Account_ViewModel() { QIds = string.Join(",", empIdList) });
}
//学员到访统计
var visitList = student_VisitRepository.GetStudentVisitStatic_V2Repository(new RB_Student_Visit_Extend()
{
QStuIds = stuIds,
StartDate = query.StartTime,
EndDate = query.EndTime,
});
//学员试听统计
var stuReserveList = visitor_ReserveRepository.GetStuReserveStaticsListRepository(new Model.ViewModel.Reserve.RB_Visitor_Reserve_Extend()
{
QVisitor_Ids = stuIds
});
//同业录入列表
List<RB_Customer_Extend> customerList = new List<RB_Customer_Extend>();
List<int> customerIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput).Select(qitem => qitem.StuSourceId)));
if (customerIdList != null && customerIdList.Count > 0)
{
customerList = customerRepository.GetCustomerListRepository(new RB_Customer_Extend()
{
CustomerIds = string.Join(",", customerIdList)
});
}
List<RB_Student_ViewModel> transStudentList = new List<RB_Student_ViewModel>();
//转介人列表
List<int> transIdList = Common.ConvertHelper.StringToList(string.Join(",", list.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction).Select(qitem => qitem.StuSourceId)));
if (transIdList != null && transIdList.Count > 0)
{
transStudentList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel()
{
StuIds = string.Join(",", transIdList)
});
}
//学习目的
string goalIds = string.Join(",", list.Select(qitem => qitem.StuPurpose));
var goalList = learningGoalsRepository.GetLearningGoalsListRepository(new Model.ViewModel.System.RB_LearningGoals_Extend()
{
QGoalIds = goalIds
});
string channelIds = string.Join(",", list.Select(qitem => qitem.StuChannel));
var channelList = channelRepository.GetChannelListRepository(new Model.ViewModel.System.RB_Channel_Extend()
{
QChannelIds = channelIds
});
var needIds = string.Join(",", list.Select(qitem => qitem.StuNeeds));
var needList = needsRepository.GetNeedsListRepository(new Model.ViewModel.System.RB_Needs_Extend()
{
QNeedsId = needIds
});
//课程顾问跟进信息
List<RB_Student_Advisor_Extend> advisorList = student_AdvisorRepository.GetStudentAdvisorListRepository(new RB_Student_Advisor_Extend() { QStuIds = stuIds });
foreach (var item in list)
{
var tempOrderList = stuOrderList?.Where(qitem => qitem.Student_Id == item.StuId)?.ToList();
var tempFollow = followList?.Where(qitem => qitem.StuId == item.StuId)?.OrderByDescending(qitem => qitem.Id)?.FirstOrDefault();
item.followUpTime = Common.ConvertHelper.FormatTime(tempFollow?.CreateTime);
item.WeekCount = stuList?.Count() ?? 0;
item.TodayCount = stuList?.Where(qitem => Common.ConvertHelper.FormatDate(qitem.CreateTime) == Common.ConvertHelper.FormatDate(DateTime.Now))?.Count() ?? 0;
item.OrderCount = tempOrderList?.Count() ?? 0;
item.RenewOrderCount = tempOrderList?.Where(qitem => qitem.RenewState == 2)?.Count() ?? 0;
item.StuGuestState = tempOrderList?.OrderByDescending(qitem => qitem.OrderId)?.LastOrDefault()?.StuGuestState ?? 0;
var tempAssistList = assistList?.Where(qitem => qitem.StuId == item.StuId)?.ToList();
foreach (var sItem in tempAssistList)
{
sItem.AssistName = accountList?.FirstOrDefault(qitem => qitem.Id == sItem.AssistId)?.AccountName ?? "";
}
item.AssistList = tempAssistList;
item.VisitCount = visitList?.FirstOrDefault(qitem => qitem.StuId == item.StuId)?.VisitCount ?? 0;
item.TrialLessonCount = stuReserveList?.FirstOrDefault(qitem => qitem.Visitor_Id == item.StuId)?.TrialLessonCount ?? 0;
if (item.CreateType == StuCreateTypeEnum.InternalIntroduction)
{
item.StuSourceIdName = accountList?.FirstOrDefault(qitem => qitem.Id == item.StuSourceId)?.AccountName ?? "";
}
else if (item.CreateType == StuCreateTypeEnum.CustomerInput)
{
var tempCustomer = customerList?.FirstOrDefault(qitem => qitem.CustomerId == item.StuSourceId);
item.StuSourceIdName = tempCustomer?.CustomerName ?? "";
if (tempCustomer != null)
{
if (tempCustomer.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.Other)
{
item.EnterpriseName = tempCustomer?.EnterpriseName ?? "";
}
else
{
item.EnterpriseName = tempCustomer?.CategoryName ?? "";
}
}
else
{
item.EnterpriseName = "";
}
}
else if (item.CreateType == StuCreateTypeEnum.TransIntroduction)
{
item.StuSourceIdName = transStudentList?.FirstOrDefault(qitem => qitem.StuId == item.StuSourceId)?.StuName ?? "";
}
item.StuStageName = stageList?.FirstOrDefault(qitem => qitem.Id == item.StuStage)?.StageName ?? "";
item.StuTypeName = stuTypeList?.FirstOrDefault(qitem => qitem.Id == item.StuType)?.Name ?? "";
item.StuChannelName = channelList?.FirstOrDefault(qitem => qitem.Id == item.StuChannel)?.Name ?? "";
item.StuPurposeName = goalList?.FirstOrDefault(qitem => qitem.Id == item.StuPurpose)?.Name ?? "";
item.StuNeedsName = needList?.FirstOrDefault(qitem => qitem.Id == item.StuNeeds)?.Name ?? "";
item.AdvisorList = advisorList?.Where(qitem => qitem.StuId == item.StuId)?.ToList() ?? new List<RB_Student_Advisor_Extend>();
{
result.Add(new
{
item.StuId,
......@@ -2055,6 +1731,12 @@ namespace Edu.Module.User
{
empIds.AddRange(courseConsultantIdList);
}
//协助老师
List<int> HelpEnterIdList = Common.ConvertHelper.StringToList(string.Join(",", orderList.Select(qitem => qitem.HelpEnterId)));
if (HelpEnterIdList != null && HelpEnterIdList.Count > 0)
{
empIds.AddRange(HelpEnterIdList);
}
string createIds = string.Join(",", empIds);
var empList = new List<RB_Account_ViewModel>();
if (!string.IsNullOrEmpty(createIds))
......@@ -2125,43 +1807,25 @@ namespace Edu.Module.User
result.Add(new
{
item.TeacherName,
item.ClassName,
item.OrderId,
item.ClassId,
item.ClassNo,
item.OrderType,
item.SourceId,
item.ClassSchoolId,
item.SchoolName,
SaleRemarkList = item?.SaleRemarkList.Select(qitem => new
{
qitem.Content,
qitem.CreateByName,
CreateTime = Common.ConvertHelper.FormatTime(qitem.CreateTime)
}),
GuestList = item?.GuestList.Select(qitem => new {
qitem.Id,
qitem.GuestName,
qitem.ClassName,
qitem.ClassNo,
qitem.CourseName,
qitem.GuestState,
qitem.GuestStateStr,
qitem.ContractId,
qitem.ContractStatusStr,
qitem.ContractNo,
qitem.TotalHours,
qitem.CompleteHours,
qitem.ValidClassHours,
}),
item.ClassName,
OpenTime = Common.ConvertHelper.FormatDate(item.OpenTime),
item.JoinType,
JoinTypeName = item.JoinType.ToName(),
item.TargetJoinType,
TargetJoinTypeName = item.TargetJoinType.ToName(),
item.SourceOrderId,
item.SourceClassName,
item.TargetOrderId,
item.TargetClassName,
item.StartClassHours,
item.CourseName,
item.CourseImg,
item.CourseSubject,
item.CourseSubjectName,
item.B2BBackground,
item.B2BIcon,
item.ClassScrollType,
item.StuSourceIdName,
item.CategoryId,
item.OrderId,
item.ClassId,
item.TradeWay,
item.Class_Price,
item.Unit_Price,
item.GuestNum,
......@@ -2169,23 +1833,157 @@ namespace Edu.Module.User
item.Income,
item.Refund,
item.DiscountMoney,
item.PerDiscountMoney,
item.PlatformTax,
DueInMoney = item.PreferPrice - (item.Income - item.Refund + item.PlatformTax + item.DiscountMoney),
item.OrderState,
OrderStateName=item.OrderState.ToName(),
item.SaleRemark,
OrderStateName = item.OrderState.ToName(),
item.OrderSource,
OrderSourceName = item.OrderSource.ToName(),
item.EnterID,
EnterIDName=empList?.FirstOrDefault(qitem=>qitem.Id==item.EnterID)?.AccountName??"",
EnterName = empList?.FirstOrDefault(qitem=>qitem.Id==item.EnterID)?.AccountName??"",
item.CreateBy,
CreateByName = empList?.FirstOrDefault(qitem => qitem.Id == item.CreateBy)?.AccountName ?? "",
item.CourseConsultantId,
CourseConsultantIdName = empList?.FirstOrDefault(qitem => qitem.Id == item.CourseConsultantId)?.AccountName ?? "",
ConsultantName = empList?.FirstOrDefault(qitem => qitem.Id == item.CourseConsultantId)?.AccountName ?? "",
IsAchievements = item.YFCommission > 0 ? 1 : 2,
YFCommissionMoney = item.YFCommission > 0 ? item.YFCommission : GetOrderYFCommission(item),
item.CommissionMoney,
item.ExtraCommissionMoney,
item.ExtraRewardMoney,
item.ExtraDeductMoney,
IsCommissionGive = item.YFCommission > 0 ? 1 : item.IsCommissionGive,
item.CommissionBack,
CreateTime = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
SaleRemark = item?.SaleRemark ?? "",
TeacherRemark = item?.TeacherRemark ?? "",
RectorRemark = item?.RectorRemark ?? "",
DirectorRemark = item?.DirectorRemark ?? "",
item.OfferId,
item.HelpEnterId,
HelpEnterName = empList?.FirstOrDefault(qitem => qitem.Id == item.HelpEnterId)?.AccountName ?? "",
item.GeneralOccupation,
item.EduOccupation,
item.IsLessPrice,
item.LessPrice,
item.OrderNature,
OrderNatureName = item.OrderNature.ToName(),
item.OldPreferPrice,
item.EffectStatus,
item.EffectStatusStr,
EffectTime = Common.ConvertHelper.FormatDate(item.EffectTime),
item.UpOrderId,
item.VisitorReserveId,
item.RenewOrderId,
item.FirstOrderId,
item.IsBackClass,
item.CourseSubject,
item.CourseSubjectName,
item.CustomerId,
item.CustomerName,
item.CustomerTel,
item.ClassScrollType,
SplitDetailsList = item?.SplitDetailsList?.Select(qitem => new
{
qitem.S_ClassId,
qitem.S_ClassName,
qitem.S_JoinType,
S_JoinTypeName = qitem.S_JoinType.ToName(),
qitem.S_OrderId,
qitem.T_ClassId,
qitem.T_ClassName,
qitem.T_JoinType,
T_JoinTypeName = qitem.T_JoinType.ToName(),
qitem.T_OrderId
}),
SaleRemarkList = item?.SaleRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = z.CreateByName,
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
TeacherRemarkList = item?.TeacherRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = z.CreateByName,
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
RectorRemarkList = item?.RectorRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = z.CreateByName,
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
DirectorRemarkList = item?.DirectorRemarkList.Select(z => new
{
z.Id,
z.Content,
CreateBy = z.CreateByName,
CreateTime = z.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
}),
GuestList = item?.GuestList.Select(z => new
{
z.Id,
z.GuestName,
z.GuestState,
z.ContractId,
z.ContractNo,
z.ContractStatus,
z.ContractStatusStr,
z.GuestStateStr,
z.GuestContractNo,
z.ContractType,
z.ContractUrl,
z.ContractUrlList,
}),
ContractList = item?.ContractList.Select(z => new
{
z.Id,
z.StudentName,
z.ContractNo,
z.GuestId,
z.Status,
}),
item.CreateType,
CreateTypeName = item.CreateType.ToName(),
item.StuSourceIdName,
item.BrokerageMoney
});
}
}
return result;
}
/// <summary>
/// 获取订单应发提成
/// </summary>
/// <param name="x"></param>
/// <returns></returns>
private static decimal GetOrderYFCommission(RB_Order_ViewModel x)
{
if (x.CommissionType == x.CommissionTypeTH)
{
if (x.CommissionType == 1)
{
return x.CommissionRate + x.CommissionRateTH - x.LessPrice;
}
else
{
return Math.Round((x.PreferPrice - x.DiscountMoney + x.LessPrice) * (x.CommissionRate + x.CommissionRateTH) / 100, 2, MidpointRounding.AwayFromZero) - x.LessPrice;
}
}
else
{
decimal commission1 = x.CommissionType == 1 ? x.CommissionRate : Math.Round((x.PreferPrice - x.DiscountMoney + x.LessPrice) * x.CommissionRate / 100, 2, MidpointRounding.AwayFromZero);
decimal commission2 = x.CommissionTypeTH == 1 ? x.CommissionRateTH : Math.Round((x.PreferPrice - x.DiscountMoney + x.LessPrice) * x.CommissionRateTH / 100, 2, MidpointRounding.AwayFromZero);
return commission1 + commission2 - x.LessPrice;
}
}
/// <summary>
/// 今日被跟进学员(被跟进的学员所有协助人可见)
/// </summary>
......
......@@ -299,6 +299,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.StuId), query.StuId);
}
if (!string.IsNullOrEmpty(query.StuIds))
{
builder.AppendFormat(" AND t.{0} IN({1}) ", nameof(RB_Student_ViewModel.StuId), query.StuIds);
}
if (!string.IsNullOrWhiteSpace(query.StuName))
{
builder.AppendFormat(" AND t.{0} LIKE @StuName ", nameof(RB_Student_ViewModel.StuName));
......
......@@ -3419,7 +3419,7 @@ namespace Edu.WebApi.Controllers.User
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var userId = 0;
//userId = base.UserInfo.Id;
userId = base.UserInfo.Id;
var query = new RB_Student_OrderGuest_ViewModel()
{
IsNotContract = 1,
......
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