varsql=$@"select * from (select t1.id,t1.parentid,t1.icon,t1.`name`,t1.path,t1.sort from dc_menu t1
join dc_menu_permission t2 on t1.id = t2.menuid and t2.delstatus = 0 and t2.username = '{username}'
join dc_menu_permission t2 on t1.id=t2.menuid and t2.delstatus=0 and t2.username='{username}'
where t1.delstatus = 0
where t1.delstatus=0 and t1.name='库存'
union all
union all
select* from dc_menu where 1 = (select isall from dc_menu_permission where username = '{username}' and isall = 1 and delstatus = 0)";
select t1.id,t1.parentid,t1.icon,t1.`name`,t1.path,t1.sort from dc_menu t1 where 1 = (select isall from dc_menu_permission where username='{username}' and isall=1 and delstatus=0)) tb order by parentid,sort";
varfromsql=" where t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
if(!string.IsNullOrWhiteSpace(platform))
{
fromsql+=" and t1.platform_type = @platform";
sqlparam.Add("platform",platform);
}
if(companyid.HasValue&&companyid.Value>0)
{
fromsql+=" and t1.company_id="+companyid.Value;//增加公司id过滤
}
if(!string.IsNullOrWhiteSpace(account))
{
fromsql+=" and t1.seller_account=@seller_account";
sqlparam.Add("seller_account",account);
}
if(!string.IsNullOrWhiteSpace(website))
{
fromsql+=" and t1.website=@website";
sqlparam.Add("website",website);
}
if(start.HasValue)
{
fromsql+=" and t1.paid_time>='"+start.Value.ToString("yyyy-MM-dd")+"'";
}
if(end.HasValue)
{
fromsql+=" and t1.paid_time<'"+end.Value.AddDays(1).ToString("yyyy-MM-dd")+"'";
}
varprefromsql=fromsql;
fromsql+=" group by t1.seller_account,t1.website,t1.platform_type";
if(!string.IsNullOrWhiteSpace(parameter.sort))
{
fromsql+=" order by "+parameter.sort+" "+parameter.order;
varsqlwhere=" where t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
if(companyid.HasValue&&companyid.Value>0)
{
sqlwhere+=" and t1.company_id="+companyid.Value;//增加公司id过滤
}
if(!string.IsNullOrEmpty(platform))
{
if(platform.ToUpper().Trim()!="FBA")
{
sqlwhere+=" and t1.bailun_order_status!='CantHandle' ";
sql+=" join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id "+(!string.IsNullOrEmpty(warehousecode)?" and t2.warehouse_code=@warehousecode":"");
sql+=" join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
sqlparam.Add("warehousetype",warehousetype);
if(!string.IsNullOrEmpty(warehousecode))
{
sqlparam.Add("warehousecode",warehousecode);
}
}
elseif(!string.IsNullOrEmpty(warehousecode))
{
sql+=" join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode";
sqlparam.Add("warehousecode",warehousecode);
}
if(!string.IsNullOrWhiteSpace(account))
{
sqlwhere+=" and t1.seller_account=@seller_account";
sqlparam.Add("seller_account",account);
}
if(!string.IsNullOrWhiteSpace(website))
{
sqlwhere+=" and t1.website=@website";
sqlparam.Add("website",website);
}
if(start.HasValue)
{
sqlwhere+=" and t1.paid_time>='"+start.Value.ToString("yyyy-MM-dd")+"'";
}
if(end.HasValue)
{
sqlwhere+=" and t1.paid_time<'"+end.Value.AddDays(1).ToString("yyyy-MM-dd")+"'";