Commit 934d0810 authored by 黄奎's avatar 黄奎

页面修改

parent eeae4f19
using System; using Edu.Common.Enum.Customer;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
...@@ -38,5 +39,10 @@ namespace Edu.Model.ViewModel.DataStatistics ...@@ -38,5 +39,10 @@ namespace Edu.Model.ViewModel.DataStatistics
/// 订单业绩金额 /// 订单业绩金额
/// </summary> /// </summary>
public decimal OrderIncome { get; set; } public decimal OrderIncome { get; set; }
/// <summary>
/// 客户类型
/// </summary>
public CatetoryTypeEnum CustomerType { get; set; }
} }
} }
...@@ -1333,9 +1333,9 @@ namespace Edu.Module.Customer ...@@ -1333,9 +1333,9 @@ namespace Edu.Module.Customer
/// <param name="StartTime"></param> /// <param name="StartTime"></param>
/// <param name="EndTime"></param> /// <param name="EndTime"></param>
/// <returns></returns> /// <returns></returns>
public object MarketChannelStaticModule(List<int> queryEmployeeList,string StartTime, string EndTime) public List<MarketChannelStaticModel> MarketChannelStaticModule(List<int> queryEmployeeList,string StartTime, string EndTime)
{ {
List<object> list = new List<object>(); List<MarketChannelStaticModel> list = new List<MarketChannelStaticModel>();
var channelList = channelRepository.GetChannelListRepository(new RB_Channel_Extend() { }); var channelList = channelRepository.GetChannelListRepository(new RB_Channel_Extend() { });
var dataList = studentRepository.GetStudentChannelStaticRepository(new RB_Student_ViewModel() var dataList = studentRepository.GetStudentChannelStaticRepository(new RB_Student_ViewModel()
{ {
...@@ -1348,14 +1348,14 @@ namespace Edu.Module.Customer ...@@ -1348,14 +1348,14 @@ namespace Edu.Module.Customer
foreach (var item in channelList) foreach (var item in channelList)
{ {
var channelTempList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && qitem.StuChannel == item.Id)?.ToList(); var channelTempList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.EmployeeInput && qitem.StuChannel == item.Id)?.ToList();
list.Add(new list.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
}); });
} }
} }
...@@ -1382,29 +1382,29 @@ namespace Edu.Module.Customer ...@@ -1382,29 +1382,29 @@ namespace Edu.Module.Customer
//企业同行 //企业同行
if (sItem.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.Company) if (sItem.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.Company)
{ {
list.Add(new list.Add(new MarketChannelStaticModel()
{ {
ChannelName = "(企业)" + (customerList?.FirstOrDefault(qitem => qitem.CustomerId == subItem.StuSourceId)?.CustomerName ?? ""), ChannelName = "(企业)" + (customerList?.FirstOrDefault(qitem => qitem.CustomerId == subItem.StuSourceId)?.CustomerName ?? ""),
ChannelId= subItem.StuSourceId, ChannelId= subItem.StuSourceId,
sItem.CustomerType, CustomerType= sItem.CustomerType,
ClueCount = tempCusList?.Count(), ClueCount = tempCusList?.Count()??0,
VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount), VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount), OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome) OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome)??0
}); });
} }
//校代同行 //校代同行
if (sItem.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.School) if (sItem.CustomerType == Common.Enum.Customer.CatetoryTypeEnum.School)
{ {
list.Add(new list.Add(new MarketChannelStaticModel()
{ {
ChannelName = "(校代)" + (customerList?.FirstOrDefault(qitem => qitem.CustomerId == subItem.StuSourceId)?.CustomerName ?? ""), ChannelName = "(校代)" + (customerList?.FirstOrDefault(qitem => qitem.CustomerId == subItem.StuSourceId)?.CustomerName ?? ""),
ChannelId=subItem.StuSourceId, ChannelId=subItem.StuSourceId,
sItem.CustomerType, CustomerType=sItem.CustomerType,
ClueCount = tempCusList?.Count(), ClueCount = tempCusList?.Count()??0,
VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount), VisitCount = tempCusList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount), OrderCount = tempCusList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome) OrderIncome = tempCusList?.Sum(qitem => qitem.OrderIncome)??0
}); });
} }
} }
...@@ -1423,14 +1423,14 @@ namespace Edu.Module.Customer ...@@ -1423,14 +1423,14 @@ namespace Edu.Module.Customer
foreach (var sItem in groupDataList) foreach (var sItem in groupDataList)
{ {
var tempInnerList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction && qitem.StuSourceId == sItem.StuSourceId)?.ToList(); var tempInnerList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.InternalIntroduction && qitem.StuSourceId == sItem.StuSourceId)?.ToList();
list.Add(new list.Add(new MarketChannelStaticModel()
{ {
ChannelName = "(内部介绍)" + (empList?.FirstOrDefault(qitem => qitem.Id == sItem.StuSourceId)?.EmployeeName ?? ""), ChannelName = "(内部介绍)" + (empList?.FirstOrDefault(qitem => qitem.Id == sItem.StuSourceId)?.EmployeeName ?? ""),
ChannelId=sItem.StuSourceId, ChannelId=sItem.StuSourceId,
ClueCount = tempInnerList?.Count(), ClueCount = tempInnerList?.Count()??0,
VisitCount = tempInnerList?.Sum(qitem => qitem.VisitCount), VisitCount = tempInnerList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = tempInnerList?.Sum(qitem => qitem.OrderCount), OrderCount = tempInnerList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = tempInnerList?.Sum(qitem => qitem.OrderIncome) OrderIncome = tempInnerList?.Sum(qitem => qitem.OrderIncome)??0
}); });
} }
...@@ -1446,25 +1446,25 @@ namespace Edu.Module.Customer ...@@ -1446,25 +1446,25 @@ namespace Edu.Module.Customer
foreach (var sItem in transTypeList) foreach (var sItem in transTypeList)
{ {
var tempTransList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction && qitem.StuSourceId == sItem.StuSourceId)?.ToList(); var tempTransList = dataList?.Where(qitem => qitem.CreateType == StuCreateTypeEnum.TransIntroduction && qitem.StuSourceId == sItem.StuSourceId)?.ToList();
list.Add(new list.Add(new MarketChannelStaticModel()
{ {
ChannelName = "(学员转介绍)" + stuList?.FirstOrDefault(qitem => qitem.StuId == sItem.StuSourceId)?.StuName ?? "", ChannelName = "(学员转介绍)" + stuList?.FirstOrDefault(qitem => qitem.StuId == sItem.StuSourceId)?.StuName ?? "",
ChannelId = sItem.StuSourceId, ChannelId = sItem.StuSourceId,
ClueCount = tempTransList?.Count(), ClueCount = tempTransList?.Count()??0,
VisitCount = tempTransList?.Sum(qitem => qitem.VisitCount), VisitCount = tempTransList?.Sum(qitem => qitem.VisitCount)??0,
OrderCount = tempTransList?.Sum(qitem => qitem.OrderCount), OrderCount = tempTransList?.Sum(qitem => qitem.OrderCount)??0,
OrderIncome = tempTransList?.Sum(qitem => qitem.OrderIncome) OrderIncome = tempTransList?.Sum(qitem => qitem.OrderIncome)??0
}); });
} }
list.Add(new list.Add(new MarketChannelStaticModel()
{ {
ChannelName = "合计", ChannelName = "合计",
ChannelId = 10005, ChannelId = 10005,
ClueCount = dataList?.Count(), ClueCount = dataList?.Count() ?? 0,
VisitCount = dataList?.Sum(qitem => qitem.VisitCount), VisitCount = dataList?.Sum(qitem => qitem.VisitCount) ?? 0,
OrderCount = dataList?.Sum(qitem => qitem.OrderCount), OrderCount = dataList?.Sum(qitem => qitem.OrderCount) ?? 0,
OrderIncome = dataList?.Sum(qitem => qitem.OrderIncome) OrderIncome = dataList?.Sum(qitem => qitem.OrderIncome) ?? 0
}); });
return list; return list;
} }
......
...@@ -623,18 +623,18 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -623,18 +623,18 @@ namespace Edu.WebApi.Controllers.Customer
ExcelDataSource header = new ExcelDataSource(); ExcelDataSource header = new ExcelDataSource();
header.ExcelRows = new List<ExcelColumn>() header.ExcelRows = new List<ExcelColumn>()
{ {
new ExcelColumn("联系人名称"), new ExcelColumn("联系人名称"){ CellWidth=20},
new ExcelColumn("类型"), new ExcelColumn("类型"){ CellWidth=20},
new ExcelColumn("同行名称"), new ExcelColumn("同行名称"){ CellWidth=20},
new ExcelColumn("电话"), new ExcelColumn("电话"){ CellWidth=20},
new ExcelColumn("QQ号"), new ExcelColumn("QQ号"){ CellWidth=20},
new ExcelColumn("微信号"), new ExcelColumn("微信号"){ CellWidth=20},
new ExcelColumn("客户数量"), new ExcelColumn("客户数量"){ CellWidth=20},
new ExcelColumn("订单数量"), new ExcelColumn("订单数量"){ CellWidth=20},
new ExcelColumn("交易额"), new ExcelColumn("交易额"){ CellWidth=20},
new ExcelColumn("审核状态"), new ExcelColumn("审核状态"){ CellWidth=20},
new ExcelColumn("加入时间"), new ExcelColumn("加入时间"){ CellWidth=20},
new ExcelColumn("负责人"), new ExcelColumn("负责人"){ CellWidth=20},
}; };
slist.Add(header); slist.Add(header);
foreach (var item in list) foreach (var item in list)
...@@ -949,6 +949,73 @@ namespace Edu.WebApi.Controllers.Customer ...@@ -949,6 +949,73 @@ namespace Edu.WebApi.Controllers.Customer
return ApiResult.Success(data: pageModel); return ApiResult.Success(data: pageModel);
} }
/// <summary>
/// 同行信息下载
/// </summary>
/// <returns></returns>
[HttpPost]
[Obsolete]
public FileContentResult DownLoadCustomer()
{
var query = new RB_Customer_Category_Extend()
{
Group_Id = base.UserInfo.Group_Id,
CategoryName = base.ParmJObj.GetStringValue("CategoryName"),
CatetoryType = (CatetoryTypeEnum)base.ParmJObj.GetInt("CatetoryType"),
};
int IsQueryAll = base.ParmJObj.GetInt("IsQueryAll");
if (IsQueryAll == 0)
{
query.CreateBy = base.UserInfo.Id;
}
var list = customerModule.GetCustomerCategoryPageModule(1, 100000, out long rowsCount, query);
string excelName = "同行资料.xls";
List<ExcelDataSource> slist = new List<ExcelDataSource>();
try
{
ExcelDataSource header = new ExcelDataSource();
header.ExcelRows = new List<ExcelColumn>()
{
new ExcelColumn("同业名称"){ CellWidth=20},
new ExcelColumn("类型"){ CellWidth=20},
new ExcelColumn("联系人数量"){ CellWidth=20},
new ExcelColumn("客户数量"){ CellWidth=20},
new ExcelColumn("订单数量"){ CellWidth=20},
new ExcelColumn("加入时间"){ CellWidth=20},
new ExcelColumn("负责人"){ CellWidth=20},
};
slist.Add(header);
foreach (var item in list)
{
var dataRow = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>()
{
new ExcelColumn(item.CategoryName),
new ExcelColumn(item.CatetoryType.ToName()),
new ExcelColumn(item.LinkManCount.ToString()),
new ExcelColumn(item.StudentCount.ToString()),
new ExcelColumn(item.OrderCount.ToString()),
new ExcelColumn(Common.ConvertHelper.FormatTime(item.CreateTime)),
new ExcelColumn(UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? ""),
}
};
slist.Add(dataRow);
}
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", excelName);
}
catch (Exception ex)
{
LogHelper.Write(ex, "OutToExcelOrderStudentClassHoursList");
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", excelName);
}
}
/// <summary> /// <summary>
/// 获取同行列表 /// 获取同行列表
/// </summary> /// </summary>
......
...@@ -2795,6 +2795,101 @@ namespace Edu.WebApi.Controllers.User ...@@ -2795,6 +2795,101 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success(data: data); return ApiResult.Success(data: data);
} }
/// <summary>
/// 渠道总表下载
/// </summary>
/// <returns></returns>
[HttpPost]
[Obsolete]
public FileContentResult DownLoadMarketChannelStudentStatic()
{
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 list = marketConsultantModule.MarketChannelStudentStaticModule(startTime, endTime, qEmpIds, isHaveAuth: base.CheckUserActionAuth("Query_MarketConsultant"));
string excelName = "渠道总表.xls";
List<ExcelDataSource> slist = new List<ExcelDataSource>();
try
{
JObject headerObj = JObject.Parse(Common.Plugin.JsonHelper.Serialize(list[0]));
var headerArray = JsonHelper.DeserializeObject<List< MarketChannelStaticModel >>(headerObj.GetStringValue("subList"));
ExcelDataSource header = new ExcelDataSource() { ExcelRows = new List<ExcelColumn>() };
var subHeader = new ExcelDataSource() { ExcelRows = new List<ExcelColumn>() };
header.ExcelRows.Add(new ExcelColumn("员工") { Rowspan = 2, CellWidth = 20 });
subHeader.ExcelRows.Add(new ExcelColumn());
if (headerArray != null && headerArray.Count > 0)
{
foreach (var item in headerArray)
{
header.ExcelRows.Add(new ExcelColumn(item.ChannelName) {Colspan=3 });
subHeader.ExcelRows.Add(new ExcelColumn("回单") { CellWidth = 10 });
subHeader.ExcelRows.Add(new ExcelColumn("到访") { CellWidth = 10 });
subHeader.ExcelRows.Add(new ExcelColumn("转化率") { CellWidth = 10 });
}
}
slist.Add(header);
slist.Add(subHeader);
foreach (var item in list)
{
var excelRows = new List<ExcelColumn>();
var dataObj = JObject.Parse(Common.Plugin.JsonHelper.Serialize(item));
var dataArray= JsonHelper.DeserializeObject<List<MarketChannelStaticModel>>(dataObj.GetStringValue("subList"));
excelRows.Add(new ExcelColumn(dataObj.GetStringValue("EmployeeName")));
if (dataArray != null && dataArray.Count > 0)
{
foreach (var subItem in dataArray)
{
decimal rate = 0;
if (subItem.ClueCount > 0)
{
rate = Math.Round(Convert.ToDecimal(subItem.VisitCount) / Convert.ToDecimal(subItem.ClueCount) * Convert.ToDecimal(100), 2);
}
excelRows.Add(new ExcelColumn(subItem.ClueCount.ToString()));
excelRows.Add(new ExcelColumn(subItem.VisitCount.ToString()));
excelRows.Add(new ExcelColumn(rate.ToString()+"%"));
}
}
var dataRow = new ExcelDataSource()
{
ExcelRows = excelRows,
};
slist.Add(dataRow);
}
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", excelName);
}
catch (Exception ex)
{
LogHelper.Write(ex, "OutToExcelOrderStudentClassHoursList");
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", excelName);
}
}
/// <summary> /// <summary>
/// 市场渠道统计 /// 市场渠道统计
/// </summary> /// </summary>
...@@ -2824,6 +2919,117 @@ namespace Edu.WebApi.Controllers.User ...@@ -2824,6 +2919,117 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success(data: data); return ApiResult.Success(data: data);
} }
/// <summary>
/// 渠道总表下载
/// </summary>
/// <returns></returns>
[HttpPost]
[Obsolete]
public FileContentResult DownLoadMarketCreateType()
{
List<ExcelDataSource> slist = new List<ExcelDataSource>();
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);
}
var queryType = base.ParmJObj.GetInt("top_Check");
var data = marketConsultantModule.MarketCreateTypeStaticModule(empList, startTime, endTime);
string excelName = "同行渠道.xls";
ExcelDataSource header = new ExcelDataSource() { ExcelRows = new List<ExcelColumn>() };
header.ExcelRows.Add(new ExcelColumn("序号") { CellWidth = 5 });
header.ExcelRows.Add(new ExcelColumn("渠道名") { CellWidth = 20 });
header.ExcelRows.Add(new ExcelColumn("回单") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("到访") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("合同数") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("新业绩金额") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("到访率") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("合同转化率") { CellWidth = 15 });
slist.Add(header);
try
{
JObject dataObj = JObject.Parse(JsonHelper.Serialize(data));
List<MarketChannelStaticModel> list = new List<MarketChannelStaticModel>();
//同行渠道
if (queryType == 1)
{
list = JsonHelper.DeserializeObject<List<MarketChannelStaticModel>>(dataObj.GetStringValue("customerDataList"));
}
//内部渠道
if (queryType == 2)
{
list = JsonHelper.DeserializeObject<List<MarketChannelStaticModel>>(dataObj.GetStringValue("innerDataList"));
}
//学校渠道
if (queryType == 3)
{
list = JsonHelper.DeserializeObject<List<MarketChannelStaticModel>>(dataObj.GetStringValue("schoolDataList"));
}
//转介渠道
if (queryType == 4)
{
list = JsonHelper.DeserializeObject<List<MarketChannelStaticModel>>(dataObj.GetStringValue("transDataList"));
}
int index = 1;
foreach (var item in list)
{
var excelRows = new List<ExcelColumn>();
excelRows.Add(new ExcelColumn(index.ToString()));
excelRows.Add(new ExcelColumn(item.ChannelName));
excelRows.Add(new ExcelColumn(item.ClueCount.ToString()));
excelRows.Add(new ExcelColumn(item.VisitCount.ToString()));
excelRows.Add(new ExcelColumn(item.OrderCount.ToString()));
excelRows.Add(new ExcelColumn(item.OrderIncome.ToString()));
decimal rate = 0;
if (item.ClueCount > 0)
{
rate = Math.Round(Convert.ToDecimal(item.VisitCount) / Convert.ToDecimal(item.ClueCount) * Convert.ToDecimal(100), 2);
}
decimal orderRate = 0;
if (item.VisitCount > 0)
{
orderRate = Math.Round(Convert.ToDecimal(item.OrderCount) / Convert.ToDecimal(item.VisitCount) * Convert.ToDecimal(100), 2);
}
excelRows.Add(new ExcelColumn(rate.ToString()+"%"));
excelRows.Add(new ExcelColumn(orderRate.ToString() + "%"));
var dataRow = new ExcelDataSource()
{
ExcelRows = excelRows,
};
slist.Add(dataRow);
index++;
}
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", excelName);
}
catch (Exception ex)
{
LogHelper.Write(ex, "OutToExcelOrderStudentClassHoursList");
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", excelName);
}
}
/// <summary> /// <summary>
/// 市场渠道统计汇总 /// 市场渠道统计汇总
/// </summary> /// </summary>
...@@ -2856,6 +3062,96 @@ namespace Edu.WebApi.Controllers.User ...@@ -2856,6 +3062,96 @@ namespace Edu.WebApi.Controllers.User
var data = marketConsultantModule.MarketChannelStaticModule(empList,startTime, endTime); var data = marketConsultantModule.MarketChannelStaticModule(empList,startTime, endTime);
return ApiResult.Success(data: data); return ApiResult.Success(data: data);
} }
/// <summary>
/// 细分渠道下载
/// </summary>
/// <returns></returns>
[HttpPost]
[Obsolete]
public FileContentResult DownLoadMarketChannelStatic()
{
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 list = marketConsultantModule.MarketChannelStaticModule(empList, startTime, endTime);
string excelName = "细分渠道.xls";
List<ExcelDataSource> slist = new List<ExcelDataSource>();
ExcelDataSource header = new ExcelDataSource() { ExcelRows = new List<ExcelColumn>() };
header.ExcelRows.Add(new ExcelColumn("序号") { CellWidth = 5 });
header.ExcelRows.Add(new ExcelColumn("渠道名") { CellWidth = 20 });
header.ExcelRows.Add(new ExcelColumn("回单") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("到访") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("合同数") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("新业绩金额") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("到访率") { CellWidth = 15 });
header.ExcelRows.Add(new ExcelColumn("合同转化率") { CellWidth = 15 });
slist.Add(header);
try
{
int index = 1;
foreach (var item in list)
{
var excelRows = new List<ExcelColumn>();
excelRows.Add(new ExcelColumn(index.ToString()));
excelRows.Add(new ExcelColumn(item.ChannelName));
excelRows.Add(new ExcelColumn(item.ClueCount.ToString()));
excelRows.Add(new ExcelColumn(item.VisitCount.ToString()));
excelRows.Add(new ExcelColumn(item.OrderCount.ToString()));
excelRows.Add(new ExcelColumn(item.OrderIncome.ToString()));
decimal rate = 0;
if (item.ClueCount > 0)
{
rate = Math.Round(Convert.ToDecimal(item.VisitCount) / Convert.ToDecimal(item.ClueCount) * Convert.ToDecimal(100), 2);
}
decimal orderRate = 0;
if (item.VisitCount > 0)
{
orderRate = Math.Round(Convert.ToDecimal(item.OrderCount) / Convert.ToDecimal(item.VisitCount) * Convert.ToDecimal(100), 2);
}
excelRows.Add(new ExcelColumn(rate.ToString() + "%"));
excelRows.Add(new ExcelColumn(orderRate.ToString() + "%"));
var dataRow = new ExcelDataSource()
{
ExcelRows = excelRows,
};
slist.Add(dataRow);
index++;
}
var byteData = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData, "application/octet-stream", excelName);
}
catch (Exception ex)
{
LogHelper.Write(ex, "OutToExcelOrderStudentClassHoursList");
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", excelName);
}
}
#endregion #endregion
} }
} }
\ No newline at end of file
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