Commit 29931154 authored by 黄奎's avatar 黄奎

页面修改

parent 4c4bd695
......@@ -397,18 +397,58 @@ where sog.Status =0 and o.Group_Id ={group_Id} and o.OrderState <>3 and IFNULL(o
/// <returns></returns>
public List<RB_Student_ViewModel> GetStudentFollowUpPageRepository(int pageIndex, int pageSize, out long count, RB_Student_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = GetStudentFollowUpSql(demodel, out DynamicParameters parameters);
string joinType = "INNER JOIN";
if (demodel.QueryTpye == 3)
{
joinType= "LEFT JOIN";
}
string sql = $@"
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
) AS clcheck ON s.StuId=clcheck.Student_Id
";
if (!string.IsNullOrEmpty(demodel.SFTime) && !string.IsNullOrEmpty(demodel.EFTime)) {
//增加跟进链表
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'";
}
sql += $" where {where} ";
if ((!string.IsNullOrEmpty(demodel.SFTime) && !string.IsNullOrEmpty(demodel.EFTime)))
{
sql += $" GROUP BY s.StuId";
}
sql += $" order by s.StuId desc";
return GetPage<RB_Student_ViewModel>(pageIndex, pageSize, out count, sql, parameters).ToList();
}
public string GetStudentFollowUpSql(RB_Student_ViewModel demodel, out DynamicParameters parameters)
{
parameters = new DynamicParameters();
string where = " 1=1 and s.Status =0 and c.CourseId <>1";//排除内部班课程
if (demodel.Group_Id > 0)
if (demodel.Group_Id > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (!string.IsNullOrEmpty(demodel.StuName))
if (!string.IsNullOrEmpty(demodel.StuName))
{
where += $" and s.{nameof(RB_Student_ViewModel.StuName)} like @StuName";
parameters.Add("StuName", "%" + demodel.StuName + "%");
}
if (!string.IsNullOrEmpty(demodel.StuRealMobile))
if (!string.IsNullOrEmpty(demodel.StuRealMobile))
{
where += $" and s.{nameof(RB_Student_ViewModel.StuRealMobile)} like @StuRealMobile";
parameters.Add("StuRealMobile", "%" + demodel.StuRealMobile + "%");
......@@ -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} ";
}
}
string joinType = "INNER JOIN";
if (demodel.QueryTpye == 3)
{
joinType= "LEFT JOIN";
}
string sql = $@"
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
) AS clcheck ON s.StuId=clcheck.Student_Id
";
if (!string.IsNullOrEmpty(demodel.SFTime) && !string.IsNullOrEmpty(demodel.EFTime)) {
//增加跟进链表
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'";
}
sql += $" where {where} ";
if ((!string.IsNullOrEmpty(demodel.SFTime) && !string.IsNullOrEmpty(demodel.EFTime)))
{
sql += $" GROUP BY s.StuId";
}
sql += $" order by s.StuId desc";
return GetPage<RB_Student_ViewModel>(pageIndex, pageSize, out count, sql, parameters).ToList();
return where;
}
/// <summary>
......@@ -584,120 +590,7 @@ FROM rb_student s
/// <returns></returns>
public RB_Student_ViewModel GetStudentFollowUpStat(RB_Student_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = " 1=1 and s.Status =0 and c.CourseId <>1";//排除内部班
if (demodel.Group_Id > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (!string.IsNullOrEmpty(demodel.StuName))
{
where += $" and s.{nameof(RB_Student_ViewModel.StuName)} like @StuName";
parameters.Add("StuName", "%" + demodel.StuName + "%");
}
if (!string.IsNullOrEmpty(demodel.StuRealMobile))
{
where += $" and s.{nameof(RB_Student_ViewModel.StuRealMobile)} like @StuRealMobile";
parameters.Add("StuRealMobile", "%" + demodel.StuRealMobile + "%");
}
if (!string.IsNullOrEmpty(demodel.QQ))
{
where += $" and s.{nameof(RB_Student_ViewModel.QQ)} like @QQ";
parameters.Add("QQ", "%" + demodel.QQ + "%");
}
if (!string.IsNullOrEmpty(demodel.WeChatNo))
{
where += $" and s.{nameof(RB_Student_ViewModel.WeChatNo)} like @WeChatNo";
parameters.Add("WeChatNo", "%" + demodel.WeChatNo + "%");
}
if (demodel.StuType > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.StuType)} ={demodel.StuType}";
}
if (demodel.StuGuestState > 0)
{
where += $" and org.GuestState ={(int)demodel.StuGuestState}";
}
if (demodel.StuChannel > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.StuChannel)} ={demodel.StuChannel}";
}
if (demodel.CreateType > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.CreateType)} ={(int)demodel.CreateType}";
}
if (demodel.StuSourceId > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.StuSourceId)} ={demodel.StuSourceId}";
}
if (demodel.StuStage > 0)
{
where += $" and s.{nameof(RB_Student_ViewModel.StuStage)} ={demodel.StuStage}";
}
if (demodel.School_Id > -1)
{
where += $" and cl.School_Id ={demodel.School_Id}";
}
if (demodel.ConsultantId > 0)
{
where += $@" AND s.StuId IN (SELECT StuId FROM rb_student_assist WHERE AssistId ={demodel.ConsultantId} AND `Status`=0)";
}
if (demodel.CourseId > 0)
{
where += $" and o.CourseId ={demodel.CourseId}";
}
if (!string.IsNullOrEmpty(demodel.SFTime) && !string.IsNullOrEmpty(demodel.EFTime))
{
if (demodel.Q_FType == 1)
{
where += $" and f.Id is not null";
}
else
{
where += $" and f.Id is null";
}
}
if (demodel.BelongType > 0)
{
//全部
if (demodel.BelongType == 1)
{
where += $@" AND (s.CreateBy={demodel.CreateBy} OR s.StuId IN (SELECT StuId FROM rb_student_assist WHERE AssistId ={demodel.CreateBy} AND `Status`=0))";
}
//我负责的
else if (demodel.BelongType == 2)
{
where += $" AND s.{nameof(RB_Student_ViewModel.CreateBy)} ={demodel.CreateBy} ";
}
//我协同的
else if (demodel.BelongType == 3)
{
where += $" AND s.StuId IN (SELECT StuId FROM rb_student_assist WHERE AssistId ={demodel.CreateBy} AND `Status`=0) ";
}
//我下属的
else if (demodel.BelongType == 4)
{
if (demodel.CreateIds != null && demodel.CreateIds.Count > 0)
{
string createIds = string.Join(",", demodel.CreateIds);
if (!string.IsNullOrEmpty(createIds))
{
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} ";
}
}
string where = GetStudentFollowUpSql(demodel, out DynamicParameters parameters);
string joinType = "INNER JOIN";
if (demodel.QueryTpye == 3)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment