@@ -312,6 +312,66 @@ LEFT JOIN rb_class as class on a.ClassId=class.ClassId
LEFT JOIN rb_teacher AS T ON A.TeacherId=T.TId
LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanNum from rb_class_lessonplan where `Status`=0 GROUP BY ClassPlanId)as lp on a.ClassPlanId=lp.ClassPlanId
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.Status),(int)DateStateEnum.Normal);
if(query!=null)
{
if(query.ClassId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.ClassId),query.ClassId);
}
if(query.ClassPlanId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.ClassPlanId),query.ClassPlanId);
}
if(query.Group_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.Group_Id),query.Group_Id);
}
if(query.School_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.School_Id),query.School_Id);
}
if(query.Teacher_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.Teacher_Id),query.Teacher_Id);
}
if(!string.IsNullOrEmpty(query.QClassIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ",nameof(RB_Class_Plan_ViewModel.ClassId),query.QClassIds);
}
if(!string.IsNullOrEmpty(query.QMonth))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y/%m')= DATE_FORMAT('{1}-01','%y/%m') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.QMonth);
}
if(!string.IsNullOrEmpty(query.StartTime))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y-%m-%d')>=DATE_FORMAT('{1}','%y-%m-%d') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.StartTime);
}
if(!string.IsNullOrEmpty(query.EndTime))
{
builder.AppendFormat(" AND DATE_FORMAT(A.{0},'%y-%m-%d')<=DATE_FORMAT('{1}','%y-%m-%d') ",nameof(RB_Class_Plan_ViewModel.ClassDate),query.EndTime);
builder.AppendFormat($@"SELECT a.*,c.ClassName,lp.LessonPlanNum,c.ClassHours,b.RoomName,IFNULL(T.TeacherHead,'') AS UserIcon,IFNULL(T.TeacherName,'') AS TeacherName FROM rb_class_plan as a LEFT JOIN rb_class as c on a.ClassId=c.ClassId
LEFT JOIN rb_class_room as b on a.ClassRoomId=b.RoomId
LEFT JOIN rb_teacher AS T ON c.Teacher_Id=T.TId
LEFT JOIN rb_student_orderguest as sog on sog.ClassId=c.ClassId
LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanNum from rb_class_lessonplan where `Status`=0 GROUP BY ClassPlanId)as lp on a.ClassPlanId=lp.ClassPlanId
where sog.Account_Id={query.StuId} and c.ClassStatus in(1,2) and c.`Status`=0 and sog.`Status`=0
");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Plan_ViewModel.Status),(int)DateStateEnum.Normal);
builder.AppendFormat($@"SELECT c.*,rbc.ClassName from rb_student as c
LEFT JOIN rb_student_orderguest as sog on sog.Student_Id=c.StuId
LEFT JOIN rb_class as rbc on rbc.ClassId=sog.ClassId
where sog.ClassId in(SELECT a.ClassId from rb_student_orderguest as a LEFT JOIN rb_class as b on a.ClassId=b.ClassId
LEFT JOIN rb_student as c on c.StuId =a.Student_Id
LEFT JOIN rb_order as o on a.OrderId=o.OrderId
where b.`Status`=0 and b.ClassStatus in(1,2) and a.status=0 and a.Account_Id={Student_Id} and o.OrderState=1 AND c.Group_Id={Group_Id} ) and sog.Account_Id!={Student_Id}