sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
if(companyid.HasValue&&companyid.Value>0)
{
...
...
@@ -172,7 +172,7 @@ namespace Bailun.DC.Services
}
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
if(companyid.HasValue&&companyid.Value>0)
{
...
...
@@ -275,7 +275,7 @@ namespace Bailun.DC.Services
}
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
if(companyid.HasValue&&companyid.Value>0)
{
...
...
@@ -392,7 +392,7 @@ namespace Bailun.DC.Services
}
}
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 and t1.bailun_interception_status in ('None','Failed') ";
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 and t1.bailun_interception_status in ('','None','Failed') ";
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 and t1.bailun_interception_status in ('None','Failed') ";
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 and t1.bailun_interception_status in ('','None','Failed') ";
if(companyid.HasValue&&companyid.Value>0)
{
...
...
@@ -587,7 +587,7 @@ namespace Bailun.DC.Services
}
}
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.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
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.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
if(!string.IsNullOrWhiteSpace(account))
{
...
...
@@ -667,7 +667,7 @@ namespace Bailun.DC.Services
}
}
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.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
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.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
if(!string.IsNullOrWhiteSpace(account))
{
...
...
@@ -736,7 +736,7 @@ namespace Bailun.DC.Services
}
}
varstrwhere=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
varstrwhere=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
if(companyid.HasValue&&companyid.Value>0)
{
...
...
@@ -897,7 +897,7 @@ namespace Bailun.DC.Services
}
}
varstrwhere=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
varstrwhere=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
varsql="select t1.origin_order_id,t1.platform_type,t1.website,t1.seller_account,(t1.amount_sales*t1.seller_order_exchange_rate) amount_sales,(t1.cost_platform_fee*if(t1.platform_type='Ebay',t1.seller_other_exchange_rate,t1.seller_order_exchange_rate)) cost_platform_fee,(t1.cost_promotion*t1.seller_order_exchange_rate) cost_promotion,t1.cost_first,(t1.amount_shipping*t1.seller_order_exchange_rate) amount_shipping,t1.cost_logistics,(t1.cost_fba_fee*t1.seller_order_exchange_rate) cost_fba_fee,t1.cost_total,t1.amount_total,t1.paid_time from dc_base_oms_order t1";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
sql+=" and t2.company_id="+companyid.Value;//增加公司id过滤
}
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
sql+=" where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('None','Failed') and t3.has_delete=0 ";
sql+=" where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('','None','Failed') and t3.has_delete=0 ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and t3.company_id="+companyid.Value;//增加公司id过滤
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') ";
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('','None','Failed') ";
sql+=" where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('None','Failed') and t3.has_delete=0 ";
sql+=" where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('','None','Failed') and t3.has_delete=0 ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and t3.company_id="+companyid.Value;//增加公司id过滤
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') and tb.has_delete=0 ";
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('','None','Failed') and tb.has_delete=0 ";
//var precolumn = "select website,platform_type as platform,sum(amount_prepaid) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
sql+=" group by bailun_order_id) t2 on t1.bailun_order_id=t2.bailun_order_id ";
}
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
sql+=" group by bailun_order_id) t2 on t1.bailun_order_id=t2.bailun_order_id ";
}
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sql+=" where t1.bailun_order_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
left join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
";
sqlwhere+=" where t1.bailun_order_status != 'Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sqlwhere+=" where t1.bailun_order_status != 'Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
left join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
";
sqlwhere+=" where t1.bailun_order_status != 'Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
sqlwhere+=" where t1.bailun_order_status != 'Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
varsql="select platform_type,bailun_sku,warehouse_name,count(origin_order_id) ordercount,sum(bailun_sku_quantity_ordered) count,sum(bailun_sku_quantity_shipped) shippingcount from dc_base_oms_sku where bailun_order_status!='Canceled' and warehouse_code!='' and ((platform_type!='FBA' and bailun_order_status!='CantHandle') or platform_type='FBA') and has_scalp=0 and has_innersale=0 and bailun_interception_status in ('None','Failed') ";
varsql="select platform_type,bailun_sku,warehouse_name,count(origin_order_id) ordercount,sum(bailun_sku_quantity_ordered) count,sum(bailun_sku_quantity_shipped) shippingcount from dc_base_oms_sku where bailun_order_status!='Canceled' and warehouse_code!='' and ((platform_type!='FBA' and bailun_order_status!='CantHandle') or platform_type='FBA') and has_scalp=0 and has_innersale=0 and bailun_interception_status in ('','None','Failed') ";
varsql="select count(origin_order_id) ordercount,sum(bailun_sku_quantity_ordered) count,sum(bailun_sku_quantity_shipped) shippingcount from dc_base_oms_sku where bailun_order_status!='Canceled' and ((platform_type!='FBA' and bailun_order_status!='CantHandle') or platform_type='FBA') and has_scalp=0 and has_innersale=0 and warehouse_code!='' and bailun_interception_status in ('None','Failed') ";
varsql="select count(origin_order_id) ordercount,sum(bailun_sku_quantity_ordered) count,sum(bailun_sku_quantity_shipped) shippingcount from dc_base_oms_sku where bailun_order_status!='Canceled' and ((platform_type!='FBA' and bailun_order_status!='CantHandle') or platform_type='FBA') and has_scalp=0 and has_innersale=0 and warehouse_code!='' and bailun_interception_status in ('','None','Failed') ";
varsql=$@"select {showcol} as count,t0.platform_type,t2.category_simple_id,t2.category_simple_name from (select t1.bailun_sku,{selcol},platform_type from dc_base_oms_sku t1 where t1.has_scalp=0 and t1.has_delete=0 and t1.has_innersale=0 and t1.bailun_order_status!='Canceled' and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') and t1.company_id=1 and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA')
varsql=$@"select {showcol} as count,t0.platform_type,t2.category_simple_id,t2.category_simple_name from (select t1.bailun_sku,{selcol},platform_type from dc_base_oms_sku t1 where t1.has_scalp=0 and t1.has_delete=0 and t1.has_innersale=0 and t1.bailun_order_status!='Canceled' and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') and t1.company_id=1 and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA')
and t1.paid_time >= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t1.paid_time < '{end.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss")}' {sqlwhere}) t0
left join dc_base_sku t2 on t0.bailun_sku = t2.bailun_sku
varfromsql=" where t1.platform_type='Ebay' and 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') ";
varfromsql=" where t1.platform_type='Ebay' and 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') ";
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') ";
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') ";
varfromsql=" where t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
varfromsql=" where t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
varsql="select t1.seller_account,(t1.amount_sales*seller_order_exchange_rate) amount_sales from dc_base_oms_order t1 where t1.bailun_order_status!='Canceled' and t1.platform_type='Ebay' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
varsql="select t1.seller_account,(t1.amount_sales*seller_order_exchange_rate) amount_sales from dc_base_oms_order t1 where t1.bailun_order_status!='Canceled' and t1.platform_type='Ebay' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
varsql="select sum(t1.amount_sales*t1.seller_order_exchange_rate) amount_sales from dc_base_oms_order t1 where t1.bailun_order_status!='Canceled' and t1.platform_type='Ebay' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
varsql="select sum(t1.amount_sales*t1.seller_order_exchange_rate) amount_sales from dc_base_oms_order t1 where t1.bailun_order_status!='Canceled' and t1.platform_type='Ebay' and t1.bailun_order_status!='CantHandle' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
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') ";
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') ";
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') ";
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') ";
varsql="select origin_order_id,bailun_order_id,platform_type,website,seller_account,paid_time,(amount_sales*seller_order_exchange_rate) amount_sales,(amount_shipping*seller_order_exchange_rate) amount_shipping,(amount_product*seller_order_exchange_rate) amount_product,(amount_tax*seller_order_exchange_rate) amount_tax,(amount_adjustment*seller_order_exchange_rate) amount_adjustment,(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,(amount_refund*seller_order_exchange_rate) amount_refund,amount_prepaid,(cost_promotion*seller_order_exchange_rate) cost_promotion,(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,cost_product,cost_shipping,cost_package,(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_logistics as cost_tail,cost_first,profit_total,profit_rate,(cost_total) cost_total from dc_base_oms_order where bailun_order_status='Handling' and bailun_shipping_status!='TotalShipping' and amount_prepaid>0 and has_scalp=0 and has_innersale=0 and bailun_interception_status in ('None','Failed') ";
varsqlcount="select sum(amount_sales*seller_order_exchange_rate) amount_sales,sum(amount_shipping*seller_order_exchange_rate) amount_shipping,sum(amount_product*seller_order_exchange_rate) amount_product,sum(amount_tax*seller_order_exchange_rate) amount_tax,sum(amount_adjustment*seller_order_exchange_rate) amount_adjustment,sum(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(amount_prepaid) amount_prepaid,sum(cost_promotion*seller_order_exchange_rate) cost_promotion,sum(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,sum(cost_product) cost_product,sum(cost_shipping) cost_shipping,sum(cost_package) cost_package,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(cost_logistics) cost_tail,sum(cost_first) cost_first,sum(profit_total) profit_total,sum(cost_total) cost_total from dc_base_oms_order where bailun_order_status='Handling' and bailun_shipping_status!='TotalShipping' and has_scalp=0 and has_innersale=0 and amount_prepaid>0 and bailun_interception_status in ('None','Failed') ";
varsql="select origin_order_id,bailun_order_id,platform_type,website,seller_account,paid_time,(amount_sales*seller_order_exchange_rate) amount_sales,(amount_shipping*seller_order_exchange_rate) amount_shipping,(amount_product*seller_order_exchange_rate) amount_product,(amount_tax*seller_order_exchange_rate) amount_tax,(amount_adjustment*seller_order_exchange_rate) amount_adjustment,(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,(amount_refund*seller_order_exchange_rate) amount_refund,amount_prepaid,(cost_promotion*seller_order_exchange_rate) cost_promotion,(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,cost_product,cost_shipping,cost_package,(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_logistics as cost_tail,cost_first,profit_total,profit_rate,(cost_total) cost_total from dc_base_oms_order where bailun_order_status='Handling' and bailun_shipping_status!='TotalShipping' and amount_prepaid>0 and has_scalp=0 and has_innersale=0 and bailun_interception_status in ('','None','Failed') ";
varsqlcount="select sum(amount_sales*seller_order_exchange_rate) amount_sales,sum(amount_shipping*seller_order_exchange_rate) amount_shipping,sum(amount_product*seller_order_exchange_rate) amount_product,sum(amount_tax*seller_order_exchange_rate) amount_tax,sum(amount_adjustment*seller_order_exchange_rate) amount_adjustment,sum(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(amount_prepaid) amount_prepaid,sum(cost_promotion*seller_order_exchange_rate) cost_promotion,sum(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,sum(cost_product) cost_product,sum(cost_shipping) cost_shipping,sum(cost_package) cost_package,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(cost_logistics) cost_tail,sum(cost_first) cost_first,sum(profit_total) profit_total,sum(cost_total) cost_total from dc_base_oms_order where bailun_order_status='Handling' and bailun_shipping_status!='TotalShipping' and has_scalp=0 and has_innersale=0 and amount_prepaid>0 and bailun_interception_status in ('','None','Failed') ";
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') ";
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('','None','Failed') ";
varfromsql=" where t1.bailun_payment_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') ";
varfromsql=" where t1.bailun_payment_status!='Canceled' and ((t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle') or t1.platform_type='FBA') and t1.bailun_order_status!='Canceled' and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') ";
sql+=" where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('None','Failed') and t3.has_delete=0 and t3.bailun_sku='FJH-L-2' ";
sql+=" where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('','None','Failed') and t3.has_delete=0 and t3.bailun_sku='FJH-L-2' ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and t3.company_id="+companyid.Value;//增加公司id过滤
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') and tb.bailun_sku='FJH-L-2'";
sql+=" where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('','None','Failed') and tb.bailun_sku='FJH-L-2'";
varsql=$@"select t1.platform_type,t1.bailun_sku_title_cn,t1.bailun_sku,sum(amount_product) as amount_product,sum(ordercount) as ordercount,sum(t1.bailun_sku_quantity_ordered) as bailun_sku_quantity_ordered,sum(t1.amount_sales) amount_sales,sum(cost_platform_fee) cost_platform_fee,sum(cost_product) cost_product,sum(t1.cost_logistics) cost_logistics,sum(profit_total) profit_total from (
select t1.platform_type,t1.bailun_sku_title_cn,t1.bailun_sku,sum(t1.amount_product*t1.bailun_sku_quantity_ordered*t1.seller_order_exchange_rate) as amount_product,count(DISTINCT bailun_order_id) as ordercount,sum(t1.bailun_sku_quantity_ordered) as bailun_sku_quantity_ordered,sum(t1.amount_sales*t1.bailun_sku_quantity_ordered*t1.seller_order_exchange_rate) amount_sales,sum(cost_platform_fee*t1.bailun_sku_quantity_ordered*t1.seller_order_exchange_rate) cost_platform_fee,sum(cost_product*t1.bailun_sku_quantity_ordered) cost_product,sum(t1.cost_logistics*t1.bailun_sku_quantity_ordered) cost_logistics,sum(profit_total*t1.bailun_sku_quantity_ordered) profit_total from dc_base_oms_sku t1
where t1.platform_type='{platform}' and t1.has_delete=0 and t1.company_id=1 and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') and t1.bailun_order_status!='Canceled' and t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle' and t1.paid_time>='{start.ToString("yyyy-MM-dd")}' and t1.paid_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'
where t1.platform_type='{platform}' and t1.has_delete=0 and t1.company_id=1 and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') and t1.bailun_order_status!='Canceled' and t1.platform_type!='FBA' and t1.bailun_order_status!='CantHandle' and t1.paid_time>='{start.ToString("yyyy-MM-dd")}' and t1.paid_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'
group by t1.bailun_sku,t1.platform_type
union all
select t1.platform_type,t1.bailun_sku_title_cn,t1.bailun_sku,sum(t1.amount_product*t1.bailun_sku_quantity_ordered*t1.seller_order_exchange_rate) as amount_product,count(DISTINCT bailun_order_id) as ordercount,sum(t1.bailun_sku_quantity_ordered) as bailun_sku_quantity_ordered,sum(t1.amount_sales*t1.bailun_sku_quantity_ordered*t1.seller_order_exchange_rate) amount_sales,sum(cost_platform_fee*t1.bailun_sku_quantity_ordered*t1.seller_order_exchange_rate) cost_platform_fee,sum(cost_product*t1.bailun_sku_quantity_ordered) cost_product,sum(t1.cost_logistics*t1.bailun_sku_quantity_ordered) cost_logistics,sum(profit_total*t1.bailun_sku_quantity_ordered) profit_total from dc_base_oms_sku t1
where t1.platform_type='{platform}' and t1.has_delete=0 and t1.company_id=1 and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('None','Failed') and t1.bailun_order_status!='Canceled' and t1.platform_type='FBA' and t1.purchase_create_time>='{start.ToString("yyyy-MM-dd")}' and t1.purchase_create_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'
where t1.platform_type='{platform}' and t1.has_delete=0 and t1.company_id=1 and t1.has_scalp=0 and t1.has_innersale=0 and t1.bailun_interception_status in ('','None','Failed') and t1.bailun_order_status!='Canceled' and t1.platform_type='FBA' and t1.purchase_create_time>='{start.ToString("yyyy-MM-dd")}' and t1.purchase_create_time<'{end.AddDays(1).ToString("yyyy-MM-dd")}'