stringwhere=$@" 1=1 and (o.Income+o.PlatformTax+o.DiscountMoney-o.Refund)<o.PreferPrice ";
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderType)} ={(int)OrderTypeEnum.CourseOrder} ";
if(demodel.Group_Id>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if(demodel.School_Id>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.School_Id)} ={demodel.School_Id}";
}
if(demodel.OrderId>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderId)} ={demodel.OrderId}";
}
else
{
if(demodel.ClassId>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.ClassId)} ={demodel.ClassId}";
}
if(demodel.OrderState>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderState)} ={(int)demodel.OrderState}";
}
if(demodel.OrderSource>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderSource)} ={(int)demodel.OrderSource}";
}
if(demodel.OrderForm>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderForm)} ={(int)demodel.OrderForm}";
}
if(demodel.EnterID>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.EnterID)} ={demodel.EnterID}";
}
if(demodel.Dept_Id>0)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.Dept_Id)} ={demodel.Dept_Id}";
}
if(demodel.Q_OrderState>0)
{
if(demodel.Q_OrderState==1)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderState)} in(1,2)";
}
elseif(demodel.Q_OrderState==2)
{
where+=$@" and o.{nameof(RB_Order_ViewModel.OrderState)} =3";
}
}
if(!string.IsNullOrEmpty(demodel.ClassName))
{
where+=$@" and c.{nameof(RB_Class.ClassName)} like '%{demodel.ClassName}%'";
}
if(!string.IsNullOrEmpty(demodel.GuestName))
{
if(demodel.Group_Id>0)
{
where+=$@" and o.OrderId in (select OrderId from rb_order_guest where Status =0 and Group_Id ={demodel.Group_Id} and GuestName like '%{demodel.GuestName}%')";
}
else
{
where+=$@" and o.OrderId in (select OrderId from rb_order_guest where Status =0 and GuestName like '%{demodel.GuestName}%')";
}
}
if(demodel.CourseId>0)
{
where+=$@" and c.{nameof(RB_Class.CouseId)} ={demodel.CourseId}";
}
if(!string.IsNullOrEmpty(demodel.StartTime))
{
where+=$@" and o.{nameof(RB_Order_ViewModel.CreateTime)} >='{demodel.StartTime}'";
}
if(!string.IsNullOrEmpty(demodel.EndTime))
{
where+=$@" and o.{nameof(RB_Order_ViewModel.CreateTime)} <='{demodel.EndTime} 23:59:59'";
}
if(!string.IsNullOrEmpty(demodel.OPStartTime))
{
where+=$@" and c.{nameof(RB_Class.OpenTime)} >='{demodel.OPStartTime}'";
}
if(!string.IsNullOrEmpty(demodel.OPEndTime))
{
where+=$@" and c.{nameof(RB_Class.OpenTime)} <='{demodel.OPEndTime} 23:59:59'";
where+=$@" and A.{nameof(RB_Teaching_BonusDetail.Type)} ={demodel.Type}";
}
stringsql=$@" select A.* from RB_Teaching_BonusDetail as A LEFT JOIN rb_teaching_bonus as b on a.BonusId=b.Id and b.State=2 where {where} order by a.Id desc";
where+=$@" and DATE_FORMAT(STR_TO_DATE(CONCAT(b.Month,'-01'),'%Y-%m-%d'),'%Y-%m-%d')>=DATE_FORMAT('{demodel.Month}','%Y-%m-%d')";
}
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";