Commit 4dcf5214 authored by liudong1993's avatar liudong1993

1

parent 220519c2
using Edu.AOP.CustomerAttribute;
using Edu.Common.Enum;
using Edu.Common.Enum.System;
using Edu.Common.Enum.User;
using Edu.Common.Plugin;
using Edu.Model.CacheModel;
using Edu.Model.ViewModel.Customer;
using Edu.Model.ViewModel.Mall;
using Edu.Model.ViewModel.User;
using Edu.Repository.Customer;
using Edu.Repository.Mall;
using Edu.Repository.Reserve;
using Edu.Repository.System;
using Edu.Repository.User;
using System;
using System.Collections.Generic;
using System.Linq;
using VT.FW.DB;
namespace Edu.Module.User
{
/// <summary>
/// 学生统计处理类
/// </summary>
public class StudentStatModule
{
/// <summary>
/// 学生仓储层对象
/// </summary>
private readonly RB_StudentRepository studentRepository = new RB_StudentRepository();
/// <summary>
/// 学员订单关联表仓储层
/// </summary>
private readonly RB_Student_OrderGuestRepository student_OrderGuestRepository = new RB_Student_OrderGuestRepository();
/// <summary>
/// 学员跟进
/// </summary>
private readonly RB_Student_FollowRepository followRepository = new RB_Student_FollowRepository();
#region 学员跟进
/// <summary>
/// 学员跟进分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public object GetStudentFollowUpPageList(int pageIndex, int pageSize, out long count, RB_Student_ViewModel demodel)
{
object Robj = new object();
var slist = student_OrderGuestRepository.GetStudentFollowUpPageList(pageIndex, pageSize, out count, demodel);
if (slist.Any()) {
string stuIds = string.Join(",", slist.Select(x => x.StuId));
//查询学生每月的跟进情况
var flist = followRepository.GetStudentFollowUpMonthList(stuIds, demodel.Group_Id);
//查询续课 学员介绍
var xlist = followRepository.GetStudentRenewMonthList(stuIds, demodel.Group_Id);//续费
var zlist = followRepository.GetStudentIntroductionMonthList(stuIds, demodel.Group_Id);//转介绍
//查询汇总数据
var TotalData = student_OrderGuestRepository.GetStudentFollowUpStat(demodel);
List<object> RList = new List<object>();
foreach (var item in slist) {
//组合所有的月份
var MonthList = flist.Where(x => x.StuId == item.StuId).Select(x => x.MonthStr).ToList();
MonthList.AddRange(xlist.Where(x => x.StuId == item.StuId).Select(x => x.MonthStr).ToList());
MonthList.AddRange(zlist.Where(x => x.StuId == item.StuId).Select(x => x.MonthStr).ToList());
MonthList = MonthList.Distinct().OrderBy(x => x).ToList();
List<object> MonthObjList = new List<object>();
foreach (var month in MonthList) {
var xmodel = xlist.Where(x => x.StuId == item.StuId && x.MonthStr == month).FirstOrDefault();
var zmodel = zlist.Where(x => x.StuId == item.StuId && x.MonthStr == month).FirstOrDefault();
var teacherModel = flist.Where(x => x.StuId == item.StuId && x.MonthStr == month && x.AssistType == AssistTypeEnum.Teacher).FirstOrDefault();
var consultantModel = flist.Where(x => x.StuId == item.StuId && x.MonthStr == month && x.AssistType == AssistTypeEnum.CourseAdviser).FirstOrDefault();
MonthObjList.Add(new
{
Month = month,
IsRenew = xmodel != null ? 1 : 2,
IntroductionNum = zmodel?.StuNum ?? 0,
Teacher = teacherModel?.Remark ?? "",
TeacherTime = teacherModel?.CreateTime.ToString("yyyy-MM-dd HH:mm") ?? "",
Consultant = consultantModel?.Remark ?? "",
ConsultantTime = consultantModel?.CreateTime.ToString("yyyy-MM-dd HH:mm") ?? ""
});
}
var StuObj = new
{
item.StuId,
item.StuName,
item.StuTel,
item.StuRealMobile,
ContractSTime = item.followUpTime,
item.CourseName,
JapanBaseInfo = item.JapanBaseInfo.ToName(),
item.StuBirthStr,
item.StuGuestState,
StuGuestStateName = item.StuGuestState.ToName(),
MonthList = MonthObjList
};
RList.Add(StuObj);
}
Robj = new
{
RList,
Stat = new
{
StuTNum = TotalData.OrderCount,
RenewNum = TotalData.RenewOrderCount,
NewNum = TotalData.OrderCount - TotalData.RenewOrderCount,
TotalData.StudyNum,
TotalData.GraduateNum,
TotalData.SuspendNum,
TotalData.DropOutNum
}
};
}
return Robj;
}
#endregion
#region 客人咨询
/// <summary>
/// 获取客人咨询分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public object GetStudentConsultPageList(int pageIndex, int pageSize, out long count, RB_Student_ViewModel demodel)
{
List<object> RList = new List<object>();
var slist = student_OrderGuestRepository.GetStudentConsultPageList(pageIndex, pageSize, out count, demodel);
if (slist.Any()) {
string stuIds = string.Join(",", slist.Select(x => x.StuId));
//查询学员最近的一条跟进记录
var flist = followRepository.GetStudentFollowUpLatelyList(stuIds, demodel.Group_Id);
foreach (var item in slist) {
var fmodel = flist.Where(x => x.StuId == item.StuId).FirstOrDefault();
RList.Add(new
{
item.StuId,
item.StuName,
item.StuBirthStr,
item.StuTel,
item.StuRealMobile,
item.StuAddress,
item.StuChannelName,
EnrollState = item.Q_EnrollState,
item.CourseId,
item.CourseName,
ConsultDate = item.ConsultDate.HasValue ? item.ConsultDate.Value.ToString("yyyy-MM-dd") : "",
item.PlanPrice,
item.BaseCondition,
item.DemandPoint,
item.ResistPoint,
item.ConsultingResults,
JapanBaseInfo = item.JapanBaseInfo.ToName(),
FUTime = fmodel?.CreateTime.ToString("yyyy-MM-dd HH:mm") ?? "",
FURemark = fmodel?.Remark ?? ""
});
}
}
return RList;
}
#endregion
}
}
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