Commit 7d2b8c13 authored by 吴春's avatar 吴春

解决冲突

parents 080d7001 22542a4b
...@@ -72,6 +72,11 @@ namespace Edu.Model.ViewModel.User ...@@ -72,6 +72,11 @@ namespace Edu.Model.ViewModel.User
/// </summary> /// </summary>
public decimal CompleteHours { get; set; } public decimal CompleteHours { get; set; }
/// <summary>
/// 学员签到课时
/// </summary>
public decimal CheckHours { get; set; }
/// <summary> /// <summary>
/// 班级状态 /// 班级状态
/// </summary> /// </summary>
......
This diff is collapsed.
...@@ -91,6 +91,23 @@ ORDER BY r.Id asc "; ...@@ -91,6 +91,23 @@ ORDER BY r.Id asc ";
return Get<RB_Scroll_Appointment_ViewModel>(sql, parameters).ToList(); 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>
/// 获取我预约的次数 /// 获取我预约的次数
/// </summary> /// </summary>
...@@ -329,7 +346,6 @@ GROUP BY StuId) as t on t.Date=sat.Date and t.StuId=sat.StuId ...@@ -329,7 +346,6 @@ GROUP BY StuId) as t on t.Date=sat.Date and t.StuId=sat.StuId
/// <param name="groupId"></param> /// <param name="groupId"></param>
public void UpdateAppointSkipCourse(int stuId, int guestId, int ChapterNum,int SChapterNo, int groupId) public void UpdateAppointSkipCourse(int stuId, int guestId, int ChapterNum,int SChapterNo, int groupId)
{ {
string sql = $@"UPDATE rb_scroll_appointment a 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) 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) ,a.CourseGradeNo = (SELECT ChapterGradeNo FROM rb_course_chapter c WHERE c.Group_Id ={groupId} and c.CourseId =a.LearnCourseId and c.ChapterNo =a.ChapterNo)
......
...@@ -40,8 +40,15 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2 ...@@ -40,8 +40,15 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2
|| query.QCourseRate == Common.Enum.Course.CourseRateEnum.N2 || query.QCourseRate == Common.Enum.Course.CourseRateEnum.N2
|| query.QCourseRate == Common.Enum.Course.CourseRateEnum.N1) || query.QCourseRate == Common.Enum.Course.CourseRateEnum.N1)
{ {
List<int> courseIdList = new List<int>();
builder.AppendFormat(" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE 1=1 AND (CourseId=B.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=A.OrderId)) AND CourseRate IN({0})) ", (int)query.QCourseRate); string chapterSql = string.Format(" SELECT DISTINCT CourseId FROM rb_course_chapter WHERE Status=0 AND CourseRate ={0} ", (int)query.QCourseRate);
List<RB_Course_Chapter> chapterList = base.Get<RB_Course_Chapter>(chapterSql).ToList();
if (chapterList != null && chapterList.Count > 0)
{
courseIdList.AddRange(chapterList.Select(qitem => qitem.CourseId).ToList());
}
builder.AppendFormat(@" AND (B.CourseId IN({0}) OR EXISTS (SELECT 1 FROM rb_order_course WHERE OrderId=A.OrderId AND CourseId IN({0}))) ", string.Join(",", courseIdList));
//builder.AppendFormat(" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE 1=1 AND (CourseId=B.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=A.OrderId)) AND CourseRate IN({0})) ", (int)query.QCourseRate);
} }
else else
{ {
...@@ -81,14 +88,7 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2 ...@@ -81,14 +88,7 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2
{ {
string guestIds = string.Join(",", list.Select(qitem => qitem.GuestId).Distinct()); string guestIds = string.Join(",", list.Select(qitem => qitem.GuestId).Distinct());
string courseIds = string.Join(",", list.Select(qitem => qitem.CourseId).Distinct()); string courseIds = string.Join(",", list.Select(qitem => qitem.CourseId).Distinct());
// string courseChapterSql = string.Format(@"
//SELECT CourseId,ChapterGradeNo
//FROM rb_course_chapter
//WHERE CourseId IN({0}) AND CourseRate IN({1}) ", courseIds, (int)query.QCourseRate);
// var chapterList= Get<RB_Course_Chapter>(courseChapterSql).ToList();
StringBuilder appointBuilder = new StringBuilder(); StringBuilder appointBuilder = new StringBuilder();
appointBuilder.AppendFormat(@" appointBuilder.AppendFormat(@"
SELECT A.Date,A.AccountId,A.State,A.GuestId,A.LearnCourseId,A.CourseGradeId,A.CourseGradeNo,IFNULL(C.ClassCheckId,0) AS ClassCheckId SELECT A.Date,A.AccountId,A.State,A.GuestId,A.LearnCourseId,A.CourseGradeId,A.CourseGradeNo,IFNULL(C.ClassCheckId,0) AS ClassCheckId
......
using Edu.Common.Enum; using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.Entity.User; using Edu.Model.Entity.User;
using Edu.Model.ViewModel.Customer; using Edu.Model.ViewModel.Customer;
using Edu.Model.ViewModel.Sell; using Edu.Model.ViewModel.Sell;
...@@ -399,11 +400,12 @@ ORDER BY {(Type == 1 ? "og.Id asc" : "og.Id desc")} LIMIT 1"; ...@@ -399,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) public RB_Student_OrderGuest_ViewModel GetStudentLearningCourse(int accountId, int group_Id, int guestId = 0)
{ {
string sql = $@" 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 FROM rb_student_orderguest og
INNER JOIN rb_order_guest g on og.GuestId = g.Id INNER JOIN rb_order_guest g on og.GuestId = g.Id
INNER JOIN rb_order o on og.OrderId = o.OrderId INNER JOIN rb_order o on og.OrderId = o.OrderId
INNER JOIN rb_class c on o.ClassId = c.ClassId 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 WHERE og.Status =0 AND g.`Status` =0 AND o.OrderState <>3 AND o.OrderType =1
"; ";
if (group_Id > 0) if (group_Id > 0)
...@@ -1003,6 +1005,13 @@ and og.TotalChapterNo > og.CourseChapterNo and (og.CourseChapterNo + 1 + IFNULL( ...@@ -1003,6 +1005,13 @@ and og.TotalChapterNo > og.CourseChapterNo and (og.CourseChapterNo + 1 + IFNULL(
/// <returns></returns> /// <returns></returns>
public List<RB_Student_OrderGuest_ViewModel> GetCanAppointmentStuListRepository_V2(string stuName, int NextChapterGradeNo, int CourseGradeId, int SchoolId, int group_Id) public List<RB_Student_OrderGuest_ViewModel> GetCanAppointmentStuListRepository_V2(string stuName, int NextChapterGradeNo, int CourseGradeId, int SchoolId, int group_Id)
{ {
List<int> courseIdList = new List<int>();
string chapterSql = string.Format(" SELECT DISTINCT CourseId FROM rb_course_chapter WHERE Status=0 AND CourseRate ={0} ", CourseGradeId);
List<RB_Course_Chapter> chapterList = base.Get<RB_Course_Chapter>(chapterSql).ToList();
if (chapterList != null && chapterList.Count > 0)
{
courseIdList.AddRange(chapterList.Select(qitem => qitem.CourseId).ToList());
}
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
string sql = $@" string sql = $@"
SELECT sog.Student_Id,sog.GuestId,sog.OrderId,cou.CourseName,s.StuName as GuestName,og.CourseChapterNo,sa.AppointNum,ss.MakeUpNum SELECT sog.Student_Id,sog.GuestId,sog.OrderId,cou.CourseName,s.StuName as GuestName,og.CourseChapterNo,sa.AppointNum,ss.MakeUpNum
...@@ -1036,7 +1045,8 @@ WHERE o.Group_Id ={group_Id} and sog.`Status` =0 and og.GuestState NOT IN(2) and ...@@ -1036,7 +1045,8 @@ WHERE o.Group_Id ={group_Id} and sog.`Status` =0 and og.GuestState NOT IN(2) and
} }
//sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND CourseId= o.CourseId AND ParentId =0 AND CourseRate ={0})", CourseGradeId); //sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND CourseId= o.CourseId AND ParentId =0 AND CourseRate ={0})", CourseGradeId);
sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND (CourseId= o.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=sog.OrderId)) AND CourseRate ={0})", CourseGradeId); //sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND (CourseId= o.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=sog.OrderId)) AND CourseRate ={0})", CourseGradeId);
sql += string.Format(@" AND (o.CourseId IN({0}) OR EXISTS (SELECT 1 FROM rb_order_course WHERE OrderId=sog.OrderId AND CourseId IN({0}))) ", string.Join(",", courseIdList));
return Get<RB_Student_OrderGuest_ViewModel>(sql, parameters).ToList(); return Get<RB_Student_OrderGuest_ViewModel>(sql, parameters).ToList();
} }
......
...@@ -347,64 +347,6 @@ namespace Edu.WebApi.Controllers.Course ...@@ -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>
/// 后台预约课(批量) /// 后台预约课(批量)
/// </summary> /// </summary>
...@@ -473,7 +415,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -473,7 +415,7 @@ namespace Edu.WebApi.Controllers.Course
demodel.StuId = item.StuId; demodel.StuId = item.StuId;
demodel.GuestId = item.GuestId; demodel.GuestId = item.GuestId;
demodel.StuName = item.StuName; demodel.StuName = item.StuName;
string msg = "";// scrollClassModule.SetAdminScrollAppointment(demodel); string msg = "";
if (msg != "") if (msg != "")
{ {
return ApiResult.Failed(msg); return ApiResult.Failed(msg);
...@@ -757,79 +699,7 @@ namespace Edu.WebApi.Controllers.Course ...@@ -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> /// <summary>
/// 后台预约课[HK2022-07-06修改] /// 后台预约课[HK2022-07-06修改]
...@@ -897,24 +767,10 @@ namespace Edu.WebApi.Controllers.Course ...@@ -897,24 +767,10 @@ namespace Edu.WebApi.Controllers.Course
return ApiResult.ParamIsNull("请传递学生ID"); 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 = ""; string msg = "";
foreach (var item in list) foreach (var item in list)
{ {
msg += scrollClassModule.SetAdminScrollAppointmentModuleV2(item, out int AppointId); msg += scrollClassModule.SetAdminScrollAppointmentModule(item, out int AppointId);
} }
if (msg == "") 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