+" PlanReturnDays = (select datediff(dd, dEndDate, dReturnDate) from tZHCProject p where p.nProjectID = a.nProjectID), LastUpdateTime = a.dLastUpdateTime ,SaleCount = 0 "
+" PlanReturnDays = (select datediff(dd, dEndDate, dReturnDate) from tZHCProject p where p.nProjectID = a.nProjectID), LastUpdateTime = a.dLastUpdateTime ,SaleCount = 0 "
+" FROM tZHCPlan a join tAgentContractGoods acg on a.sAgentContractNO = acg.sAgentContractNO and a.nGoodsID = acg.nGoodsID "
+" FROM tZHCPlan a join tAgentContractGoods acg on a.sAgentContractNO = acg.sAgentContractNO and a.nGoodsID = acg.nGoodsID "
+" WHERE a.nProjectID = ? ";
+" WHERE a.nProjectID = ? ";
Stringsql0="select so.nPlanID, sum(so.nSaleQty) nSaleQty from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nPlanID = p.nPlanID and p.nProjectID = "+projectId+" group by nPlanID";
+" FROM tZHCProject a join tOrg o on a.sOrgNO = o.sOrgNO "
+" join tZHCPlan b on a.nProjectID = b.nProjectID "
+" left join tSalesOrderSub ts WITH(NOLOCK) on ts.dOrderDate >= a.dStartDate "
+" and ts.dOrderDate <= a.dEndDate "
+" and ts.sSalesOrderTypeID = '4' "//--众筹订单
+" and ts.nOrderStatus&1 = 0 "
+" and ts.nOrderStatus&32 = 32 "//--已付款
+" left join tSalesOrderSubDtl td WITH(NOLOCK) on ts.sSubOrderID = td.sSubOrderID and td.sAgentContractNO = b.sAgentContractNO and td.nGoodsID = b.nGoodsID "