+ec.FirstClassFee + ec.SecondClassFee + ec.ThirdClassFee as TotalSub
,ec.FirstClassHours + ec.SecondClassHours + ec.ThirdClassHours as ClassHours
,IFNULL(o.PreferPrice,0) -IFNULL(o.TextbookFee,0) -IFNULL(o.CoursewareFee,0) as CourseFee
,IFNULL(o.DiscountMoney,0) as DiscountMoney
,IFNULL(o.PreferPrice,0) as TotalSub
,IFNULL(g.TotalHours,0) as ClassHours
FROM(
SELECT p.TeacherId,p.OrderGuestId,SUM(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
WHERE p.`Status`=0 and p.Group_Id ={groupId} and p.TeacherId in ({userIds}) and p.ClassDate >= '{startMonth}' and p.ClassDate <='{endMonth} 23:59:59'
GROUP BY p.TeacherId,p.OrderGuestId
)tt
LEFT JOIN rb_education_contract ec on tt.OrderGuestId = ec.GuestId and ec.Status <>4
left join rb_order_guest g on g.Id = tt.OrderGuestId
left join rb_order o on o.OrderId =g.OrderId
GROUP BY tt.TeacherId,tt.OrderGuestId
)q";
...
...
@@ -680,12 +679,10 @@ case when tt.ClassHours>0 and tt.TotalSub >0 then
FROM (
SELECT p.OrderGuestId,p.CurrentDeductionHours,t2.GuestName,p.TeacherId,t3.TeacherName,t2.OrderId,ec.ContractNo,if(cp.PlanType=2,'预约课',c.ClassName) as ClassName,c.ClassNo,if(cp.PlanType=2,co2.CourseName,co.CourseName) as CourseName,p.ClassId,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId
,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,o.EnterID,o.HelpEnterId
,ec.FirstCourseFee + ec.SecondCourseFee + ec.ThirdCourseFee as CourseFee
,ec.FirstDiscountMoney + ec.SecondDiscountMoney + ec.ThirdDiscountMoney as DiscountMoney
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
...
...
@@ -761,12 +758,10 @@ case when tt.ClassHours>0 and tt.TotalSub >0 then
FROM (
SELECT p.OrderGuestId,p.CurrentDeductionHours,t2.GuestName,p.TeacherId,t3.TeacherName,t2.OrderId,ec.ContractNo,if(cp.PlanType=2,'预约课',c.ClassName) as ClassName,c.ClassNo,if(cp.PlanType=2,co2.CourseName,co.CourseName) as CourseName,p.ClassId,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId
,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,o.EnterID,o.HelpEnterId
,ec.FirstCourseFee + ec.SecondCourseFee + ec.ThirdCourseFee as CourseFee
,ec.FirstDiscountMoney + ec.SecondDiscountMoney + ec.ThirdDiscountMoney as DiscountMoney
+ec.FirstClassFee + ec.SecondClassFee + ec.ThirdClassFee as TotalSub
,ec.FirstClassHours + ec.SecondClassHours + ec.ThirdClassHours as ClassHours
,IFNULL(o.PreferPrice,0) -IFNULL(o.TextbookFee,0) -IFNULL(o.CoursewareFee,0) as CourseFee
,IFNULL(o.DiscountMoney,0) as DiscountMoney
,IFNULL(o.PreferPrice,0) as TotalSub
,IFNULL(g.TotalHours,0) as ClassHours
FROM(
SELECT case when cp.PlanType=2 then t2.ClassId else p.ClassId end as ClassId,p.OrderGuestId,SUM(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
...
...
@@ -836,7 +829,8 @@ LEFT JOIN rb_order_guest t2 on p.OrderGuestId = t2.Id
WHERE p.`Status`=0 and p.Group_Id ={groupId} and case when cp.PlanType=2 then t2.ClassId in({classIds}) else p.ClassId in({classIds}) end
GROUP BY case when cp.PlanType=2 then t2.ClassId else p.ClassId end,p.OrderGuestId
)tt
LEFT JOIN rb_education_contract ec on tt.OrderGuestId = ec.GuestId and ec.Status <>4
left join rb_order_guest g on g.Id = tt.OrderGuestId