Commit a7b7d332 authored by liudong1993's avatar liudong1993

1 课程顾问排名

parent 3052f66f
......@@ -5018,5 +5018,33 @@ namespace Edu.Module.Finance
return flag ? "" : "出问题了,请联系管理员";
}
#endregion
#region 课程顾问排名统计
/// <summary>
/// 获取课程滚排名统计
/// </summary>
/// <param name="empId"></param>
/// <param name="startMonth"></param>
/// <param name="endMonth"></param>
/// <param name="group_Id"></param>
/// <returns></returns>
public List<RB_Order_ViewModel> GetConsultantRankList(int empId, string startMonth, string endMonth, int group_Id)
{
var list = orderRepository.GetConsultantRankList(empId, startMonth, endMonth, group_Id);
if (list.Any()) {
//查询人员
string empIds = string.Join(",", list.Select(x => x.CourseConsultantId).Distinct());
var empList = accountRepository.GetEmployeeListRepository(new Model.ViewModel.User.Employee_ViewModel() { Group_Id = group_Id, QIds = empIds });
foreach (var item in list) {
item.DueInMoney = item.PreferPrice - item.Income - item.PlatformTax + item.Refund;
item.HelpEnterName = empList.Where(x => x.Id == item.CourseConsultantId).FirstOrDefault()?.EmployeeName ?? "";
}
}
return list.OrderByDescending(x => x.PreferPrice).ToList();
}
#endregion
}
}
......@@ -1419,6 +1419,22 @@ WHERE 1=1 AND A.OrderState IN(1,2) {0}
return dicList;
}
/// <summary>
/// 获取课程顾问排名统计
/// </summary>
/// <param name="empId"></param>
/// <param name="startMonth"></param>
/// <param name="endMonth"></param>
/// <param name="group_Id"></param>
/// <returns></returns>
public List<RB_Order_ViewModel> GetConsultantRankList(int empId, string startMonth, string endMonth, int group_Id)
{
string sql = $@"SELECT o.CourseConsultantId,SUM(o.PreferPrice - o.DiscountMoney) as PreferPrice
,SUM(o.Income) as Income,SUM(Refund) AS Refund,SUM(o.PlatformTax) as PlatformTax
,COUNT(0) as CancelNum
FROM rb_order o WHERE o.Group_Id ={group_Id} and o.OrderState <>3 and o.CreateTime >='{startMonth}' and o.CreateTime <='{endMonth} 23:59:59' and o.CourseConsultantId >0 {(empId>0? " and o.CourseConsultantId ="+empId : "")}
GROUP BY o.CourseConsultantId";
return Get<RB_Order_ViewModel>(sql).ToList();
}
}
}
......@@ -2766,5 +2766,148 @@ namespace Edu.WebApi.Controllers.Finance
}
#endregion
#region 课程顾问排名统计
/// <summary>
/// 获取课程顾问排名统计
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetConsultantRankList() {
var userInfo = base.UserInfo;
int EmpId = base.ParmJObj.GetInt("EmpId", 0);
string StartMonth = base.ParmJObj.GetStringValue("StartMonth");
string EndMonth = base.ParmJObj.GetStringValue("EndMonth");
if (string.IsNullOrEmpty(StartMonth))
{
return ApiResult.ParamIsNull("请选择开始月份");
}
if (string.IsNullOrEmpty(EndMonth))
{
return ApiResult.ParamIsNull("请选择结束月份");
}
try
{
StartMonth = Convert.ToDateTime(StartMonth + "-01").ToString("yyyy-MM-dd");
EndMonth = Convert.ToDateTime(EndMonth + "-01").AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
}
catch (Exception)
{
return ApiResult.Failed("日期格式有误");
}
var list = financeModule.GetConsultantRankList(EmpId, StartMonth, EndMonth, userInfo.Group_Id);
return ApiResult.Success("", list.Select(x => new
{
x.CourseConsultantId,
x.HelpEnterName,
x.PreferPrice,
x.Income,
x.PlatformTax,
x.Refund,
x.DueInMoney,
OrderNum = x.CancelNum
}));
}
/// <summary>
/// 课程顾问排名统计导出
/// </summary>
/// <returns></returns>
[HttpPost]
[Obsolete]
public FileContentResult GetConsultantRankListToExcel()
{
List<ExcelDataSource> slist = new List<ExcelDataSource>();
ExcelDataSource header = new ExcelDataSource()
{
ExcelRows = new List<ExcelColumn>(30) {
new ExcelColumn(value:"课程顾问"){CellWidth=20,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"应收"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"实收"){CellWidth=20,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"退款"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"平台税金"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"待收"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER },
new ExcelColumn(value:"报名人数"){CellWidth=15,HAlignmentEnum= HAlignmentEnum.CENTER,VAlignmentEnum= VAlignmentEnum.CENTER }
}
};
slist.Add(header);
string ExcelName = "顾问业绩统计" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
var userInfo = base.UserInfo;
int EmpId = base.ParmJObj.GetInt("EmpId", 0);
string StartMonth = base.ParmJObj.GetStringValue("StartMonth");
string EndMonth = base.ParmJObj.GetStringValue("EndMonth");
if (string.IsNullOrEmpty(StartMonth))
{
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
if (string.IsNullOrEmpty(EndMonth))
{
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
try
{
StartMonth = Convert.ToDateTime(StartMonth + "-01").ToString("yyyy-MM-dd");
EndMonth = Convert.ToDateTime(EndMonth + "-01").AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
}
catch (Exception)
{
var byteData1 = ExcelTempLateHelper.ToExcelExtend(slist);
return File(byteData1, "application/octet-stream", ExcelName);
}
var list = financeModule.GetConsultantRankList(EmpId, StartMonth, EndMonth, userInfo.Group_Id);
try
{
foreach (var item in list)
{
ExcelDataSource firstRow = new ExcelDataSource(30)
{
ExcelRows = new List<ExcelColumn>()
{
new ExcelColumn(value: item.HelpEnterName){ },
new ExcelColumn(value: item.PreferPrice.ToString("#0.00")){ },
new ExcelColumn(value: item.Income.ToString("#0.00")){ },
new ExcelColumn(value: item.Refund.ToString("#0.00")){ },
new ExcelColumn(value: item.PlatformTax.ToString("#0.00")){ },
new ExcelColumn(value: item.DueInMoney.ToString("#0.00")){ },
new ExcelColumn(value: item.CancelNum.ToString()){ },
}
};
slist.Add(firstRow);
}
ExcelDataSource firstRowT = new ExcelDataSource(30)
{
ExcelRows = new List<ExcelColumn>()
{
new ExcelColumn(value: "合计"){ },
new ExcelColumn(value: ""){ },
new ExcelColumn(value: list.Sum(x=>x.PreferPrice).ToString("#0.00")){ },
new ExcelColumn(value: list.Sum(x=>x.Income).ToString("#0.00")){ },
new ExcelColumn(value: list.Sum(x=>x.Refund).ToString("#0.00")){ },
new ExcelColumn(value: list.Sum(x=>x.PlatformTax).ToString("#0.00")){ },
new ExcelColumn(value: list.Sum(x=>x.DueInMoney).ToString("#0.00")){ },
new ExcelColumn(value: list.Sum(x=>x.CancelNum).ToString()){ },
}
};
slist.Add(firstRowT);
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
}
}
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