Commit d53d0f91 authored by 黄奎's avatar 黄奎

页面修改

parent 9d144dc5
......@@ -15,6 +15,7 @@ using VT.FW.DB;
using Edu.Common.Enum;
using Edu.Repository.System;
using Edu.Model.ViewModel.System;
using Edu.Common.Enum.User;
namespace Edu.Module.Customer
{
......@@ -78,6 +79,11 @@ namespace Edu.Module.Customer
/// </summary>
private readonly RB_ChannelRepository channelRepository = new RB_ChannelRepository();
/// <summary>
/// 同行列表
/// </summary>
private readonly RB_CustomerRepository customerRepository = new RB_CustomerRepository();
/// <summary>
/// 清除数据
/// </summary>
......@@ -609,7 +615,7 @@ namespace Edu.Module.Customer
}
dayList.Add(tempObj);
}
var yesDataList = lastList?.Where(qitem =>qitem.Date.Year== end.AddDays(-1).Year && qitem.Date.Month== end.AddDays(-1).Month)?.ToList();
var yesDataList = lastList?.Where(qitem => qitem.Date.Year == end.AddDays(-1).Year && qitem.Date.Month == end.AddDays(-1).Month)?.ToList();
obj = new
{
dayList,
......@@ -674,11 +680,11 @@ namespace Edu.Module.Customer
QCreateByIds = EmpIds
});
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 =>qitem.Date.Year== end.AddDays(-1).Year && qitem.Date.Month== end.AddDays(-1).Month )?.ToList();
var yesDataList = lastList?.Where(qitem => qitem.Date.Year == end.AddDays(-1).Year && qitem.Date.Month == end.AddDays(-1).Month)?.ToList();
obj = new
{
DayStr = Common.ConvertHelper.FormatMonthDay(end.AddDays(-1)),
WeekStr=Common.Plugin.StringHelper.GetWeek(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,
......@@ -721,8 +727,8 @@ namespace Edu.Module.Customer
CurMonthOrderSale = yesDataList?.Sum(qitem => qitem.CurMonthOrderSale) ?? 0,
LastMonthOrderSale= yesDataList?.Sum(qitem => qitem.LastMonthOrderSale) ?? 0,
CurMonthOrderGoal = consultantGoal?.GoalMoney??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,
......@@ -750,7 +756,7 @@ namespace Edu.Module.Customer
string deptIds = string.Join(",", list.Select(qitem => qitem.Dept_Id));
if (!string.IsNullOrEmpty(deptIds))
{
deptList= departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel()
deptList = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel()
{
QDeptIds = deptIds
});
......@@ -874,7 +880,7 @@ namespace Edu.Module.Customer
/// 市场部渠道数据统计
/// </summary>
/// <returns></returns>
public List<object> MarketChannelStaticModule(string StartTime, string EndTime)
public List<object> MarketChannelStudentStaticModule(string StartTime, string EndTime)
{
List<object> list = new List<object>();
var empList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel()
......@@ -895,22 +901,83 @@ namespace Edu.Module.Customer
foreach (var eItem in empList)
{
List<object> subList = new List<object>();
var tempList = dataList?.Where(qitem => qitem.CreateBy == eItem.Id)?.ToList();
//包含的数据
string singleIds = "";
if (channelList != null && channelList.Count > 0)
{
foreach (var item in channelList)
{
var tempList = dataList?.Where(qitem => qitem.CreateBy == eItem.Id && qitem.StuChannel == item.Id)?.ToList();
if (item.StaticTypeList != null && item.StaticTypeList.Contains("1"))
{
singleIds += "," + item.Id;
var channelTempList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && qitem.StuChannel == item.Id)?.ToList();
subList.Add(new
{
ChannelName = item.Name,
ChannelId = item.Id,
ClueCount= tempList?.Count(),
VisitCount= tempList?.Sum(qitem=>qitem.VisitCount),
OrderCount= tempList?.Sum(qitem=>qitem.OrderCount),
OrderIncome = tempList?.Sum(qitem=>qitem.OrderIncome)
ClueCount = channelTempList?.Count(),
VisitCount = channelTempList?.Sum(qitem => qitem.VisitCount),
OrderCount = channelTempList?.Sum(qitem => qitem.OrderCount),
OrderIncome = channelTempList?.Sum(qitem => qitem.OrderIncome)
});
}
}
}
var customerList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput)?.ToList();
subList.Add(new
{
ChannelName = "同行介绍",
ChannelId = 10001,
ClueCount = customerList?.Count(),
VisitCount = customerList?.Sum(qitem => qitem.VisitCount),
OrderCount = customerList?.Sum(qitem => qitem.OrderCount),
OrderIncome = customerList?.Sum(qitem => qitem.OrderIncome)
});
var innerList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction)?.ToList();
subList.Add(new
{
ChannelName = "内部介绍",
ChannelId = 10002,
ClueCount = innerList?.Count(),
VisitCount = innerList?.Sum(qitem => qitem.VisitCount),
OrderCount = innerList?.Sum(qitem => qitem.OrderCount),
OrderIncome = innerList?.Sum(qitem => qitem.OrderIncome)
});
var transList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction)?.ToList();
subList.Add(new
{
ChannelName = "学员转介绍",
ChannelId = 10003,
ClueCount = transList?.Count(),
VisitCount = transList?.Sum(qitem => qitem.VisitCount),
OrderCount = transList?.Sum(qitem => qitem.OrderCount),
OrderIncome = transList?.Sum(qitem => qitem.OrderIncome)
});
var otherList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && !singleIds.Contains(qitem.StuChannel.ToString()))?.ToList();
subList.Add(new
{
ChannelName = "其他",
ChannelId = 10004,
ClueCount = otherList?.Count(),
VisitCount = otherList?.Sum(qitem => qitem.VisitCount),
OrderCount = otherList?.Sum(qitem => qitem.OrderCount),
OrderIncome = otherList?.Sum(qitem => qitem.OrderIncome)
});
subList.Add(new
{
ChannelName = "合计",
ChannelId = 10005,
ClueCount = tempList?.Count(),
VisitCount = tempList?.Sum(qitem => qitem.VisitCount),
OrderCount = tempList?.Sum(qitem => qitem.OrderCount),
OrderIncome = tempList?.Sum(qitem => qitem.OrderIncome)
});
list.Add(new
{
eItem.Id,
......@@ -922,6 +989,114 @@ namespace Edu.Module.Customer
return list;
}
/// <summary>
/// 市场部学员创建类型统计
/// </summary>
/// <param name="StartTime"></param>
/// <param name="EndTime"></param>
/// <returns></returns>
public object MarketCreateTypeStaticModule(string StartTime, string EndTime)
{
var dataList = studentRepository.GetStudentChannelStaticRepository(new RB_Student_ViewModel()
{
StartTime = StartTime,
EndTime = EndTime
});
var enumList = Common.Plugin.EnumHelper.EnumToList(typeof(StuCreateTypeEnum));
List<object> customerDataList = new List<object>();
List<object> innerDataList = new List<object>();
List<object> transDataList = new List<object>();
foreach (var item in enumList)
{
if (item.Id == (int)StuCreateTypeEnum.EmployeeInput)
{
}
else if (item.Id == (int)StuCreateTypeEnum.CustomerInput)
{
var cusIds = string.Join(",", dataList.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput).Select(qitem => qitem.StuSourceId));
List<RB_Customer_Extend> customerList = new List<RB_Customer_Extend>();
if (!string.IsNullOrEmpty(cusIds))
{
customerList= customerRepository.GetCustomerListRepository(new RB_Customer_Extend() { CustomerIds = cusIds });
}
var groupDataList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput)
?.GroupBy(qitem => new { qitem.StuSourceId })
?.Select(qitem => new { qitem.Key.StuSourceId });
foreach (var sItem in groupDataList)
{
var tempCusList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput && qitem.StuSourceId == sItem.StuSourceId)?.ToList();
customerDataList.Add(new
{
ChannelName = customerList?.FirstOrDefault(qitem=>qitem.CustomerId==sItem.StuSourceId)?.CustomerName??"",
StuSourceId = sItem.StuSourceId,
ClueCount = tempCusList?.Count(),
VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount),
OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount),
OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome)
});
}
}
else if (item.Id == (int)StuCreateTypeEnum.InternalIntroduction)
{
var empIds = string.Join(",", dataList.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction).Select(qitem => qitem.StuSourceId));
List<Employee_ViewModel> empList = new List<Employee_ViewModel>();
if (!string.IsNullOrEmpty(empIds))
{
empList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { QIds = empIds });
}
var groupDataList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction)
?.GroupBy(qitem => new { qitem.StuSourceId })
?.Select(qitem => new { qitem.Key.StuSourceId });
foreach (var sItem in groupDataList)
{
var tempCusList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput && qitem.StuSourceId == sItem.StuSourceId)?.ToList();
innerDataList.Add(new
{
ChannelName = empList?.FirstOrDefault(qitem => qitem.Id == sItem.StuSourceId)?.EmployeeName ?? "",
StuSourceId = sItem.StuSourceId,
ClueCount = tempCusList?.Count(),
VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount),
OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount),
OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome)
});
}
}
else
{
var stuIds = string.Join(",", dataList.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction).Select(qitem => qitem.StuSourceId));
List<RB_Student_ViewModel> stuList = new List<RB_Student_ViewModel>();
if (!string.IsNullOrEmpty(stuIds))
{
stuList = studentRepository.GetStudentListRepository(new RB_Student_ViewModel() { StuIds= stuIds });
}
var groupDataList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction)
?.GroupBy(qitem => new { qitem.StuSourceId })
?.Select(qitem => new { qitem.Key.StuSourceId });
foreach (var sItem in groupDataList)
{
var tempCusList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction && qitem.StuSourceId == sItem.StuSourceId)?.ToList();
transDataList.Add(new
{
ChannelName = stuList?.FirstOrDefault(qitem => qitem.StuId == sItem.StuSourceId)?.StuName ?? "",
StuSourceId = sItem.StuSourceId,
ClueCount = tempCusList?.Count(),
VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount),
OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount),
OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome)
});
}
}
}
return new {
customerDataList,
innerDataList,
transDataList,
};
}
#endregion
}
}
\ No newline at end of file
......@@ -941,6 +941,7 @@ WHERE 1=1
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.StuId,A.CreateBy,A.StuChannel,A.CreateType,IFNULL(B.VisitCount,0) AS VisitCount,IFNULL(C.CourseOrderCount,0) AS OrderCount,IFNULL(c.Income,0) AS OrderInCome
,A.CustomerId,A.StuSourceId
FROM RB_Student AS A
LEFT JOIN(SELECT StuId,Count(1) AS VisitCount FROM rb_student_visit WHERE Status=0 GROUP BY StuId) AS B ON A.StuId=B.StuId
LEFT JOIN(SELECT og.Student_Id,COUNT(1) AS CourseOrderCount,SUM(o.Income) AS Income FROM rb_student_orderguest AS og INNER JOIN rb_order AS o ON og.OrderId=o.OrderId WHERE O.OrderState NOT IN(3,4) GROUP BY og.Student_Id ) AS C ON A.StuId=C.Student_Id
......@@ -964,6 +965,5 @@ WHERE A.Status=0
var list = Get<RB_Student_ViewModel>(builder.ToString()).ToList();
return list;
}
}
}
\ No newline at end of file
......@@ -2762,7 +2762,7 @@ namespace Edu.WebApi.Controllers.User
/// <summary>
/// 市场渠道统计
/// 市场渠道月薪统计
/// </summary>
/// <returns></returns>
[HttpPost]
......@@ -2790,7 +2790,40 @@ namespace Edu.WebApi.Controllers.User
{
qEmpIds = string.Join(",", empList);
}
var data = marketConsultantModule.MarketChannelStaticModule(startTime, endTime);
var data = marketConsultantModule.MarketChannelStudentStaticModule(startTime, endTime);
return ApiResult.Success(data: data);
}
/// <summary>
/// 市场渠道统计
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowRepeatAttribute]
public ApiResult MarketCreateType()
{
string startTime = base.ParmJObj.GetStringValue("startTime");
if (string.IsNullOrEmpty(startTime))
{
startTime = "2022-01-01";
}
string endTime = base.ParmJObj.GetStringValue("endTime");
if (string.IsNullOrEmpty(endTime))
{
endTime = Common.ConvertHelper.FormatDate(DateTime.Now);
}
string empIds = base.ParmJObj.GetStringValue("empList");
List<int> empList = new List<int>();
if (!string.IsNullOrEmpty(empIds))
{
empList = JsonHelper.DeserializeObject<List<int>>(empIds);
}
string qEmpIds = "";
if (empList != null && empList.Count > 0)
{
qEmpIds = string.Join(",", empList);
}
var data = marketConsultantModule.MarketCreateTypeStaticModule(startTime, endTime);
return ApiResult.Success(data: data);
}
......
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