where+=$@" and {nameof(RB_Goods_OrderCommission.TenantId)}={dmodel.TenantId}";
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.TenantId)}={dmodel.TenantId}";
}
if(dmodel.MallBaseId>0)
{
where+=$@" and {nameof(RB_Goods_OrderCommission.MallBaseId)}={dmodel.MallBaseId}";
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.MallBaseId)}={dmodel.MallBaseId}";
}
if(dmodel.OrderId>0)
{
where+=$@" and {nameof(RB_Goods_OrderCommission.OrderId)}={dmodel.OrderId}";
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.OrderId)}={dmodel.OrderId}";
}
if(dmodel.UserId>0)
{
where+=$@" and {nameof(RB_Goods_OrderCommission.UserId)}={dmodel.UserId}";
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.UserId)}={dmodel.UserId}";
}
if(!string.IsNullOrEmpty(dmodel.OrderIds))
{
where+=$@" and {nameof(RB_Goods_OrderCommission.OrderId)} in({dmodel.OrderIds})";
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.OrderId)} in({dmodel.OrderIds})";
}
stringsql=$@"SELECT OrderId,UserId,Grade,Type,SUM(Commission) as Commission FROM RB_Goods_OrderCommission where {where} group by OrderId,UserId,Grade,Type order by Grade asc";
stringsql=$@"SELECT oc.OrderId,oc.UserId,oc.Grade,oc.Type,SUM(oc.Commission) as Commission FROM RB_Goods_OrderCommission oc
left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5)
where {where} group by oc.OrderId,oc.UserId,oc.Grade,oc.Type order by oc.Grade asc";