sql=$@"select sum(t2.amount_sales*t1.quantity_shipped*t2.seller_order_exchange_rate) as amount_sales,sum(t2.cost_product*t1.quantity_shipped) as cost_product,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay',t2.seller_other_exchange_rate,t2.seller_order_exchange_rate))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_paypal_fee*t2.seller_order_exchange_rate*t1.quantity_shipped) as cost_paypal_fee,sum(t2.cost_first*t1.quantity_shipped) as cost_first,sum(t2.cost_logistics*t1.quantity_shipped) as cost_logistics,sum(t2.cost_handle_platform*t1.quantity_shipped) as cost_handle_platform,if(t6.financecategoryname is null,'',t6.financecategoryname) as financecategoryname,((t2.total_fee-t2.shipping)*t2.wms_to_cny_exchange_rate*t1.quantity_shipped) as total_fee from dc_base_oms_pick t1
//自发货订单明细
join dc_base_oms_sku t2 on t1.bailun_order_id = t2.bailun_order_id and t1.bailun_sku=t2.bailun_sku and t2.bailun_order_status != 'Canceled' and t2.has_scalp = 0 and ((t2.platform_type!='FBA' and t2.bailun_order_status!='CantHandle') or t2.platform_type='FBA') and t2.has_scalp = 0 and t2.has_innersale = 0 and t2.has_delete=0 and t2.company_id=1
sql=$@"select sum(amount_sales*quantity_shipped*seller_order_exchange_rate) as amount_sales,sum(cost_product*quantity_shipped) as cost_product,sum(cost_platform_fee*(if(platform_type='Ebay',seller_other_exchange_rate,seller_order_exchange_rate))*quantity_shipped) as cost_platform_fee,sum(cost_paypal_fee*seller_order_exchange_rate*quantity_shipped) as cost_paypal_fee,sum(cost_first*quantity_shipped) as cost_first,sum(cost_logistics*quantity_shipped) as cost_logistics,sum(cost_handle_platform*quantity_shipped) as cost_handle_platform,if(financecategoryname is null,'',financecategoryname) as financecategoryname,((total_fee-shipping)*wms_to_cny_exchange_rate*quantity_shipped) as total_fee from dc_month_sales_profit_orderdetail where month='{day.ToString("yyyy-MM")}' and platform_type!='FBA' group by financecategoryname";
left join dc_base_sku t5 on t2.bailun_sku=t5.bailun_sku
left join dc_base_sku_finance_category t6 on t6.bailuncategoryid=t5.bailun_category_id
where t1.has_delete=0 and t1.shipping_status = 'TotalShipping' and t1.company_id=1 and t1.shipping_time>='{day.ToString("yyyy-MM-dd")}' and t1.shipping_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'
sql=$@"select sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_ordered) as amount_sales,sum(cost_product*bailun_sku_quantity_ordered) as cost_product,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_ordered) as cost_platform_fee,sum(cost_first*bailun_sku_quantity_ordered) as cost_first,sum(cost_logistics*bailun_sku_quantity_ordered) as cost_logistics,sum(cost_fba_fee*seller_order_exchange_rate*bailun_sku_quantity_ordered) cost_fba_fee,if(t6.financecategoryname is null,'',t6.financecategoryname) as financecategoryname from dc_base_oms_sku tb left join dc_base_sku t5 on tb.bailun_sku=t5.bailun_sku
//FBA订单明细
left join dc_base_sku_finance_category t6 on t6.bailuncategoryid=t5.bailun_category_id
sql=$@"select sum(amount_sales*quantity_shipped*seller_order_exchange_rate) as amount_sales,sum(cost_product*quantity_shipped) as cost_product,sum(cost_platform_fee*(if(platform_type='Ebay',seller_other_exchange_rate,seller_order_exchange_rate))*quantity_shipped) as cost_platform_fee,sum(cost_paypal_fee*seller_order_exchange_rate*quantity_shipped) as cost_paypal_fee,sum(cost_first*quantity_shipped) as cost_first,sum(cost_logistics*quantity_shipped) as cost_logistics,sum(cost_handle_platform*quantity_shipped) as cost_handle_platform,if(financecategoryname is null,'',financecategoryname) as financecategoryname,((total_fee-shipping)*wms_to_cny_exchange_rate*quantity_shipped) as total_fee from dc_month_sales_profit_orderdetail where month='{day.ToString("yyyy-MM")}' and platform_type='FBA' group by financecategoryname";
where tb.company_id=1 and tb.bailun_order_status!='Canceled' and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') and tb.platform_type='FBA' and tb.purchase_create_time>='{day.ToString("yyyy-MM-dd")}' and tb.purchase_create_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'
sql=$@"select sum(t1.amount_refund_rmb) from dc_base_crm_refund t1 where t1.shipping_status in ('TotalShipping','PartShipping') and t1.is_deleted=0 and is_freeze=0 and t1.company_id=1 and t1.refund_time>='{day.ToString("yyyy-MM-dd")}' and t1.refund_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}' and t1.shipping_status!='UnShipping'";
sql=$@"select sum(t1.amount_refund_rmb) from dc_base_crm_refund t1 where t1.shipping_status in ('TotalShipping','PartShipping') and t1.is_deleted=0 and is_freeze=0 and t1.company_id=1 and t1.refund_time>='{day.ToString("yyyy-MM-dd")}' and t1.refund_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}' and t1.shipping_status!='UnShipping'";
...
@@ -636,7 +630,7 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
...
@@ -636,7 +630,7 @@ join dc_base_warehouse t3 on t1.warehouse_code=t3.warehouse_code
varcheckSaved=cn.QueryFirstOrDefault<dc_month_sales_profit>("select * from dc_month_sales_profit where isedit=0 and month='"+day.ToString("yyyy-MM")+"'");
if(checkSaved!=null)
{
return;
}
varsql=$@"select t1.id as pickid,t2.id as orderskuid,t2.bailun_sku,t2.amount_sales,t2.cost_product,t2.cost_platform_fee,t2.cost_paypal_fee,t2.cost_first,t2.cost_logistics,t2.cost_handle_platform,t2.total_fee,t2.seller_order_exchange_rate,t2.seller_other_exchange_rate,t2.wms_to_cny_exchange_rate,t2.shipping,t1.quantity_shipped,t1.shipping_time,t2.platform_type,t2.cost_fba_fee,if(t6.financecategoryname is null,'',t6.financecategoryname) as financecategoryname
from dc_base_oms_pick t1
join dc_base_oms_sku t2 on t1.bailun_order_id = t2.bailun_order_id and t1.bailun_sku=t2.bailun_sku and t2.bailun_order_status != 'Canceled' and t2.has_scalp = 0 and ((t2.platform_type!='FBA' and t2.bailun_order_status!='CantHandle') or t2.platform_type='FBA') and t2.has_scalp = 0 and t2.has_innersale = 0 and t2.has_delete=0 and t2.company_id=1
left join dc_base_sku t5 on t2.bailun_sku=t5.bailun_sku
left join dc_base_sku_finance_category t6 on t6.bailuncategoryid=t5.bailun_category_id
where t1.has_delete=0 and t1.shipping_status = 'TotalShipping' and t1.company_id=1 and t1.shipping_time>='{day.ToString("yyyy-MM-dd")}' and t1.shipping_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'
sql=$@"select 0 as pickid,tb.id as orderskuid,tb.bailun_sku,tb.amount_sales,tb.cost_product,tb.cost_platform_fee,tb.cost_paypal_fee,tb.cost_first,tb.cost_logistics,tb.cost_handle_platform,tb.total_fee,tb.seller_order_exchange_rate,tb.seller_other_exchange_rate,tb.wms_to_cny_exchange_rate,tb.shipping,tb.bailun_sku_quantity_ordered as quantity_shipped,tb.purchase_create_time as shipping_time,tb.platform_type,tb.cost_fba_fee,if(t6.financecategoryname is null,'',t6.financecategoryname) as financecategoryname
from dc_base_oms_sku tb left join dc_base_sku t5 on tb.bailun_sku=t5.bailun_sku
left join dc_base_sku_finance_category t6 on t6.bailuncategoryid=t5.bailun_category_id
where tb.company_id=1 and tb.bailun_order_status!='Canceled' and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') and tb.platform_type='FBA' and tb.purchase_create_time>='{day.ToString("yyyy-MM-dd")}' and tb.purchase_create_time<'{day.AddMonths(1).ToString("yyyy-MM-dd")}'