varsql=$"select {str_statistic_col},count(distinct tb.bailun_order_id) order_count,sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"* tb.bailun_sku_quantity_ordered) as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay',"+(isUSD?"tb.other_to_usd_exchange_rate":"tb.seller_other_exchange_rate")+","+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"))*tb.bailun_sku_quantity_ordered) as cost_platform_fee,sum(tb.cost_first*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) as cost_first,sum(tb.cost_logistics*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_tail,sum(tb.cost_handle_bailun*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_handle_bailun,sum(tb.cost_handle_platform*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_handle_platform,sum(tb.amount_refund*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) amount_refund,sum(tb.cost_fba_fee*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) cost_fba_fee,sum(tb.cost_paypal_fee*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) cost_paypal_fee,sum(tb.amount_shipping*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) amount_shipping,sum(tb.cost_promotion*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) cost_promotion,sum(tb.cost_product*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_product,sum(tb.profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) profit_total,(sum(tb.profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+")/sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+")) profit_rate,count(distinct (case when (tb.amount_prepaid>0 and tb.bailun_order_status!='Finished') then tb.bailun_order_id else null end)) as noshippingcount,sum(tb.amount_prepaid*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) amount_prepaid from dc_base_oms_sku tb ";
varsql=$"select {str_statistic_col},count(distinct tb.bailun_order_id) order_count,sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"* tb.bailun_sku_quantity_ordered) as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay',"+(isUSD?"tb.other_to_usd_exchange_rate":"tb.seller_other_exchange_rate")+","+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"))*tb.bailun_sku_quantity_ordered) as cost_platform_fee,sum(tb.cost_first*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) as cost_first,sum(tb.cost_logistics*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_tail,sum(tb.cost_handle_bailun*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_handle_bailun,sum(tb.cost_handle_platform*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_handle_platform,sum(tb.amount_refund*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) amount_refund,sum(tb.cost_fba_fee*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) cost_fba_fee,sum(tb.cost_paypal_fee*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) cost_paypal_fee,sum(tb.amount_shipping*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) amount_shipping,sum(tb.cost_promotion*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+"*tb.bailun_sku_quantity_ordered) cost_promotion,sum(tb.cost_product*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) cost_product,sum(tb.profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) profit_total,(sum(tb.profit_total*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+")/sum(tb.amount_sales*"+(isUSD?"tb.order_to_usd_exchange_rate":"tb.seller_order_exchange_rate")+")) profit_rate,count(distinct (case when (tb.amount_prepaid>0 and tb.bailun_order_status!='Finished') then tb.bailun_order_id else null end)) as noshippingcount,sum(tb.amount_prepaid*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) amount_prepaid,sum(tb.amount_adjustment*"+(isUSD?"tb.cny_to_usd_exchange_rate":"1")+"*tb.bailun_sku_quantity_ordered) amount_adjustment from dc_base_oms_sku tb ";
varsql=$@"select {str_statistic_col},count(DISTINCT t2.bailun_order_id) order_count,sum(t2.amount_sales*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) as amount_sales,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay',"+(isUSD?"t2.other_to_usd_exchange_rate":"t2.seller_other_exchange_rate")+","+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_first*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) as cost_first,sum(t2.cost_logistics*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_tail,sum(t2.cost_handle_bailun*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_handle_bailun,sum(t2.cost_handle_platform*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_handle_platform,sum(t2.amount_refund*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) amount_refund,sum(t2.cost_product*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_product,sum(t2.profit_total*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) profit_total,(sum(t2.profit_total*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped)/sum(t2.amount_sales*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped)) profit_rate,count(distinct (case when (t2.amount_prepaid>0 and t2.bailun_order_status!='Finished') then t2.bailun_order_id else null end)) as noshippingcount,sum(t2.amount_prepaid*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) amount_prepaid,sum(t2.cost_fba_fee*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) cost_fba_fee,sum(t2.cost_paypal_fee*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) cost_paypal_fee,sum(t2.amount_shipping*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) amount_shipping,sum(t2.cost_promotion*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) cost_promotion from (select t0.id,t0.bailun_order_id,t0.quantity_shipped,t0.bailun_sku from dc_base_oms_pick t0 ";
varsql=$@"select {str_statistic_col},count(DISTINCT t2.bailun_order_id) order_count,sum(t2.amount_sales*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) as amount_sales,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay',"+(isUSD?"t2.other_to_usd_exchange_rate":"t2.seller_other_exchange_rate")+","+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_first*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) as cost_first,sum(t2.cost_logistics*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_tail,sum(t2.cost_handle_bailun*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_handle_bailun,sum(t2.cost_handle_platform*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_handle_platform,sum(t2.amount_refund*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) amount_refund,sum(t2.cost_product*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) cost_product,sum(t2.profit_total*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) profit_total,(sum(t2.profit_total*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped)/sum(t2.amount_sales*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped)) profit_rate,count(distinct (case when (t2.amount_prepaid>0 and t2.bailun_order_status!='Finished') then t2.bailun_order_id else null end)) as noshippingcount,sum(t2.amount_prepaid*"+(isUSD?"t2.cny_to_usd_exchange_rate":"1")+"*t1.quantity_shipped) amount_prepaid,sum(t2.cost_fba_fee*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) cost_fba_fee,sum(t2.cost_paypal_fee*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) cost_paypal_fee,sum(t2.amount_shipping*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) amount_shipping,sum(t2.cost_promotion*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) cost_promotion,sum(t2.amount_adjustment*"+(isUSD?"t2.order_to_usd_exchange_rate":"t2.seller_order_exchange_rate")+"*t1.quantity_shipped) amount_adjustment from (select t0.id,t0.bailun_order_id,t0.quantity_shipped,t0.bailun_sku from dc_base_oms_pick t0 ";