where+=$" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
}
if(dmodel.GoodsID>0)
{
where+=$" and b.GoodsId={dmodel.GoodsID} ";
}
if(dmodel.CompanyId>0)
{
where+=$" and b.CompanyId={dmodel.CompanyId} ";
}
if(!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
where+=$" and DATE_FORMAT(a.PaymentTime,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
if(!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
where+=$" and DATE_FORMAT(a.PaymentTime,'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' ) ";
}
}
stringsql=$@" SELECT a.OrderSource,a.OrderStatus,a.PaymentTime,a.UserId,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,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+IFNULL(b.InsuranceMoney,0)) as AllPrice,SUM(b.DepositMoney+b.DepositFreightMoney) as TotalDepositMoney ,
(IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight,
0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,oa.RefundActual,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney
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 rb_member_user as muser on muser.id=b.CompanyId
left join rb_goods_orderaftersale oa on b.ID= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) {where}
// where += $" and DATE_FORMAT(a.CancelTime,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
//}
//if (!string.IsNullOrWhiteSpace(dmodel.EndDate))
//{
// where += $" and DATE_FORMAT(a.CancelTime,'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' ) ";
//}
}
stringsql=$@" SELECT a.OrderSource,a.OrderStatus,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,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+IFNULL(b.InsuranceMoney,0)) as AllPrice ,
(IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight,
0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney
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 rb_member_user as muser on muser.id=b.CompanyId {where}
// where += $" and DATE_FORMAT(oa.FinishTime,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
//}
//if (!string.IsNullOrWhiteSpace(dmodel.EndDate))
//{
// where += $" and DATE_FORMAT(oa.FinishTime,'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' ) ";
//}
}
stringsql=$@" SELECT a.OrderSource,a.OrderStatus,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,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+IFNULL(b.InsuranceMoney,0)) as AllPrice ,
(IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight,
0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,oa.RefundActual,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney
from rb_goods_orderaftersale as oa
LEFT JOIN rb_goods_orderdetail as b on b.ID= oa.OrderDetialId
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_member_user as muser on muser.id=b.CompanyId
where oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) {where}
@@ -1711,7 +1711,7 @@ FROM RB_Member_User AS a LEFT JOIN rb_miai_baseinfo AS b ON a.Id = b.UserId) as
}
/// <summary>
/// 获取日期以前付款用户数量
/// 获取日期截止付款用户数量
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
...
...
@@ -1741,7 +1741,7 @@ GROUP BY u.Id)t ";
stringsql=$@"SELECT count(0) FROM
(select u.Id from RB_Member_User u
LEFT JOIN rb_goods_order o on u.Id = o.UserId
where u.TenantId={tenantId} and u.MallBaseId={mallBaseId} and o.CreateDate <='{startTime} 23:59:59' and o.PaymentTime is not null and u.Id in({userIds})
where u.TenantId={tenantId} and u.MallBaseId={mallBaseId} and o.OrderStatus <>7 and o.CreateDate <'{startTime}' and o.PaymentTime is not null and u.Id in({userIds})