where+=$@" and od.{nameof(RB_Goods_OrderDetail.SupplierId)}={dmodel.SupplierId}";
}
if(!string.IsNullOrEmpty(dmodel.StartTime))
{
where+=$@" and o.{nameof(RB_Goods.CreateDate)} >='{dmodel.StartTime}'";
}
if(!string.IsNullOrEmpty(dmodel.EndTime))
{
where+=$@" and o.{nameof(RB_Goods.CreateDate)} <='{dmodel.EndTime+" 23:59:59"}'";
}
if(!string.IsNullOrEmpty(dmodel.GoodsName))
{
where+=$@" and od.{nameof(RB_Goods_OrderDetail.GoodsName)}='{dmodel.GoodsName}'";
}
if(dmodel.CommissionState>0)
{
switch(dmodel.CommissionState)
{
case2:where+=$@" and o.{nameof(RB_Goods_Order.OrderStatus)}={(int)OrderStatusEnum.Completed}";break;
case1:where+=$@" and o.{nameof(RB_Goods_Order.OrderStatus)} in(2,3,4,6)";break;
case3:where+=$@" and o.{nameof(RB_Goods_Order.OrderStatus)}=1 ";break;
}
}
else
{
where+=$@" and o.{nameof(RB_Goods_Order.OrderStatus)} in(1,2,3,4,5,6)";
}
stringsql=$@"SELECT GROUP_CONCAT(oc.OrderDetailId) as OrderDetailIds,oc.OrderId,oc.OrderDetailId,o.OrderNo,o.UserId,oc.CommissionRatio,oc.Type,oc.CommissionState,o.OrderStatus as DistrbutionOrderSelectStatus,SUM(oc.Commission) as Commission
FROM RB_Goods_OrderIntroduction oc
inner join rb_goods_order o on oc.OrderId = o.OrderId
INNER JOIN rb_goods_orderdetail as od on od.Id=oc.OrderDetailId
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,o.OrderNo order by oc.OrderId desc";