Commit 0f2c8884 authored by liudong1993's avatar liudong1993

提成发放次数

parent b8678149
......@@ -14,6 +14,11 @@ namespace Edu.Model.ViewModel.Course
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 当前发放次数
/// </summary>
public int IssueNum { get; set; }
/// <summary>
/// 用户ids
/// </summary>
......
......@@ -399,6 +399,44 @@ namespace Edu.Module.Course
return list;
}
/// <summary>
/// 获取用户提成明细列表 (有当前发放次数的)
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Sell_Commission_Details_ViewModel> GetSellCommissionUserDetailList_V2(RB_Sell_Commission_Details_ViewModel dmodel)
{
var list = sell_Commission_DetailsRepository.GetSellCommissionUserDetailList(dmodel);
if (list.Any())
{
//查询用户 部门 校区
string userIds = string.Join(",", list.Select(x => x.UserId).Distinct());
string deptIds = string.Join(",", list.Select(x => x.Depart_Id).Distinct());
string schoolIds = string.Join(",", list.Select(x => x.School_Id).Distinct());
var ulist = accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = dmodel.Group_Id, QIds = userIds });
var dlist = departmentRepository.GetDepartmentListRepository(new RB_Department_ViewModel() { Group_Id = dmodel.Group_Id, QDeptIds = deptIds });
var slist = schoolRepository.GetSchoolListRepository(new RB_School_ViewModel() { Group_Id = dmodel.Group_Id, QSIds = schoolIds });
//查询出所属班级信息
string classIds = string.Join(",", list.Select(x => x.ClassId).Distinct());
var clist = classRepository.GetClassListRepository(new RB_Class_ViewModel() { Group_Id = dmodel.Group_Id, Q_ClassIds = classIds });
//查询班级类型
string classTypeIds = string.Join(",", list.Select(x => x.ClassType).Distinct());
var ctlist = class_TypeRepository.GetClassTypeListRepository(new RB_Class_Type_ViewModel() { Q_CTypeIds = classTypeIds, Group_Id = dmodel.Group_Id });
foreach (var item in list)
{
var umodel = ulist.Where(x => x.Id == item.UserId).FirstOrDefault();
item.UserName = umodel.EmployeeName + (umodel.LeaveStatus == Common.Enum.User.LeaveStatusEnum.Departure ? "离职" : "");
item.DeptName = dlist.Where(x => x.DeptId == item.Depart_Id).FirstOrDefault()?.DeptName ?? "";
item.SchoolName = slist.Where(x => x.SId == item.School_Id).FirstOrDefault()?.SName ?? "";
item.ClassName = clist.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.ClassName ?? "";
item.ClassNo = clist.Where(x => x.ClassId == item.ClassId).FirstOrDefault()?.ClassNo ?? "";
item.ClassTypeName = ctlist.Where(x => x.CTypeId == item.ClassType).FirstOrDefault()?.CTypeName ?? "";
}
}
return list;
}
/// <summary>
/// 创建提成s
/// </summary>
......
......@@ -57,6 +57,51 @@ namespace Edu.Repository.Course
return Get<RB_Sell_Commission_Details_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取用户明细统计
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Sell_Commission_Details_ViewModel> GetSellCommissionUserDetailList(RB_Sell_Commission_Details_ViewModel demodel)
{
string where = $@" 1=1";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.PeriodId > 0)
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if (demodel.UserId > 0)
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.UserId)} ={demodel.UserId}";
}
if (!string.IsNullOrEmpty(demodel.UserIds))
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.UserId)} in({demodel.UserIds})";
}
if (demodel.ClassId > 0)
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.ClassId)} ={demodel.ClassId}";
}
if (demodel.OrderId > 0)
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.OrderId)} ={demodel.OrderId}";
}
if (!string.IsNullOrEmpty(demodel.OrderIds))
{
where += $@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.OrderId)} in({demodel.OrderIds})";
}
string sql = $@" select r.*,
(select count(0) from RB_Sell_Commission_Details r1 where r1.UserId = r.UserId and r1.OrderId = r.OrderId and r1.Id <= r.Id) as IssueNum
from RB_Sell_Commission_Details r where {where} order by r.Id asc";
return Get<RB_Sell_Commission_Details_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取分页列表
/// </summary>
......
......@@ -202,7 +202,7 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.ParamIsNull("请传递期数id");
}
var list = sellCommissionModule.GetSellCommissionUserDetailList(dmodel);
var list = sellCommissionModule.GetSellCommissionUserDetailList_V2(dmodel);
return ApiResult.Success("", list.Select(x => new
{
x.School_Id,
......@@ -217,6 +217,7 @@ namespace Edu.WebApi.Controllers.Course
x.ClassType,
x.ClassTypeName,
x.OrderId,
x.IssueNum,
x.StudentCount,
x.Periods,
TotalCommissionMoney = x.CommissionMoney + x.OtherMoney + x.BackMoney,
......
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