WHERE o.TenantId={tenantId} and o.MallBaseId={mallBaseId} and o.OrderStatus = 7 AND o.PaymentTime IS NOT NULL AND DATE_FORMAT(o.PaymentTime,'%Y-%m-%d') <> DATE_FORMAT(o.CancelTime,'%Y-%m-%d') AND o.CancelTime>='{startTime}' AND o.CancelTime <'{endTime}'";
WHERE o.TenantId={tenantId} and o.MallBaseId={mallBaseId} and o.OrderStatus = 7 AND o.PaymentTime IS NOT NULL AND DATE_FORMAT(o.PaymentTime,'%Y-%m-%d') <> DATE_FORMAT(o.CancelTime,'%Y-%m-%d') AND o.CancelTime>='{startTime}' AND o.CancelTime <'{endTime}'";
...
@@ -699,41 +699,43 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
...
@@ -699,41 +699,43 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
// payMemerNumWhere += $@" and {nameof(RB_Goods_Order.OrderSource)}={(int)dmodel.PlatformType}";
// payMemerNumWhere += $@" and {nameof(RB_Goods_Order.OrderSource)}={(int)dmodel.PlatformType}";
//}
//}
if(dmodel.OrderStatus>0)
if(dmodel.OrderStatus==1||dmodel.OrderStatus==0)
{
where+=$@" and a.{nameof(RB_Goods_Order.OrderStatus)} in (2,4,3,5,6)";
payMemerNumWhere+=$@" and {nameof(RB_Goods_Order.OrderStatus)} in (2,4,5,3,6)";
}
elseif(dmodel.OrderStatus==2)
{
where+=$@" and a.{nameof(RB_Goods_Order.OrderStatus)}=5";
payMemerNumWhere+=$@" and {nameof(RB_Goods_Order.OrderStatus)}=5";
}
elseif(dmodel.OrderStatus==3)
{
{
if(dmodel.OrderStatus==1)
where+=$@" and a.{nameof(RB_Goods_Order.OrderStatus)}=7";
{
payMemerNumWhere+=$@" and {nameof(RB_Goods_Order.OrderStatus)}=7";
where+=$@" and a.{nameof(RB_Goods_Order.OrderStatus)} in (1,2,4,3,6)";
payMemerNumWhere+=$@" and {nameof(RB_Goods_Order.OrderStatus)} in (1,2,4,3,6)";
}
elseif(dmodel.OrderStatus==2)
{
where+=$@" and a.{nameof(RB_Goods_Order.OrderStatus)}=5";
payMemerNumWhere+=$@" and {nameof(RB_Goods_Order.OrderStatus)}=5";
}
elseif(dmodel.OrderStatus==3)
{
where+=$@" and a.{nameof(RB_Goods_Order.OrderStatus)}=7";
payMemerNumWhere+=$@" and {nameof(RB_Goods_Order.OrderStatus)}=7";
}
elseif(dmodel.OrderStatus==4)//后面做因为现在还没有售后表
{
where+=$@" and a.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)} in (1,2,4,3)";
}
elseif(dmodel.OrderStatus==5)//后面做因为现在还没有售后表
{
}
}
}
elseif(dmodel.OrderStatus==4)//后面做因为现在还没有售后表
{
where+=$@" and a.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)} in (1,2,4,3)";
}
elseif(dmodel.OrderStatus==5)//后面做因为现在还没有售后表
{
where+=$@" and a.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)} =5";
}
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
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' )";
where+=$" AND DATE_FORMAT(a.{nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
payMemerNumWhere+=$" AND DATE_FORMAT({nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
// payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
payMemerNumWhere+=$" AND DATE_FORMAT(a.{nameof(RB_Goods_OrderAfterSale.CreateDate)},'%Y-%m-%d' )>= DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' )";
}
}
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
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' )";
where+=$" AND DATE_FORMAT(a.{nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
payMemerNumWhere+=$" AND DATE_FORMAT({nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
payMemerNumWhere+=$" AND DATE_FORMAT(a.{nameof(RB_Goods_OrderAfterSale.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
// payMemerNumWhere += $" AND DATE_FORMAT({nameof(RB_Goods_Order.CreateDate)},'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' )";
@@ -751,7 +753,7 @@ LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,
...
@@ -751,7 +753,7 @@ LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc";
as t GROUP BY t.CreateDate desc";
}
}
elseif(dmodel.OrderStatus==4)
else
{
{
sql=$@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
sql=$@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.Refund as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.Refund as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
...
@@ -759,22 +761,22 @@ LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,
...
@@ -759,22 +761,22 @@ LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc";
as t GROUP BY t.CreateDate desc";
}
}
elseif(dmodel.OrderStatus==4)
// else if (dmodel.OrderStatus == 4)
{
// {
sql=$@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.Refund as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
//from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.Refund as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
//LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
//as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
as t GROUP BY t.CreateDate desc";
//as t GROUP BY t.CreateDate desc";
}
// }
elseif(dmodel.OrderStatus==5)
// else if (dmodel.OrderStatus == 5)
{
// {
sql=$@"SELECT t.CreateDate,SUM(t.ReNumber)as GoodsNum ,COUNT(t.ReOrderId)as OrderNum ,SUM(t.Income)as PayMoney,MAX(t.PayMemerNum) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.RefundActual as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
//from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,a.ReNumber,a.RefundActual as Income,c.PayMemerNum,a.ReOrderId from RB_Goods_OrderAfterSale as a
LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
//LEFT JOIN (SELECT COUNT(DISTINCT UserId) as PayMemerNum, DATE_FORMAT(CreateDate,'%Y-%m-%d' ) as CreateDate from RB_Goods_OrderAfterSale where {payMemerNumWhere} GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d' ))
as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
//as c on c.CreateDate=DATE_FORMAT(a.CreateDate,'%Y-%m-%d' ) {where} )
(SELECT COUNT(UserId) from rb_goods_order where DATE_FORMAT(CreateDate,'%Y-%m-%d' )=t.CreateDate {payMemerNumWhere} GROUP BY UserId) as PayMemerNum
(SELECT COUNT(UserId) from rb_goods_order where DATE_FORMAT(CreateDate,'%Y-%m-%d' )=t.CreateDate {payMemerNumWhere} GROUP BY UserId) as PayMemerNum
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId from rb_goods_order as a
from (SELECT DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )as CreateDate,b.GoodsNum,a.UserId,a.Income,a.OrderId from rb_goods_order as a
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId {where})
LEFT JOIN (SELECT OrderId,SUM(Number)as GoodsNum from rb_goods_orderdetail where 1=1 {orderTypeWhere} GROUP BY OrderId)as b on a.OrderId=b.OrderId {where})
stringwhere="where 1=1 and a.OrderStatus in(2,3,4,5,6) ";
where+=$" and b.SupplierId={dmodel.SupplierId} ";
}
if(dmodel!=null)
if(dmodel.OneUserId>0)
{
{
if(!string.IsNullOrWhiteSpace(dmodel.OrderNo))
where+=$" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
{
}
where+=$" and a.OrderNo like'%{dmodel.OrderNo}%'";
if(dmodel.GoodsID>0)
}
{
where+=$" and b.GoodsId={dmodel.GoodsID} ";
if(dmodel.SupplierId>0)
}
{
where+=$" and b.SupplierId={dmodel.SupplierId} ";
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
}
{
if(dmodel.OneUserId>0)
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
{
}
where+=$" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
}
{
if(dmodel.GoodsID>0)
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )< DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
{
}
where+=$" and b.GoodsId={dmodel.GoodsID} ";
}
}
stringsql=$@" SELECT MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )< DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
}
stringsql=$@" SELECT MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
c.OneCommission,c.OneUserId,c.OneUserName,d.TwoCommission,d.TwoUserId,d.TwoUserName,0 as OtherPrice,e.ALLCommission,0 as Paid
c.OneCommission,c.OneUserId,c.OneUserName,d.TwoCommission,d.TwoUserId,d.TwoUserName,0 as OtherPrice,e.ALLCommission,0 as Paid
...
@@ -904,48 +906,48 @@ LEFT JOIN (SELECT SUM(goc.Commission) as OneCommission,goc.OrderDetailId,goc.Use
...
@@ -904,48 +906,48 @@ LEFT JOIN (SELECT SUM(goc.Commission) as OneCommission,goc.OrderDetailId,goc.Use
LEFT JOIN (SELECT SUM(goc.Commission) as TwoCommission,goc.OrderDetailId,goc.UserId as TwoUserId,mu.`Name` as TwoUserName from rb_goods_ordercommission as goc LEFT JOIN rb_member_user as mu on goc.UserId=mu.Id where goc.Grade=2 and goc.CommissionState=2 GROUP BY goc.OrderDetailId ) as d on b.Id=d.OrderDetailId
LEFT JOIN (SELECT SUM(goc.Commission) as TwoCommission,goc.OrderDetailId,goc.UserId as TwoUserId,mu.`Name` as TwoUserName from rb_goods_ordercommission as goc LEFT JOIN rb_member_user as mu on goc.UserId=mu.Id where goc.Grade=2 and goc.CommissionState=2 GROUP BY goc.OrderDetailId ) as d on b.Id=d.OrderDetailId
LEFT JOIN (SELECT SUM(Commission) as ALLCommission,OrderDetailId from rb_goods_ordercommission GROUP BY OrderId ) as e on b.Id=e.OrderDetailId {where}
LEFT JOIN (SELECT SUM(Commission) as ALLCommission,OrderDetailId from rb_goods_ordercommission GROUP BY OrderId ) as e on b.Id=e.OrderDetailId {where}
stringwhere="where 1=1 and a.OrderStatus in(2,3,4,5,6) ";
stringwhere="where 1=1 and a.OrderStatus in(2,3,4,5,6) ";
if(dmodel!=null)
if(dmodel!=null)
{
{
if(!string.IsNullOrWhiteSpace(dmodel.OrderNo))
if(!string.IsNullOrWhiteSpace(dmodel.OrderNo))
{
{
where+=$" and a.OrderNo like'%{dmodel.OrderNo}%'";
where+=$" and a.OrderNo like'%{dmodel.OrderNo}%'";
}
}
if(dmodel.SupplierId>0)
if(dmodel.SupplierId>0)
{
{
where+=$" and b.SupplierId={dmodel.SupplierId} ";
where+=$" and b.SupplierId={dmodel.SupplierId} ";
}
}
if(dmodel.OneUserId>0)
if(dmodel.OneUserId>0)
{
{
where+=$" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
where+=$" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
}
}
if(dmodel.GoodsID>0)
if(dmodel.GoodsID>0)
{
{
where+=$" and b.GoodsId={dmodel.GoodsID} ";
where+=$" and b.GoodsId={dmodel.GoodsID} ";
}
}
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
{
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
}
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
{
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )< DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
where+=$" and DATE_FORMAT(a.CreateDate,'%Y-%m-%d' )< DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
}
}
}
stringsql=$@" SELECT MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
stringsql=$@" SELECT MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
c.OneCommission,c.OneUserId,c.OneUserName,d.TwoCommission,d.TwoUserId,d.TwoUserName,0 as OtherPrice,e.ALLCommission,0 as Paid
c.OneCommission,c.OneUserId,c.OneUserName,d.TwoCommission,d.TwoUserId,d.TwoUserName,0 as OtherPrice,e.ALLCommission,0 as Paid
...
@@ -956,86 +958,86 @@ LEFT JOIN (SELECT SUM(goc.Commission) as OneCommission,goc.OrderDetailId,goc.Use
...
@@ -956,86 +958,86 @@ LEFT JOIN (SELECT SUM(goc.Commission) as OneCommission,goc.OrderDetailId,goc.Use
LEFT JOIN (SELECT SUM(goc.Commission) as TwoCommission,goc.OrderDetailId,goc.UserId as TwoUserId,mu.`Name` as TwoUserName from rb_goods_ordercommission as goc LEFT JOIN rb_member_user as mu on goc.UserId=mu.Id where goc.Grade=2 and goc.CommissionState=2 GROUP BY goc.OrderDetailId ) as d on b.Id=d.OrderDetailId
LEFT JOIN (SELECT SUM(goc.Commission) as TwoCommission,goc.OrderDetailId,goc.UserId as TwoUserId,mu.`Name` as TwoUserName from rb_goods_ordercommission as goc LEFT JOIN rb_member_user as mu on goc.UserId=mu.Id where goc.Grade=2 and goc.CommissionState=2 GROUP BY goc.OrderDetailId ) as d on b.Id=d.OrderDetailId
LEFT JOIN (SELECT SUM(Commission) as ALLCommission,OrderDetailId from rb_goods_ordercommission GROUP BY OrderId ) as e on b.Id=e.OrderDetailId {where}
LEFT JOIN (SELECT SUM(Commission) as ALLCommission,OrderDetailId from rb_goods_ordercommission GROUP BY OrderId ) as e on b.Id=e.OrderDetailId {where}
GROUP BY b.GoodsId,b.SupplierId,b.OrderId ";
GROUP BY b.GoodsId,b.SupplierId,b.OrderId ";
// string sql = $@" SELECT MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
// string sql = $@" SELECT MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
//SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
//SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
//SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
//SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
//c.OneCommission,d.TwoCommission,0 as OtherPrice,e.ALLCommission,0 as Paid
//c.OneCommission,d.TwoCommission,0 as OtherPrice,e.ALLCommission,0 as Paid
//from rb_goods_orderdetail as b
//from rb_goods_orderdetail as b
//LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId
//LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId
//LEFT JOIN rb_supplier as f on f.ID=b.SupplierId
//LEFT JOIN rb_supplier as f on f.ID=b.SupplierId
//LEFT JOIN (SELECT SUM(Commission) as OneCommission,OrderId from rb_goods_ordercommission where Grade=1 and CommissionState=2 GROUP BY OrderId ) as c on a.OrderId=c.OrderId
//LEFT JOIN (SELECT SUM(Commission) as OneCommission,OrderId from rb_goods_ordercommission where Grade=1 and CommissionState=2 GROUP BY OrderId ) as c on a.OrderId=c.OrderId
//LEFT JOIN (SELECT SUM(Commission) as TwoCommission,OrderId from rb_goods_ordercommission where Grade=2 and CommissionState=2 GROUP BY OrderId ) as d on a.OrderId=d.OrderId
//LEFT JOIN (SELECT SUM(Commission) as TwoCommission,OrderId from rb_goods_ordercommission where Grade=2 and CommissionState=2 GROUP BY OrderId ) as d on a.OrderId=d.OrderId
//LEFT JOIN (SELECT SUM(Commission) as ALLCommission,OrderId from rb_goods_ordercommission GROUP BY OrderId ) as e on a.OrderId=e.OrderId {where}
//LEFT JOIN (SELECT SUM(Commission) as ALLCommission,OrderId from rb_goods_ordercommission GROUP BY OrderId ) as e on a.OrderId=e.OrderId {where}
stringsql=$@"SELECT od.GoodsId,SUM(od.Number) as GoodsTotalNum FROM rb_goods_orderdetail od
stringsql=$@"SELECT od.GoodsId,SUM(od.Number) as GoodsTotalNum FROM rb_goods_orderdetail od
INNER JOIN rb_goods_order o on od.OrderId=o.OrderId
INNER JOIN rb_goods_order o on od.OrderId=o.OrderId
WHERE od.TenantId={tenantId} and od.MallBaseId={mallBaseId} and o.`Status`=0 and o.OrderStatus in (1,2,3,4,5,6) and o.Recycled=2 AND o.UserId={userId} and od.GoodsId in ({limitGoodsIds})
WHERE od.TenantId={tenantId} and od.MallBaseId={mallBaseId} and o.`Status`=0 and o.OrderStatus in (1,2,3,4,5,6) and o.Recycled=2 AND o.UserId={userId} and od.GoodsId in ({limitGoodsIds})
stringsql=$@"SELECT t.GoodsId,COUNT(0) as OrderNum FROM(
stringsql=$@"SELECT t.GoodsId,COUNT(0) as OrderNum FROM(
SELECT od.GoodsId,o.* FROM rb_goods_orderdetail od
SELECT od.GoodsId,o.* FROM rb_goods_orderdetail od
INNER JOIN rb_goods_order o on od.OrderId=o.OrderId
INNER JOIN rb_goods_order o on od.OrderId=o.OrderId
WHERE od.TenantId={tenantId} and od.MallBaseId={mallBaseId} and o.`Status`=0 and o.OrderStatus in (1,2,3,4,5,6) and o.Recycled=2 AND o.UserId={userId} and od.GoodsId in ({limitGoodsIds})
WHERE od.TenantId={tenantId} and od.MallBaseId={mallBaseId} and o.`Status`=0 and o.OrderStatus in (1,2,3,4,5,6) and o.Recycled=2 AND o.UserId={userId} and od.GoodsId in ({limitGoodsIds})
stringsql=$@"SELECT OrderId,UserId,OrderNo,OrderSource,CouponsIds FROM rb_goods_order where TenantId ={t} and MallBaseId ={m} and `Status`=0 and OrderStatus =1 and DATE_ADD(CreateDate,INTERVAL {cancelTime} MINUTE) < '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
stringsql=$@"SELECT OrderId,UserId,OrderNo,OrderSource,CouponsIds FROM rb_goods_order where TenantId ={t} and MallBaseId ={m} and `Status`=0 and OrderStatus =1 and DATE_ADD(CreateDate,INTERVAL {cancelTime} MINUTE) < '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
stringsql=$@"SELECT OrderId,UserId,OrderNo,OrderSource,CouponsIds FROM rb_goods_order where TenantId ={t} and MallBaseId ={m} and `Status`=0 and OrderStatus =3 and DATE_ADD(DeliveryTime,INTERVAL {day} DAY) < '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
stringsql=$@"SELECT OrderId,UserId,OrderNo,OrderSource,CouponsIds FROM rb_goods_order where TenantId ={t} and MallBaseId ={m} and `Status`=0 and OrderStatus =3 and DATE_ADD(DeliveryTime,INTERVAL {day} DAY) < '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";