@@ -751,7 +751,24 @@ GROUP BY A.ClassPlanId,A.StuId,A.CourseId ,A.ClassDate,A.ClassRoomId
...
@@ -751,7 +751,24 @@ GROUP BY A.ClassPlanId,A.StuId,A.CourseId ,A.ClassDate,A.ClassRoomId
{
{
where.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.ClassId),query.ClassId);
where.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.ClassId),query.ClassId);
}
}
if(query.AppointState>0){
if(!string.IsNullOrEmpty(query.StuName))
{
whereAppoint.AppendFormat(@" AND og.GuestName LIKE '%{0}%' ",query.StuName);
whereReserve.AppendFormat(@" AND Exists
(
SELECT 1
FROM rb_visitor_reserve AS vr LEFT JOIN rb_student AS B ON vr.Visitor_Id=B.StuId
WHERE vr.ReserveClassId=A.ReserveClassId AND vr.Status=0 AND B.StuName LIKE '%{0}%'
)
",query.StuName);
where.AppendFormat(@"AND EXISTS
(
SELECT 1 FROM rb_order_guest AS gu INNER JOIN rb_order AS o ON gu.OrderId=o.OrderId WHERE gu.`Status`=0 AND o.OrderState<>3 AND gu.ClassId=A.ClassId AND gu.GuestName LIKE '%{0}%'
)",query.StuName);
}
if(query.AppointState>0)
{
if(query.AppointState==1)
if(query.AppointState==1)
{
{
whereAppoint.AppendFormat(" AND A.{0}=1 ",nameof(RB_Scroll_Appointment_ViewModel.State));
whereAppoint.AppendFormat(" AND A.{0}=1 ",nameof(RB_Scroll_Appointment_ViewModel.State));
...
@@ -776,13 +793,12 @@ GROUP BY A.ClassPlanId,A.StuId,A.CourseId ,A.ClassDate,A.ClassRoomId
...
@@ -776,13 +793,12 @@ GROUP BY A.ClassPlanId,A.StuId,A.CourseId ,A.ClassDate,A.ClassRoomId
builderAppoint.AppendFormat(@"
builderAppoint.AppendFormat(@"
SELECT 3 as ClassType,IFNULL(t1.ClassTimeId,0) as ClassTimeId,a.CourseSTime as NewPlanDateTime,a.CourseSTime as StartTime,a.CourseETime as EndTime, IFNULL(t1.ClassPlanId,0) as ClassPlanId, 0 as ClassId, a.Date as ClassDate, a.RoomId as ClassRoomId,'预约课' as ClassName, c.CourseName
SELECT 3 as ClassType,IFNULL(t1.ClassTimeId,0) as ClassTimeId,a.CourseSTime as NewPlanDateTime,a.CourseSTime as StartTime,a.CourseETime as EndTime, IFNULL(t1.ClassPlanId,0) as ClassPlanId, 0 as ClassId, a.Date as ClassDate, a.RoomId as ClassRoomId,'预约课' as ClassName, c.CourseName
,ac.AccountId as Teacher_Id,t.TeacherName,r.RoomName,r.SeatNum as RoomNum, og.TotalChapterNo as TotalPlanNum, GROUP_CONCAT(a.Id) AS AppointIds,a.ChapterNo,0 as ReserveType
,ac.AccountId as Teacher_Id,t.TeacherName,r.RoomName,r.SeatNum as RoomNum, og.TotalChapterNo as TotalPlanNum, GROUP_CONCAT(a.Id) AS AppointIds,a.ChapterNo,0 as ReserveType
FROM rb_scroll_appointment a
FROM rb_scroll_appointment a INNER JOIN rb_course c on a.CourseId = c.CourseId
INNER JOIN rb_course c on a.CourseId = c.CourseId
INNER JOIN rb_account ac on a.AccountId = ac.Id
INNER JOIN rb_account ac on a.AccountId = ac.Id
INNER JOIN rb_teacher t on t.TId = ac.AccountId
INNER JOIN rb_teacher t on t.TId = ac.AccountId
INNER JOIN rb_class_room r on a.RoomId = r.RoomId
INNER JOIN rb_class_room r on a.RoomId = r.RoomId
INNER JOIN rb_order_guest og on a.GuestId = og.Id
INNER JOIN rb_order_guest og on a.GuestId = og.Id
LEFT JOIN rb_class_time t1 on t1.ClassPlanId = a.ClassPlanId
LEFT JOIN rb_class_time t1 on t1.ClassPlanId = a.ClassPlanId
WHERE 1=1 {0} GROUP BY a.CourseSTime,a.CourseETime,a.RoomId,a.Date ",whereAppoint.ToString());
WHERE 1=1 {0} GROUP BY a.CourseSTime,a.CourseETime,a.RoomId,a.Date ",whereAppoint.ToString());
builderReserveClass.AppendFormat(@"
builderReserveClass.AppendFormat(@"
...
@@ -797,9 +813,8 @@ WHERE 1=1 {0} ", whereReserve.ToString());
...
@@ -797,9 +813,8 @@ WHERE 1=1 {0} ", whereReserve.ToString());
SELECT 1 as ClassType,F.ClassTimeId,CONCAT( DATE_FORMAT(A.ClassDate,'%Y-%m-%d') ,' ',f.StartTime,':00') AS NewPlanDateTime,F.StartTime,f.EndTime,A.ClassPlanId, A.ClassId,A.ClassDate,A.ClassRoomId,B.ClassName,C.CourseName,
SELECT 1 as ClassType,F.ClassTimeId,CONCAT( DATE_FORMAT(A.ClassDate,'%Y-%m-%d') ,' ',f.StartTime,':00') AS NewPlanDateTime,F.StartTime,f.EndTime,A.ClassPlanId, A.ClassId,A.ClassDate,A.ClassRoomId,B.ClassName,C.CourseName,
B.Teacher_Id,IFNULL(D.TeacherName,'') AS TeacherName,E.RoomName,IFNULL(E.SeatNum,0) AS RoomNum,plan.TotalPlanNum , '' as AppointIds,0 as ChapterNo,0 as ReserveType
B.Teacher_Id,IFNULL(D.TeacherName,'') AS TeacherName,E.RoomName,IFNULL(E.SeatNum,0) AS RoomNum,plan.TotalPlanNum , '' as AppointIds,0 as ChapterNo,0 as ReserveType
FROM rb_class_time as F INNER JOIN
FROM rb_class_time as F INNER JOIN rb_class_plan AS A on F.ClassPlanId=a.ClassPlanId
rb_class_plan AS A on F.ClassPlanId=a.ClassPlanId
INNER JOIN rb_class AS B ON A.ClassId=B.ClassId
INNER JOIN rb_class AS B ON A.ClassId=B.ClassId
LEFT JOIN rb_course AS C ON B.CouseId=C.CourseId
LEFT JOIN rb_course AS C ON B.CouseId=C.CourseId
LEFT JOIN rb_teacher AS D ON B.Teacher_Id=D.TId
LEFT JOIN rb_teacher AS D ON B.Teacher_Id=D.TId
LEFT JOIN rb_class_room AS E ON A.ClassRoomId=E.RoomId
LEFT JOIN rb_class_room AS E ON A.ClassRoomId=E.RoomId
SELECT r.*,c.AccountId as TeacherId,c.WorkUserId,t.TeacherName,t.TeacherHead,s.StuName,sch.OpenId as StuOpenId,cou.CourseName,cou.ScrollMinNum,cou.ScrollMaxNum,cou.CourseTimeId,cr.RoomName
SELECT r.*,c.AccountId as TeacherId,c.WorkUserId,t.TeacherName,t.TeacherHead,s.StuName,sch.OpenId as StuOpenId,cou.CourseName,cou.ScrollMinNum,cou.ScrollMaxNum,cou.CourseTimeId,cr.RoomName