SELECT A.*,IFNULL(B.ClassName,'') AS ClassName,IFNULL(B.ClassNo,'') AS ClassNo,IFNULL(C.JoinType,0) AS StuJoinType,IFNULL(D.GuestState,0) AS StuGuestState
,C.OrderState,IFNULL(D.TotalHours,0) AS TotalHours,IFNULL(D.CompleteHours,0) AS CompleteHours,IFNULL(B.ClassStatus,0) AS ClassStatus,IFNULL(D.RenewState,0) AS RenewState
,IFNULL(D.GuestName,'') AS GuestName,IFNULL(E.CourseName,'') AS CourseName,IFNULL(F.Id,0) AS ContractId,F.ContractNo
FROM RB_Student_OrderGuest AS A INNER JOIN rb_class AS B ON A.ClassId=B.ClassId
INNER JOIN rb_order AS C ON A.OrderId=C.OrderId
INNER JOIN rb_order_guest AS D ON A.GuestId=D.Id
INNER JOIN rb_course AS E ON c.CourseId=E.CourseId
INNER JOIN rb_education_contract AS F ON A.GuestId=F.GuestId AND A.OrderId=F.OrderId
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Student_OrderGuest_ViewModel.Status),(int)DateStateEnum.Normal);
if(query!=null)
{
if(query.ClassId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Student_OrderGuest_ViewModel.ClassId),query.ClassId);
}
if(query.OrderId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Student_OrderGuest_ViewModel.OrderId),query.OrderId);
}
if(query.GuestId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Student_OrderGuest_ViewModel.GuestId),query.GuestId);
}
if(query.Student_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Student_OrderGuest_ViewModel.Student_Id),query.Student_Id);
}
if(!string.IsNullOrEmpty(query.QStudentIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ",nameof(RB_Student_OrderGuest_ViewModel.Student_Id),query.QStudentIds);
}
if(query.Account_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Student_OrderGuest_ViewModel.Account_Id),query.Account_Id);