sqlpay=$"select sum(cashier_paymoneyrmb) cashier_paymoneyrmb from dc_base_finance_cashier where cashier_type=1 and cashier_status=1 and sourcecode in ('newCost','oldbuy') and type_name='销售费用/物流费' and cashier_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and cashier_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'";
sqlsales=$"select sum(cost_first*bailun_sku_quantity_ordered) as cost_first from dc_base_oms_sku where paid_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and paid_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and bailun_order_status!='Canceled' and cost_first>0 and has_scalp=0 and has_delete=0 and has_innersale=0 and company_id=1";
sqlhappen=$@"select sum(t2.cost_tail*t1.quantity_shipped) from dc_base_oms_pick t1
join dc_base_oms_sku t2 on t1.bailun_sku = t2.bailun_sku and t1.origin_order_id = t2.origin_order_id and t2.bailun_order_status != 'Canceled' and t2.has_scalp = 0 and t2.has_delete = 0 and t2.has_innersale = 0 and t2.company_id = 1 and t2.cost_tail > 0
where t1.shipping_time >= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t1.shipping_time < '{end.ToString("yyyy-MM-dd HH:mm:ss")}' and t1.has_delete = 0 and t1.company_id = 1 and t1.shipping_status = 'TotalShipping'";
sqlsales=$"select sum(cost_logistics*bailun_sku_quantity_ordered) from dc_base_oms_sku t1 where paid_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and paid_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and bailun_order_status!='Canceled' and has_scalp=0 and has_delete=0 and has_innersale=0 and company_id=1 and cost_logistics>0";
sqlpay=$"select sum(cashier_paymoneyrmb) cashier_paymoneyrmb from dc_base_finance_cashier where cashier_type=1 and cashier_status=1 and sourcecode ='Buy' and cashier_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and cashier_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'";
varsql=$@"select t1.id,t2.warehouse_code,((((t1.amount_product-t1.cost_platform_fee)*t1.seller_order_exchange_rate)-t1.cost_logistics-t1.cost_handle_bailun)*t2.quantity_shipped) as productvalue, t1.platform_type,t1.seller_account,t1.bailun_account_id,t1.website,t1.bailun_order_id,t1.origin_order_id,t1.transaction_id,t1.paid_time,t1.gmt_modified,t1.bailun_sku,(t1.amount_sales*t1.seller_order_exchange_rate*t2.quantity_shipped) amount_sales,(t1.profit_total*t2.quantity_shipped) profit_total,t2.quantity_shipped as platform_sku_quantity_shipped,t1.company_id,t2.pick_order_id,t2.shipping_time,t2.has_delete
varstr="";
from dc_base_oms_sku t1
join dc_base_oms_pick t2 on t1.bailun_order_id = t2.bailun_order_id and t1.bailun_sku = t2.bailun_sku and t2.gmt_modified >= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t2.gmt_modified < '{end.ToString("yyyy-MM-dd HH:mm:ss")}' and t2.shipping_status = 'TotalShipping' and t2.company_id = 1
where t1.bailun_order_status != 'Canceled' and t1.has_scalp = 0 and t1.bailun_order_status != 'CantHandle' and t1.has_scalp = 0 and t1.has_innersale = 0 and t1.company_id = 1 and t1.has_delete = 0 ";
if(!string.IsNullOrEmpty(orderno))
if(!string.IsNullOrEmpty(orderno))
{
{
sql+=" and t1.bailun_order_id=@orderno";
str+=$" and t2.bailun_order_id='{orderno}'";
sqlparam.Add("orderno",orderno);
}
}
varsql=$@"select t1.id,t2.warehouse_code,((((t1.amount_product-t1.cost_platform_fee)*t1.seller_order_exchange_rate)-t1.cost_logistics-t1.cost_handle_bailun)*t2.quantity_shipped) as productvalue, t1.platform_type,t1.seller_account,t1.bailun_account_id,t1.website,t1.bailun_order_id,t1.origin_order_id,t1.transaction_id,t1.paid_time,t1.gmt_modified,t1.bailun_sku,(t1.amount_sales*t1.seller_order_exchange_rate*t2.quantity_shipped) amount_sales,(t1.profit_total*t2.quantity_shipped) profit_total,t2.quantity_shipped as platform_sku_quantity_shipped,t1.company_id,t2.pick_order_id,t2.shipping_time,t2.has_delete from
(select t2.origin_order_id,t2.bailun_sku,t2.quantity_shipped,t2.warehouse_code,t2.shipping_time,t2.has_delete,t2.pick_order_id from dc_base_oms_pick t2 where t2.gmt_modified>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t2.gmt_modified<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and t2.shipping_status='TotalShipping' and t2.company_id=1 {str}{" limit "+(page-1)*pagesize+","+pagesize}) t2
left join dc_base_oms_sku t1 on t1.origin_order_id=t2.origin_order_id and t1.bailun_sku=t2.bailun_sku and t1.has_delete = 0";