---通讯助手扣费
execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_txzs_kf'')' into vv_datacnt;
if ( vv_datacnt >0 ) then
execute immediate 'drop table ZJ201101300006_txzs_kf purge';
end if;
execute immediate '
create table ZJ201101300006_txzs_kf
nologging as
select /*+ parallel(a, 20) */
subno
,b_subno_trunk
,CALL_Date
,CALL_time
,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,
msrn
from DGDM_DW.TB_DW_LS_CDR_sms_day a
where b_subno_trunk = ''1065869506''
and deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'') --上月1日
and deal_date < to_date('''||vv_date_now||'03'',''yyyymmdd'') --当月3日
and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)
and CALL_Date >= '''||vv_date_pre4||'01'' --上月1日
and call_date < '''||vv_date_now4||'01'' --本月1日
'
;
/*
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
set colsep |
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
set feedback on
*/
/*
spool ZJ201101300006_txzs_kf201102.txt
select SUBNO||'|'||round(sum(AFTER_MOB_FEE_0+AFTER_TOLL_FEE_0+AFTER_INF_FEE_0)/100,2)||'|' from ZJ201101300006_txzs_kf
group by subno;
spool off;
exit
*/
---天气预报月租扣费
execute immediate 'select count(1) from user_tables where table_name = upper('''||'ZJ201101300004_121_bi'||vv_date_pre||''')' into vv_datacnt;
if ( vv_datacnt >0 ) then
execute immediate 'drop table ZJ201101300004_121_bi'||vv_date_pre||' purge';
end if;
execute immediate '
create table ZJ201101300004_121_bi'||vv_date_pre||'
nologging as
select /*+ parallel(a,16) */
a.subno,
case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0
,msrn,
imsi
from DGDM_DW.TB_DW_LS_CDR_sms_day a
where a.bus_type = ''52''
and a.subbus_type=''15''
and a.deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')
and a.deal_date <= to_date('''||vv_date_now||'03'',''yyyymmdd'')
and a.CALL_Date >= '''||vv_date_pre4||'01''
and a.CALL_Date < '''||vv_date_now4||'01''
'
;
---导出
/*
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
set colsep |
set feedback on
et colsep |
alter session set nls_date_format='yyyy-mm-dd';
spool ZJ201101300004_121_bi201102.txt
select subno||'|'||
round(sum(nvl(AFTER_MOB_FEE_0,0)+nvl(AFTER_TOLL_FEE_0,0)+nvl(AFTER_INF_FEE_0,0)),2)/100||'|'||
msrn||'|'
from ZJ201101300004_121_bi201102
group by subno,msrn;
spool off;
*/
---短信回执
execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_dxhz_kf'')' into vv_datacnt;
if ( vv_datacnt >0 ) then
execute immediate 'drop table ZJ201101300006_dxhz_kf purge';
end if;
execute immediate '
create table ZJ201101300006_dxhz_kf
nologging as
select /*+ parallel(a,20)*/
subno
,b_subno_trunk
,CALL_Date
,CALL_time
,case when ROLLBACK_FLAG=''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when ROLLBACK_FLAG=''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when ROLLBACK_FLAG=''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,
msrn
from DGDM_DW.TB_DW_LS_CDR_sms_day a
where b_subno_trunk = ''10658689''
and deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')
and deal_date < to_date('''||vv_date_now||'03'',''yyyymmdd'')
and (AFTER_MOB_FEE <> 0 or AFTER_TOLL_FEE <> 0 or AFTER_INF_FEE <> 0)
and a.CALL_Date >= '''||vv_date_pre4||'01''
and a.CALL_Date < '''||vv_date_now4||'01''
'
;
/*
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
set colsep |
set feedback on
et colsep |
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
spool ZJ201101300006_dxhz_kf.txt
select a.subno||'|'||
a.msrn||'|'||
a.b_subno_trunk||'|'||
((a.AFTER_MOB_FEE_0+a.AFTER_TOLL_FEE_0+a.AFTER_INF_FEE_0))/100||'|'
from ZJ201101300006_dxhz_kf a
where 1=1;
spool off;
*/
--来电提醒扣费
execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_ldtx_kf'')' into vv_datacnt;
if ( vv_datacnt >0 ) then
execute immediate 'drop table ZJ201101300006_ldtx_kf purge';
end if;
execute immediate '
create table ZJ201101300006_ldtx_kf
nologging as
select /*+ parallel(a, 20) */
a.subno
,b_subno_trunk
,CALL_Date
,CALL_time
,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,
a.msrn,
a.BUS_TYPE , --业务类型
a.SUBBUS_TYPE ,--子业务类型
a.RAT_TYPE --计费类型
from DGDM_DW.TB_DW_LS_CDR_sms_day a
where b_subno_trunk = ''1065849''
and deal_date>= to_date('''||vv_date_pre||'01'',''yyyymmdd'')
and deal_date< to_date('''||vv_date_now||'03'',''yyyymmdd'')
and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)
and a.CALL_Date >= '''||vv_date_pre4||'01''
and a.CALL_Date < '''||vv_date_now4||'01''
union all
select /*+ parallel(a,20) */
a.subno
,b_subno_trunk
,CALL_Date
,CALL_time
,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,
a.msrn,
a.BUS_TYPE , --业务类型
a.SUBBUS_TYPE ,--子业务类型
a.RAT_TYPE --计费类型
from DGDM_DW.TB_DW_LS_CDR_data_day a
where b_subno_trunk = ''1065849''
and deal_date>= to_date('''||vv_date_pre||'01'',''yyyymmdd'')
and deal_date< to_date('''||vv_date_now||'03'',''yyyymmdd'')
and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)
and a.CALL_Date >= '''||vv_date_pre4||'01''
and a.CALL_Date < '''||vv_date_now4||'01''
union all
select /*+ parallel(a,20) */
a.subno
,b_subno_trunk
,CALL_Date
,CALL_time
,case when ROLLBACK_FLAG = ''0'' then AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when ROLLBACK_FLAG = ''0'' then AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,
a.msrn,
a.BUS_TYPE , --业务类型
a.SUBBUS_TYPE ,--子业务类型
a.RAT_TYPE --计费类型
from DGDM_DW.TB_DW_LS_CDR_gsm_day a
where b_subno_trunk = ''1065849''
and deal_date >= to_date('''||vv_date_pre||'01'',''yyyymmdd'')
and deal_date < to_date('''||vv_date_now||'03'',''yyyymmdd'')
and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)
and a.CALL_Date >= '''||vv_date_pre4||'01''
and a.CALL_Date < '''||vv_date_now4||'01''
'
;
/*
SET NEWPAGE NONE HEADING OFF SPACE 0 PAGESIZE 0 TRIMOUT ON TRIMSPOOL ON LINESIZE 2500 colsep | feedback off termout off pages 0
set colsep |
set feedback on
et colsep |
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
spool ZJ201101300006_ldtx_kf201102.txt
select a.subno||'|'||
a.msrn||'|'||
a.b_subno_trunk||'|'||
((a.AFTER_MOB_FEE_0+a.AFTER_TOLL_FEE_0+a.AFTER_INF_FEE_0))/100||'|'
from ZJ201101300006_ldtx_kf a
where 1=1;
spool off;
*/
----手机证券扣费
execute immediate 'select count(1) from user_tables where table_name = upper(''ZJ201101300006_sjzj_kf'')' into vv_datacnt;
if ( vv_datacnt >0 ) then
execute immediate 'drop table ZJ201101300006_sjzj_kf purge';
end if;
execute immediate '
create table ZJ201101300006_sjzj_kf
nologging as
select /*+ parallel(a,18) parallel(b,18)*/
distinct
a.servnumber,
a.prodid,
(case when a.brand=''BrandMzone'' then ''动感地带'' else (case when a.brand = ''BrandGotone'' then ''全球通'' else ''神州行'' end)end) brand,
b.SPBIZID
from dgdm_ods.to_cm_subs_subscriber_a a,
dgdm_ods.to_cm_Subs_SPService_a b
where a.subsid = b.subsid
and a.active = 1
and a.DEAL_DATE=to_date(to_char(sysdate-1,''yyyymmdd''),''yyyymmdd'')
and b.SPBIZID = ''13000023''
and b.status = ''1''
and b.DEAL_DATE=to_date(to_char(sysdate-1,''yyyymmdd''),''yyyymmdd'')
'
;
----彩信折扣券
execute immediate 'select count(1) from user_tables where table_name = upper('''||'tb_lzw_cxzkq_'||vv_date_pre||''')' into vv_datacnt;
if ( vv_datacnt >0 ) then
execute immediate 'drop table tb_lzw_cxzkq_'||vv_date_pre||' purge';
end if;
---手机报扣费
execute immediate '
create table tb_lzw_cxzkq_'||vv_date_pre||' nologging as
select /*+ parallel(a, 20) */
a.subno
,a.b_subno_trunk
,a.CALL_Date
,a.CALL_time
,case when a.ROLLBACK_FLAG=''0'' then a.AFTER_MOB_FEE else 0-AFTER_MOB_FEE end AFTER_MOB_FEE_0
,case when a.ROLLBACK_FLAG=''0'' then a.AFTER_TOLL_FEE else 0-AFTER_TOLL_FEE end AFTER_TOLL_FEE_0
,case when a.ROLLBACK_FLAG=''0'' then a.AFTER_INF_FEE else 0-AFTER_INF_FEE end AFTER_INF_FEE_0,
a.msrn
from DGDM_DW.TB_DW_LS_CDR_data_day a
where a.b_subno_trunk=''10658880''
and a.msrn=''125843''
and deal_date>= to_date('''||vv_date_pre||'01'',''yyyymmdd'')
and deal_date< to_date('''||vv_date_now||'03'',''yyyymmdd'')
and (AFTER_MOB_FEE<>0 or AFTER_TOLL_FEE<>0 or AFTER_INF_FEE <>0)
and a.CALL_Date >= '''||vv_date_pre4||'01''
and a.CALL_Date < '''||vv_date_now4||'01''
'
;
END SP_LZW_zj201101300004;
/