varfromsql=" where t1.paid_time>='"+start.ToString("yyyy-MM-dd")+"' and t1.paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and t1.platform_type='Amazon' and t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 ";
if(companyid.HasValue&&companyid.Value>0)
...
...
@@ -223,6 +248,7 @@ namespace Bailun.DC.Services
sqlparam.Add("website",website);
}
varprefromsql=fromsql;
fromsql+=" and t1.bailun_payment_status!='Canceled' and t1.bailun_order_status!='CantHandle'";
fromsql+=" group by t1.seller_account,t1.website,t1.platform_type";
varfromsql=" where t1.paid_time>='"+start.ToString("yyyy-MM-dd")+"' and t1.paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and t1.platform_type='Amazon' and t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 ";
varsql=@"select platform_type,seller_account,website,sum(amount_sales*seller_order_exchange_rate) 'amount_product',sum(cost_product) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate) 'platform_fee',sum(cost_first) 'head_fee',count(id) 'order_count',sum(cost_total) 'cost_count',sum(cost_shipping) 'nofba_logisticsfee',sum(profit_total) 'profit_count',(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_package) cost_package,count(amount_prepaid>0 or null) as noshippingcount from dc_base_oms_order where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and platform_type='FBA' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0";
varsql=@"select t1.platform_type,t1.seller_account,t1.website,sum(t1.amount_sales*t1.seller_order_exchange_rate) 'amount_product',sum(t1.cost_product) 'cost_product',sum(t1.cost_platform_fee*t1.seller_order_exchange_rate) 'platform_fee',sum(t1.cost_first) 'head_fee',count(t1.id) 'order_count',sum(t1.cost_total) 'cost_count',sum(t1.cost_shipping) 'nofba_logisticsfee',sum(t1.profit_total) 'profit_count',(sum(t1.profit_total)/sum(t1.amount_total*t1.seller_order_exchange_rate)) 'profit_rate',sum(t1.amount_prepaid) amount_prepaid,sum(t1.amount_refund*t1.seller_order_exchange_rate) amount_refund,sum(t1.cost_fba_fee*t1.seller_order_exchange_rate) cost_fba_fee,sum(t1.cost_paypal_fee*t1.seller_order_exchange_rate) cost_paypal_fee,sum(t1.cost_package) cost_package,count(t1.amount_prepaid>0 or null) as noshippingcount from dc_base_oms_order t1 ";
if(!string.IsNullOrWhiteSpace(skucategoryids))
{
sql+=" join dc_base_oms_sku t3 on t1.bailun_order_id=t3.bailun_order_id ";
sql+=" where t1.paid_time>='"+start.ToString("yyyy-MM-dd")+"' and t1.paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and t1.platform_type='FBA' and t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 ";
if(!string.IsNullOrWhiteSpace(account))
{
sql+=" and seller_account=@seller_account";
sql+=" and t1.seller_account=@seller_account";
sqlparam.Add("seller_account",account);
}
if(!string.IsNullOrWhiteSpace(website))
{
sql+=" and website=@website";
sql+=" and t1.website=@website";
sqlparam.Add("website",website);
}
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
sql+=" and t1.company_id="+companyid.Value;//增加公司id过滤
}
sql+=" group by seller_account,website,platform_type";
sql+=" group by t1.seller_account,t1.website,t1.platform_type";
if(!string.IsNullOrWhiteSpace(parameter.sort))
{
sql+=" order by "+parameter.sort+" "+parameter.order;
sql+=" order by t1."+parameter.sort+" "+parameter.order;
varsql=@"select sum(amount_sales*seller_order_exchange_rate) 'amount_product',sum(cost_product) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate) 'platform_fee',sum(cost_first) 'head_fee',count(id) 'order_count',sum(cost_total) 'cost_count',sum(cost_shipping) 'nofba_logisticsfee',sum(profit_total) 'profit_count',(sum(profit_total)/sum(amount_product*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_package) cost_package,count(amount_prepaid>0 or null) as noshippingcount from dc_base_oms_order where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and platform_type='FBA' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0";
varsql=@"select sum(t1.amount_sales*t1.seller_order_exchange_rate) 'amount_product',sum(t1.cost_product) 'cost_product',sum(t1.cost_platform_fee*t1.seller_order_exchange_rate) 'platform_fee',sum(t1.cost_first) 'head_fee',count(t1.id) 'order_count',sum(t1.cost_total) 'cost_count',sum(t1.cost_shipping) 'nofba_logisticsfee',sum(t1.profit_total) 'profit_count',(sum(t1.profit_total)/sum(t1.amount_product*t1.seller_order_exchange_rate)) 'profit_rate',sum(t1.amount_prepaid) amount_prepaid,sum(t1.amount_refund*t1.seller_order_exchange_rate) amount_refund,sum(t1.cost_fba_fee*t1.seller_order_exchange_rate) cost_fba_fee,sum(t1.cost_paypal_fee*t1.seller_order_exchange_rate) cost_paypal_fee,sum(t1.cost_package) cost_package,count(t1.amount_prepaid>0 or null) as noshippingcount from dc_base_oms_order t1 ";
if(!string.IsNullOrWhiteSpace(skucategoryids))
{
sql+=" join dc_base_oms_sku t3 on t1.bailun_order_id=t3.bailun_order_id ";
sql+=" where t1.paid_time>='"+start.ToString("yyyy-MM-dd")+"' and t1.paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and t1.platform_type='FBA' and t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 ";
if(!string.IsNullOrWhiteSpace(account))
{
sql+=" and seller_account=@seller_account";
sql+=" and t1.seller_account=@seller_account";
sqlparam.Add("seller_account",account);
}
if(!string.IsNullOrWhiteSpace(website))
{
sql+=" and website=@website";
sql+=" and t1.website=@website";
sqlparam.Add("website",website);
}
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id"+companyid.Value;
sql+=" and t1.company_id="+companyid.Value;//增加公司id筛选
varstrwhere="select t1.origin_order_id,t1.platform_type,t1.website,t1.seller_account,t1.bailun_sku,t1.order_currency,t1.cost_fba_fee,(t1.fba_fee_rmb*t1.seller_order_exchange_rate) fba_fee_rmb,t2.average_fba_fee,t2.min_fba_fee,t2.max_fba_fee,t1.create_time,t1.seller_order_exchange_rate from dc_base_oms_sku t1 join dc_mid_fba_fee_avg t2 on t1.bailun_sku=t2.bailun_sku and t1.website=t2.website where t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.platform_type in ('Amazon','FBA') and t1.has_fba_exception=1";
strwhere+=" join dc_mid_fba_fee_avg t2 on t1.bailun_sku=t2.bailun_sku and t1.website=t2.website ";
strwhere+=" where t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.platform_type in ('Amazon','FBA') and t1.has_fba_exception=1 ";
varstrwhere="select origin_order_id,bailun_order_id,seller_account,amount_product,cost_platform_fee,(cost_platform_fee/amount_product) platform_fee_rate,platform_type,website,create_time from dc_base_oms_order where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and has_platform_exception=1 ";
varstrwhere="select t1.origin_order_id,t1.bailun_order_id,t1.seller_account,t1.amount_product,t1.cost_platform_fee,(t1.cost_platform_fee/t1.amount_product) platform_fee_rate,t1.platform_type,t1.website,t1.create_time from dc_base_oms_order t1 ";
if(!string.IsNullOrWhiteSpace(skucategoryids))
{
strwhere+=" join dc_base_oms_sku t3 on t1.bailun_order_id=t3.bailun_order_id ";
strwhere+=" and t3.bailun_category_id in ("+s+") ";
}
}
}
strwhere+=" where t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.has_platform_exception=1 ";
if(companyid.HasValue&&companyid.Value>0)
{
strwhere+=" and company_id="+companyid.Value;//增加公司id过滤
strwhere+=" and t1.company_id="+companyid.Value;//增加公司id过滤
}
if(!string.IsNullOrWhiteSpace(platform))
{
if(platform.ToUpper()=="AMAZON")
{
strwhere+=" and platform_type in ('Amazon','FBA')";
strwhere+=" and t1.platform_type in ('Amazon','FBA')";
varstrwhere="select sum(amount_product) amount_product,sum(cost_platform_fee) cost_platform_fee from dc_base_oms_order where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and has_platform_exception=1 ";
varstrwhere="select sum(t1.amount_product) amount_product,sum(t1.cost_platform_fee) cost_platform_fee from dc_base_oms_order t1 ";
if(!string.IsNullOrWhiteSpace(skucategoryids))
{
strwhere+=" join dc_base_oms_sku t3 on t1.bailun_order_id=t3.bailun_order_id ";
strwhere+=" and t3.bailun_category_id in ("+s+") ";
}
}
}
strwhere+=" where t1.bailun_order_status!='Canceled' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.has_platform_exception=1 ";
if(companyid.HasValue&&companyid.Value>0)
{
strwhere+=" and company_id="+companyid.Value;//增加公司id过滤
strwhere+=" and t1.company_id="+companyid.Value;//增加公司id过滤
}
if(!string.IsNullOrWhiteSpace(platform))
{
if(platform.ToUpper()=="AMAZON")
{
strwhere+=" and platform_type in ('Amazon','FBA')";
strwhere+=" and t1.platform_type in ('Amazon','FBA')";