@@ -274,6 +274,7 @@ FROM rb_student AS t LEFT JOIN rb_group AS g ON t.Group_Id=g.GId
LEFT JOIN rb_customer c on (c.CustomerId = t.StuSourceId AND t.CreateType=2)
LEFT JOIN rb_account as a ON (t.StuId=a.AccountId AND a.AccountType=4 )
LEFT JOIN rb_student_advisorconfig AS b ON t.AdvisorStatus=B.Id
LEFT JOIN (SELECT Student_Id,Count(1) AS OrderCount FROM rb_student_orderguest GROUP BY Student_Id) AS org ON t.StuId=org.Student_Id
WHERE 1=1
");
if(query!=null)
...
...
@@ -465,12 +466,20 @@ WHERE 1=1
//查询未跟进的线索
if(query.IsQueryNotAppointment==1)
{
builder.Append(" AND IFNULL(org.OrderCount,0)=0 ");
builder.AppendFormat(" AND Exists(SELECT StuId FROM RB_Student_Appointment WHERE `Status`=0 AND t.StuId=StuId AND IFNULL(Feedback,'')='') ");
}
//查询未跟进学员
if(query.IsQueryNotFollow==1)
{
builder.AppendFormat(" AND NOT Exists (SELECT StuId FROM rb_student_follow WHERE `Status`=0 AND t.StuId=StuId) ");
builder.Append(" AND IFNULL(org.OrderCount,0)>0 ");
builder.AppendFormat(" AND NOT Exists (SELECT StuId FROM rb_student_follow WHERE `Status`=0 AND t.StuId=StuId AND CreateBy={0}) ",query.CreateBy);
}
//查询今日跟进
if(query.IsQueryTodayFollow==1)
{
builder.Append(" AND IFNULL(org.OrderCount,0)>0 ");
builder.AppendFormat(" AND Exists (SELECT StuId FROM rb_student_follow WHERE `Status`=0 AND t.StuId=StuId AND CreateBy={0} AND CreateTime>='{1}' AND CreateTime<='{2} 23:59:59') ",query.CreateBy,query.StartTime,query.EndTime);
}
}
builder.AppendFormat(" ORDER BY t.{0} DESC ",nameof(RB_Student_ViewModel.StuId));