varsql=@"select platform_type,seller_account,website,sum(amount_product*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_first) 'cost_count',sum(cost_shipping) 'nofba_logisticsfee',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first)) 'profit_count',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first))/sum(amount_product*seller_order_exchange_rate) 'profit_rate',sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund from dc_base_oms_order where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.ToString("yyyy-MM-dd")+"' and platform_type='Amazon' and bailun_order_status!='Canceled' ";
varsql=@"select platform_type,seller_account,website,sum(amount_product*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_sales*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund 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='Amazon' and bailun_order_status!='Canceled' ";
if(!string.IsNullOrWhiteSpace(account))
{
...
...
@@ -76,7 +76,7 @@ namespace Bailun.DC.Services
{
varsqlparam=newDynamicParameters();
varsql=@"select sum(amount_product*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_first) 'cost_count',sum(cost_shipping) 'nofba_logisticsfee',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first)) 'profit_count',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first))/sum(amount_product*seller_order_exchange_rate) 'profit_rate',sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund from dc_base_oms_order where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.ToString("yyyy-MM-dd")+"' and platform_type='Amazon' and bailun_order_status!='Canceled' ";
varsql=@"select sum(amount_product*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_sales*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund from dc_base_oms_order 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='Amazon' and bailun_order_status!='Canceled' ";
if(!string.IsNullOrWhiteSpace(account))
{
...
...
@@ -113,7 +113,7 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取亚马逊的销售统计数据(非FBA)
/// 获取亚马逊的销售统计数据(FBA)
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="account">销售帐号</param>
...
...
@@ -127,7 +127,7 @@ namespace Bailun.DC.Services
varsqlparam=newDynamicParameters();
varsql=@"select platform_type,seller_account,website,sum(amount_product*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_first) 'cost_count',sum(cost_shipping) 'nofba_logisticsfee',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first)) 'profit_count',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first))/sum(amount_product*seller_order_exchange_rate) 'profit_rate', order_currency 'currency' from dc_base_oms_order where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.ToString("yyyy-MM-dd")+"' and platform_type='FBA' and bailun_order_status!='Canceled' ";
varsql=@"select platform_type,seller_account,website,sum(amount_product*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 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' ";
if(!string.IsNullOrWhiteSpace(account))
{
...
...
@@ -163,7 +163,7 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取亚马逊的销售统计数据(非FBA) 统计
/// 获取亚马逊的销售统计数据(FBA) 统计
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="account">销售帐号</param>
...
...
@@ -174,7 +174,7 @@ namespace Bailun.DC.Services
{
varsqlparam=newDynamicParameters();
varsql=@"select sum(amount_product*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_first) 'cost_count',sum(cost_shipping) 'nofba_logisticsfee',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first)) 'profit_count',(sum(amount_product*seller_order_exchange_rate)-sum(cost_shipping)-sum(cost_total+cost_first))/sum(amount_product*seller_order_exchange_rate) 'profit_rate', order_currency 'currency' from dc_base_oms_order where paid_time>='"+start.ToString("yyyy-MM-dd")+"' and paid_time<'"+end.ToString("yyyy-MM-dd")+"' and platform_type='FBA' and bailun_order_status!='Canceled' ";
varsql=@"select sum(amount_product*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 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' ";
varsql="select id,platform_type,website,origin_order_id,bailun_order_id,seller_account,order_currency,amount_total,amount_product,amount_shipping,amount_tax,amount_adjustment,amount_gift_wrap,amount_refund,cost_total,cost_promotion,cost_platform_fee,cost_product,cost_shipping,cost_package,cost_fba_fee,cost_paypal_fee,cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_tail,cost_first,profit_total,profit_rate,create_time,paid_time,seller_order_exchange_rate,seller_other_exchange_rate from dc_base_oms_order where bailun_order_status!='Canceled' ";
varsql="select id,platform_type,website,origin_order_id,bailun_order_id,seller_account,order_currency,amount_total,amount_product,amount_shipping,amount_tax,amount_adjustment,amount_gift_wrap,amount_refund,cost_total,cost_promotion,cost_platform_fee,cost_product,cost_shipping,cost_package,cost_fba_fee,cost_paypal_fee,cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_tail,cost_first,profit_total,profit_rate,create_time,paid_time,seller_order_exchange_rate,seller_other_exchange_rate,(seller_order_exchange_rate*amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled' ";
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")+"'";
}
sqlwhere+=" group by t1.seller_account,t1.website,t1.order_currency,t1.platform_type";
if(!string.IsNullOrWhiteSpace(parameter.sort))
{
sqlwhere+=" order by "+parameter.sort+" "+parameter.order;
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")+"'";