stringwhere="where 1=1 and a.OrderStatus in(2,3,4,5,6) ";
if(dmodel!=null)
{
...
...
@@ -838,6 +838,15 @@ as t GROUP BY t.CreateDate desc";
{
where+=$" and b.SupplierId={dmodel.SupplierId} ";
}
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 ,
...
...
@@ -853,13 +862,56 @@ GROUP BY b.GoodsId,b.SupplierId,b.OrderId ";
stringwhere="where 1=1 and a.OrderStatus in(2,3,4,5,6) ";
if(dmodel!=null)
{
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))
{
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(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
from rb_goods_orderdetail as b
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 (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 ALLCommission,OrderId from rb_goods_ordercommission GROUP BY OrderId ) as e on a.OrderId=e.OrderId {where}
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")}'";