Commit 4cee7ff1 authored by liudong1993's avatar liudong1993

试听课 课时费

parent 67fbe49b
......@@ -107,5 +107,10 @@ namespace Edu.Model.Entity.Sell
/// 提成确认状态0-未确认,1-已确认
/// </summary>
public int SureStatus { get; set; }
/// <summary>
/// 分类 1基础课 2试听课
/// </summary>
public int CouseClassify { get; set; }
}
}
......@@ -74,5 +74,35 @@ namespace Edu.Model.ViewModel.Reserve
/// 转化率
/// </summary>
public decimal ConversionRates { get; set; }
/// <summary>
/// 老师Ids
/// </summary>
public string TeacherIds { get; set; }
/// <summary>
/// 签到人数
/// </summary>
public int CheckNum { get; set; }
/// <summary>
/// 试听课时费
/// </summary>
public decimal ClassHourFee { get; set; }
/// <summary>
/// 是否启用基础课时 1是
/// </summary>
public int BaseHoursEnabled { get; set; }
/// <summary>
/// 启用时间 (存到月)
/// </summary>
public string EnableTime { get; set; }
/// <summary>
/// 校区
/// </summary>
public string SName { get; set; }
}
}
......@@ -11,6 +11,7 @@ using Edu.Model.ViewModel.Course;
using Edu.Model.ViewModel.Finance;
using Edu.Model.ViewModel.Grade;
using Edu.Model.ViewModel.Log;
using Edu.Model.ViewModel.Reserve;
using Edu.Model.ViewModel.Sell;
using Edu.Model.ViewModel.User;
using Edu.Repository.Course;
......@@ -136,6 +137,14 @@ namespace Edu.Module.Course
/// 投稿信息
/// </summary>
private readonly Repository.WeChat.RB_Contribute_InfoRepository contribute_InfoRepository = new Repository.WeChat.RB_Contribute_InfoRepository();
/// <summary>
/// 试听课程
/// </summary>
private readonly RB_TrialLessonRepository trialLessonRepository = new RB_TrialLessonRepository();
/// <summary>
/// 试听班级
/// </summary>
private readonly Repository.Reserve.RB_Reserve_ClassRepository reserve_ClassRepository = new Repository.Reserve.RB_Reserve_ClassRepository();
......@@ -593,10 +602,45 @@ namespace Edu.Module.Course
}
}
}
#region 试听课
List<RB_Teaching_BonusDetail_ViewModel> stDateList = new List<RB_Teaching_BonusDetail_ViewModel>();
var stlist = reserve_ClassRepository.GetClassReserveList(new RB_Reserve_Class_Extend() { Group_Id = userInfo.Group_Id, TeacherIds = dmodel.TeacherIds, ClassTime = StartTime, EndTime = EndTime });
if (stlist.Any()) {
//每次试听课 算一个课时
foreach (var item in stlist) {
stDateList.Add(new RB_Teaching_BonusDetail_ViewModel()
{
BonusId = bonusId,
CheckInNum = item.CheckNum,
ClassId = item.ReserveClassId,
CourseHour = 1,
CreateBy = dmodel.CreateBy,
CreateTime = DateTime.Now,
Date = item.ClassDate,
Group_Id = dmodel.Group_Id,
Id = 0,
Money = item.ClassHourFee,
School_Id = item.School_Id,
Status = 0,
TeacherId = item.TeacherId,
Type = 1,
UnitPrice = item.ClassHourFee,
UpdateBy = dmodel.UpdateBy,
UpdateTime = DateTime.Now,
CouseClassify = 2
});
}
}
#endregion
var trans = teaching_BonusDetailRepository.DbTransaction;
try
{
decimal TotalMoney = 0;
//基础课
foreach (var item in plist)
{
var dateqList = DateList.Where(x => x.TeacherId == item.TeacherId && x.ClassId == item.ClassId && x.Date == item.ClassDate).ToList();
......@@ -627,10 +671,17 @@ namespace Edu.Module.Course
Type = item.TeacherId == item.Teacher_Id ? 1 : 2,
UnitPrice = unitPrice,
UpdateBy = dmodel.UpdateBy,
UpdateTime = DateTime.Now
UpdateTime = DateTime.Now,
CouseClassify = 1
}, trans);
TotalMoney += ksNum * unitPrice;
}
//试听课
foreach (var item in stDateList) {
teaching_BonusDetailRepository.Insert(item, trans);
TotalMoney += item.Money;
}
#region 更新状态为待确认
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Teaching_Bonus_ViewModel.State), BonusStateEnum.Wait},
......
......@@ -150,6 +150,14 @@ namespace Edu.Module.Finance
/// 收据
/// </summary>
private readonly RB_Receipt_InfoRepository receipt_InfoRepository = new RB_Receipt_InfoRepository();
/// <summary>
/// 试听课程
/// </summary>
private readonly RB_TrialLessonRepository trialLessonRepository = new RB_TrialLessonRepository();
/// <summary>
/// 试听班级
/// </summary>
private readonly Repository.Reserve.RB_Reserve_ClassRepository reserve_ClassRepository = new Repository.Reserve.RB_Reserve_ClassRepository();
......@@ -3152,7 +3160,34 @@ namespace Edu.Module.Finance
Hours = Hours,
HourMoney = HourMoney,
UnitPrice = unitPrice,
Money = KSMoney
Money = KSMoney,
CouseClassify = 1
});
}
}
//查询试听课
var rclist = reserve_ClassRepository.GetTeacherHoursDetialList(userIds, schoolId, 0, startMonth, endMonth, groupId);
if (rclist.Any()) {
decimal ClassHourMinute = configModel.BasicMinutes;//课时分钟数
decimal Hours = Math.Round(1 * ClassHourMinute / 60, 2, MidpointRounding.AwayFromZero);//小时
foreach (var item in rclist) {
DateList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.ClassTime + "~" + item.EndTime,
TeacherId = item.TeacherId,
TeacherName = item.TeacherName,
ClassId = item.ReserveClassId,
ClassName = "试听课",
CouseId = item.TrialLessonId,
CourseName = item.LessonName,
KSNum = 1,
Hours = Hours,
HourMoney = Math.Round(item.ClassHourFee / Hours, 2, MidpointRounding.AwayFromZero),
UnitPrice = item.ClassHourFee,
Money = item.ClassHourFee,
CouseClassify = 2
});
}
}
......@@ -3160,6 +3195,7 @@ namespace Edu.Module.Finance
//查询期间 学生的上课总课时 + 合同课时单价
var sTimeList = class_CheckRepository.GetStudentHoursList(groupId, userIds, startMonth, endMonth);
DateList = DateList.OrderBy(x => x.Date).ToList();
//根据学生id
//查询课时费 (要注意 需排除每个月老师的基础课时)
foreach (var item in userList)
......@@ -3307,6 +3343,36 @@ namespace Edu.Module.Finance
}
}
//查询试听课
var rclist = reserve_ClassRepository.GetTeacherHoursDetialList(userIds, schoolId, 0, startMonth, endMonth, groupId);
if (rclist.Any())
{
decimal ClassHourMinute = configModel.BasicMinutes;//课时分钟数
decimal Hours = Math.Round(1 * ClassHourMinute / 60, 2, MidpointRounding.AwayFromZero);//小时
foreach (var item in rclist)
{
DateList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.ClassTime + "~" + item.EndTime,
TeacherId = item.TeacherId,
TeacherName = item.TeacherName,
ClassId = item.ReserveClassId,
ClassName = "试听课",
CouseId = item.TrialLessonId,
CourseName = item.LessonName,
KSNum = 1,
Hours = Hours,
HourMoney = Math.Round(item.ClassHourFee / Hours, 2, MidpointRounding.AwayFromZero),
UnitPrice = item.ClassHourFee,
Money = item.ClassHourFee,
CouseClassify = 2
});
}
}
DateList = DateList.OrderBy(x => x.Date).ToList();
//查询期间 学生的上课总课时 + 合同课时单价
var sTimeList = class_CheckRepository.GetStudentHoursList(groupId, userIds, startMonth, endMonth);
......@@ -3441,7 +3507,12 @@ namespace Edu.Module.Finance
List<RB_Teaching_BonusDetail_ViewModel> RList = new List<RB_Teaching_BonusDetail_ViewModel>();
//根据学生签到表 查询
var list = class_CheckRepository.GetTeacherConsumptionHoursDetialPageList(pageIndex, pageSize, out count, teacherId, schoolId, classId, startMonth, endMonth, groupId);
if (list.Any()) {
var rclist = new List<Model.ViewModel.Reserve.RB_Reserve_Class_Extend>();
if (pageSize == 1000 || pageSize == 10000) {
//查询试听课
rclist = reserve_ClassRepository.GetTeacherHoursDetialList(teacherId.ToString(), schoolId, 0, startMonth, endMonth, groupId);
}
if (list.Any() || rclist.Any()) {
//班级类型查询
var cTypeList = class_TypeRepository.GetClassTypeListRepository(new RB_Class_Type_ViewModel() { Group_Id = groupId });
//基础配置
......@@ -3487,6 +3558,38 @@ namespace Edu.Module.Finance
});
}
//试听课
if (rclist.Any())
{
decimal ClassHourMinute = configModel.BasicMinutes;//课时分钟数
decimal Hours = Math.Round(1 * ClassHourMinute / 60, 2, MidpointRounding.AwayFromZero);//小时
foreach (var item in rclist)
{
RList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.ClassTime + "~" + item.EndTime,
TeacherId = item.TeacherId,
TeacherName = item.TeacherName,
ClassId = item.ReserveClassId,
ClassName = "试听课",
CouseId = item.TrialLessonId,
CourseName = item.LessonName,
KSNum = 1,
Hours = Hours,
HourMoney = Math.Round(item.ClassHourFee / Hours, 2, MidpointRounding.AwayFromZero),
UnitPrice = item.ClassHourFee,
Money = item.ClassHourFee,
CouseClassify = 2,
BaseHoursEnabled = item.BaseHoursEnabled,
EnableTime = item.EnableTime,
SName = item.SName
});
}
}
RList = RList.OrderBy(x => x.Date).ToList();
//初始化 基础课时
DateTime STime = Convert.ToDateTime(startMonth);
while (true)
......@@ -3557,7 +3660,9 @@ namespace Edu.Module.Finance
List<RB_Teaching_BonusDetail_ViewModel> RList = new List<RB_Teaching_BonusDetail_ViewModel>();
//根据学生签到表 查询
var list = class_CheckRepository.GetTeacherConsumptionHoursDetialList(teacherId.ToString(), schoolId, classId, startMonth, endMonth, groupId);
if (list.Any())
//查询试听课
var rclist = reserve_ClassRepository.GetTeacherHoursDetialList(teacherId.ToString(), schoolId, 0, startMonth, endMonth, groupId);
if (list.Any() || rclist.Any())
{
//班级类型查询
var cTypeList = class_TypeRepository.GetClassTypeListRepository(new RB_Class_Type_ViewModel() { Group_Id = groupId });
......@@ -3604,6 +3709,38 @@ namespace Edu.Module.Finance
});
}
//试听课
if (rclist.Any())
{
decimal ClassHourMinute = configModel.BasicMinutes;//课时分钟数
decimal Hours = Math.Round(1 * ClassHourMinute / 60, 2, MidpointRounding.AwayFromZero);//小时
foreach (var item in rclist)
{
RList.Add(new RB_Teaching_BonusDetail_ViewModel
{
Date = item.ClassDate,
TimeBucket = item.ClassTime + "~" + item.EndTime,
TeacherId = item.TeacherId,
TeacherName = item.TeacherName,
ClassId = item.ReserveClassId,
ClassName = "试听课",
CouseId = item.TrialLessonId,
CourseName = item.LessonName,
KSNum = 1,
Hours = Hours,
HourMoney = Math.Round(item.ClassHourFee / Hours, 2, MidpointRounding.AwayFromZero),
UnitPrice = item.ClassHourFee,
Money = item.ClassHourFee,
CouseClassify = 2,
BaseHoursEnabled = item.BaseHoursEnabled,
EnableTime = item.EnableTime,
SName = item.SName
});
}
}
RList = RList.OrderBy(x => x.Date).ToList();
//初始化 基础课时
DateTime STime = Convert.ToDateTime(startMonth);
while (true)
......
......@@ -155,5 +155,80 @@ WHERE 1=1 AND c.Status=0 AND NOT(CONCAT(substring(C.ClassDate,1,10),' ',C.ClassT
}
return result>0;
}
/// <summary>
/// 获取试听班级列表
/// </summary>
/// <param name="rB_Reserve_Class_Extend"></param>
/// <returns></returns>
public List<RB_Reserve_Class_Extend> GetClassReserveList(RB_Reserve_Class_Extend dmodel)
{
string where = " 1=1 and c.Status =0 and c.TrialLessonId >0 and t.CalculateType =2";
if (dmodel.Group_Id > 0)
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.Group_Id)} ={dmodel.Group_Id}";
}
if (!string.IsNullOrEmpty(dmodel.TeacherIds))
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.TeacherId)} in({dmodel.TeacherIds})";
}
if (!string.IsNullOrEmpty(dmodel.ClassTime))
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.ClassDate)} >='{dmodel.ClassTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.ClassDate)} <='{dmodel.EndTime} 23:59:59'";
}
string sql = $@"select c.*,t.ClassHourFee,t.LessonName as ClassName,(select count(0) from rb_visitor_reserve v where v.ReserveClassId = c.ReserveClassId and v.Status =0 ) as CheckNum
from RB_Reserve_Class c
left join rb_triallesson t on c.TrialLessonId = t.Id
where {where}";
return Get<RB_Reserve_Class_Extend>(sql).ToList();
}
/// <summary>
/// 获取试听班级列表
/// </summary>
/// <param name="userIds"></param>
/// <param name="schoolId"></param>
/// <param name="classId"></param>
/// <param name="startMonth"></param>
/// <param name="endMonth"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public List<RB_Reserve_Class_Extend> GetTeacherHoursDetialList(string userIds, int schoolId, int classId, string startMonth, string endMonth, int groupId)
{
string where = " 1=1 and c.Status =0 and c.TrialLessonId >0 and t.CalculateType =2";
if (groupId > 0)
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.Group_Id)} ={groupId}";
}
if (schoolId > 0)
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.School_Id)} ={schoolId}";
}
if (!string.IsNullOrEmpty(userIds))
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.TeacherId)} in({userIds})";
}
if (!string.IsNullOrEmpty(startMonth))
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.ClassDate)} >='{startMonth}'";
}
if (!string.IsNullOrEmpty(endMonth))
{
where += $@" and c.{nameof(RB_Reserve_Class_Extend.ClassDate)} <='{endMonth} 23:59:59'";
}
string sql = $@"select c.*,t.ClassHourFee,t.LessonName,t2.TeacherName,t2.BaseHoursEnabled,t2.EnableTime,s.SName
from RB_Reserve_Class c
left join rb_triallesson t on c.TrialLessonId = t.Id
LEFT JOIN rb_teacher t2 on c.TeacherId = t2.TId
left join rb_school s on s.SId = c.School_Id
where {where}";
return Get<RB_Reserve_Class_Extend>(sql).ToList();
}
}
}
......@@ -155,10 +155,13 @@ where {where} order by bd.Date asc";
where += $@" and b.{nameof(RB_Teaching_BonusDetail.Type)} ={demodel.Type}";
}
string sql = $@" select b.*,t.TeacherName,c.ClassName,c.ClassNo,s.SName from RB_Teaching_BonusDetail b
string sql = $@" select b.*,t.TeacherName,case when b.CouseClassify =1 then c.ClassName else tr.LessonName end as ClassName,
c.ClassNo,s.SName from RB_Teaching_BonusDetail b
left join rb_teacher t on b.TeacherId = t.TId
left join rb_class c on b.ClassId = c.ClassId
left join rb_class c on b.ClassId = c.ClassId and b.CouseClassify =1
left join rb_school s on b.School_Id = s.SId
left join rb_reserve_class rc on b.ClassId = rc.ReserveClassId and b.CouseClassify =2
left join rb_triallesson tr on rc.TrialLessonId = tr.Id
where {where} order by b.TeacherId asc,b.Date asc";
return Get<RB_Teaching_BonusDetail_ViewModel>(sql).ToList();
}
......
......@@ -268,14 +268,15 @@ namespace Edu.WebApi.Controllers.Course
x.TeacherName,
x.SName,
x.ClassId,
x.ClassName,
x.ClassNo,
ClassName = x.ClassName + (x.CouseClassify == 2 ? "(试听)" : ""),
ClassNo = string.IsNullOrEmpty(x.ClassNo) ? "-" : x.ClassNo,
x.Type,
x.CourseHour,
x.DeductionHour,
x.UnitPrice,
x.CheckInNum,
x.Money
x.Money,
x.CouseClassify
}),
Statistics = slit.GroupBy(x => x.SName).Select(x => new
{
......@@ -342,8 +343,8 @@ namespace Edu.WebApi.Controllers.Course
new ExcelColumn(value: item.Date.ToString("yyyyMMdd")){ },
new ExcelColumn(value: item.TeacherName){ },
new ExcelColumn(value: item.SName){ },
new ExcelColumn(value: item.ClassNo){ },
new ExcelColumn(value: item.ClassName){ },
new ExcelColumn(value: string.IsNullOrEmpty(item.ClassNo) ? "-" : item.ClassNo){ },
new ExcelColumn(value: item.ClassName + (item.CouseClassify == 2 ? "(试听)" :"")){ },
new ExcelColumn(value: item.Type==1?"带班":"代课"){ },
new ExcelColumn(value: item.DeductionHour.ToString()){ },
new ExcelColumn(value: item.CourseHour.ToString()){ },
......
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