varfromsql=" where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and platform_type='Amazon' and bailun_order_status!='Canceled' and has_scalp=0 and has_innersale=0 ";
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 ";
varfromsql=" where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.AddDays(1).ToString("yyyy-MM-dd")+"' and platform_type='Amazon' and bailun_order_status!='Canceled' and has_scalp=0 and has_innersale=0 ";
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 origin_order_id,platform_type,website,seller_account,platform_order_type,bailun_sku,amount_product,cost_first,amount_shipping,cost_promotion,cost_shipping,cost_fba_fee,cost_platform_fee,cost_package,amount_total,cost_total+cost_shipping as cost_total,paid_time,seller_order_exchange_rate,finance_order_exchange_rate from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
varsql="select origin_order_id,platform_type,website,seller_account,platform_order_type,bailun_sku,amount_product,cost_first,amount_shipping,cost_promotion,cost_shipping,cost_fba_fee,cost_platform_fee,cost_package,amount_total,cost_total+cost_shipping as cost_total,paid_time,seller_order_exchange_rate,finance_order_exchange_rate from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
varsql="select sum(amount_product) amount_product,sum(cost_first) cost_first,sum(amount_shipping) amount_shipping,sum(cost_promotion) cost_promotion,sum(cost_shipping) cost_shipping,sum(cost_fba_fee) cost_fba_fee,sum(cost_platform_fee) cost_platform_fee,sum(cost_package) cost_package,sum(amount_total) amount_total,sum(cost_total+cost_shipping) as cost_total from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
varsql="select sum(amount_product) amount_product,sum(cost_first) cost_first,sum(amount_shipping) amount_shipping,sum(cost_promotion) cost_promotion,sum(cost_shipping) cost_shipping,sum(cost_fba_fee) cost_fba_fee,sum(cost_platform_fee) cost_platform_fee,sum(cost_package) cost_package,sum(amount_total) amount_total,sum(cost_total+cost_shipping) as cost_total from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and 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";
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";
if(companyid.HasValue&&companyid.Value>0)
{
strwhere+=" and t1.company_id="+companyid.Value;//增加公司id过滤
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 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 ";
if(companyid.HasValue&&companyid.Value>0)
{
strwhere+=" and company_id="+companyid.Value;//增加公司id过滤
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(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 ";
if(companyid.HasValue&&companyid.Value>0)
{
strwhere+=" and company_id="+companyid.Value;//增加公司id过滤
varsql="select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay',"+(isUSD?"tb.other_to_usd_exchange_rate":"tb.seller_other_exchange_rate")+","+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"))) as cost_platform_fee,sum(cost_first*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") as cost_first,sum(cost_tail*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_tail,sum(cost_handle_bailun*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_bailun,sum(cost_handle_platform*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_platform,sum(amount_refund*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") amount_refund,sum(cost_product*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_product,sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") profit_total,(sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+")/sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+")) profit_rate,count(amount_prepaid>0 or null) as noshippingcount,sum(amount_prepaid*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") amount_prepaid from dc_base_oms_order tb ";
varsql="select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay',"+(isUSD?"tb.other_to_usd_exchange_rate":"tb.seller_other_exchange_rate")+","+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"))) as cost_platform_fee,sum(cost_first*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") as cost_first,sum(cost_tail*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_tail,sum(cost_handle_bailun*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_bailun,sum(cost_handle_platform*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_platform,sum(amount_refund*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") amount_refund,sum(cost_product*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_product,sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") profit_total,(sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+")/sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+")) profit_rate,count(amount_prepaid>0 or null) as noshippingcount,sum(amount_prepaid*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") amount_prepaid from dc_base_oms_order tb ";
varsql="select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay',"+(isUSD?"tb.other_to_usd_exchange_rate":"tb.seller_other_exchange_rate")+","+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"))) as cost_platform_fee,sum(cost_first*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") as cost_first,sum(cost_tail*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_tail,sum(cost_handle_bailun*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_bailun,sum(cost_handle_platform*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_platform,sum(amount_refund*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") amount_refund,sum(cost_product*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_product,sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") profit_total,(sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+")/sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+")) profit_rate,count(amount_prepaid>0 or null) as noshippingcount,sum(amount_prepaid*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") amount_prepaid from dc_base_oms_order tb ";
varsql="select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay',"+(isUSD?"tb.other_to_usd_exchange_rate":"tb.seller_other_exchange_rate")+","+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"))) as cost_platform_fee,sum(cost_first*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") as cost_first,sum(cost_tail*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_tail,sum(cost_handle_bailun*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_bailun,sum(cost_handle_platform*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_handle_platform,sum(amount_refund*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+") amount_refund,sum(cost_product*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") cost_product,sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") profit_total,(sum(profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+")/sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+")) profit_rate,count(amount_prepaid>0 or null) as noshippingcount,sum(amount_prepaid*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+") amount_prepaid from dc_base_oms_order tb ";
sql+=" and shipping_time<'"+shipend.Value.AddDays(1).ToString("yyyy-MM-dd")+"'";
sql+=" and shipping_time<'"+shipend.Value.AddDays(1).ToString("yyyy-MM-dd")+"'";
}
}
//sql += " company_id="+companyid; //按公司区分
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
}
sql+=" group by bailun_order_id ";
sql+=" group by bailun_order_id ";
sql+=" ) t2 on tb.bailun_order_id=t2.bailun_order_id ";
sql+=" ) t2 on tb.bailun_order_id=t2.bailun_order_id ";
sql+=" where tb.bailun_order_status!='Canceled' and tb.has_scalp=0 and tb.bailun_order_status!='CantHandle' and tb.has_scalp=0 and tb.has_innersale=0 ";
sql+=" where tb.bailun_order_status!='Canceled' and tb.has_scalp=0 and tb.bailun_order_status!='CantHandle' and tb.has_scalp=0 and tb.has_innersale=0 ";
//sql += " and tb.company_id=" + companyid; //按公司区分
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and tb.company_id="+companyid.Value;//增加公司id过滤
varprecolumn="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' ";
varprecolumn="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' ";
varsql="select platform_type as platform,website,sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) saleamount,count(bailun_order_id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) platformfee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit,(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) returnamount,(sum(amount_refund)/sum(amount_sales)) returnamountrate,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and bailun_sku_quantity_shipped>0";
varsql="select platform_type as platform,website,sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) saleamount,count(bailun_order_id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) platformfee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit,(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) returnamount,(sum(amount_refund)/sum(amount_sales)) returnamountrate,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and bailun_sku_quantity_shipped>0";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
varsql="select sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) saleamount,count(bailun_order_id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) platformfee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit,(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) returnamount,(sum(amount_refund)/sum(amount_sales)) returnamountrate,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and bailun_sku_quantity_shipped>0";
varsql="select sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) saleamount,count(bailun_order_id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) platformfee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit,(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) returnamount,(sum(amount_refund)/sum(amount_sales)) returnamountrate,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and bailun_sku_quantity_shipped>0";
varprecolumn="select sum(amount_prepaid) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
varprecolumn="select sum(amount_prepaid) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
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 bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
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 bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
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 bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and warehouse_code!='' ";
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 bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 and warehouse_code!='' ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
varfromsql=" where platform_type='Ebay' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0";
varfromsql=" where platform_type='Ebay' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0";
if(companyid.HasValue&&companyid.Value>0)
{
fromsql+=" and company_id="+companyid.Value;//增加公司id过滤
}
if(!string.IsNullOrWhiteSpace(account))
if(!string.IsNullOrWhiteSpace(account))
{
{
fromsql+=" and t1.seller_account=@seller_account";
fromsql+=" and t1.seller_account=@seller_account";
varsqlwhere=" where platform_type='Ebay' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0";
varsqlwhere=" where platform_type='Ebay' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0";
if(companyid.HasValue&&companyid.Value>0)
{
sqlwhere+=" and company_id="+companyid.Value;//增加公司id过滤
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_oms_pick t2 on t1.origin_order_id=t2.origin_order_id "+(!string.IsNullOrEmpty(warehousecode)?" and t2.warehouse_code=@warehousecode":"");
varfromsql=" where platform_type='Ebay' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
varfromsql=" where platform_type='Ebay' and bailun_order_status!='Canceled' and bailun_order_status!='CantHandle' and has_scalp=0 and has_innersale=0 ";
if(companyid.HasValue&&companyid.Value>0)
{
fromsql+=" and company_id="+companyid.Value;//增加公司id过滤
}
if(!string.IsNullOrWhiteSpace(account))
if(!string.IsNullOrWhiteSpace(account))
{
{
fromsql+=" and t1.seller_account=@seller_account";
fromsql+=" and t1.seller_account=@seller_account";
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_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";
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_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";
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_tail) 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";
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_tail) 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";
varsql="select origin_order_id,platform_type,website,order_currency,seller_order_exchange_rate,platform_sku_quantity_ordered,platform_sku_unit_price,item_id,platform_sku from dc_base_oms_platform_sku where has_delete=0 and has_scalp=0 and bailun_order_status!='Canceled' ";
varsql="select origin_order_id,platform_type,website,order_currency,seller_order_exchange_rate,platform_sku_quantity_ordered,platform_sku_unit_price,item_id,platform_sku from dc_base_oms_platform_sku where has_delete=0 and has_scalp=0 and bailun_order_status!='Canceled' ";
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤
}
if(start.HasValue)
if(start.HasValue)
{
{
sql+=" and paid_time>='"+start.Value.ToString("yyyy-MM-dd HH:mm:ss")+"'";
sql+=" and paid_time>='"+start.Value.ToString("yyyy-MM-dd HH:mm:ss")+"'";
varsql="select seller_id,seller_account,sum(profit_total) profit_total from dc_base_oms_order where has_scalp=0 and has_innersale=0 and bailun_order_status!='Canceled'";
varsql="select seller_id,seller_account,sum(profit_total) profit_total from dc_base_oms_order where has_scalp=0 and has_innersale=0 and bailun_order_status!='Canceled'";
varsqlparam=newDynamicParameters();
varsqlparam=newDynamicParameters();
if(companyid.HasValue&&companyid.Value>0)
{
sql+=" and company_id="+companyid.Value;//增加公司id过滤