Commit acacf5c4 authored by liudong1993's avatar liudong1993

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

parents 1bf38c90 21b9b640
...@@ -17,6 +17,8 @@ using Edu.Repository.System; ...@@ -17,6 +17,8 @@ using Edu.Repository.System;
using Edu.Model.ViewModel.System; using Edu.Model.ViewModel.System;
using Edu.Common.Enum.User; using Edu.Common.Enum.User;
using Edu.Common.Plugin; using Edu.Common.Plugin;
using Newtonsoft.Json.Linq;
using System.Dynamic;
namespace Edu.Module.Customer namespace Edu.Module.Customer
{ {
...@@ -1020,7 +1022,7 @@ namespace Edu.Module.Customer ...@@ -1020,7 +1022,7 @@ namespace Edu.Module.Customer
}); });
foreach (var eItem in empList) foreach (var eItem in empList)
{ {
List<object> subList = new List<object>(); List<MarketChannelStaticModel> subList = new List<MarketChannelStaticModel>();
var tempList = dataList?.Where(qitem => qitem.CreateBy == eItem.Id)?.ToList(); var tempList = dataList?.Where(qitem => qitem.CreateBy == eItem.Id)?.ToList();
//包含的数据 //包含的数据
string singleIds = ""; string singleIds = "";
...@@ -1037,77 +1039,97 @@ namespace Edu.Module.Customer ...@@ -1037,77 +1039,97 @@ namespace Edu.Module.Customer
{ {
singleIds += "," + item.Id; singleIds += "," + item.Id;
var channelTempList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && qitem.StuChannel == item.Id)?.ToList(); var channelTempList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && qitem.StuChannel == item.Id)?.ToList();
subList.Add(new subList.Add(new MarketChannelStaticModel()
{ {
ChannelName = item.Name, ChannelName = item.Name,
ChannelId = item.Id, ChannelId = item.Id,
ClueCount = channelTempList?.Count(), ClueCount = channelTempList?.Count()??0,
VisitCount = channelTempList?.Sum(qitem => qitem.VisitCount), VisitCount = channelTempList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = channelTempList?.Sum(qitem => qitem.OrderCount), OrderCount = channelTempList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = channelTempList?.Sum(qitem => qitem.OrderIncome) OrderIncome = channelTempList?.Sum(qitem => qitem.OrderIncome)??0
}); });
} }
} }
} }
var customerList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput)?.ToList(); var customerList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.CustomerInput)?.ToList();
subList.Add(new subList.Add(new MarketChannelStaticModel()
{ {
ChannelName = "同行介绍", ChannelName = "同行介绍",
ChannelId = 10001, ChannelId = 10001,
ClueCount = customerList?.Count(), ClueCount = customerList?.Count()??0,
VisitCount = customerList?.Sum(qitem => qitem.VisitCount), VisitCount = customerList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = customerList?.Sum(qitem => qitem.OrderCount), OrderCount = customerList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = customerList?.Sum(qitem => qitem.OrderIncome) OrderIncome = customerList?.Sum(qitem => qitem.OrderIncome)??0
}); });
var innerList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction)?.ToList(); var innerList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction)?.ToList();
subList.Add(new subList.Add(new MarketChannelStaticModel()
{ {
ChannelName = "内部介绍", ChannelName = "内部介绍",
ChannelId = 10002, ChannelId = 10002,
ClueCount = innerList?.Count(), ClueCount = innerList?.Count()??0,
VisitCount = innerList?.Sum(qitem => qitem.VisitCount), VisitCount = innerList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = innerList?.Sum(qitem => qitem.OrderCount), OrderCount = innerList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = innerList?.Sum(qitem => qitem.OrderIncome) OrderIncome = innerList?.Sum(qitem => qitem.OrderIncome)??0
}); });
var transList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction)?.ToList(); var transList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction)?.ToList();
subList.Add(new subList.Add(new MarketChannelStaticModel()
{ {
ChannelName = "学员转介绍", ChannelName = "学员转介绍",
ChannelId = 10003, ChannelId = 10003,
ClueCount = transList?.Count(), ClueCount = transList?.Count()??0,
VisitCount = transList?.Sum(qitem => qitem.VisitCount), VisitCount = transList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = transList?.Sum(qitem => qitem.OrderCount), OrderCount = transList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = transList?.Sum(qitem => qitem.OrderIncome) OrderIncome = transList?.Sum(qitem => qitem.OrderIncome)??0
}); });
var otherList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && !singleIds.Contains(qitem.StuChannel.ToString()))?.ToList(); var otherList = tempList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && !singleIds.Contains(qitem.StuChannel.ToString()))?.ToList();
subList.Add(new subList.Add(new MarketChannelStaticModel()
{ {
ChannelName = "其他", ChannelName = "其他",
ChannelId = 10004, ChannelId = 10004,
ClueCount = otherList?.Count(), ClueCount = otherList?.Count()??0,
VisitCount = otherList?.Sum(qitem => qitem.VisitCount), VisitCount = otherList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = otherList?.Sum(qitem => qitem.OrderCount), OrderCount = otherList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = otherList?.Sum(qitem => qitem.OrderIncome) OrderIncome = otherList?.Sum(qitem => qitem.OrderIncome)??0
}); });
subList.Add(new subList.Add(new MarketChannelStaticModel()
{ {
ChannelName = "合计", ChannelName = "合计",
ChannelId = 10005, ChannelId = 10005,
ClueCount = tempList?.Count(), ClueCount = tempList?.Count()??0,
VisitCount = tempList?.Sum(qitem => qitem.VisitCount), VisitCount = tempList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = tempList?.Sum(qitem => qitem.OrderCount), OrderCount = tempList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = tempList?.Sum(qitem => qitem.OrderIncome) OrderIncome = tempList?.Sum(qitem => qitem.OrderIncome)??0
}); });
list.Add(new Dictionary<string, object> dicList = new Dictionary<string, object>();
for (var i = 0; i < subList.Count; i++)
{ {
if (i == 0)
{
dicList.Add(string.Format("Id"), eItem.Id);
dicList.Add(string.Format("EmployeeName"), eItem.EmployeeName);
}
decimal rate = 0;
if (subList[i].ClueCount > 0)
{
rate = Math.Round(Convert.ToDecimal(subList[i].VisitCount) / Convert.ToDecimal(subList[i].ClueCount) * Convert.ToDecimal(100), 2);
}
dicList.Add(string.Format("ChannelName{0}", i), subList[i].ChannelName);
dicList.Add(string.Format("ClueCount{0}", i), subList[i].ClueCount);
dicList.Add(string.Format("VisitCount{0}", i), subList[i].VisitCount);
dicList.Add(string.Format("Rates{0}", i), rate+"%");
}
list.Add(new {
eItem.Id, eItem.Id,
eItem.EmployeeName, eItem.EmployeeName,
subList dicList,
subList,
}); });
} }
} }
......
...@@ -968,7 +968,11 @@ WHERE A.Status=0 ...@@ -968,7 +968,11 @@ WHERE A.Status=0
} }
if (query.CreateIds != null && query.CreateIds.Count > 0) if (query.CreateIds != null && query.CreateIds.Count > 0)
{ {
builder.AppendFormat(" AND A.{0} IN({0}) ", nameof(RB_Student_ViewModel.CreateBy), string.Join(",", query.CreateIds)); string str = string.Join(",", query.CreateIds);
if (!string.IsNullOrEmpty(str))
{
builder.AppendFormat(" AND A.{0} IN({0}) ", nameof(RB_Student_ViewModel.CreateBy), str);
}
} }
} }
var list = Get<RB_Student_ViewModel>(builder.ToString()).ToList(); var list = Get<RB_Student_ViewModel>(builder.ToString()).ToList();
......
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