varsql=$"select t1.platform_type,{(isUSD?"sum(t1.amount_refund_usd)":"sum(t1.amount_refund_rmb)")} as amount_refund from dc_base_crm_refund t1 join dc_base_oms_order t2 on t1.origin_order_id=t2.origin_order_id and t2.bailun_order_status!='Canceled' and t1.bailun_account_id and t2.bailun_account_id ";
varsql=$"select t1.platform_type,{(isUSD?"sum(t1.amount_refund_usd)":"sum(t1.amount_refund_rmb)")} as amount_refund from dc_base_crm_refund t1 where t1.order_status!='Canceled' and t1.is_deleted=0 and is_freeze=0 ";
varsql1=$" union all select t1.platform_type,{(isUSD?"sum(t1.amount_refund_usd)":"sum(t1.amount_refund_rmb)")} as amount_refund from dc_base_crm_refund t1 join dc_base_oms_order t2 on t1.origin_order_id=t2.transaction_id and t2.bailun_order_status!='Canceled' and t1.bailun_account_id and t2.bailun_account_id ";
sql+=" where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type!='Ebay' ";
sql1+=" where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type='Ebay' ";
//合并订单的退款数据 非Ebay
varsql01=$@" union all select t01.platform_type,{(isUSD?"sum(t01.amount_refund_usd)":"sum(t01.amount_refund_rmb)")} as amount_refund from (
select t1.amount_refund_rmb,t1.amount_refund_usd,t1.platform_type,t2.aftermerged_bailun_order_no from dc_base_crm_refund t1
join dc_base_oms_order t2 on t1.origin_order_id=t2.origin_order_id and t2.aftermerged_bailun_order_no != '' and t1.bailun_account_id and t2.bailun_account_id
where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type!='Ebay' ";
//合并订单的退款数据 Ebay
varsql02=$@" union all select t01.platform_type,{(isUSD?"sum(t01.amount_refund_usd)":"sum(t01.amount_refund_rmb)")} as amount_refund from (
select t1.amount_refund_rmb,t1.amount_refund_usd,t1.platform_type,t2.aftermerged_bailun_order_no from dc_base_crm_refund t1
join dc_base_oms_order t2 on t1.origin_order_id=t2.transaction_id and t2.aftermerged_bailun_order_no !='' and t1.bailun_account_id and t2.bailun_account_id
where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type='Ebay' ";