stringwhere=$" where 1=1 and a.OrderStatus in(2,3,4,6,5)";
if(dmodel.TenantId>0)
{
where+=$@" and a.{nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}";
}
if(dmodel.MallBaseId>0)
{
where+=$@" and a.{nameof(RB_Goods_Order.MallBaseId)}={dmodel.MallBaseId}";
}
if(dmodel.PlatformType>0)
{
where+=$@" and a.{nameof(RB_Goods_Order.OrderSource)}={(int)dmodel.PlatformType}";
}
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
where+=$" AND DATE_FORMAT(a.{nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
}
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
where+=$" AND DATE_FORMAT(a.{nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
}
stringsql=$@" select a.*,b.GoodsTotalNum from rb_goods_order as a LEFT JOIN (SELECT OrderId,COUNT(*) as GoodsTotalNum from rb_goods_orderdetail GROUP BY OrderId)as b