- create or replace function func_get_user_by_msisdn(msisdn in number)
- ------------------------------------------------------------------------------
- ---功能描述:通过用户的电话号码,调用局方存储过程 获取用户的基本信息, ---
- --- 以遍更新card_user_info本地数据表。 ---
- ---参数: msisdn in number 代表用户的电话号码(SIM卡) ---
- ---时间:2008-09-05 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- return pkg_gps_audit.user_record
- is
- user_record_info pkg_gps_audit.user_record; --用户基本信息类型
- v_success number := 1; --成功标志
- begin
- --首先获取正常用户的基本信息
- begin
- pkg_gps_audit.proc_get_userinfo(msisdn,user_record_info);
- v_success := 1;
- exception when others then
- v_success := 0;
- end;
- --其次,如果正常用户获取不到,再查离线用户信息
- if v_success < 1 then
- begin
- pkg_gps_audit.proc_get_cancel_userinfo(msisdn,user_record_info);
- v_success := 1;
- exception when others then
- v_success := 0;
- end;
- end if;
- if v_success > 0 then
- return user_record_info;
- else
- raise no_data_found;
- end if;
- return user_record_info;
- end func_get_user_by_msisdn;
- create or replace function func_get_user_id(msisdn_bak in number)
- ------------------------------------------------------------------------------
- ---功能描述:通过用户的电话号码获取用户的ID,(有保证数据及时性) ---
- ---参数: msisdn in number 代表用户的电话号码(SIM卡) ---
- ---时间:2008-09-05 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- return number
- is
- user_info pkg_gps_audit.user_record; --用户基本信息
- card_info card_user_info%rowtype; --用户基本信息表结构
- type base_cursor is ref cursor;
- cr base_cursor;
- user_id number(15); --用户ID;
- begin
- begin
- --如果本地card_user_info表可以找到数据,先在本地查找。
- open cr for select * from card_user_info where msisdn = msisdn_bak;
- fetch cr into card_info;
- if cr%found then
- user_id := card_info.user_id;
- else
- --获取用户基本信息
- user_info := func_get_user_by_msisdn(msisdn_bak);
- user_id := user_info.user_id;
- end if;
- close cr;
- --返回用户ID
- return user_id;
- exception
- when others then
- raise no_data_found; --抛出异常
- end;
- end;
- create or replace function func_is_first_day
- ------------------------------------------------------------------------------
- ---功能描述:判断今天是否是该月的第一天(1号) ---
- ---返回参数:1代表是,0代表不是 ---
- ---时间:2008-09-05 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- return number
- is
- v_result number := 0;
- v_day varchar2(2);
- begin
- select to_char(sysdate,'dd') into v_day from dual;
- if v_day = '01' then
- v_result := 1;
- else
- v_result := 0;
- end if;
- return(v_result);
- end func_is_first_day;
- create or replace procedure proc_delete_day_fee_info
- ------------------------------------------------------------------------------
- ---功能描述: 只保留一个月得数据(8月的日账单10月份删除) ---
- ---时间:2008-09-08 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- is
- type base_cursor is ref cursor;
- cf base_cursor;
- v_fee_id number(18);
- begin
- begin
- open cf for select a.fee_id from user_fee_info a ,day_fee_info b where a.fee_id = b.fee_id and to_char(b.start_time,'yyyy-mm') = to_char(add_months(sysdate,0),'yyyy-mm');
- fetch cf into v_fee_id;
- while cf%found loop
- delete from user_fee_info where fee_id = v_fee_id;
- delete from day_fee_info where fee_id = v_fee_id;
- commit;
- fetch cf into v_fee_id;
- end loop;
- close cf;
- exception when others then
- rollback;
- return;
- end;
- end proc_delete_day_fee_info;
- create or replace procedure proc_delete_month_fee_info
- ------------------------------------------------------------------------------
- ---功能描述: 只保留6个月得数据(8月的日账单1月份删除) ---
- ---时间:2008-09-08 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- is
- type base_cursor is ref cursor;
- cf base_cursor;
- v_fee_id number(18);
- begin
- begin
- open cf for select a.fee_id from user_fee_info a ,month_fee_info b where a.fee_id = b.fee_id and to_char(b.start_time,'yyyy-mm') = to_char(add_months(sysdate,0),'yyyy-mm');
- fetch cf into v_fee_id;
- while cf%found loop
- delete from user_fee_info where fee_id = v_fee_id;
- delete from month_fee_info where fee_id = v_fee_id;
- commit;
- fetch cf into v_fee_id;
- end loop;
- close cf;
- exception when others then
- rollback;
- return;
- end;
- end proc_delete_month_fee_info;
- create or replace procedure proc_down_card_user_info
- ------------------------------------------------------------------------------
- ---功能描述:(重要)通过查询本地的group_sims表,获取sim号码集合。 ---
- --- 该表里面的sim字段有两种类型,1种是真实的sim号码,另外一种是 ---
- --- 虚拟的SIM号码,该虚拟的号码可以对应多哥真实的SIM号码。 ---
- --- simtype字段代表SIM类型,0代表是虚拟的号码,1代表是真实的号码。 ---
- --- 当sim字段为虚拟号码时,对应的simtype为0,同时groupsim为空 ---
- --- 当sim字段为真实号码时,对应的simtype为1,如果groupsim为空, ---
- --- 代表该号码没有对应的虚拟号。 ---
- --- groupuserid字段代表号码所对应的本地用户,一个用户可以对应多个 ---
- --- sim(虚拟的与真实的。) ---
- --- ---
- --- 遍历group_sims表,查询sim字段,如果为虚拟号码,就调用 ---
- --- proc_get_payed_msisdns,获取其绑定的真实号码,然后将该批真实 ---
- --- 号码插入到group_sims,同时更新card_user_info表,如果sim是 ---
- --- 真实号码,则只更新card_user_info表 。 ---
- ---时间:2008-09-05 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- is
- group_sims_info group_sims%rowtype;--定义group_sims表类型
- type type_group_sims_ref is ref cursor; --定义group_sims表游标类型
- group_sims_ref type_group_sims_ref;
- user_record_info pkg_gps_audit.user_record; --定义用户基本类型
- msisdn_table_temp pkg_gps_audit.msisdn_table; --用户SIM号码集合
- msisdn_len number(10) := 0; --用户SIM号码集合长度
- v_success number(1) := 1; --成功标志
- begin
- begin
- --打开group_sims游标
- open group_sims_ref for select * from group_sims where (groupsim is null or length(ltrim(groupsim)) = 0);
- fetch group_sims_ref into group_sims_info;
- --开始遍历该游标
- while group_sims_ref%found loop
- --首先判断是否是虚拟号码,
- if group_sims_info.simtype = 0 then
- --首先通过虚拟号码,获取对应的SIM号码;
- begin
- pkg_gps_audit.proc_get_payed_msisdns(group_sims_info.sim,msisdn_table_temp,msisdn_len);
- if msisdn_len > 0 then
- for iLen in 1 .. msisdn_len loop
- --首先更新原来group_sims表中同一个虚拟卡所对应的sim卡(先删后插)
- delete from group_sims t where t.simtype = 1 and to_number(t.groupsim) = group_sims_info.sim and t.groupuserid = group_sims_info.groupuserid;
- for xLen in 1..msisdn_len loop
- begin
- -----通过msisdn获取用户基本信息
- user_record_info := func_get_user_by_msisdn(msisdn_table_temp(xLen));
- exception when others then
- dbms_output.put_line('通过msisdn获取用户基本信息出现了异常!');
- v_success := 0;
- end;
- if v_success > 0 then
- insert into group_sims(id,sim,groupsim,groupuserid,simtype,updatetime)values(
- SEQ_GROUP_SIMS.Nextval,to_char(msisdn_table_temp(xLen)),group_sims_info.sim,group_sims_info.groupuserid,
- 1,sysdate);
- --更新原来在card_user_info里面的数据(先删除已经存在的再插入新的数据)
- delete from card_user_info where msisdn = msisdn_table_temp(xLen);
- insert into card_user_info(user_id,msisdn,brand_name,deal_name,service_status,stop_time,status)
- values(user_record_info.user_id,user_record_info.msisdn,user_record_info.brand_name,user_record_info.deal_name
- ,user_record_info.service_status,user_record_info.stop_time,1);
- end if;
- --提交数据
- commit;
- end loop;
- end loop;
- end if;
- --没有与该虚拟卡对应的SIM号码
- if msisdn_len <= 0 then
- --首先更新原来group_sims表中同一个虚拟卡所对应的sim卡(先删后插)
- delete from group_sims t where t.simtype = 1 and to_number(t.groupsim) = group_sims_info.sim and t.groupuserid = group_sims_info.groupuserid;
- commit;
- end if;
- exception when others then
- --回滚数据
- rollback;
- dbms_output.put_line('首先通过虚拟号码,获取对应的SIM号码出现了异常!');
- end;
- end if;
- --如果是真实号码,并且没有附属虚拟号码,则直接更新card_user_info表
- if group_sims_info.simtype > 0 and (group_sims_info.groupsim is null or length(group_sims_info.groupsim) = 0 ) then
- begin
- user_record_info := func_get_user_by_msisdn(group_sims_info.sim);
- --更新原来在card_user_info里面的数据(先删除已经存在的再插入新的数据)
- delete from card_user_info where msisdn = group_sims_info.sim ;
- insert into card_user_info(user_id,msisdn,brand_name,deal_name,service_status,stop_time,status)
- values(user_record_info.user_id,user_record_info.msisdn,user_record_info.brand_name,user_record_info.deal_name
- ,user_record_info.service_status,user_record_info.stop_time,1);
- --提交数据
- commit;
- exception when others then
- --回滚数据
- rollback;
- dbms_output.put_line('更新card_user_info表出现了异常');
- end;
- end if;
- --遍历游标
- fetch group_sims_ref into group_sims_info;
- end loop;
- --关闭游标
- close group_sims_ref;
- exception
- when others then
- return;
- end;
- end proc_down_card_user_info;
- create or replace procedure proc_down_change_card
- ------------------------------------------------------------------------------
- ---功能描述:(重要)通过查询本地的group_sims表,获取sim号码集合。 ---
- --- 该表里面的sim字段有两种类型,1种是真实的sim号码,另外一种是 ---
- --- 虚拟的SIM号码,该虚拟的号码可以对应多哥真实的SIM号码。 ---
- --- simtype字段代表SIM类型,0代表是虚拟的号码,1代表是真实的号码。 ---
- --- 当sim字段为虚拟号码时,对应的simtype为0,同时groupsim为空 ---
- --- 当sim字段为真实号码时,对应的simtype为1,如果groupsim为空, ---
- --- 代表该号码没有对应的虚拟号。 ---
- --- groupuserid字段代表号码所对应的本地用户,一个用户可以对应多个 ---
- --- sim(虚拟的与真实的。) ---
- --- ---
- --- 遍历group_sims表,查询sim字段,如果为虚拟号码,就调用 ---
- --- proc_get_payed_msisdns,获取其绑定的真实号码,然后再获取换补卡---
- --- 信息以更新change_card表,如果sim是真实号码, ---
- --- 则只更新change_card表 。 ---
- ---时间:2008-09-05 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- is
- group_sims_info group_sims%rowtype;--定义group_sims表类型
- type type_group_sims_ref is ref cursor; --定义group_sims表游标类型
- group_sims_ref type_group_sims_ref;
- simcard_table_temp pkg_gps_audit.simcard_table; --用户换补卡信息集合
- simcard_len number(10) := 0; --用户换补卡信息集合长度
- msisdn_table_temp pkg_gps_audit.msisdn_table; --用户SIM号码集合
- msisdn_len number(10) := 0; --用户SIM号码集合长度
- begin
- begin
- --打开group_sims游标
- open group_sims_ref for select * from group_sims where (groupsim is null or length(ltrim(groupsim)) = 0);
- fetch group_sims_ref into group_sims_info;
- --开始遍历该游标
- while group_sims_ref%found loop
- --首先判断是否是虚拟号码,
- if group_sims_info.simtype = 0 then
- --首先通过虚拟号码,获取对应的SIM号码;
- begin
- pkg_gps_audit.proc_get_payed_msisdns(group_sims_info.sim,msisdn_table_temp,msisdn_len);
- if msisdn_len > 0 then --有数据
- for iLen in 1 .. msisdn_len loop
- begin
- --通过用户ID,获取远程的换补卡用户信息集合
- pkg_gps_audit.proc_get_simcard_his(func_get_user_id(msisdn_table_temp(iLen)),simcard_table_temp,simcard_len);
- --更新原来在change_card里面的数据(先删除已经存在的再插入新的数据)
- if simcard_len > 0 then
- --这个步骤的删除条件 有待确认。??
- delete from change_card where msisdn = group_sims_info.sim ;
- for ilen in 1 .. simcard_len loop
- insert into change_card(user_id,msisdn,accept_time,accept_memo,status) values(
- simcard_table_temp(ilen).user_id,simcard_table_temp(ilen).msisdn,simcard_table_temp(ilen).accept_time,
- simcard_table_temp(ilen).accept_memo,1);
- end loop;
- end if;
- if simcard_len = 0 then
- dbms_output.put_line('通过用户IfffffffffD,获取远程的换补卡用户信息集合,出现了异常!');
- end if;
- commit;
- exception when others then
- dbms_output.put_line('通过用户ID,获取远程的换补卡用户信息集合,出现了异常!');
- rollback;
- end;
- end loop;
- end if;
- exception when others then
- --回滚数据
- rollback;
- dbms_output.put_line('首先通过虚拟号码,获取对应的SIM号码出现了异常!');
- end;
- end if;
- if group_sims_info.simtype > 0 and (group_sims_info.groupsim is null or length(group_sims_info.groupsim) = 0 ) then --如果是真实号码,并且没有附属虚拟号码,则直接更新change_card表
- begin
- --通过用户ID,获取远程的换补卡用户信息集合
- pkg_gps_audit.proc_get_simcard_his(func_get_user_id(group_sims_info.sim),simcard_table_temp,simcard_len);
- --更新原来在change_card里面的数据(先删除已经存在的再插入新的数据)
- if simcard_len > 0 then
- --这个步骤的删除条件 有待确认。??
- delete from change_card where msisdn = group_sims_info.sim ;
- for ilen in 1 .. simcard_len loop
- insert into change_card(user_id,msisdn,accept_time,accept_memo,status) values(
- simcard_table_temp(ilen).user_id,simcard_table_temp(ilen).msisdn,simcard_table_temp(ilen).accept_time,
- simcard_table_temp(ilen).accept_memo,1);
- end loop;
- end if;
- --提交数据
- commit;
- exception when others then
- --回滚数据
- rollback;
- dbms_output.put_line('更新change_card表出现了异常');
- end;
- end if;
- --遍历游标
- fetch group_sims_ref into group_sims_info;
- end loop;
- --关闭游标
- close group_sims_ref;
- exception
- when others then
- return;
- end;
- end proc_down_change_card;
- create or replace procedure proc_down_fee_info
- ------------------------------------------------------------------------------
- ---功能描述:(重要)通过查询本地的group_sims表,获取sim号码集合。 ---
- --- 该表里面的sim字段有两种类型,1种是真实的sim号码,另外一种是 ---
- --- 虚拟的SIM号码,该虚拟的号码可以对应多哥真实的SIM号码。 ---
- --- simtype字段代表SIM类型,0代表是虚拟的号码,1代表是真实的号码。 ---
- --- 当sim字段为虚拟号码时,对应的simtype为0,同时groupsim为空 ---
- --- 当sim字段为真实号码时,对应的simtype为1,如果groupsim为空, ---
- --- 代表该号码没有对应的虚拟号。 ---
- --- groupuserid字段代表号码所对应的本地用户,一个用户可以对应多个 ---
- --- sim(虚拟的与真实的。) ---
- --- ---
- --- 遍历group_sims表,查询sim字段,如果为虚拟号码,就调用 ---
- --- proc_get_payed_msisdns,获取其绑定的真实号码,然后获取每日消费---
- --- 情况,再分别保存到day_fee_Info,month_fee_info两张表,如果 ---
- --- sim是 真实号码,则只更新day_fee_Info,month_fee_info表 。 ---
- ---时间:2008-09-05 ---
- ---作者:zhouyq ---
- ---单位:厦门新科技软件股份有限公司 ---
- ------------------------------------------------------------------------------
- is
- group_sims_info group_sims%rowtype;--定义group_sims表类型
- type type_group_sims_ref is ref cursor; --定义group_sims表游标类型
- group_sims_ref type_group_sims_ref;
- msisdn_table_temp pkg_gps_audit.msisdn_table; --用户SIM号码集合
- msisdn_len number(10) := 0; --用户SIM号码集合长度
- base_fee pkg_gps_audit.fee_record; --用户每日消费结构信息
- is_first_day number(1); --是否是每月一号标志
- user_fee_info_nextval number(15); --user_fee_info表的下一个序列号
- user_fee_info_temp pkg_gps_audit.fee_record; --user_fee_info数据缓存
- v_fee_id number(15);--消费ID
- begin
- begin
- --打开group_sims游标
- open group_sims_ref for select * from group_sims where (groupsim is null or length(ltrim(groupsim)) = 0);
- fetch group_sims_ref into group_sims_info;
- --开始遍历该游标
- while group_sims_ref%found loop
- --首先判断是否是虚拟号码,
- if group_sims_info.simtype = 0 then
- --首先通过虚拟号码,获取对应的SIM号码;
- begin
- pkg_gps_audit.proc_get_payed_msisdns(group_sims_info.sim,msisdn_table_temp,msisdn_len);
- if msisdn_len > 0 then --有数据
- for iLen in 1 .. msisdn_len loop
- --首先获取该用户每日消费记录,如果今天刚好是1号,那么获取到的数据刚好是上个月1-30号的总和
- --如果不是1号,那么获取到的是本月前几天的总和
- pkg_gps_audit.proc_get_userfee(func_get_user_id(msisdn_table_temp(iLen)),base_fee);
- --判断当前日期是否是每月1号
- is_first_day := func_is_first_day();
- if is_first_day = 1 then --1号
- -----(begin)保存到user_fee_info,day_fee_info表--------------
- begin
- -----计算出上个月的总和
- begin
- select user_id,
- sum(fee_base),sum(fee_pkg_month),sum(fee_keep),sum(fee_oth_month),sum(fee_vpn),
- sum(fee_shift),sum(fee_local),sum(fee_long),sum(fee_inprov),sum(fee_inprov_long),
- sum(fee_outprov),sum(fee_outprov_long),sum(fee_inter),sum(fee_inter_long),
- sum(fee_cmnet),sum(fee_trust),sum(fee_ptp_sms),sum(fee_mms),sum(fee_magazine),
- sum(fee_gprs),sum(fee_wap),sum(fee_data_month),
- sum(fee_data),sum(fee_ring),sum(fee_display),sum(fee_ext),sum(fee_other),
- sum(fee_all),sum(fee_for_others),sum(fee_by_others)
- into user_fee_info_temp from user_fee_info
- where user_id = base_fee.user_id
- and fee_id in (select fee_id from day_fee_info where to_char(start_time,'yyyy-mm') = to_char(add_months(sysdate,-1),'yyyy-mm')) group by user_id ;
- exception when others then
- user_fee_info_temp.user_id := base_fee.user_id;
- user_fee_info_temp.fee_base := 0.00;
- user_fee_info_temp.fee_pkg_month := 0.00;
- user_fee_info_temp.fee_keep := 0.00;
- user_fee_info_temp.fee_oth_month := 0.00;
- user_fee_info_temp.fee_vpn := 0.00;
- user_fee_info_temp.fee_shift := 0.00;
- user_fee_info_temp.fee_local := 0.00;
- user_fee_info_temp.fee_long := 0.00;
- user_fee_info_temp.fee_inprov := 0.00;
- user_fee_info_temp.fee_inprov_long := 0.00;
- user_fee_info_temp.fee_outprov := 0.00;
- user_fee_info_temp.fee_outprov_long := 0.00;
- user_fee_info_temp.fee_inter := 0.00;
- user_fee_info_temp.fee_inter_long := 0.00;
- user_fee_info_temp.fee_cmnet := 0.00;
- user_fee_info_temp.fee_trust := 0.00;
- user_fee_info_temp.fee_ptp_sms := 0.00;
- user_fee_info_temp.fee_mms := 0.00;
- user_fee_info_temp.fee_magazine := 0.00;
- user_fee_info_temp.fee_gprs := 0.00;
- user_fee_info_temp.fee_wap := 0.00;
- user_fee_info_temp.fee_data_month := 0.00;
- user_fee_info_temp.fee_data := 0.00;
- user_fee_info_temp.fee_ring := 0.00;
- user_fee_info_temp.fee_display := 0.00;
- user_fee_info_temp.fee_ext := 0.00;
- user_fee_info_temp.fee_other := 0.00;
- user_fee_info_temp.fee_all := 0.00;
- user_fee_info_temp.fee_for_others := 0.00;
- user_fee_info_temp.fee_by_others := 0.00;
- end;
- --保存到user_fee_info,day_fee_info表
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values(
- user_fee_info_nextval,base_fee.user_id,
- decode(sign(base_fee.fee_base-user_fee_info_temp.fee_base),1,base_fee.fee_base-user_fee_info_temp.fee_base,0.00),
- decode(sign(base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month),1,base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month,0.00),
- decode(sign(base_fee.fee_keep-user_fee_info_temp.fee_keep),1,base_fee.fee_keep-user_fee_info_temp.fee_keep,0.00),
- decode(sign(base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month),1,base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month,0.00),
- decode(sign(base_fee.fee_vpn-user_fee_info_temp.fee_vpn),1,base_fee.fee_vpn-user_fee_info_temp.fee_vpn,0.00),
- decode(sign(base_fee.fee_shift-user_fee_info_temp.fee_shift),1,base_fee.fee_shift-user_fee_info_temp.fee_shift,0.00),
- decode(sign(base_fee.fee_local-user_fee_info_temp.fee_local),1,base_fee.fee_local-user_fee_info_temp.fee_local,0.00),
- decode(sign(base_fee.fee_long-user_fee_info_temp.fee_long),1,base_fee.fee_long-user_fee_info_temp.fee_long,0.00),
- decode(sign(base_fee.fee_inprov-user_fee_info_temp.fee_inprov),1,base_fee.fee_inprov-user_fee_info_temp.fee_inprov,0.00),
- decode(sign(base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long),1,base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long,0.00),
- decode(sign(base_fee.fee_outprov-user_fee_info_temp.fee_outprov),1,base_fee.fee_outprov-user_fee_info_temp.fee_outprov,0.00),
- decode(sign(base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long),1,base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long,0.00),
- decode(sign(base_fee.fee_inter-user_fee_info_temp.fee_inter),1,base_fee.fee_inter-user_fee_info_temp.fee_inter,0.00),
- decode(sign(base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long),1,base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long,0.00),
- decode(sign(base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet),1,base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet,0.00),
- decode(sign(base_fee.fee_trust-user_fee_info_temp.fee_trust),1,base_fee.fee_trust-user_fee_info_temp.fee_trust,0.00),
- decode(sign(base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms),1,base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms,0.00),
- decode(sign(base_fee.fee_mms-user_fee_info_temp.fee_mms),1,base_fee.fee_mms-user_fee_info_temp.fee_mms,0.00),
- decode(sign(base_fee.fee_magazine-user_fee_info_temp.fee_magazine),1,base_fee.fee_magazine-user_fee_info_temp.fee_magazine,0.00),
- decode(sign(base_fee.fee_gprs-user_fee_info_temp.fee_gprs),1,base_fee.fee_gprs-user_fee_info_temp.fee_gprs,0.00),
- decode(sign(base_fee.fee_wap-user_fee_info_temp.fee_wap),1,base_fee.fee_wap-user_fee_info_temp.fee_wap,0.00),
- decode(sign(base_fee.fee_data_month-user_fee_info_temp.fee_data_month),1,base_fee.fee_data_month-user_fee_info_temp.fee_data_month,0.00),
- decode(sign(base_fee.fee_data-user_fee_info_temp.fee_data),1,base_fee.fee_data-user_fee_info_temp.fee_data,0.00),
- decode(sign(base_fee.fee_ring-user_fee_info_temp.fee_ring),1,base_fee.fee_ring-user_fee_info_temp.fee_ring,0.00),
- decode(sign(base_fee.fee_display-user_fee_info_temp.fee_display),1,base_fee.fee_display-user_fee_info_temp.fee_display,0.00),
- decode(sign(base_fee.fee_ext-user_fee_info_temp.fee_ext),1,base_fee.fee_ext-user_fee_info_temp.fee_ext,0.00),
- decode(sign(base_fee.fee_other-user_fee_info_temp.fee_other),1,base_fee.fee_other-user_fee_info_temp.fee_other,0.00),
- decode(sign(base_fee.fee_all-user_fee_info_temp.fee_all),1,base_fee.fee_all-user_fee_info_temp.fee_all,0.00),
- decode(sign(base_fee.fee_for_others-user_fee_info_temp.fee_for_others),1,base_fee.fee_for_others-user_fee_info_temp.fee_for_others,0.00),
- decode(sign(base_fee.fee_by_others-user_fee_info_temp.fee_by_others),1,base_fee.fee_by_others-user_fee_info_temp.fee_by_others,0.00) );
- insert into day_fee_info(id,fee_id,start_time) values(seq_day_fee_info.nextval,user_fee_info_nextval,sysdate-1);
- commit;
- exception when others then
- rollback;
- dbms_output.put_line('保存到user_fee_info,day_fee_info表出现了异常');
- end;
- -------------(end)保存到user_fee_info,day_fee_info表-------------------------------------
- -------------------(begin)保存到user_fee_info,month_fee_info表---------------------------------
- begin
- begin
- ----首先删除再更新原来的user_fee_info,month_fee_info
- select a.fee_id into v_fee_id from month_fee_info a, user_fee_info b where a.fee_id = b.fee_id and b.user_id = base_fee.user_id and to_char(a.start_time,'yyyy-mm') = to_char(add_months(sysdate,-1),'yyyy-mm');
- delete from user_fee_info x where x.fee_id = v_fee_id;
- delete from month_fee_info y where y.fee_id = v_fee_id;
- commit;
- exception when others then
- rollback;
- end;
- ----插入新的数据
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values( user_fee_info_nextval,base_fee.user_id, base_fee.fee_base, base_fee.fee_pkg_month,
- base_fee.fee_keep, base_fee.fee_oth_month, base_fee.fee_vpn,
- base_fee.fee_shift, base_fee.fee_local, base_fee.fee_long, base_fee.fee_inprov,
- base_fee.fee_inprov_long, base_fee.fee_outprov, base_fee.fee_outprov_long,
- base_fee.fee_inter, base_fee.fee_inter_long, base_fee.fee_cmnet,
- base_fee.fee_trust, base_fee.fee_ptp_sms, base_fee.fee_mms,
- base_fee.fee_magazine, base_fee.fee_gprs, base_fee.fee_wap,
- base_fee.fee_data_month, base_fee.fee_data, base_fee.fee_ring,
- base_fee.fee_display, base_fee.fee_ext, base_fee.fee_other,
- base_fee.fee_all, base_fee.fee_for_others, base_fee.fee_by_others);
- insert into month_fee_info(id,fee_id,start_time) values(seq_month_fee_info.nextval,user_fee_info_nextval,sysdate-1);
- commit;
- exception when others then
- rollback;
- dbms_output.put_line('保存到user_fee_info,month_fee_info表出现了异常');
- end;
- ----------------(end)保存到user_fee_info,month_fee_info表--------------------------------------
- else --不是本月第一天
- -------------------(begin)保存到user_fee_info,day_fee_info表-------------------
- begin
- begin
- --计算出本月的总和
- select user_id,
- sum(fee_base),sum(fee_pkg_month),sum(fee_keep),sum(fee_oth_month),sum(fee_vpn),
- sum(fee_shift),sum(fee_local),sum(fee_long),sum(fee_inprov),sum(fee_inprov_long),
- sum(fee_outprov),sum(fee_outprov_long),sum(fee_inter),sum(fee_inter_long),
- sum(fee_cmnet),sum(fee_trust),sum(fee_ptp_sms),sum(fee_mms),sum(fee_magazine),
- sum(fee_gprs),sum(fee_wap),sum(fee_data_month),
- sum(fee_data),sum(fee_ring),sum(fee_display),sum(fee_ext),sum(fee_other),
- sum(fee_all),sum(fee_for_others),sum(fee_by_others)
- into user_fee_info_temp from user_fee_info
- where user_id = base_fee.user_id
- and fee_id in (select fee_id from day_fee_info where to_char(start_time,'yyyy-mm') = to_char(sysdate,'yyyy-mm')) group by user_id ;
- exception when others then
- user_fee_info_temp.user_id := base_fee.user_id;
- user_fee_info_temp.fee_base := 0.00;
- user_fee_info_temp.fee_pkg_month := 0.00;
- user_fee_info_temp.fee_keep := 0.00;
- user_fee_info_temp.fee_oth_month := 0.00;
- user_fee_info_temp.fee_vpn := 0.00;
- user_fee_info_temp.fee_shift := 0.00;
- user_fee_info_temp.fee_local := 0.00;
- user_fee_info_temp.fee_long := 0.00;
- user_fee_info_temp.fee_inprov := 0.00;
- user_fee_info_temp.fee_inprov_long := 0.00;
- user_fee_info_temp.fee_outprov := 0.00;
- user_fee_info_temp.fee_outprov_long := 0.00;
- user_fee_info_temp.fee_inter := 0.00;
- user_fee_info_temp.fee_inter_long := 0.00;
- user_fee_info_temp.fee_cmnet := 0.00;
- user_fee_info_temp.fee_trust := 0.00;
- user_fee_info_temp.fee_ptp_sms := 0.00;
- user_fee_info_temp.fee_mms := 0.00;
- user_fee_info_temp.fee_magazine := 0.00;
- user_fee_info_temp.fee_gprs := 0.00;
- user_fee_info_temp.fee_wap := 0.00;
- user_fee_info_temp.fee_data_month := 0.00;
- user_fee_info_temp.fee_data := 0.00;
- user_fee_info_temp.fee_ring := 0.00;
- user_fee_info_temp.fee_display := 0.00;
- user_fee_info_temp.fee_ext := 0.00;
- user_fee_info_temp.fee_other := 0.00;
- user_fee_info_temp.fee_all := 0.00;
- user_fee_info_temp.fee_for_others := 0.00;
- user_fee_info_temp.fee_by_others := 0.00;
- end;
- --保存到user_fee_info,day_fee_info表
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values(
- user_fee_info_nextval,base_fee.user_id,
- decode(sign(base_fee.fee_base-user_fee_info_temp.fee_base),1,base_fee.fee_base-user_fee_info_temp.fee_base,0.00),
- decode(sign(base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month),1,base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month,0.00),
- decode(sign(base_fee.fee_keep-user_fee_info_temp.fee_keep),1,base_fee.fee_keep-user_fee_info_temp.fee_keep,0.00),
- decode(sign(base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month),1,base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month,0.00),
- decode(sign(base_fee.fee_vpn-user_fee_info_temp.fee_vpn),1,base_fee.fee_vpn-user_fee_info_temp.fee_vpn,0.00),
- decode(sign(base_fee.fee_shift-user_fee_info_temp.fee_shift),1,base_fee.fee_shift-user_fee_info_temp.fee_shift,0.00),
- decode(sign(base_fee.fee_local-user_fee_info_temp.fee_local),1,base_fee.fee_local-user_fee_info_temp.fee_local,0.00),
- decode(sign(base_fee.fee_long-user_fee_info_temp.fee_long),1,base_fee.fee_long-user_fee_info_temp.fee_long,0.00),
- decode(sign(base_fee.fee_inprov-user_fee_info_temp.fee_inprov),1,base_fee.fee_inprov-user_fee_info_temp.fee_inprov,0.00),
- decode(sign(base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long),1,base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long,0.00),
- decode(sign(base_fee.fee_outprov-user_fee_info_temp.fee_outprov),1,base_fee.fee_outprov-user_fee_info_temp.fee_outprov,0.00),
- decode(sign(base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long),1,base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long,0.00),
- decode(sign(base_fee.fee_inter-user_fee_info_temp.fee_inter),1,base_fee.fee_inter-user_fee_info_temp.fee_inter,0.00),
- decode(sign(base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long),1,base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long,0.00),
- decode(sign(base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet),1,base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet,0.00),
- decode(sign(base_fee.fee_trust-user_fee_info_temp.fee_trust),1,base_fee.fee_trust-user_fee_info_temp.fee_trust,0.00),
- decode(sign(base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms),1,base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms,0.00),
- decode(sign(base_fee.fee_mms-user_fee_info_temp.fee_mms),1,base_fee.fee_mms-user_fee_info_temp.fee_mms,0.00),
- decode(sign(base_fee.fee_magazine-user_fee_info_temp.fee_magazine),1,base_fee.fee_magazine-user_fee_info_temp.fee_magazine,0.00),
- decode(sign(base_fee.fee_gprs-user_fee_info_temp.fee_gprs),1,base_fee.fee_gprs-user_fee_info_temp.fee_gprs,0.00),
- decode(sign(base_fee.fee_wap-user_fee_info_temp.fee_wap),1,base_fee.fee_wap-user_fee_info_temp.fee_wap,0.00),
- decode(sign(base_fee.fee_data_month-user_fee_info_temp.fee_data_month),1,base_fee.fee_data_month-user_fee_info_temp.fee_data_month,0.00),
- decode(sign(base_fee.fee_data-user_fee_info_temp.fee_data),1,base_fee.fee_data-user_fee_info_temp.fee_data,0.00),
- decode(sign(base_fee.fee_ring-user_fee_info_temp.fee_ring),1,base_fee.fee_ring-user_fee_info_temp.fee_ring,0.00),
- decode(sign(base_fee.fee_display-user_fee_info_temp.fee_display),1,base_fee.fee_display-user_fee_info_temp.fee_display,0.00),
- decode(sign(base_fee.fee_ext-user_fee_info_temp.fee_ext),1,base_fee.fee_ext-user_fee_info_temp.fee_ext,0.00),
- decode(sign(base_fee.fee_other-user_fee_info_temp.fee_other),1,base_fee.fee_other-user_fee_info_temp.fee_other,0.00),
- decode(sign(base_fee.fee_all-user_fee_info_temp.fee_all),1,base_fee.fee_all-user_fee_info_temp.fee_all,0.00),
- decode(sign(base_fee.fee_for_others-user_fee_info_temp.fee_for_others),1,base_fee.fee_for_others-user_fee_info_temp.fee_for_others,0.00),
- decode(sign(base_fee.fee_by_others-user_fee_info_temp.fee_by_others),1,base_fee.fee_by_others-user_fee_info_temp.fee_by_others,0.00) );
- insert into day_fee_info(id,fee_id,start_time) values(seq_day_fee_info.nextval,user_fee_info_nextval,sysdate-1);
- commit;
- exception when others then
- rollback;
- dbms_output.put_line('保存到user_fee_info,day_fee_info表出现了异常');
- end;
- ------------------(end)保存到user_fee_info,day_fee_info表----------------------------------
- ----------------(begin)保存到user_fee_info,month_fee_info表----------------------
- begin
- begin
- ----首先删除再更新原来的user_fee_info,month_fee_info
- select a.fee_id into v_fee_id from month_fee_info a, user_fee_info b where a.fee_id = b.fee_id and b.user_id = base_fee.user_id and to_char(a.start_time,'yyyy-mm') = to_char(sysdate,'yyyy-mm') ;
- delete from user_fee_info x where x.fee_id = v_fee_id;
- delete from month_fee_info y where y.fee_id = v_fee_id;
- commit;
- exception when others then
- rollback;
- end;
- ----插入新的数据
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values( user_fee_info_nextval,base_fee.user_id, base_fee.fee_base, base_fee.fee_pkg_month,
- base_fee.fee_keep, base_fee.fee_oth_month, base_fee.fee_vpn,
- base_fee.fee_shift, base_fee.fee_local, base_fee.fee_long, base_fee.fee_inprov,
- base_fee.fee_inprov_long, base_fee.fee_outprov, base_fee.fee_outprov_long,
- base_fee.fee_inter, base_fee.fee_inter_long, base_fee.fee_cmnet,
- base_fee.fee_trust, base_fee.fee_ptp_sms, base_fee.fee_mms,
- base_fee.fee_magazine, base_fee.fee_gprs, base_fee.fee_wap,
- base_fee.fee_data_month, base_fee.fee_data, base_fee.fee_ring,
- base_fee.fee_display, base_fee.fee_ext, base_fee.fee_other,
- base_fee.fee_all, base_fee.fee_for_others, base_fee.fee_by_others);
- insert into month_fee_info(id,fee_id,start_time) values(seq_month_fee_info.nextval,user_fee_info_nextval,sysdate);
- commit;
- exception when others then
- rollback;
- dbms_output.put_line('保存到user_fee_info,month_fee_info表出现了异常');
- end;
- ----------------(end)保存到user_fee_info,month_fee_info表----------------------
- end if;
- end loop;
- end if;
- exception when others then
- --回滚数据
- rollback;
- dbms_output.put_line('首先通过虚拟号码,获取对应的SIM号码出现了异常!');
- end;
- end if;
- --如果是真实号码,并且没有附属虚拟号码,则直接更新day_fee_info,month_fee_info表
- if group_sims_info.simtype > 0 and (group_sims_info.groupsim is null or length(group_sims_info.groupsim) = 0 ) then
- begin
- --首先获取该用户每日消费记录,如果今天刚好是1号,那么获取到的数据刚好是上个月1-30号的总和
- --如果不是1号,那么获取到的是本月前几天的总和
- pkg_gps_audit.proc_get_userfee(func_get_user_id(group_sims_info.sim),base_fee);
- --判断当前日期是否是每月1号
- is_first_day := func_is_first_day();
- if is_first_day = 1 then
- ----------------------(begin)-------------------
- begin
- begin
- --计算出上个月的总和
- select user_id,
- sum(fee_base),sum(fee_pkg_month),sum(fee_keep),sum(fee_oth_month),sum(fee_vpn),
- sum(fee_shift),sum(fee_local),sum(fee_long),sum(fee_inprov),sum(fee_inprov_long),
- sum(fee_outprov),sum(fee_outprov_long),sum(fee_inter),sum(fee_inter_long),
- sum(fee_cmnet),sum(fee_trust),sum(fee_ptp_sms),sum(fee_mms),sum(fee_magazine),
- sum(fee_gprs),sum(fee_wap),sum(fee_data_month),
- sum(fee_data),sum(fee_ring),sum(fee_display),sum(fee_ext),sum(fee_other),
- sum(fee_all),sum(fee_for_others),sum(fee_by_others)
- into user_fee_info_temp from user_fee_info
- where user_id = func_get_user_id(group_sims_info.sim)
- and fee_id in (select fee_id from day_fee_info where to_char(start_time,'yyyy-mm') = to_char(add_months(sysdate,-1),'yyyy-mm'))
- group by user_id ;
- exception when others then
- user_fee_info_temp.user_id := base_fee.user_id;
- user_fee_info_temp.fee_base := 0.00;
- user_fee_info_temp.fee_pkg_month := 0.00;
- user_fee_info_temp.fee_keep := 0.00;
- user_fee_info_temp.fee_oth_month := 0.00;
- user_fee_info_temp.fee_vpn := 0.00;
- user_fee_info_temp.fee_shift := 0.00;
- user_fee_info_temp.fee_local := 0.00;
- user_fee_info_temp.fee_long := 0.00;
- user_fee_info_temp.fee_inprov := 0.00;
- user_fee_info_temp.fee_inprov_long := 0.00;
- user_fee_info_temp.fee_outprov := 0.00;
- user_fee_info_temp.fee_outprov_long := 0.00;
- user_fee_info_temp.fee_inter := 0.00;
- user_fee_info_temp.fee_inter_long := 0.00;
- user_fee_info_temp.fee_cmnet := 0.00;
- user_fee_info_temp.fee_trust := 0.00;
- user_fee_info_temp.fee_ptp_sms := 0.00;
- user_fee_info_temp.fee_mms := 0.00;
- user_fee_info_temp.fee_magazine := 0.00;
- user_fee_info_temp.fee_gprs := 0.00;
- user_fee_info_temp.fee_wap := 0.00;
- user_fee_info_temp.fee_data_month := 0.00;
- user_fee_info_temp.fee_data := 0.00;
- user_fee_info_temp.fee_ring := 0.00;
- user_fee_info_temp.fee_display := 0.00;
- user_fee_info_temp.fee_ext := 0.00;
- user_fee_info_temp.fee_other := 0.00;
- user_fee_info_temp.fee_all := 0.00;
- user_fee_info_temp.fee_for_others := 0.00;
- user_fee_info_temp.fee_by_others := 0.00;
- end;
- --保存到user_fee_info,day_fee_info表
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values(
- user_fee_info_nextval,base_fee.user_id,
- decode(sign(base_fee.fee_base-user_fee_info_temp.fee_base),1,base_fee.fee_base-user_fee_info_temp.fee_base,0.00),
- decode(sign(base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month),1,base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month,0.00),
- decode(sign(base_fee.fee_keep-user_fee_info_temp.fee_keep),1,base_fee.fee_keep-user_fee_info_temp.fee_keep,0.00),
- decode(sign(base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month),1,base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month,0.00),
- decode(sign(base_fee.fee_vpn-user_fee_info_temp.fee_vpn),1,base_fee.fee_vpn-user_fee_info_temp.fee_vpn,0.00),
- decode(sign(base_fee.fee_shift-user_fee_info_temp.fee_shift),1,base_fee.fee_shift-user_fee_info_temp.fee_shift,0.00),
- decode(sign(base_fee.fee_local-user_fee_info_temp.fee_local),1,base_fee.fee_local-user_fee_info_temp.fee_local,0.00),
- decode(sign(base_fee.fee_long-user_fee_info_temp.fee_long),1,base_fee.fee_long-user_fee_info_temp.fee_long,0.00),
- decode(sign(base_fee.fee_inprov-user_fee_info_temp.fee_inprov),1,base_fee.fee_inprov-user_fee_info_temp.fee_inprov,0.00),
- decode(sign(base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long),1,base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long,0.00),
- decode(sign(base_fee.fee_outprov-user_fee_info_temp.fee_outprov),1,base_fee.fee_outprov-user_fee_info_temp.fee_outprov,0.00),
- decode(sign(base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long),1,base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long,0.00),
- decode(sign(base_fee.fee_inter-user_fee_info_temp.fee_inter),1,base_fee.fee_inter-user_fee_info_temp.fee_inter,0.00),
- decode(sign(base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long),1,base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long,0.00),
- decode(sign(base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet),1,base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet,0.00),
- decode(sign(base_fee.fee_trust-user_fee_info_temp.fee_trust),1,base_fee.fee_trust-user_fee_info_temp.fee_trust,0.00),
- decode(sign(base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms),1,base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms,0.00),
- decode(sign(base_fee.fee_mms-user_fee_info_temp.fee_mms),1,base_fee.fee_mms-user_fee_info_temp.fee_mms,0.00),
- decode(sign(base_fee.fee_magazine-user_fee_info_temp.fee_magazine),1,base_fee.fee_magazine-user_fee_info_temp.fee_magazine,0.00),
- decode(sign(base_fee.fee_gprs-user_fee_info_temp.fee_gprs),1,base_fee.fee_gprs-user_fee_info_temp.fee_gprs,0.00),
- decode(sign(base_fee.fee_wap-user_fee_info_temp.fee_wap),1,base_fee.fee_wap-user_fee_info_temp.fee_wap,0.00),
- decode(sign(base_fee.fee_data_month-user_fee_info_temp.fee_data_month),1,base_fee.fee_data_month-user_fee_info_temp.fee_data_month,0.00),
- decode(sign(base_fee.fee_data-user_fee_info_temp.fee_data),1,base_fee.fee_data-user_fee_info_temp.fee_data,0.00),
- decode(sign(base_fee.fee_ring-user_fee_info_temp.fee_ring),1,base_fee.fee_ring-user_fee_info_temp.fee_ring,0.00),
- decode(sign(base_fee.fee_display-user_fee_info_temp.fee_display),1,base_fee.fee_display-user_fee_info_temp.fee_display,0.00),
- decode(sign(base_fee.fee_ext-user_fee_info_temp.fee_ext),1,base_fee.fee_ext-user_fee_info_temp.fee_ext,0.00),
- decode(sign(base_fee.fee_other-user_fee_info_temp.fee_other),1,base_fee.fee_other-user_fee_info_temp.fee_other,0.00),
- decode(sign(base_fee.fee_all-user_fee_info_temp.fee_all),1,base_fee.fee_all-user_fee_info_temp.fee_all,0.00),
- decode(sign(base_fee.fee_for_others-user_fee_info_temp.fee_for_others),1,base_fee.fee_for_others-user_fee_info_temp.fee_for_others,0.00),
- decode(sign(base_fee.fee_by_others-user_fee_info_temp.fee_by_others),1,base_fee.fee_by_others-user_fee_info_temp.fee_by_others,0.00) );
- insert into day_fee_info(id,fee_id,start_time) values(seq_day_fee_info.nextval,user_fee_info_nextval,sysdate-1);
- commit;
- exception when others then
- rollback;
- dbms_output.put_line('保存到user_fee_info,day_fee_info表出现了异常');
- end;
- ------------------(end)-------------------------------
- -------------------(begin)-----------------------------------------
- begin
- --保存到user_fee_info,month_fee_info表
- begin
- ----首先删除再更新原来的user_fee_info,month_fee_info
- select a.fee_id into v_fee_id from month_fee_info a, user_fee_info b where a.fee_id = b.fee_id and b.user_id = base_fee.user_id and to_char(a.start_time,'yyyy-mm') = to_char(add_months(sysdate,-1),'yyyy-mm') ;
- delete from user_fee_info x where x.fee_id = v_fee_id;
- delete from month_fee_info y where y.fee_id = fee_id;
- commit;
- exception when others then
- rollback;
- end;
- ----插入新的数据
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values( user_fee_info_nextval,base_fee.user_id, base_fee.fee_base, base_fee.fee_pkg_month,
- base_fee.fee_keep, base_fee.fee_oth_month, base_fee.fee_vpn,
- base_fee.fee_shift, base_fee.fee_local, base_fee.fee_long, base_fee.fee_inprov,
- base_fee.fee_inprov_long, base_fee.fee_outprov, base_fee.fee_outprov_long,
- base_fee.fee_inter, base_fee.fee_inter_long, base_fee.fee_cmnet,
- base_fee.fee_trust, base_fee.fee_ptp_sms, base_fee.fee_mms,
- base_fee.fee_magazine, base_fee.fee_gprs, base_fee.fee_wap,
- base_fee.fee_data_month, base_fee.fee_data, base_fee.fee_ring,
- base_fee.fee_display, base_fee.fee_ext, base_fee.fee_other,
- base_fee.fee_all, base_fee.fee_for_others, base_fee.fee_by_others);
- insert into month_fee_info(id,fee_id,start_time) values(seq_month_fee_info.nextval,user_fee_info_nextval,sysdate-1);
- commit;
- exception when others then
- rollback;
- dbms_output.put_line('保存到user_fee_info,month_fee_info表出现了异常');
- end;
- ----------------------(end)-----------------------------------------------
- else --不是本月第一天
- ------------------------(begin)-------------------------------------
- begin
- --保存到user_fee_info,day_fee_info表
- begin
- --计算出本月的总和
- select user_id,
- sum(fee_base),sum(fee_pkg_month),sum(fee_keep),sum(fee_oth_month),sum(fee_vpn),
- sum(fee_shift),sum(fee_local),sum(fee_long),sum(fee_inprov),sum(fee_inprov_long),
- sum(fee_outprov),sum(fee_outprov_long),sum(fee_inter),sum(fee_inter_long),
- sum(fee_cmnet),sum(fee_trust),sum(fee_ptp_sms),sum(fee_mms),sum(fee_magazine),
- sum(fee_gprs),sum(fee_wap),sum(fee_data_month),
- sum(fee_data),sum(fee_ring),sum(fee_display),sum(fee_ext),sum(fee_other),
- sum(fee_all),sum(fee_for_others),sum(fee_by_others)
- into user_fee_info_temp from user_fee_info
- where user_id = func_get_user_id(group_sims_info.sim)
- and fee_id in (select fee_id from day_fee_info where to_char(start_time,'yyyy-mm') = to_char(sysdate,'yyyy-mm'))
- group by user_id ;
- exception when others then
- user_fee_info_temp.user_id := base_fee.user_id;
- user_fee_info_temp.fee_base := 0.00;
- user_fee_info_temp.fee_pkg_month := 0.00;
- user_fee_info_temp.fee_keep := 0.00;
- user_fee_info_temp.fee_oth_month := 0.00;
- user_fee_info_temp.fee_vpn := 0.00;
- user_fee_info_temp.fee_shift := 0.00;
- user_fee_info_temp.fee_local := 0.00;
- user_fee_info_temp.fee_long := 0.00;
- user_fee_info_temp.fee_inprov := 0.00;
- user_fee_info_temp.fee_inprov_long := 0.00;
- user_fee_info_temp.fee_outprov := 0.00;
- user_fee_info_temp.fee_outprov_long := 0.00;
- user_fee_info_temp.fee_inter := 0.00;
- user_fee_info_temp.fee_inter_long := 0.00;
- user_fee_info_temp.fee_cmnet := 0.00;
- user_fee_info_temp.fee_trust := 0.00;
- user_fee_info_temp.fee_ptp_sms := 0.00;
- user_fee_info_temp.fee_mms := 0.00;
- user_fee_info_temp.fee_magazine := 0.00;
- user_fee_info_temp.fee_gprs := 0.00;
- user_fee_info_temp.fee_wap := 0.00;
- user_fee_info_temp.fee_data_month := 0.00;
- user_fee_info_temp.fee_data := 0.00;
- user_fee_info_temp.fee_ring := 0.00;
- user_fee_info_temp.fee_display := 0.00;
- user_fee_info_temp.fee_ext := 0.00;
- user_fee_info_temp.fee_other := 0.00;
- user_fee_info_temp.fee_all := 0.00;
- user_fee_info_temp.fee_for_others := 0.00;
- user_fee_info_temp.fee_by_others := 0.00;
- end;
- --保存到user_fee_info,day_fee_info表
- select seq_user_fee_info.nextval into user_fee_info_nextval from dual;
- insert into user_fee_info(fee_id,user_id,fee_base,fee_pkg_month,fee_keep,fee_oth_month,fee_vpn,
- fee_shift,fee_local,fee_long,fee_inprov,fee_inprov_long,fee_outprov,fee_outprov_long,fee_inter,fee_inter_long,
- fee_cmnet,fee_trust,fee_ptp_sms,fee_mms,fee_magazine,fee_gprs,fee_wap,fee_data_month,
- fee_data,fee_ring,fee_display,fee_ext,fee_other,fee_all,fee_for_others,fee_by_others)
- values(
- user_fee_info_nextval,base_fee.user_id,
- decode(sign(base_fee.fee_base-user_fee_info_temp.fee_base),1,base_fee.fee_base-user_fee_info_temp.fee_base,0.00),
- decode(sign(base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month),1,base_fee.fee_pkg_month-user_fee_info_temp.fee_pkg_month,0.00),
- decode(sign(base_fee.fee_keep-user_fee_info_temp.fee_keep),1,base_fee.fee_keep-user_fee_info_temp.fee_keep,0.00),
- decode(sign(base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month),1,base_fee.fee_oth_month-user_fee_info_temp.fee_oth_month,0.00),
- decode(sign(base_fee.fee_vpn-user_fee_info_temp.fee_vpn),1,base_fee.fee_vpn-user_fee_info_temp.fee_vpn,0.00),
- decode(sign(base_fee.fee_shift-user_fee_info_temp.fee_shift),1,base_fee.fee_shift-user_fee_info_temp.fee_shift,0.00),
- decode(sign(base_fee.fee_local-user_fee_info_temp.fee_local),1,base_fee.fee_local-user_fee_info_temp.fee_local,0.00),
- decode(sign(base_fee.fee_long-user_fee_info_temp.fee_long),1,base_fee.fee_long-user_fee_info_temp.fee_long,0.00),
- decode(sign(base_fee.fee_inprov-user_fee_info_temp.fee_inprov),1,base_fee.fee_inprov-user_fee_info_temp.fee_inprov,0.00),
- decode(sign(base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long),1,base_fee.fee_inprov_long-user_fee_info_temp.fee_inprov_long,0.00),
- decode(sign(base_fee.fee_outprov-user_fee_info_temp.fee_outprov),1,base_fee.fee_outprov-user_fee_info_temp.fee_outprov,0.00),
- decode(sign(base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long),1,base_fee.fee_outprov_long-user_fee_info_temp.fee_outprov_long,0.00),
- decode(sign(base_fee.fee_inter-user_fee_info_temp.fee_inter),1,base_fee.fee_inter-user_fee_info_temp.fee_inter,0.00),
- decode(sign(base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long),1,base_fee.fee_inter_long-user_fee_info_temp.fee_inter_long,0.00),
- decode(sign(base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet),1,base_fee.fee_cmnet-user_fee_info_temp.fee_cmnet,0.00),
- decode(sign(base_fee.fee_trust-user_fee_info_temp.fee_trust),1,base_fee.fee_trust-user_fee_info_temp.fee_trust,0.00),
- decode(sign(base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms),1,base_fee.fee_ptp_sms-user_fee_info_temp.fee_ptp_sms,0.00),
- decode(sign(base_fee.fee_mms-user_fee_info_temp.fee_mms),1,base_fee.fee_mms-user_fee_info_temp.fee_mms,0.00),
- decode(sign(base_fee.fee_magazine-user_fee_info_temp.fee_magazine),1,base_fee.fee_magazine-user_fee_info_temp.fee_magazine,0.00),
- decode(sign(base_fee.fee_gprs-user_fee_info_temp.fee_gprs),1,base_fee.fee_gprs-user_fee_info_temp.fee_gprs,0.00),
- decode(sign(base_fee.fee_wap-user_fee_info_temp.fee_wap),1,base_fee.fee_wap-user_fee_info_temp.fee_wap,0.00),
- decode(sign(base_fee.fee_data_month-user_fee_info_temp.fee_data_month),1,base_fee.fee_data_month-user_fee_info_temp.fee_data_month,0.00),
- decode(sign(base_fee.fee_data-user_fee_info_temp.fee_data),1,base_fee.fee_data-user_fee_info_temp.fee_data,0.00),
- decode(sign(base_fee.fee_ring-user_fee_info_temp.fee_ring),1,base_fee
发表评论
-
产生一个 类似 SL201106090001 这种格式的流水号
2011-12-25 22:22 948要求格式为: SL ... -
oracle 方便快捷的数据导入/导出命令
2011-12-25 20:31 810一、数据库的导出 :3种模式:全库导出,用户导出,表导出 ... -
Oracle正则表达式
2011-12-24 19:44 732Oracle正则表达式 Oracle 10g数据 ... -
Oracle 修改带数据的字段类型
2011-12-24 19:41 831Oracle 修改带数据的字段类型 由于需求变动, ... -
PL/SQL几个有用的设置
2011-12-24 13:51 7181、自动补全 菜单Tools->Preferen ...
相关推荐
"TX_CON_0088_oracle_oracle存储过程实战_"这个主题深入探讨了如何在实际环境中应用Oracle存储过程,包括其创建、实现以及后台调用等关键环节。 首先,我们来了解如何创建存储过程。在Oracle中,创建一个存储过程...
本示例代码为我们提供了一个关于如何使用Oracle数据库处理XML文档的实际例子。通过学习这些知识点,开发者可以更好地理解和掌握如何利用Oracle数据库的强大功能来处理和操作XML数据,从而提高开发效率并实现更复杂的...
在JSF(JavaServer Faces)编程领域,"经过修改的jsf编程实战导航例子14"是一个关于学生班级管理系统的实战项目。这个项目基于《jsf编程实战导航》这本书中的例子,作者对原有的示例进行了扩展和完善,以涵盖更全面...
4. Oracle存储结构:深入理解表的存储方式,如heap tables、index-organized tables以及B树索引的工作原理。 5. 数据仓库与OLAP:介绍数据仓库设计原则,星型和雪花模式,以及Oracle的OLAP功能如物质化视图、快速聚...
总而言之,《Oracle Service Bus 11g 开发食谱》是一本不可多得的实战指南,对于使用Oracle Service Bus 11g开发企业级集成解决方案的开发者来说,是一本宝贵的参考资料。通过阅读本书,开发者可以提升自己的技能,...
PLSQL,全称为Procedural Language/SQL,是Oracle数据库提供的一个编程环境,结合了SQL的查询能力与过程式编程语言的功能,使得开发者能够编写存储过程、函数、触发器等数据库对象,从而实现复杂的数据库管理和应用...
【描述】"ibatis演示例子 开发环境:eclipse4.3 ibatis2.3 oracle10g"这部分信息表明,开发过程中使用了Eclipse IDE的4.3版本作为开发工具,iBATIS框架的2.3版本,以及Oracle数据库的10g版本。Eclipse是Java开发中...
同时,了解Oracle数据库的特性,如索引、存储过程、触发器和视图,对于设计高效的数据访问层至关重要。 Servlet是Java Web开发的关键组件,用于扩展Web服务器的功能。Servlet可以接收和响应HTTP请求,生成动态内容...
ADO.NET是微软.NET框架下的一种数据访问技术,用于与各种数据库进行交互,包括SQL Server、Oracle、MySQL等。...实际例子将使理论知识更具实践意义,帮助开发者更好地应对实际项目中的数据访问需求。
数据库部分可能是MySQL、Oracle或其他关系型数据库,用于存储人力资源管理系统的各种数据,如员工个人信息、部门信息、职位信息等。数据库设计的好坏直接影响到系统的性能和扩展性,因此合理的数据库模型和索引优化...
SSH在Java开发中是一个非常重要的概念,全称为Spring、...总之,这个"JAVA+很好的ssh例子"是一个宝贵的学习资源,通过深入研究和实践,你可以快速掌握Java企业级开发的核心技术,并为自己的职业道路打下坚实的基础。
`SqlCommand`的`CommandType`属性设置为`StoredProcedure`,即可调用存储过程。源码可能包含调用存储过程并处理返回结果的示例。 6. **参数化查询**: 避免SQL注入攻击的最佳实践是使用参数化查询。`SqlCommand`...
【标题】"jsp入门 包含简单的登录注册例子"是一个非常适合初学者的教程,它旨在帮助新接触JavaServer Pages(JSP)技术的开发者...通过这个过程,你将学习到Web开发中的核心概念,为将来更复杂的项目打下坚实的基础。
在IT领域,构建一个图书管理系统是一项常见的学习与实战项目,它能够帮助我们深入理解Java编程语言以及Web应用开发中的Servlet技术。本项目以“图书管理系统”为主题,结合Java和Servlet,提供了一个实际的案例分析...
JavaFX是Oracle公司推出的一种用于开发桌面、移动和Web应用的现代Java GUI框架。它基于Java语言,提供了丰富的UI控件和动画效果,使得开发者能够轻松创建出美观且交互性强的应用程序。JavaFX支持FXML(FXML是用于...
《实战JSP开发》这本书是针对Java服务器页面(JSP)技术的一本实践教程,旨在帮助读者通过实际项目开发来掌握JSP的核心概念和技术。源代码"loginModule-src.rar"包含的是书中关于登录模块的实现代码,对于学习JSP...
读者可以在欣赏一个个有趣例子的过程中,不知不觉具备开发真正商业项目的能力。 本书集实用性、思想性、趣味性于一体,内容共分为技术基础总结、系统架构设计思想及项目实战解析三部分,随书所附光盘收录大量实例...
在IT行业中,数据库是存储和管理数据的核心工具,而连接数据库是进行数据操作的第一步。在本实战教程中,我们将探讨如何使用ActiveX Data Objects(ADO)技术在MFC(Microsoft Foundation Classes)环境下,通过...
5. **数据库设计**:项目中可能涉及到MySQL或Oracle等关系型数据库,用于存储人事资源数据。设计合理的数据库表结构,编写高效的SQL查询语句是项目的关键部分。 6. **Web前端技术**:可能使用HTML、CSS、JavaScript...
读者可以在欣赏一个个有趣例子的过程中,不知不觉具备开发真正商业项目的能力。 本书集实用性、思想性、趣味性于一体,内容共分为技术基础总结、系统架构设计思想及项目实战解析三部分,随书所附光盘收录大量实例...