varsql=$"select account_entry_type,description,bj_date,gross_amount,item_id,account_id,currency,exchange_rate,company_id from dc_base_finance_ebay where bj_date>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and bj_date<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and account_entry_type in ('{string.Join("','",feetype)}') ";
varsql="select t1.id,t1.account_entry_type,t1.description,t1.gmt_date,t1.gross_amount,t1.item_id,t1.net_amount,t1.vat_percent,t1.order_line_id,t1.currency,t1.exchange_rate,(t1.exchange_rate*t1.gross_amount) gross_amount_rmb,t2.account_name from dc_base_finance_ebay t1 ";
varsql="select t1.id,t1.account_entry_type,t1.description,t1.bj_date as gmt_date,t1.gross_amount,t1.item_id,t1.net_amount,t1.vat_percent,t1.order_line_id,t1.currency,t1.exchange_rate,(t1.exchange_rate*t1.gross_amount) gross_amount_rmb,t2.account_name from dc_base_finance_ebay t1 ";
sql+=" left join dc_base_company_account t2 on t1.company_id=t2.company_id and t1.account_id=t2.account_id ";
varsql="select t1.warehouse_code,t1.warehouse_name,t1.usable_stock,t1.usable_stock_amount,t1.quantity_purchase,t1.quantity_purchase_amount,t1.quantity_transfer,t1.quantity_transfer_amount,t1.yd_sales_amount,t1.yd_sales_count,t1.yd_sales_stockamount,t1.yd_grossprofit,t1.yd_grossprofit_rate,t1.pre30_sales_amount,t1.pre30_sales_count,t1.pre30_stockamount,t1.pre30_grossprofit,t1.pre30_grossprofit_rate,t1.pre30_return_rate,t1.pre30_stockamount_turn_rate,t1.pre30_stockamount_add,t1.pre30_stockamount__rate,t1.pre30_stocknum_turn_rate,t1.pre30_stock_add_count,t1.pre30_stocknum_rate,t1.pre30_stockamount_vendibility_day,t1.pre30_stocknum_vendibility_day,t1.bailun_sku,t1.category_name from dc_mid_sku_profit t1 where 1=1 ";
left join dc_mid_transit t4 on t.bailun_sku=t4.bailun_sku and t.warehouse_code=t4.warehouse_code"
,null,null,true,5*60);
//前一天销量
varlist1day=cn.Query<Models.mSkuWarehouse>($@"select t1.bailun_sku,t1.warehouse_code,sum(t1.bailun_sku_quantity_ordered) count,sum(t1.profit_total) profit_total from dc_base_oms_sku t1
varlist1day=cn.Query<Models.mSkuWarehouse>($@"select t.*,t2.unit_price,t2.category_id,t2.category_name,t3.usable_stock,t4.quantity_purchase,t4.quantity_transfer,t2.sku_title_cn from
(select t1.bailun_sku,t1.warehouse_code,t1.warehouse_name,sum(t1.bailun_sku_quantity_ordered) count,sum(t1.amount_sales*t1.bailun_sku_quantity_shipped*t1.seller_order_exchange_rate) amount,sum(t1.profit_total) profit_total from dc_base_oms_sku t1
where t1.bailun_order_status!='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.has_cancle=0 and t1.paid_time>='{end.AddDays(-1).ToString("yyyy-MM-dd")}' and paid_time<'{end.ToString("yyyy-MM-dd")}' and t1.warehouse_code!='' and t1.company_id=1
group by t1.bailun_sku,t1.warehouse_code",null,null,true,5*60);
group by t1.bailun_sku,t1.warehouse_code) t
left join dc_base_sku t2 on t.bailun_sku=t2.bailun_sku
left join dc_base_stock t3 on t.bailun_sku=t3.bailun_sku and t.warehouse_code=t3.warehouse_code
left join dc_mid_transit t4 on t.bailun_sku=t4.bailun_sku and t.warehouse_code=t4.warehouse_code"
,null,null,true,5*60);
//采购入库
varlistPurchasePutin=cn.Query<Models.mPutIn>($@"select bailun_sku,warehouse_code,sum(count) count from dc_base_purchase_inbound where update_time>='{start.ToString("yyyy-MM-dd")}'and update_time<'{end.ToString("yyyy-MM-dd")}' and status=1 and bailun_sku in ('{string.Join("','",list30day.Select(a=>a.bailun_sku).Distinct())}')
group by bailun_sku,warehouse_code",null,null,true,5*60);