stringsql=$@"SELECT OrderGuestId, SUM(StudyNum) as MinutesNum FROM rb_class_check where `Status`=0 and Group_Id ={groupId} and CheckStatus =0 and OrderGuestId in ({guestIds}) group by OrderGuestId";
stringsql=$@"SELECT OrderGuestId, SUM(CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check where `Status`=0 and Group_Id ={groupId} and CheckStatus =0 and OrderGuestId in ({guestIds}) group by OrderGuestId";
stringsql=$@"SELECT OrderGuestId, SUM(CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check where `Status`=0 and Group_Id ={groupId} and OrderGuestId in ({guestIds}) group by OrderGuestId";
stringsql=$@"SELECT g.OrderId,DATE_FORMAT(c.CreateTime,'%Y-%m') as MonthDateStr,SUM(c.CurrentDeductionHours) CurrentDeductionHours FROM rb_order_guest g
left join rb_class_check c on g.Id = c.OrderGuestId
WHERE g.Group_Id ={groupId} and g.`Status`=0 and g.GuestState <>2 and c.`Status` =0 and g.OrderId in({orderIds})
group by g.OrderId,DATE_FORMAT(c.CreateTime,'%Y-%m');";
where+=$" and c.CouseId not in ({courseIds})";//排除内部班
}
stringsql=$@"SELECT o.* FROM rb_order o
inner join rb_class c on o.ClassId = c.ClassId
WHERE o.Group_Id ={group_Id} and o.OrderState =1 and o.CommissionRate >0 and c.OpenTime <= '{eDate} 23:59:59' {where} and o.PreferPrice <= (o.Income - o.Refund + o.DiscountMoney + o.PlatformTax) and (o.IsCommissionGiveOK =0 or (o.ExtraRewardMoney -o.ExtraDeductMoney)<> o.ExtraCommissionMoney);";
stringsql=$@"SELECT COUNT(0) FROM rb_order WHERE Group_Id ={group_Id} and OrderState =1 and (EnterID ={userId} or HelpEnterId ={userId} ) and CommissionBack >0";
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if(demodel.School_Id>=0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.School_Id)} ={demodel.School_Id}";
}
if(demodel.PeriodId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if(demodel.UserId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.UserId)} ={demodel.UserId}";
}
if(demodel.ClassId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.ClassId)} ={demodel.ClassId}";
}
if(demodel.OrderId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_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,sum(r.CurrentExtraMoney + r.DeductionExtraMoney) as CurrentExtraMoney
from RB_Sell_Commission_Details r where {where} group by r.UserId,r.Depart_Id,r.School_Id";
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if(demodel.School_Id>=0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.School_Id)} ={demodel.School_Id}";
}
if(demodel.Depart_Id>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.Depart_Id)} ={demodel.Depart_Id}";
}
if(demodel.PeriodId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.PeriodId)} ={demodel.PeriodId}";
}
if(demodel.UserId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.UserId)} ={demodel.UserId}";
}
if(demodel.ClassId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.ClassId)} ={demodel.ClassId}";
}
if(demodel.OrderId>0)
{
where+=$@" and r.{nameof(RB_Sell_Commission_Details_ViewModel.OrderId)} ={demodel.OrderId}";
}
stringsql=$@" select sum(r.CurrentPeriodMoney + r.CurrentExtraMoney + r.DeductionMoney + r.DeductionExtraMoney) from RB_Sell_Commission_Details r where {where}";