LEFT JOIN rb_point_courseclass as cc on tc.CourseClassId=cc.ID
left join (SELECT CourseId,SUM(case when OrderStaus =2 then 1 else 0 end) AS ConfirmNum,COUNT(0) AS OrderNum
FROM rb_point_teachercourseorder WHERE State =0 and OrderStaus in (2,3,4) GROUP BY CourseId) o on tc.ID =o.CourseId
where tc.state=0 and cc.state=0 ");
if(where!=null)
{
if(where.TenantId>0)
{
sb.AppendFormat(" and tc.TenantId={0}",where.TenantId);
}
if(where.MallBaseId>0)
{
sb.AppendFormat(" and tc.MallBaseId={0}",where.MallBaseId);
}
if(where.MallBaseId>0)
{
sb.AppendFormat(" and tc.MallBaseId={0}",where.MallBaseId);
}
if(where.CourseClassId>0)
{
sb.AppendFormat(" and tc.CourseClassId={0}",where.CourseClassId);
}
if(where.TeacherId>0)
{
sb.AppendFormat(" and tc.TeacherId={0}",where.TeacherId);
}
if(!string.IsNullOrEmpty(where.SelectStartTime))
{
sb.AppendFormat(" AND DATE_FORMAT(tc.{0},'%y-%m-%d')>=DATE_FORMAT('{1}','%y-%m-%d') ",nameof(RB_Point_TeacherCourse_Extend.StudyDate),where.SelectStartTime);
}
if(!string.IsNullOrEmpty(where.SelectEndTime))
{
sb.AppendFormat(" AND DATE_FORMAT(tc.{0},'%y-%m-%d')<=DATE_FORMAT('{1}','%y-%m-%d') ",nameof(RB_Point_TeacherCourse_Extend.StudyDate),where.SelectEndTime);
}
if(where.ID>0)
{
sb.AppendFormat(" and tc.ID={0}",where.ID);
}
if(where.CourseStudyState>0){
if(where.CourseStudyState==1)
{
sb.AppendFormat(" AND CONCAT(DATE_FORMAT(StudyDate,'%Y-%m-%d'),' ',StudyEndDate) >= '{1}' ",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
elseif(where.CourseStudyState==2)
{
sb.AppendFormat(" AND CONCAT(DATE_FORMAT(StudyDate,'%Y-%m-%d'),' ',StudyEndDate) < '{1}' ",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));