Stringsql="select distinct a.* from tSalesOrder a, tSalesOrderSub b where a.sSalesOrderID = b.sSalesOrderID and a.sShopNO = '"+shopNo+"' and a.sOrgNO = '"+orgNo+"'";
if(status==0){
sql+="";
}elseif(status==1){
sql+=" and sSalesOrderPayTypeID = '4' and nOrderStatus = 0";
sql+=" and a.sSalesOrderPayTypeID = '4' and a.nOrderStatus = 0";
}elseif(status==2){
sql+=" and ((sSalesOrderPayTypeID = '2' and nOrderStatus = 0) or (sSalesOrderPayTypeID = '4' and nOrderStatus&37 = 32))";
sql+=" and ((a.sSalesOrderPayTypeID = '2' and a.nOrderStatus = 0) or (a.sSalesOrderPayTypeID = '4' and a.nOrderStatus&37 = 32))";
}elseif(status==3){
sql+=" and nOrderStatus&29 = 4 and nOrderStatus&128=0 ";
sql+=" and a.nOrderStatus&29 = 4 and a.nOrderStatus&128=0 ";
}elseif(status==4){
sql+=" and nOrderStatus&129 = 128 and nOrderStatus&16=0 ";
sql+=" and a.nOrderStatus&129 = 128 and a.nOrderStatus&16=0 ";
}elseif(status==5){
sql+=" and nOrderStatus&17 = 16";
sql+=" and a.nOrderStatus&17 = 16";
}elseif(status==6){
sql+=" and nOrderStatus&1 = 1";
}else{
sql+=" and a.nOrderStatus&1 = 1";
}elseif(status==7){
sql+=" and b.sSalesOrderTypeID = '0'and b.nDebtAmount > 0 ";
}else{
thrownewXException("订单状态不存在");
}
if(orderType!=null&&orderType.length>0){
sql+=" and sB2BOrderTypeID in ("+StringUtil.join("', '","'","'","",orderType)+")";
sql+=" and a.sB2BOrderTypeID in ("+StringUtil.join("', '","'","'","",orderType)+")";