Commit 8d261c91 authored by 黄奎's avatar 黄奎

查询调整

parent 8f6b30ab
...@@ -40,8 +40,15 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2 ...@@ -40,8 +40,15 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2
|| query.QCourseRate == Common.Enum.Course.CourseRateEnum.N2 || query.QCourseRate == Common.Enum.Course.CourseRateEnum.N2
|| query.QCourseRate == Common.Enum.Course.CourseRateEnum.N1) || query.QCourseRate == Common.Enum.Course.CourseRateEnum.N1)
{ {
List<int> courseIdList = new List<int>();
builder.AppendFormat(" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE 1=1 AND (CourseId=B.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=A.OrderId)) AND CourseRate IN({0})) ", (int)query.QCourseRate); string chapterSql = string.Format(" SELECT DISTINCT CourseId FROM rb_course_chapter WHERE Status=0 AND CourseRate ={0} ", (int)query.QCourseRate);
List<RB_Course_Chapter> chapterList = base.Get<RB_Course_Chapter>(chapterSql).ToList();
if (chapterList != null && chapterList.Count > 0)
{
courseIdList.AddRange(chapterList.Select(qitem => qitem.CourseId).ToList());
}
builder.AppendFormat(@" AND (B.CourseId IN({0}) OR EXISTS (SELECT 1 FROM rb_order_course WHERE OrderId=A.OrderId AND CourseId IN({0}))) ", string.Join(",", courseIdList));
//builder.AppendFormat(" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE 1=1 AND (CourseId=B.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=A.OrderId)) AND CourseRate IN({0})) ", (int)query.QCourseRate);
} }
else else
{ {
...@@ -81,14 +88,7 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2 ...@@ -81,14 +88,7 @@ WHERE 1=1 AND B.OrderState=1 AND B.OrderType=1 AND E.ClassScrollType=2
{ {
string guestIds = string.Join(",", list.Select(qitem => qitem.GuestId).Distinct()); string guestIds = string.Join(",", list.Select(qitem => qitem.GuestId).Distinct());
string courseIds = string.Join(",", list.Select(qitem => qitem.CourseId).Distinct()); string courseIds = string.Join(",", list.Select(qitem => qitem.CourseId).Distinct());
// string courseChapterSql = string.Format(@"
//SELECT CourseId,ChapterGradeNo
//FROM rb_course_chapter
//WHERE CourseId IN({0}) AND CourseRate IN({1}) ", courseIds, (int)query.QCourseRate);
// var chapterList= Get<RB_Course_Chapter>(courseChapterSql).ToList();
StringBuilder appointBuilder = new StringBuilder(); StringBuilder appointBuilder = new StringBuilder();
appointBuilder.AppendFormat(@" appointBuilder.AppendFormat(@"
SELECT A.Date,A.AccountId,A.State,A.GuestId,A.LearnCourseId,A.CourseGradeId,A.CourseGradeNo,IFNULL(C.ClassCheckId,0) AS ClassCheckId SELECT A.Date,A.AccountId,A.State,A.GuestId,A.LearnCourseId,A.CourseGradeId,A.CourseGradeNo,IFNULL(C.ClassCheckId,0) AS ClassCheckId
......
using Edu.Common.Enum; using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.Entity.User; using Edu.Model.Entity.User;
using Edu.Model.ViewModel.Customer; using Edu.Model.ViewModel.Customer;
using Edu.Model.ViewModel.Sell; using Edu.Model.ViewModel.Sell;
...@@ -1003,6 +1004,13 @@ and og.TotalChapterNo > og.CourseChapterNo and (og.CourseChapterNo + 1 + IFNULL( ...@@ -1003,6 +1004,13 @@ and og.TotalChapterNo > og.CourseChapterNo and (og.CourseChapterNo + 1 + IFNULL(
/// <returns></returns> /// <returns></returns>
public List<RB_Student_OrderGuest_ViewModel> GetCanAppointmentStuListRepository_V2(string stuName, int NextChapterGradeNo, int CourseGradeId, int SchoolId, int group_Id) public List<RB_Student_OrderGuest_ViewModel> GetCanAppointmentStuListRepository_V2(string stuName, int NextChapterGradeNo, int CourseGradeId, int SchoolId, int group_Id)
{ {
List<int> courseIdList = new List<int>();
string chapterSql = string.Format(" SELECT DISTINCT CourseId FROM rb_course_chapter WHERE Status=0 AND CourseRate ={0} ", CourseGradeId);
List<RB_Course_Chapter> chapterList = base.Get<RB_Course_Chapter>(chapterSql).ToList();
if (chapterList != null && chapterList.Count > 0)
{
courseIdList.AddRange(chapterList.Select(qitem => qitem.CourseId).ToList());
}
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
string sql = $@" string sql = $@"
SELECT sog.Student_Id,sog.GuestId,sog.OrderId,cou.CourseName,s.StuName as GuestName,og.CourseChapterNo,sa.AppointNum,ss.MakeUpNum SELECT sog.Student_Id,sog.GuestId,sog.OrderId,cou.CourseName,s.StuName as GuestName,og.CourseChapterNo,sa.AppointNum,ss.MakeUpNum
...@@ -1036,7 +1044,8 @@ WHERE o.Group_Id ={group_Id} and sog.`Status` =0 and og.GuestState NOT IN(2) and ...@@ -1036,7 +1044,8 @@ WHERE o.Group_Id ={group_Id} and sog.`Status` =0 and og.GuestState NOT IN(2) and
} }
//sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND CourseId= o.CourseId AND ParentId =0 AND CourseRate ={0})", CourseGradeId); //sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND CourseId= o.CourseId AND ParentId =0 AND CourseRate ={0})", CourseGradeId);
sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND (CourseId= o.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=sog.OrderId)) AND CourseRate ={0})", CourseGradeId); //sql += string.Format(@" AND EXISTS (SELECT 1 FROM rb_course_chapter WHERE Status=0 AND (CourseId= o.CourseId OR CourseId IN(SELECT CourseId FROM rb_order_course WHERE OrderId=sog.OrderId)) AND CourseRate ={0})", CourseGradeId);
sql += string.Format(@" AND (o.CourseId IN({0}) OR EXISTS (SELECT 1 FROM rb_order_course WHERE OrderId=sog.OrderId AND CourseId IN({0}))) ", string.Join(",", courseIdList));
return Get<RB_Student_OrderGuest_ViewModel>(sql, parameters).ToList(); return Get<RB_Student_OrderGuest_ViewModel>(sql, parameters).ToList();
} }
......
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