Commit a91c5ee9 authored by 黄奎's avatar 黄奎

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents c391ada1 0f68ce9c
......@@ -139,6 +139,11 @@ namespace Edu.Model.ViewModel.User
/// </summary>
public int AppointNum { get; set; }
/// <summary>
/// 可补课数量
/// </summary>
public int MakeUpNum { get; set; }
/// <summary>
/// 订单创建时间
/// </summary>
......
......@@ -5514,57 +5514,54 @@ namespace Edu.Module.Course
if (classScrollType == 2)
{
//约课
planModel = class_PlanRepository.GetToDayClassPlanForYK(stuId, courseId, groupId);
//planModel = class_PlanRepository.GetToDayClassPlanForYK(stuId, courseId, groupId, 1);
//约课查询 约课记录里的 已上课 /未上课 的最近一条记录
NextCourseNo = scroll_AppointmentRepository.GetNextAppointList(guestId, groupId, 2);
ReviewCourseNo = scroll_AppointmentRepository.GetNextAppointList(guestId, groupId, 1);
}
else
{
planModel = class_PlanRepository.GetToDayClassPlan(classId, groupId);
}
if (planModel != null)
{
int zj = 1;
if (classScrollType == 2)
{
var ogModel = order_GuestRepository.GetEntity(guestId);
zj = ogModel.CourseChapterNo + 1;//这次课的章节
}
else
{
zj = planModel.LessonPlanNum + 1;
}
if (planModel.ClassDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
{
//查询上课时间 看这节课到底上没有上
var timeList = class_TimeRepository.GetClassTimeListRepository(new RB_Class_Time_ViewModel() { Group_Id = groupId, ClassPlanId = planModel.ClassPlanId });
string MaxTime = timeList.Max(x => x.EndTime);
if (DateTime.Now < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + MaxTime))
if (planModel != null) {
int zj = planModel.LessonPlanNum + 1;
if (planModel.ClassDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
{
//查询上课时间 看这节课到底上没有上
var timeList = class_TimeRepository.GetClassTimeListRepository(new RB_Class_Time_ViewModel() { Group_Id = groupId, ClassPlanId = planModel.ClassPlanId });
string MaxTime = timeList.Max(x => x.EndTime);
if (DateTime.Now < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + MaxTime))
{
//当日课未结束
NextCourseNo = zj;
ReviewCourseNo = zj - 1;
}
else
{
//当日课已结束
ReviewCourseNo = zj;
NextCourseNo = zj + 1;
}
}
else if (planModel.ClassDate > DateTime.Now)
{
//当日课未结束
//未开始上此课
NextCourseNo = zj;
ReviewCourseNo = zj - 1;
}
else
{
//当日课已结束
//这节课已上了
ReviewCourseNo = zj;
NextCourseNo = zj + 1;
}
}
else if (planModel.ClassDate > DateTime.Now)
else
{
//未开始上此课
NextCourseNo = zj;
ReviewCourseNo = zj - 1;
//可能未开班 可能计划不存在 直接查询 第一章节的词汇
NextCourseNo = 1;
}
else {
//这节课已上了
ReviewCourseNo = zj;
NextCourseNo = zj + 1;
}
}
else {
//可能未开班 可能计划不存在 直接查询 第一章节的词汇
NextCourseNo = 1;
}
int NextNum = 0, ReviewNum = 0;
if (NextCourseNo > 0) {
......
......@@ -237,10 +237,10 @@ namespace Edu.Module.Course
//人数未达标 取消课程
foreach (var qitem in item.Where(x => !CancelStuId.Contains(x.StuId)))
{
if (qitem.AppointType != 3)
{
CancelStuId.Add(qitem.StuId);
}
//if (qitem.AppointType != 3)
//{
// CancelStuId.Add(qitem.StuId);
//}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Scroll_Appointment_ViewModel.State), Common.Enum.Course.CourseAppointStateEnum.Cancel},
{ nameof(RB_Scroll_Appointment_ViewModel.Remark), qitem.Remark +";人数"+item.Where(x => !CancelStuId.Contains(x.StuId)).Count()+",成本人数"+item.Key.ScrollMinNum+",未满足定时器取消"+DateTime.Now},
......@@ -290,7 +290,8 @@ namespace Edu.Module.Course
}
#region 之后的取消
if (qitem.AppointType !=3)
//暂时取消
if (qitem.AppointType == -1)
{
var clist = scroll_AppointmentRepository.GetAppointList(new RB_Scroll_Appointment_ViewModel() { Group_Id = groupId, StartTime = qitem.Date.ToString("yyyy-MM-dd"), StuId = qitem.StuId, State = Common.Enum.Course.CourseAppointStateEnum.WaitSure });
foreach (var qcitem in clist)
......@@ -671,10 +672,16 @@ namespace Edu.Module.Course
//更新 order_guest 表 上课章节 请假也暂时先算完成课时(请假应该是有补课的)
var gmodel = order_GuestRepository.GetEntity(item.GuestId);
if (gmodel != null && gmodel.CourseChapterNo < item.ChapterNo) {
//ld 2022-03-08 修改为学员上课最大课时
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(Model.ViewModel.Sell.RB_Order_Guest_ViewModel.CourseChapterNo), gmodel.CourseChapterNo +1},
{ nameof(Model.ViewModel.Sell.RB_Order_Guest_ViewModel.CompleteHours), gmodel.CompleteHours + clist.Sum(x=>x.ClassHours)}
{ nameof(Model.ViewModel.Sell.RB_Order_Guest_ViewModel.CourseChapterNo), item.ChapterNo},
{ nameof(Model.ViewModel.Sell.RB_Order_Guest_ViewModel.CompleteHours), item.ChapterNo * clist.Sum(x=>x.ClassHours)}
};
if (gmodel.TotalChapterNo <= item.ChapterNo)
{
//章节已上完了 修改为 毕业
keyValues1.Add(nameof(Model.ViewModel.Sell.RB_Order_Guest_ViewModel.GuestState), Common.Enum.Course.GuestStateEnum.Graduate);
}
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName = nameof(Model.ViewModel.Sell.RB_Order_Guest_ViewModel.Id),
......
This diff is collapsed.
......@@ -54,6 +54,10 @@ WHERE 1=1 AND A.Status=0 ");
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Check_ViewModel.OrderGuestId), query.OrderGuestId);
}
if (!string.IsNullOrEmpty(query.QClassPlanIds))
{
builder.AppendFormat(" AND ct.ClassPlanId IN({0}) ", query.QClassPlanIds);
}
if (!string.IsNullOrEmpty(query.QOrderGuestIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Class_Check_ViewModel.OrderGuestId), query.QOrderGuestIds);
......
......@@ -44,6 +44,10 @@ namespace Edu.Repository.Scroll
{
where += $@" and r.{nameof(RB_Scroll_Appointment_ViewModel.CourseEndTime)} <='{demodel.CourseEndTimeStr}'";
}
if (!string.IsNullOrEmpty(demodel.ShiftSort))
{
where += $@" and r.{nameof(RB_Scroll_Appointment_ViewModel.ShiftSort)} ='{demodel.ShiftSort}'";
}
if (demodel.TeacherId > 0)
{
where += $@" and c.AccountId ={demodel.TeacherId}";
......@@ -64,6 +68,14 @@ namespace Edu.Repository.Scroll
{
where += $@" and r.{nameof(RB_Scroll_Appointment_ViewModel.AppointType)} ={demodel.AppointType}";
}
if (demodel.CourseGradeId > 0)
{
where += $@" and r.{nameof(RB_Scroll_Appointment_ViewModel.CourseGradeId)} ={(int)demodel.CourseGradeId}";
}
if (demodel.CourseGradeNo > 0)
{
where += $@" and r.{nameof(RB_Scroll_Appointment_ViewModel.CourseGradeNo)} ={demodel.CourseGradeNo}";
}
string sql = $@"
SELECT r.*,c.AccountId as TeacherId,s.StuName,cou.CourseName,cou.ScrollMinNum,cou.ScrollMaxNum From RB_Scroll_Appointment r
......@@ -293,5 +305,30 @@ WHERE a.Group_Id ={group_Id} and a.State =3 and a.AppointType =1 and a.CourseGra
ORDER BY a.OrderId DESC";
return Get<RB_Scroll_Appointment_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取约课下一次课
/// </summary>
/// <param name="guestId"></param>
/// <param name="groupId"></param>
/// <param name="type"></param>
/// <returns></returns>
public int GetNextAppointList(int guestId, int groupId, int type)
{
if (type == 1)
{
//复习
string sql = $@"SELECT ChapterNo FROM rb_scroll_appointment WHERE Group_Id ={groupId} and State <>5 and GuestId ={guestId} and CourseEndTime <= NOW() ORDER BY CourseEndTime DESC LIMIT 1";
var robj = ExecuteScalar(sql);
return robj == null ? 0 : Convert.ToInt32(robj);
}
else {
//下一次约课
string sql = $@"SELECT ChapterNo FROM rb_scroll_appointment WHERE Group_Id ={groupId} and State <>5 and GuestId ={guestId} and CourseEndTime > NOW() ORDER BY CourseEndTime ASC LIMIT 1";
var robj = ExecuteScalar(sql);
return robj == null ? 0 : Convert.ToInt32(robj);
}
}
}
}
......@@ -301,7 +301,7 @@ FROM rb_student_orderguest og
INNER JOIN rb_order_guest g on og.GuestId = g.Id
INNER JOIN rb_order o on og.OrderId = o.OrderId
INNER JOIN rb_class c on o.ClassId = c.ClassId
WHERE og.Status =0 and g.`Status` =0 and o.Group_Id ={group_Id} and o.OrderState <>3 and o.OrderType =1 and g.TotalHours > g.CompleteHours and og.Student_Id ={accountId} {(guestId > 0 ? "and og.GuestId =" + guestId : "")}
WHERE og.Status =0 and g.`Status` =0 and o.Group_Id ={group_Id} and o.OrderState <>3 and o.OrderType =1 {(guestId > 0 ? "" : "and g.TotalHours > g.CompleteHours")} and og.Student_Id ={accountId} {(guestId > 0 ? "and og.GuestId =" + guestId : "")}
ORDER BY og.Id asc LIMIT 1";
return Get<RB_Student_OrderGuest_ViewModel>(sql).FirstOrDefault();
}
......@@ -813,6 +813,39 @@ and og.TotalChapterNo > og.CourseChapterNo and (og.CourseChapterNo + 1 + IFNULL(
return Get<RB_Student_OrderGuest_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取可约课的学生列表
/// </summary>
/// <param name="group_Id"></param>
/// <returns></returns>
public List<RB_Student_OrderGuest_ViewModel> GetCanAppointmentStuList_V2(string stuName, int NextChapterGradeNo, int CourseGradeId, int SchoolId, int group_Id)
{
string sql = $@"SELECT sog.Student_Id,sog.GuestId,sog.OrderId,cou.CourseName,s.StuName as GuestName,og.CourseChapterNo,sa.AppointNum,ss.MakeUpNum FROM rb_student_orderguest sog
INNER JOIN rb_order_guest og on sog.GuestId = og.Id
INNER JOIN rb_order o on sog.OrderId = o.OrderId
INNER JOIN rb_course cou on o.CourseId = cou.CourseId
INNER JOIN rb_student s on sog.Student_Id = s.StuId
INNER JOIN rb_class c on o.ClassId = c.ClassId
inner join rb_course_chapter cc on o.CourseId = cc.CourseId and cc.ParentId =0 and cc.ChapterGradeNo ={NextChapterGradeNo} and cc.CourseRate ={CourseGradeId}
LEFT JOIN (
SELECT sa1.StuId,COUNT(0) as AppointNum FROM rb_scroll_appointment sa1
INNER JOIN rb_student s1 on sa1.StuId = s1.StuId
WHERE sa1.`Status` =0 and sa1.State <>5 and sa1.Group_Id ={group_Id} and s1.StuName LIKE '%{stuName}%' and sa1.CourseGradeId ={CourseGradeId} and sa1.CourseGradeNo ={NextChapterGradeNo} GROUP BY sa1.StuId
) sa on sog.Student_Id = sa.StuId
LEFT JOIN (
SELECT ss1.StuId,COUNT(0) as MakeUpNum FROM rb_scroll_skipcourse ss1
INNER JOIN rb_student s1 on ss1.StuId = s1.StuId
WHERE ss1.`Status` =0 and ss1.State =1 and ss1.Group_Id ={group_Id} and s1.StuName LIKE '%{stuName}%' and ss1.CourseGradeId ={CourseGradeId} and ss1.CourseGradeNo ={NextChapterGradeNo} GROUP BY ss1.StuId
) ss on sog.Student_Id = ss.StuId
WHERE o.Group_Id ={group_Id} and sog.`Status` =0 and og.GuestState <>2 and o.OrderState <>3 and c.ClassScrollType =2 and s.StuName LIKE '%{stuName}%'";
if (SchoolId >= 0)
{
sql += $@" and o.ScrollSchoolId ={SchoolId}";
}
return Get<RB_Student_OrderGuest_ViewModel>(sql).ToList();
}
/// <summary>
/// 获取所有学习中的学生列表
/// </summary>
......
......@@ -725,6 +725,221 @@ namespace Edu.WebApi.Controllers.Course
}
#endregion
#region 约课调整
/// <summary>
/// 获取可约课的学生列表(包括补课 重上)
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCanAppointmentStuList_V2()
{
var userInfo = base.UserInfo;
string StuName = base.ParmJObj.GetStringValue("StuName");//学生姓名
int CourseGradeId = base.ParmJObj.GetInt("CourseGradeId", 0);//上课等级ID
int NextCourseGradeNo = base.ParmJObj.GetInt("NextCourseGradeNo", 0);//上课等级ID对应的课次
int SchoolId = base.ParmJObj.GetInt("SchoolId", -1);//约课校区
if (string.IsNullOrEmpty(StuName) || CourseGradeId <= 0 || NextCourseGradeNo <= 0)
{
return ApiResult.ParamIsNull();
}
var list = scrollClassModule.GetCanAppointmentStuList_V2(StuName, NextCourseGradeNo, CourseGradeId, SchoolId, userInfo.Group_Id);
return ApiResult.Success("", list.Select(x => new
{
StuId = x.Student_Id,
StuName = x.GuestName,
x.GuestId,
x.OrderId,
x.CourseName,
x.CourseChapterNo,
x.AppointNum,
State = x.AppointNum > 0 ? 3 : 1
}));
}
/// <summary>
/// 后台预约课(可随机约课)
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetAdminScrollAppointment_V2()
{
var userInfo = base.UserInfo;
RB_Scroll_Appointment_ViewModel demodel = JsonHelper.DeserializeObject<RB_Scroll_Appointment_ViewModel>(base.RequestParm.Msg.ToString());
if (demodel.TeacherId <= 0)
{
return ApiResult.ParamIsNull("请传递老师编号ID");
}
if (string.IsNullOrEmpty(demodel.ShiftSort))
{
return ApiResult.ParamIsNull("请传递上课时段");
}
if (demodel.StuId <= 0)
{
return ApiResult.ParamIsNull("请传递学生ID");
}
if (demodel.GuestId <= 0)
{
return ApiResult.ParamIsNull("请传递学生ID");
}
if (demodel.CourseGradeId <= 0 && demodel.CourseGradeNo <= 0)
{
return ApiResult.ParamIsNull("请传递上课的等级");
}
#region 验证是否连续的时段
List<int> SortList = JsonHelper.DeserializeObject<List<int>>("[" + demodel.ShiftSort + "]");
int MinSort = SortList.Min(x => x);
string ShiftSort = "";
for (var i = 0; i < SortList.Count(); i++)
{
ShiftSort += (MinSort + i) + ",";
}
if (ShiftSort != demodel.ShiftSort + ",")
{
return ApiResult.ParamIsNull("需预约连续的时段");
}
#endregion
demodel.State = CourseAppointStateEnum.WaitSure;
demodel.Status = 0;
demodel.Group_Id = userInfo.Group_Id;
demodel.CreateBy = userInfo.Id;
demodel.CreateTime = DateTime.Now;
demodel.UpdateBy = userInfo.Id;
demodel.UpdateTime = DateTime.Now;
string msg = scrollClassModule.SetAdminScrollAppointment_V2(demodel, out int AppointId);
if (msg == "")
{
return ApiResult.Success("", AppointId);
}
else
{
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 补历史约课
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetAdminScrollMakeUp() {
var userInfo = base.UserInfo;
RB_Scroll_Appointment_ViewModel demodel = JsonHelper.DeserializeObject<RB_Scroll_Appointment_ViewModel>(base.RequestParm.Msg.ToString());
if (demodel.TeacherId <= 0)
{
return ApiResult.ParamIsNull("请传递老师编号ID");
}
if (string.IsNullOrEmpty(demodel.ShiftSort))
{
return ApiResult.ParamIsNull("请传递上课时段");
}
if (demodel.StuId <= 0)
{
return ApiResult.ParamIsNull("请传递学生ID");
}
if (demodel.GuestId <= 0)
{
return ApiResult.ParamIsNull("请传递学生ID");
}
if (demodel.CourseGradeId <= 0 && demodel.CourseGradeNo <= 0)
{
return ApiResult.ParamIsNull("请传递上课的等级");
}
#region 验证是否连续的时段
List<int> SortList = JsonHelper.DeserializeObject<List<int>>("[" + demodel.ShiftSort + "]");
int MinSort = SortList.Min(x => x);
string ShiftSort = "";
for (var i = 0; i < SortList.Count(); i++)
{
ShiftSort += (MinSort + i) + ",";
}
if (ShiftSort != demodel.ShiftSort + ",")
{
return ApiResult.ParamIsNull("需预约连续的时段");
}
#endregion
demodel.State = CourseAppointStateEnum.WaitSure;
demodel.Status = 0;
demodel.Group_Id = userInfo.Group_Id;
demodel.CreateBy = userInfo.Id;
demodel.CreateTime = DateTime.Now;
demodel.UpdateBy = userInfo.Id;
demodel.UpdateTime = DateTime.Now;
string msg = scrollClassModule.SetAdminScrollMakeUp(demodel, out int AppointId);
if (msg == "")
{
return ApiResult.Success("", AppointId);
}
else
{
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 取消已确认的预约
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult CancelSureAppointment()
{
var userInfo = base.UserInfo;
string AppointIds = base.ParmJObj.GetStringValue("AppointIds");
int TeacherId = base.ParmJObj.GetInt("TeacherId", 0);
string Date = base.ParmJObj.GetStringValue("Date");
string ShiftSort = base.ParmJObj.GetStringValue("ShiftSort");
if (string.IsNullOrEmpty(AppointIds) || TeacherId <= 0 || string.IsNullOrEmpty(Date) || string.IsNullOrEmpty(ShiftSort))
{
return ApiResult.ParamIsNull();
}
string msg = scrollClassModule.CancelSureAppointment(AppointIds, TeacherId, Date, ShiftSort, userInfo);
if (msg == "")
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 切换约课老师
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetScrollTeacher() {
var userInfo = base.UserInfo;
int TeacherId = base.ParmJObj.GetInt("TeacherId", 0);
string Date = base.ParmJObj.GetStringValue("Date");
string ShiftSort = base.ParmJObj.GetStringValue("ShiftSort");
int NewTeacherId = base.ParmJObj.GetInt("NewTeacherId", 0);
if (TeacherId <= 0 || NewTeacherId <= 0 || string.IsNullOrEmpty(Date) || string.IsNullOrEmpty(ShiftSort))
{
return ApiResult.ParamIsNull();
}
//string msg = scrollClassModule.SetScrollTeacher(TeacherId, Date, ShiftSort, NewTeacherId, userInfo);
//if (msg == "")
//{
// return ApiResult.Success();
//}
//else
//{
// return ApiResult.Failed(msg);
//}
return ApiResult.Success();
}
#endregion
#region 初始化约课数据
/// <summary>
/// 初始化约课数据
......
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