SELECT q.ClassId,q.ClassNo,q.ClassName,SUM(q.CurrentDeductionHours) AS CurrentDeductionHours FROM(
SELECT cc.ClassId,cc.ClassDate,cc.ClassTimeId,MAX(cc.CurrentDeductionHours) as CurrentDeductionHours,
c.ClassName,c.ClassNo
FROM rb_class_check cc
LEFT JOIN rb_class c on cc.ClassId = c.ClassId
WHERE cc.`Status` =0 and cc.Group_Id ={group_Id} and cc.ClassDate >='{startTime}' and cc.ClassDate <='{endTime} 23:59:59' {where} GROUP BY cc.ClassId,cc.ClassDate,cc.ClassTimeId)q GROUP BY q.ClassId";
@@ -378,7 +378,7 @@ WHERE p.`Status`=0 AND p.Group_Id={group_Id} AND p.ClassId ={classId}
//LEFT JOIN (SELECT ClassPlanId,COUNT(*) as LessonPlanSummaryNum from rb_class_lessonplan where `Status`=0 and ISNULL(Summary)=0 and LENGTH(trim(Summary))>0 GROUP BY ClassPlanId)as lps on a.ClassPlanId=lps.ClassPlanId
//WHERE 1=1 and class.ClassStatus=2 and t.`Status`=0
// ");
// builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Status), (int)DateStateEnum.Normal);
// builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Plan_ViewModel.Status), (int)DateStateEnum.Normal);
if(query!=null)
{
if(query.ClassId>0)
...
...
@@ -419,7 +419,7 @@ WHERE p.`Status`=0 AND p.Group_Id={group_Id} AND p.ClassId ={classId}
join rb_class_plan d on c.ClassPlanId = d.ClassPlanId
// from rb_class_time c left
// join rb_class_plan d on c.ClassPlanId = d.ClassPlanId
where d.ClassDate < b.ClassDate and c.ClassId = b.ClassId)
from rb_class_plan b where b.ClassPlanId = "+planId+" and b.`Status`= 0";
// where d.ClassDate < b.ClassDate and c.ClassId = b.ClassId)
//from rb_class_plan b where b.ClassPlanId = " + planId + " and b.`Status`= 0";
stringsql="select (select Count(0) from rb_class_plan b where b.ClassId=a.ClassId and b.ClassDate<a.ClassDate) from rb_class_plan a where ClassPlanId="+planId+" and `Status`=0";
builder.AppendFormat(" AND ({0}='{1}' or {2} like '{3}.%')",nameof(RB_Course_Chapter_ViewModel.ChapterNo),currentHours,nameof(RB_Course_Chapter_ViewModel.ChapterNo),currentHours);
//builder.AppendFormat(" ORDER BY {0} Desc",nameof(RB_Course_Chapter_ViewModel.CurrentHours));
stringsql=$@"SELECT d.ClassId,SUM(d.CurrentPeriodMoney + d.CurrentExtraMoney + d.DeductionMoney + d.DeductionExtraMoney) AS CurrentPeriodMoney FROM rb_sell_commission_details d
INNER JOIN rb_sell_commission_periods p on d.PeriodId = p.Id
WHERE p.Group_Id ={group_Id} and d.ClassId in ({classIds}) and STR_TO_DATE(CONCAT(p.Periods,'-01'),'%Y-%m-%d') >='{startTime}' and STR_TO_DATE(CONCAT(p.Periods,'-01'),'%Y-%m-%d') <='{endTime} 23:59:59'
stringsql=$@" select A.*,b.`Month` from RB_Teaching_BonusDetail as A LEFT JOIN rb_teaching_bonus as b on a.BonusId=b.Id where {where} order by a.Id desc";
stringsql=$@"SELECT d.ClassId,SUM(d.Money) AS Money FROM rb_teaching_bonusdetail d
INNER JOIN rb_teaching_bonus p on d.BonusId = p.Id
WHERE p.Group_Id ={group_Id} and d.ClassId in ({classIds}) and STR_TO_DATE(CONCAT(p.`Month`,'-01'),'%Y-%m-%d') >='{startTime}' and STR_TO_DATE(CONCAT(p.`Month`,'-01'),'%Y-%m-%d') <='{endTime} 23:59:59'
where.Append(" AND case when b.Type=2 then b.CreateDate>='"+model.sAduitDate.Value.ToString("yyyy-MM-dd")+"' and b.CreateDate<='"+model.eAduitDate.Value.ToString("yyyy-MM-dd")+" 23:59:59' else b.TradeDate>='"+model.sAduitDate.Value.ToString("yyyy-MM-dd")+"' and b."+nameof(RB_Finance.TradeDate)+"<='"+model.eAduitDate.Value.ToString("yyyy-MM-dd")+" 23:59:59' end");
...
...
@@ -234,16 +237,13 @@ WHERE {1} {2} ", TableName, where, " ORDER BY A.FrID DESC");
}
if(model.OrderSource.HasValue)
{
where.Append(" and IFNULL(b.OrderSource,0)!="+(int)model.OrderSource);
where.Append(" and IFNULL(b.OrderSource,0)="+(int)model.OrderSource);
}
if(model.Is_TCID==1)
{
where.Append(" and IFNULL(b.OrderSource,0) not in("+(int)OrderResourceEnum.BulkAirTicket+","+(int)OrderResourceEnum.DomesticTicket+","+(int)OrderResourceEnum.TicketService+","+(int)OrderResourceEnum.Visia+")");
where.Append($@" And case when td.{nameof(RB_TradeWay.Type)}={(int)BranchAccountEnum.CashPool} then td.AccountId not in (14,15,19,20,21,22,23) else 1=1 end ");//日本 老挝地接部专户
where.Append(" AND b."+nameof(RB_Finance.FinanceType)+"="+model.FinanceType+"");
}
builder.AppendFormat(@"select distinct b.FrID,IFNULL(b.MatchMoney,0) as MatchMoney,IFNULL(E.TCID,0)TCID,D.Name,b.Status,b.TradeDate,b.CreateDate,b.RB_Branch_Id,a.ID,a.CostTypeId,IFNULL(b.Is_Cashier,0)Is_Cashier,a.Money,b.OrderID,b.OrderSource,b.SourceID,IFNULL(b.PayMoney,0)PayMoney,IFNULL(b.Fee,0)Fee,b.Type
from rb_financedetail a INNER JOIN rb_finance as b on a.FinanceId=b.FrID and a.`Status`=0