stringsql=$@"SELECT t.CreateDate as StartTime,SUM(t.FreightMoney + t.Final_Price) AS Income FROM (
stringsql=$@"SELECT t.CreateDate as StartTime,SUM(t.FreightMoney + t.Final_Price) AS Income FROM (
SELECT o.OrderId,DATE_FORMAT(o.CreateDate,'%y-%m-%d') AS CreateDate,o.FreightMoney,SUM(od.Final_Price) AS Final_Price FROM rb_goods_order o
SELECT o.OrderId,DATE_FORMAT(o.CreateDate,'%Y-%m-%d') AS CreateDate,o.FreightMoney,SUM(od.Final_Price) AS Final_Price FROM rb_goods_order o
LEFT JOIN rb_goods_orderdetail od on o.OrderId = od.OrderId
LEFT JOIN rb_goods_orderdetail od on o.OrderId = od.OrderId
LEFT JOIN rb_goods_orderaftersale oa on od.Id = oa.OrderDetialId and oa.Type=1 and oa.ReOrderStatus =5
LEFT JOIN rb_goods_orderaftersale oa on od.Id = oa.OrderDetialId and oa.Type=1 and oa.ReOrderStatus =5
WHERE o.MallBaseId ={mallBaseId} and o.OrderStatus in(2,3,4,5,6) and o.Recycled=2 and o.`Status`=0 and o.UserId ={userId} and o.CreateDate >= '{startTime}' AND o.CreateDate <= '{endTime} 23:59:59' AND oa.ReOrderId is NULL
WHERE o.MallBaseId ={mallBaseId} and o.OrderStatus in(2,3,4,5,6) and o.Recycled=2 and o.`Status`=0 and o.UserId ={userId} and o.CreateDate >= '{startTime}' AND o.CreateDate <= '{endTime} 23:59:59' AND oa.ReOrderId is NULL