where+=$@" and r.{nameof(RB_Sell_Achievements_Details_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if(demodel.School_Id>=0)
{
where+=$@" and r.{nameof(RB_Sell_Achievements_Details_ViewModel.School_Id)} ={demodel.School_Id}";
}
if(demodel.PeriodId>0)
{
where+=$@" and r.{nameof(RB_Sell_Achievements_Details_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if(demodel.UserId>0)
{
where+=$@" and r.{nameof(RB_Sell_Achievements_Details_ViewModel.UserId)} ={demodel.UserId}";
}
if(demodel.ClassId>0)
{
where+=$@" and r.{nameof(RB_Sell_Achievements_Details_ViewModel.ClassId)} ={demodel.ClassId}";
}
if(demodel.OrderId>0)
{
where+=$@" and r.{nameof(RB_Sell_Achievements_Details_ViewModel.OrderId)} ={demodel.OrderId}";
}
stringsql=$@" select r.UserId,r.Depart_Id,r.School_Id,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney
from RB_Sell_Achievements_Details r where {where} group by r.UserId,r.Depart_Id,r.School_Id";
stringsql=$@"SELECT d.ClassId,SUM(d.CurrentPeriodMoney + d.DeductionMoney) AS CurrentPeriodMoney FROM RB_Sell_Achievements_Details d
INNER JOIN rb_sell_achievements_periods p on d.PeriodId = p.Id
left join rb_class c on d.ClassId = c.ClassId
WHERE p.Group_Id ={group_Id}{where} 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'