-
Notifications
You must be signed in to change notification settings - Fork 418
Description
接口内容:
return db.dw_all.page("""
select
zz.mer_no as mer_no,
zz.mer_name as mer_name,
zz.fee_succ_time as billing_date,
round(sum(zz.trans_amt),2) as sum_trans_amt,
round(sum(zz.fee_amt),2) as sum_fee
from
(
select
t1.org_id as mer_no,
t4.purchname as mer_name,
sum(ifnull(t1.shouldxlfee,0) + ifnull(t1.shouldsettleamt,0) + ifnull(t1.shoulddlfee,0) ) as trans_amt ,
sum(ifnull(t3.fee_service_real, 0)) as fee_amt ,
substr(t5.pay_time,1,10) as fee_succ_time
from
(
select a.settle_day, a.org_id, sum( case when a.splitter_type = 1 then a.splitter_amount else 0.0 end ) shouldxlfee,
sum( case when a.splitter_type = 8 then a.splitter_amount else 0.0 end ) shouldsettleamt,
sum( case when a.splitter_type = 10 then a.splitter_amount else 0.0 end ) shoulddlfee
from
ods_prepaid_card_xlkkernel_splittingdetail a
where org_id in (${mer_nos})
group by
a.settle_day,
a.org_id
) t1
left join ods_prepaid_card_xlkkernel_settledetailmerchant t3 on t3.settle_day = t1.settle_day
and t3.org_id = t1.org_id
left join
(select purchaseid,purchname,
row_number() over(partition by purchaseid order by primary_id desc) as rn
from ods_prepaid_card_xlkkernel_settleproperty where nature = 1 ) t4
on
t4.purchaseid = t1.org_id
and
t4.rn=1
left join (select * ,
row_number() over(partition by purchaseid,settle_day order by primary_id desc) as rn
from ods_prepaid_card_xlkkernel_merchant_paylist where
DATE_FORMAT(pay_time, '%Y-%m-%d') >= ${fee_succ_time_min}
and
DATE_FORMAT(pay_time, '%Y-%m-%d') <= ${fee_succ_time_max} ) t5
on
t5.purchaseid = t1.org_id
and t5.settle_day = t1.settle_day
and t5.rn = 1
where
t5.settle_status = 3
and t5.pay_time is not null
group by t1.org_id,t4.purchname,substr(t5.pay_time,1,10)
)zz
group by zz.mer_no,zz.mer_name,zz.fee_succ_time
order by zz.mer_no,zz.mer_name,zz.fee_succ_time
""")