Commit ae505222 authored by edz's avatar edz

push channel_pay_7_30.zip

parent ef4016f8
channel_pay_7_30=新增用户支付数据-分渠道
#step1_1.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online tl_hdfs_ios_idfa_tmp
\ No newline at end of file
#step1_2.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_device_day_active_status
\ No newline at end of file
#step1_3.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_trade_order_detail_day
#step2.job
type=command
dependencies=step1_1,step1_2,step1_3
command=curl -X GET http://localhost:8553/api/report/email/channel_pay_7_30/hanyingyue@igengmei.com/weiyimin@igengmei.com
\ No newline at end of file
--新增用户支付分渠道数据
SELECT partition_date as `日期`
,device_os_type as `设备`
,channel as `渠道`
,sum(order_num_7)`7天内支付订单量`
,sum(order_num_30)`30天内支付订单量`
-- ,sum(order_num_90)`90天内支付订单量`
-- ,sum(dev_num_30)`30天内支付设备数(设备数当天去重,按月加总时不去重)`
-- ,sum(dev_num_60)`60天内支付设备数(设备数当天去重,按月加总时不去重)`
-- ,sum(dev_num_90)`90天内支付设备数(设备数当天去重,按月加总时不去重)`
,sum(gmv_7)`7天内支付订单额`
,sum(gmv_30)`30天内支付订单额`
-- ,sum(gmv_90)`90天内支付订单额`
FROM
(
SELECT mas.partition_date,device_os_type,channel
,nvl(sum(case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,7) then order_num end),0) as order_num_7
,nvl(sum(case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,30) then order_num end),0) as order_num_30
,nvl(sum(case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,90) then order_num end),0) as order_num_90
,nvl(count(distinct case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,7) then a.device_id end),0) as dev_num_7
,nvl(count(distinct case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,30) then a.device_id end),0) as dev_num_30
,nvl(count(distinct case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,90) then a.device_id end),0) as dev_num_90
,nvl(sum(case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,7) then service_price end),0) as gmv_7
,nvl(sum(case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,30) then service_price end),0) as gmv_30
,nvl(sum(case when a.pay_date>=mas.partition_date and a.pay_date<=date_add(mas.partition_date,90) then service_price end),0) as gmv_90
FROM
(
SELECT concat_ws('-',substr(partition_date,1,4),substr(partition_date,5,2),substr(partition_date,7,2)) as partition_date
,a.device_id,device_os_type
,case when ios_device.idfa is not null then ios_device.channel else a.first_channel_source_type END as channel
FROM
(
select partition_date,device_id,device_os_type
,first_channel_source_type
from online.ml_device_day_active_status
where partition_date>=regexp_replace(date_sub(current_date(),30),'-','')
AND partition_date<= regexp_replace(date_sub(current_date(),1),'-','')
and active_type in ('1','2')
)a
LEFT JOIN
(
SELECT channel,idfa
FROM
(
SELECT channel,idfa,row_number () over (PARTITION BY idfa ORDER BY active_time asc) rn--,substr(active_time,1,7) as new_month
FROM online.tl_hdfs_ios_idfa_tmp --设备表,区分App Store 明细渠道名字
)a
WHERE rn = 1
)ios_device
on ios_device.idfa=a.device_id
)mas
left join
(
SELECT device_id,SUBSTR(pay_date,1,10) as pay_date
,count(distinct order_id) as order_num
,sum(service_price) as service_price
FROM online.ml_trade_order_detail_day
WHERE PARTITION_DATE = regexp_replace(date_sub(current_date(),1),'-','')
and is_pure_user='true'
AND regexp_replace(SUBSTR(pay_date,1,10),'-','') >=regexp_replace(date_sub(current_date(),30),'-','')
AND regexp_replace(SUBSTR(pay_date,1,10),'-','')<=REGEXP_REPLACE(date_sub(current_date(),1),'-','')
group by device_id,SUBSTR(pay_date,1,10)
)a
on mas.device_id=a.device_id
group by mas.partition_date,device_os_type,channel
)t
group by partition_date
,device_os_type
,channel
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment