stringsql=$@"SELECT MAX(Date) AS Date, COUNT(0) as ScrollMinNum FROM rb_scroll_appointment WHERE `Status` =0 and State <>5 and CourseEndTime >='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}' and Group_Id ={group_Id} and StuId ={stuId} HAVING COUNT(0) >0";
stringwhere=$@" 1=1 and r.{nameof(RB_Scroll_Appointment_ViewModel.Status)} =0 and r.{nameof(RB_Scroll_Appointment_ViewModel.State)} <>5";
if(demodel.Group_Id>0)
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if(demodel.State>0)
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.State)} ={(int)demodel.State}";
}
if(demodel.AccountId>0)
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.AccountId)} ={demodel.AccountId}";
}
if(demodel.TeacherId>0)
{
where+=$@" and c.AccountId ={demodel.TeacherId}";
}
if(demodel.StuId>0)
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.StuId)} ={demodel.StuId}";
}
if(demodel.CourseId>0)
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.CourseId)} ={demodel.CourseId}";
}
if(!string.IsNullOrEmpty(demodel.StartTime))
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.Date)} >='{demodel.StartTime}'";
}
if(!string.IsNullOrEmpty(demodel.EntTime))
{
where+=$@" and r.{nameof(RB_Scroll_Appointment_ViewModel.Date)} <='{demodel.EntTime} 23:59:59'";
}
stringsql=$@"
SELECT r.*,c.AccountId as TeacherId,t.TeacherName,t.TeacherHead,s.StuName,cou.CourseName,cou.ScrollMinNum,cou.ScrollMaxNum,cou.CourseTimeId From RB_Scroll_Appointment r
inner join rb_account c on r.AccountId = c.Id
inner join rb_teacher t on c.AccountId = t.TId
inner join rb_student s on r.StuId = s.StuId
inner join rb_course cou on r.CourseId = cou.CourseId
stringsql=$@"SELECT og.*,o.CourseId,g.CourseChapterNo 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
WHERE og.Status =0 and g.`Status` =0 and o.Group_Id ={group_Id} and o.OrderState <>3 and o.OrderType =1 and g.GuestState =1 and og.Student_Id ={accountId}