Commit 22542a4b authored by 黄奎's avatar 黄奎

约课,新增课时验证

parent 8d261c91
......@@ -72,6 +72,11 @@ namespace Edu.Model.ViewModel.User
/// </summary>
public decimal CompleteHours { get; set; }
/// <summary>
/// 学员签到课时
/// </summary>
public decimal CheckHours { get; set; }
/// <summary>
/// 班级状态
/// </summary>
......
This diff is collapsed.
......@@ -91,6 +91,23 @@ ORDER BY r.Id asc ";
return Get<RB_Scroll_Appointment_ViewModel>(sql, parameters).ToList();
}
/// <summary>
/// 查询学员 已预约,且为上课 次数,用于计算是否约满课程
/// </summary>
/// <param name="GuestId"></param>
/// <returns></returns>
public List<RB_Scroll_Appointment_ViewModel> GetStuScrollAppointmentNotFinishRepository(int GuestId)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT r.*
FROM RB_Scroll_Appointment r
WHERE 1=1 AND r.Status=0 AND Date>='{0}' AND r.State IN(1,2,6)
", Common.ConvertHelper.FormatDate(DateTime.Now));
builder.AppendFormat(" AND r.GuestId IN({0}) ", GuestId);
return Get<RB_Scroll_Appointment_ViewModel>(builder.ToString()).ToList();
}
/// <summary>
/// 获取我预约的次数
/// </summary>
......@@ -329,7 +346,6 @@ GROUP BY StuId) as t on t.Date=sat.Date and t.StuId=sat.StuId
/// <param name="groupId"></param>
public void UpdateAppointSkipCourse(int stuId, int guestId, int ChapterNum,int SChapterNo, int groupId)
{
string sql = $@"UPDATE rb_scroll_appointment a
SET a.ChapterNo = a.ChapterNo +{ChapterNum},a.CourseGradeId = (SELECT CourseRate FROM rb_course_chapter c WHERE c.Group_Id ={groupId} and c.CourseId =a.LearnCourseId and c.ChapterNo =a.ChapterNo)
,a.CourseGradeNo = (SELECT ChapterGradeNo FROM rb_course_chapter c WHERE c.Group_Id ={groupId} and c.CourseId =a.LearnCourseId and c.ChapterNo =a.ChapterNo)
......
......@@ -400,11 +400,12 @@ ORDER BY {(Type == 1 ? "og.Id asc" : "og.Id desc")} LIMIT 1";
public RB_Student_OrderGuest_ViewModel GetStudentLearningCourse(int accountId, int group_Id, int guestId = 0)
{
string sql = $@"
SELECT og.*,o.CourseId,g.CourseChapterNo,c.ClassScrollType,o.ScrollSchoolId
SELECT og.*,o.CourseId,g.CourseChapterNo,c.ClassScrollType,o.ScrollSchoolId,g.TotalHours,g.CompleteHours,IFNULL(cc.CheckHours,0) AS CheckHours
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
LEFT JOIN (SELECT OrderGuestId,SUM(CurrentDeductionHours) AS CheckHours FROM rb_class_check WHERE Status=0 GROUP BY OrderGuestId) AS cc ON og.GuestId=cc.OrderGuestId
WHERE og.Status =0 AND g.`Status` =0 AND o.OrderState <>3 AND o.OrderType =1
";
if (group_Id > 0)
......
......@@ -347,64 +347,6 @@ namespace Edu.WebApi.Controllers.Course
}
}
/// <summary>
/// 后台预约课
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetAdminScrollAppointment()
{
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");
}
#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(demodel, out int AppointId);
if (msg == "")
{
return ApiResult.Success("", AppointId);
}
else
{
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 后台预约课(批量)
/// </summary>
......@@ -473,7 +415,7 @@ namespace Edu.WebApi.Controllers.Course
demodel.StuId = item.StuId;
demodel.GuestId = item.GuestId;
demodel.StuName = item.StuName;
string msg = "";// scrollClassModule.SetAdminScrollAppointment(demodel);
string msg = "";
if (msg != "")
{
return ApiResult.Failed(msg);
......@@ -757,79 +699,7 @@ namespace Edu.WebApi.Controllers.Course
}));
}
/// <summary>
/// 后台预约课(可随机约课)
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetAdminScrollAppointment_V2()
{
var userInfo = base.UserInfo;
RB_Scroll_Appointment_ViewModel demodel = new RB_Scroll_Appointment_ViewModel()
{
CourseGradeId = (CourseRateEnum)base.ParmJObj.GetInt("CourseGradeId"),
CourseGradeNo = base.ParmJObj.GetInt("CourseGradeNo"),
CourseId = base.ParmJObj.GetInt("CourseId"),
Date = base.ParmJObj.GetDateTime("Date"),
GuestId = base.ParmJObj.GetInt("GuestId"),
RoomId = base.ParmJObj.GetInt("RoomId"),
ShiftSort = base.ParmJObj.GetStringValue("ShiftSort"),
StuId = base.ParmJObj.GetInt("StuId"),
StuName = base.ParmJObj.GetStringValue("StuName"),
TeacherId = base.ParmJObj.GetInt("TeacherId"),
};
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.SetAdminScrollAppointmentModuleV2(demodel, out int AppointId);
if (msg == "")
{
return ApiResult.Success("", AppointId);
}
else
{
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 后台预约课[HK2022-07-06修改]
......@@ -897,24 +767,10 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.ParamIsNull("请传递学生ID");
}
#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
string msg = "";
foreach (var item in list)
{
msg += scrollClassModule.SetAdminScrollAppointmentModuleV2(item, out int AppointId);
msg += scrollClassModule.SetAdminScrollAppointmentModule(item, out int AppointId);
}
if (msg == "")
{
......
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