stringwhere=$" 1=1 and o.Recycled=2 and oa.ReOrderId is null";
stringwhere=$" 1=1 and o.Recycled=2 ";
if(dmodel.TenantId>0)
if(dmodel.TenantId>0)
{
{
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.TenantId)}={dmodel.TenantId}";
where+=$@" and o.{nameof(RB_Goods_OrderCommission.TenantId)}={dmodel.TenantId}";
}
}
if(dmodel.MallBaseId>0)
if(dmodel.MallBaseId>0)
{
{
where+=$@" and oc.{nameof(RB_Goods_OrderCommission.MallBaseId)}={dmodel.MallBaseId}";
where+=$@" and o.{nameof(RB_Goods_OrderCommission.MallBaseId)}={dmodel.MallBaseId}";
}
}
if(dmodel.OrderId>0)
if(dmodel.OrderId>0)
{
{
...
@@ -256,7 +256,7 @@ where {where} group by oc.OrderId,o.OrderNo,oc.UserId,oc.Type,oc.Grade order by
...
@@ -256,7 +256,7 @@ where {where} group by oc.OrderId,o.OrderNo,oc.UserId,oc.Type,oc.Grade order by
}
}
if(dmodel.UserId>0)
if(dmodel.UserId>0)
{
{
where+=string.Format(@" and (oc.UserId={0} OR o.UserId={0}) ",dmodel.UserId);
where+=string.Format(@" and o.UserId={0} ",dmodel.UserId);
}
}
if(!string.IsNullOrEmpty(dmodel.OrderIds))
if(!string.IsNullOrEmpty(dmodel.OrderIds))
{
{
...
@@ -277,11 +277,21 @@ where {where} group by oc.OrderId,o.OrderNo,oc.UserId,oc.Type,oc.Grade order by
...
@@ -277,11 +277,21 @@ where {where} group by oc.OrderId,o.OrderNo,oc.UserId,oc.Type,oc.Grade order by
}
}
stringsql=$@"
stringsql=$@"
SELECT oc.OrderId,o.OrderNo,o.UserId,oc.Type,oc.Grade,oc.CommissionState,o.OrderStatus as DistrbutionOrderSelectStatus,SUM(oc.Commission) as Commission
SELECT o.OrderId,o.OrderNo,o.UserId,o.OrderStatus AS DistrbutionOrderSelectStatus
FROM rb_goods_order o LEFT JOIN RB_Goods_OrderCommission oc on oc.OrderId = o.OrderId
,IFNULL(oc.Commission,0) AS Commission,oc.Type AS Type,oc.Grade AS Grade,oc.CommissionState AS CommissionState
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)
FROM rb_goods_order o
where {where} group by oc.OrderId,o.OrderNo,oc.UserId,oc.Type,oc.Grade order by oc.OrderId desc";