varsql="select platform_type as platform,website,sum(amount_total*seller_order_exchange_rate) saleamount,count(id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate) platformfee,(sum(amount_total*seller_order_exchange_rate)/count(id)) customerprice,sum(profit_total) profit,(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate) returnamount,(sum(amount_refund*seller_order_exchange_rate)/sum(amount_total*seller_order_exchange_rate)) returnamountrate,sum(cost_first) cost_first,sum(cost_tail) cost_tail,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'";
varprecolumn="select website,platform_type as platform,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' ";
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_sku_quantity_shipped>0";
precolumn+=" and website in ('"+string.Join("','",list.Select(a=>a.website))+"') and platform_type in ('"+string.Join("','",list.Select(a=>a.platform).Distinct())+"')";
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,(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_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";
sql+=" join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
presql+=" join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id "+(!string.IsNullOrEmpty(warehousecode)?" and t2.warehouse_code=@warehousecode":"");
presql+=" join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
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":"");
sql+=" join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
sql+=" join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
presql+=" join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id "+(!string.IsNullOrEmpty(warehousecode)?" and t2.warehouse_code=@warehousecode":"");
presql+=" join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";