Commit acaa9d1f authored by 吴春's avatar 吴春

提交代码

parent 68870cf3
......@@ -286,6 +286,40 @@ namespace Edu.Module.Course
}
/// <summary>
/// 确认销售提成
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool UpdateSureSellCommission(int UserId, int Id)
{
IDictionary<string, object> fileds = new Dictionary<string, object>
{
{ nameof(RB_Sell_Commission_Details_ViewModel.SureStatus), 1 },
};
IList<WhereHelper> auditrecordWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(RB_Sell_Commission_Details_ViewModel.Id),
FiledValue = Id,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(RB_Sell_Commission_Details_ViewModel.UserId),
FiledValue = UserId,
OperatorEnum = OperatorEnum.Equal
}
};
return sell_Commission_DetailsRepository.Update(fileds, auditrecordWhereHelpers);
}
/// <summary>
/// 获取提成统计
/// </summary>
......@@ -1623,7 +1657,8 @@ namespace Edu.Module.Course
var model = sell_Commission_PeriodsRepository.GetEntity(periodId);
if (model == null) { return "周期不存在"; }
List<int> EmpIdList = new List<int>();
if (!string.IsNullOrEmpty(model.EmpIds)) {
if (!string.IsNullOrEmpty(model.EmpIds))
{
EmpIdList = JsonHelper.DeserializeObject<List<int>>("[" + model.EmpIds + "]");
}
var list = GetSellCommissionUserList(new RB_Sell_Commission_Details_ViewModel() { Group_Id = userInfo.Group_Id, PeriodId = periodId });
......@@ -1654,8 +1689,10 @@ namespace Edu.Module.Course
EmpIdList = JsonHelper.DeserializeObject<List<int>>("[" + model.EmpIds + "]");
}
List<int> NewIdList = JsonHelper.DeserializeObject<List<int>>("[" + empIds + "]");
foreach (var item in NewIdList) {
if (EmpIdList.Contains(item)) {
foreach (var item in NewIdList)
{
if (EmpIdList.Contains(item))
{
return "用户ID" + item + "已发放了提成,无法重复发放";
}
}
......
......@@ -871,19 +871,183 @@ namespace Edu.Module.Course
return teaching_BonusDetailRepository.GetListByTeacherId(demodel);
}
#endregion
#region 教师绩效
/// <summary>
/// 获取教师绩效分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Teaching_Perf_ViewModel> GetTeachingPerfPageList(int pageIndex, int pageSize, out long count, RB_Teaching_Perf_ViewModel dmodel)
/// <summary>
/// 新增教师奖励
/// </summary>
/// <param name="dmodel"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public List<RB_Teaching_BonusDetail_ViewModel> GetEstimateTeachingBonusAdd(RB_Teaching_Bonus_ViewModel dmodel, UserInfo userInfo)
{
//验证当月教师是否已存在奖励
var tlist = teaching_BonusRepository.GetList(new RB_Teaching_Bonus_ViewModel() { Group_Id = userInfo.Group_Id, Month = Convert.ToDateTime(dmodel.Month).ToString("yyyy-MM") }).Where(x => x.State != BonusStateEnum.Cancel).ToList();
if (tlist.Any())
{
string[] teacherArr = dmodel.TeacherIds.Split(',');
foreach (var item in tlist)
{
foreach (var qitem in teacherArr)
{
if (("," + item.TeacherIds + ",").Contains("," + qitem + ","))
{
return new List<RB_Teaching_BonusDetail_ViewModel>();
}
}
}
}
//基础配置
var configModel = class_ConfigRepository.GetClassConfigRepository(new RB_Class_Config_ViewModel() { Group_Id = userInfo.Group_Id });
if (configModel == null || configModel.BasicHourFee <= 0 || configModel.BasicMinutes <= 0) { return new List<RB_Teaching_BonusDetail_ViewModel>(); }
//查询当月 老师对应所有的课程
string StartTime = dmodel.Month + "-01";
string EndTime = Convert.ToDateTime(dmodel.Month + "-01").AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
var plist = class_PlanRepository.GetClassPlanList_V2(new RB_Class_Plan_ViewModel() { Group_Id = userInfo.Group_Id, Q_TeacherIds = dmodel.TeacherIds, StartTime = StartTime, EndTime = EndTime });
//查询所有课程的上课时间
List<RB_Class_Type_ViewModel> typeList = new List<RB_Class_Type_ViewModel>();
List<RB_Class_Check_ViewModel> checkList = new List<RB_Class_Check_ViewModel>();
List<RB_Teacher_ViewModel> teacherList = new List<RB_Teacher_ViewModel>();
List<RB_Teaching_BonusDetail_ViewModel> DateList = new List<RB_Teaching_BonusDetail_ViewModel>();
List<RB_Teaching_BonusDetail_ViewModel> resultdetailList = new List<RB_Teaching_BonusDetail_ViewModel>();
if (plist.Any())
{
string pids = string.Join(",", plist.Select(x => x.ClassPlanId));
string classTypeIds = string.Join(",", plist.Select(x => x.ClassType).Distinct());
typeList = class_TypeRepository.GetClassTypeListRepository(new RB_Class_Type_ViewModel() { Group_Id = userInfo.Group_Id, Q_CTypeIds = classTypeIds });
//查询签到数据
string classIds = string.Join(",", plist.Select(x => x.ClassId).Distinct());
checkList = class_CheckRepository.GetClassCheckStatistics(new RB_Class_Check_ViewModel() { Group_Id = userInfo.Group_Id, Q_ClassIds = classIds, StartDate = StartTime, EndDate = EndTime });
//查询教师列表
string teacherIds = string.Join(",", plist.Select(x => x.TeacherId).Distinct());
teacherList = teacherRepository.GetTeacherListRepository(new RB_Teacher_ViewModel() { QTIds = teacherIds });
//根据学生签到表 查询
var list = class_CheckRepository.GetTeacherConsumptionHoursDetialList(teacherIds, -1, 0, StartTime, EndTime, userInfo.Group_Id);
if (list.Any())
{
foreach (var item in list)
{
//上课课时
decimal KSNum = item.CurrentDeductionHours;//使用签到表的课时
var typeModel = typeList.Where(x => x.CTypeId == item.ClassType).FirstOrDefault();
decimal unitPrice = configModel.BasicHourFee + (typeModel?.AddHourFee ?? 0) + (item?.BaseHourFee ?? 0);
//课时费 需要每个班级 单独计算 因为 班级有附加费用
decimal KSMoney = KSNum * unitPrice;
DateList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.StartDate + "~" + item.EndDate,
TeacherId = item.TeacherId,
TeacherName = item.TeacherName,
ClassId = item.ClassId,
ClassName = item.ClassName,
CouseId = item.CouseId,
CourseName = item.CourseName,
KSNum = KSNum,
UnitPrice = unitPrice,
Money = KSMoney
});
}
}
}
try
{
foreach (var item in plist)
{
var dateqList = DateList.Where(x => x.TeacherId == item.TeacherId && x.Date == item.ClassDate).ToList();
//查询课时
decimal ksNum = dateqList.Sum(x => x.KSNum);
//查询课单价
var typeModel = typeList.Where(x => x.CTypeId == item.ClassType).FirstOrDefault();
var teacherModel = teacherList.Where(x => x.TId == item.TeacherId).FirstOrDefault();
decimal unitPrice = configModel.BasicHourFee + (typeModel?.AddHourFee ?? 0) + (teacherModel?.BaseHourFee ?? 0);
//签到人数
var checkModel = checkList.Where(x => x.ClassId == item.ClassId && x.ClassDate == item.ClassDate).FirstOrDefault();
resultdetailList.Add(new RB_Teaching_BonusDetail_ViewModel()
{
BonusId = 0,
CheckInNum = checkModel?.CheckNum ?? 0,
ClassId = item.ClassId,
CourseHour = ksNum,
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
Date = item.ClassDate,
Group_Id = dmodel.Group_Id,
Id = 0,
Money = ksNum * unitPrice,
School_Id = dmodel.School_Id,
Status = 0,
TeacherId = item.TeacherId,
Type = item.TeacherId == item.Teacher_Id ? 1 : 2,
UnitPrice = unitPrice,
UpdateBy = dmodel.UpdateBy,
UpdateTime = DateTime.Now
});
}
return resultdetailList;
}
catch (Exception ex)
{
LogHelper.Write(ex, "GetEstimateTeachingBonusAdd");
return new List<RB_Teaching_BonusDetail_ViewModel> ();
}
}
/// <summary>
/// 确认老师课时费
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool UpdateSureTeachingBonusDetail(int TeacherId, int Id)
{
IDictionary<string, object> fileds = new Dictionary<string, object>
{
{ nameof(RB_Teaching_BonusDetail_ViewModel.SureStatus), 1 },
};
IList<WhereHelper> auditrecordWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(RB_Teaching_BonusDetail_ViewModel.Id),
FiledValue = Id,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(RB_Teaching_BonusDetail_ViewModel.TeacherId),
FiledValue = TeacherId,
OperatorEnum = OperatorEnum.Equal
}
};
return teaching_BonusDetailRepository.Update(fileds, auditrecordWhereHelpers);
}
#endregion
#region 教师绩效
/// <summary>
/// 获取教师绩效分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Teaching_Perf_ViewModel> GetTeachingPerfPageList(int pageIndex, int pageSize, out long count, RB_Teaching_Perf_ViewModel dmodel)
{
var list = teaching_PerfRepository.GetPageList(pageIndex, pageSize, out count, demodel: dmodel);
if (list.Any())
......
......@@ -341,7 +341,7 @@ where {where}";
{
where += $@" and DATE_FORMAT(STR_TO_DATE(CONCAT(b.Month,'-01'),'%Y-%m-%d'),'%Y-%m-%d')>=DATE_FORMAT('{demodel.Month}','%Y-%m-%d')";
}
string sql = $@" select A.*,,b.`Month` from RB_Teaching_BonusDetail as A LEFT JOIN rb_teaching_bonus as b on a.BonusId=b.Id where {where} order by a.Id desc";
string sql = $@" select A.*,b.`Month` from RB_Teaching_BonusDetail as A LEFT JOIN rb_teaching_bonus as b on a.BonusId=b.Id where {where} order by a.Id desc";
return Get<RB_Teaching_BonusDetail_ViewModel>(sql).ToList();
}
}
......
......@@ -232,7 +232,7 @@ namespace Edu.WebApi.Controllers.Course
/// <summary>
/// 老师上课计划统计
/// 教室使用记录
/// </summary>
/// <returns></returns>
public ApiResult GetNewClassRoomTimeList()
......
......@@ -248,12 +248,12 @@ namespace Edu.WebApi.Controllers.User
}
else
{
//userList = sellCommissionModule.GetEstimateSellCommissionInfo(System.DateTime.Now.ToString("yyyy-MM-01"), base.UserInfo);
//if (userList != null && userList.Any())
//{
// totalCommiommission = userList.Sum(x => x.CurrentPeriodMoney + x.CurrentExtraMoney + x.DeductionMoney + x.DeductionExtraMoney);
teacherList = teachingRewardsModule.GetEstimateTeachingBonusAdd(new RB_Teaching_Bonus_ViewModel { Month = System.DateTime.Now.ToString("yyyy-MM"), TeacherIds = base.UserInfo.Id.ToString() }, base.UserInfo);
if (teacherList != null && teacherList.Any())
{
totalTCommiommission = teacherList.Sum(x => x.Money);
//}
}
}
#endregion
#endregion
......@@ -371,6 +371,32 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success("", commiommissionList);
}
/// <summary>
/// 确认销售提成
/// </summary>
/// <returns></returns>
public ApiResult UpdateSureTeachingBonusDetail()
{
int Id = base.ParmJObj.GetInt("Id");
int UserId = base.UserInfo.AccountId;
bool retult = teachingRewardsModule.UpdateSureTeachingBonusDetail(UserId, Id);
return retult ? ApiResult.Success("") : ApiResult.Failed("确认失败");
}
/// <summary>
/// 确认销售提成
/// </summary>
/// <returns></returns>
public ApiResult UpdatSureSellCommission()
{
int Id = base.ParmJObj.GetInt("Id");
int UserId = base.UserInfo.Id;
bool retult = sellCommissionModule.UpdateSureSellCommission(UserId, Id);
return retult ? ApiResult.Success("") : ApiResult.Failed("确认失败");
}
#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