SELECT s.StuId,s.StuName,s.StuTel,s.FirstEnrollDate,s.StuRealMobile,s.StuPurpose,s.QQ,DATE_FORMAT(ec.CreateTime,'%Y-%m-%d') as followUpTime
,c.CourseId,c.CourseName,s.JapanBaseInfo,s.StuBirth,org.GuestState as StuGuestState,s.StuChannel,s.CreateType,s.StuSourceId,s.CreateBy
,s.AdvisorStatus,s.AdvisorWinRate,s.AdvisorExpectDate,IFNULL(B.Name,'') AS AdvisorStatusName,org.GraduationTime,clcheck.ClassDate AS BeginClassDate
FROM rb_student s
{joinType} rb_student_orderguest og on og.Student_Id = s.StuId
{joinType} (SELECT og.Student_Id,MAX(og.Id) as Id FROM rb_student_orderguest og INNER JOIN rb_order o on og.OrderId = o.OrderId WHERE o.OrderState <>3 GROUP BY og.Student_Id) stu on og.Id = stu.Id and og.Student_Id = s.StuId
{joinType} rb_order_guest org on org.Id = og.GuestId
{joinType} rb_order o on og.OrderId = o.OrderId
{joinType} rb_class cl on cl.ClassId = o.ClassId
{joinType} rb_course c on o.CourseId = c.CourseId
LEFT JOIN rb_education_contract ec on ec.GuestId = og.GuestId
LEFT JOIN rb_student_advisorconfig AS b ON s.AdvisorStatus=B.Id
LEFT JOIN (
SELECT B.Student_Id,MIN(A.ClassDate) AS ClassDate
FROM rb_class_check AS A INNER JOIN rb_student_orderguest AS B ON A.OrderGuestId=B.GuestId
WHERE A.Status=0 AND A.CheckStatus=0 GROUP BY B.Student_Id
sql+=$@" LEFT JOIN rb_student_follow f on s.StuId = f.StuId and f.`Status` =0 and f.AssistType in(2,4) and f.CreateTime >='{demodel.SFTime}' and f.CreateTime <='{demodel.EFTime} 23:59:59'";
@@ -500,7 +540,7 @@ where sog.Status =0 and o.Group_Id ={group_Id} and o.OrderState <>3 and IFNULL(o
{
tempCreateIds+=","+demodel.QCreateBys;
}
where+=string.Format(@"
where+=string.Format(@"
AND ( s.CreateBy IN({0})
OR s.StuId IN (SELECT StuId FROM rb_student_assist WHERE AssistId IN({0}) AND `Status`=0)
)
...
...
@@ -540,41 +580,7 @@ where sog.Status =0 and o.Group_Id ={group_Id} and o.OrderState <>3 and IFNULL(o
where+=$" AND s.{nameof(RB_Student_ViewModel.CreateBy)} ={demodel.CreateBy} ";
}
}
stringjoinType="INNER JOIN";
if(demodel.QueryTpye==3)
{
joinType="LEFT JOIN";
}
stringsql=$@"
SELECT s.StuId,s.StuName,s.StuTel,s.FirstEnrollDate,s.StuRealMobile,s.StuPurpose,s.QQ,DATE_FORMAT(ec.CreateTime,'%Y-%m-%d') as followUpTime
,c.CourseId,c.CourseName,s.JapanBaseInfo,s.StuBirth,org.GuestState as StuGuestState,s.StuChannel,s.CreateType,s.StuSourceId,s.CreateBy
,s.AdvisorStatus,s.AdvisorWinRate,s.AdvisorExpectDate,IFNULL(B.Name,'') AS AdvisorStatusName,org.GraduationTime,clcheck.ClassDate AS BeginClassDate
FROM rb_student s
{joinType} rb_student_orderguest og on og.Student_Id = s.StuId
{joinType} (SELECT og.Student_Id,MAX(og.Id) as Id FROM rb_student_orderguest og INNER JOIN rb_order o on og.OrderId = o.OrderId WHERE o.OrderState <>3 GROUP BY og.Student_Id) stu on og.Id = stu.Id and og.Student_Id = s.StuId
{joinType} rb_order_guest org on org.Id = og.GuestId
{joinType} rb_order o on og.OrderId = o.OrderId
{joinType} rb_class cl on cl.ClassId = o.ClassId
{joinType} rb_course c on o.CourseId = c.CourseId
LEFT JOIN rb_education_contract ec on ec.GuestId = og.GuestId
LEFT JOIN rb_student_advisorconfig AS b ON s.AdvisorStatus=B.Id
LEFT JOIN (
SELECT B.Student_Id,MIN(A.ClassDate) AS ClassDate
FROM rb_class_check AS A INNER JOIN rb_student_orderguest AS B ON A.OrderGuestId=B.GuestId
WHERE A.Status=0 AND A.CheckStatus=0 GROUP BY B.Student_Id
sql+=$@" LEFT JOIN rb_student_follow f on s.StuId = f.StuId and f.`Status` =0 and f.AssistType in(2,4) and f.CreateTime >='{demodel.SFTime}' and f.CreateTime <='{demodel.EFTime} 23:59:59'";
where+=$" AND (s.{nameof(RB_Student_ViewModel.CreateBy)} IN({createIds}) OR s.StuId IN (SELECT StuId FROM rb_student_assist WHERE AssistId IN({createIds}) AND `Status`=0)) ";
}
}
else
{
where+=$" AND s.{nameof(RB_Student_ViewModel.CreateBy)} ={demodel.CreateBy} ";
}
}
}
else
{
if(demodel.CreateBy>0)
{
where+=$" AND s.{nameof(RB_Student_ViewModel.CreateBy)} ={demodel.CreateBy} ";