clear buffer
set define off
set sqlblanklines on
spool m_200_sproc.log
--connect
--ISMP V4 Order通用鉴权批价(电信版本) 实现性能:订购鉴权批价
--订购入库、退订入库、产品收费期揭示鉴权、暂停/激活产品订购关系鉴权
--暂停/激活产品订购关系更新
--订购鉴权批价
prompt zxdbm_200.slp_200_telicomsubreq
create or replace procedure zxdbm_200.slp_200_telicomsubreq
(
i_oa in varchar2, --发起方/赠送方用户号码i_ua in varchar2, --应用方/受赠方用户号码i_oatype in number, --发起方地址类型i_datype in number, --应用方地址类型i_servicetype in number, --业务能力类型i_serviceflowtype in number, --业务流程类型i_srvprodid in varchar2, --业务/产品代码i_actiontype in number, --动作类型i_cmdchannel in number, --动作起源i_countrycode in varchar2, --国家码i_spaccesscode in varchar2, --antuprice音讯中的SP接入码i_isthird in number, --0:一般订购 1:赠送i_silent in number, --缄默去激活开关i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_direct in number, --订购方向 0:正向订购 1:SP反向定购i_supportproductid in number, --同步SP、SP下发应用service还是productid 0-serviceid 1-productidi_prepaidtype in number, --预付费接口类型 1-OCS 2-非OCS 3-依据号段抉择是OCS或者非OCSi_monthconsumedlimit in number, --零碎级月生产限度金额i_isnondreplay in number, --是否须要二次确认,1-不须要,0-须要i_checkpseudocode in number, --零碎开关:是否反对伪码 0-不反对 1-反对i_provinceorder in number, --零碎开关:是否反对跨省赠送 0-不反对 1-反对i_rentday in number, --账期截止日期i_mutidbmode in number, --是否多DB环境 0:否 1:是i_isfromnmsc in number, --是否nmsc过去的音讯 0:否 1:是i_spordernoticeuser in number, --sp反向订购是否与用户交互(告诉用户,二次确认) 0:否 1:是i_freemodule in number, --收费期计费形式: 0:失常形式 1:优惠形式i_eventid in varchar2, --事件IDi_channelid in varchar2, --渠道商ID--added by youqunxia 20130805 Order3.02.01i_webgwcnfmswitch in number, --用来管制来自WEBGW的申请,是否进行二次确认,0-不须要 1-须要i_startcmdchannel in number, --二次确认时的最后起源动作起源i_isexperience in number, --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0i_fullmonthmode in number, --退订应用足月模式 0-可用到订购日 1-可用到订购日前一天i_effectiveswitch in number, --VSOP发动的订购退订立刻失效开关是否关上,0-敞开,1-关上o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_srcmsisdn out varchar2, --去掉前缀的发起方/赠送方用户号码o_usemsisdn out varchar2, --去掉前缀的应用方/受赠方用户号码o_paymsisdn out varchar2, --去掉前缀的计费方号码o_srcmsisdntype out number, --发起方号码类型,1:msisdn,2:phs,3:pstno_usemsisdntype out number, --应用方号码类型,1:msisdn,2:phs,3:pstno_userindex out number, --应用方号码序号o_payuserindex out number, --付费方号码序号o_needreplay out number, --产品订购是否须要用户二次确认,0-不须要,1-须要o_paytype out number, --计费号码的付费类型 0:后付费 1:预付费 2:准预付费o_oppaytype out number, --话单专用付费类型o_scptype out number, --对预付费扣费的设施类型 1:OCS;2:非OCSo_subfee out number, --本次订购须要扣取的费用o_colortype out number, --应用方号码名单类型 0-普通用户,1-黑名单,2-白名单, 3-灰名单,4-红名单o_usertype out number, --应用方类型 1-普通用户 2-运营商测试用户 3-SP测试用户o_producttype out number, --产品类型 1-失常产品 2-测试产品o_cpid out varchar2, --CP/SP代码o_cpindex out number, --CP/SP序号o_cpcnshortname out varchar2, --CP/SP名称o_cpsubscribeurl out varchar2, --CP/SP订购URLo_cptype out number, --CP/SP类型 0:本省 1:是全国业务o_protocoltype out number, --定购同步协定类型0-ismp(wbs形式),1-smgp2.0(cngp1.0),2-smgp3.0o_msgtosp out varchar2, --SMGP/CNGP同步sp的音讯内容o_cnfmmsgtosp out varchar2, --SMGP2.0/CNGP1.0向sp发送同步确认音讯内容o_customersrvtel out varchar2, --CP/SP客服电话o_serviceid out varchar2, --业务代码o_serviceindex out number, --业务序号o_servicename out varchar2, --业务名称o_productid out varchar2, --产品代码o_productindex out number, --产品序号o_productname out varchar2, --产品名称o_smschargingcn out varchar2, --产品资费短信形容o_autocontinue out number, --周期性订购是否主动续订o_servicetype out number, --产品业务能力类型o_subcapability out number, --产品业务能力子类型o_srvtypeid out varchar2, --业务能力编码,对应ssys_service_type表中的srvtypeido_corpid out varchar2, --团体代码o_corpindex out number, --团体序号o_corpcnshortname out varchar2, --团体名称o_paymode out varchar2, --团体付费模式 团体付费/集体付费o_freetime out varchar2, --产品订购关系收费期o_nextrentdate out varchar2, --产品订购关系下次扣租日期o_substarttime out varchar2, --产品订购关系失效工夫o_subendtime out varchar2, --产品订购关系生效工夫o_substatus out number, --产品订购关系状态o_lastrenttime out varchar2, --产品订购关系上次扣租工夫o_payfordate out varchar2, --月租已付日期o_fixusetimes out number, --产品包量值o_chargetype out number, --产品计费类型o_cyctype out number, --产品周期类型o_linknum out varchar2, --业务话单中同一个流程中二次确认前后话单的关联o_maxlimitfee out varchar2, --用户月生产限额o_pseudocode out varchar2, --伪码o_pcodemsisdnswitch out number, --伪码和实在号码之间是否有转换: 0否 1实在号码转化伪码 2伪码转化为实在号码o_chanelplayerstate out number, --cp/sp状态,0-申请,1-失常,2-暂停(暂停代收费),3-预登记,4-登记,5-解冻,21-暂停端口o_eventstate out number, --0,失常 1,登记o_ordertype out number, --定购类型,1-定购,2-点播,3-不须要定购点播o_spaccesscode out varchar2, --SP接入码o_cancelaccesscode out varchar2, --产品退订接入码o_maincapability out number, --组合业务主业务能力类型o_submaincapability out number, --组合业务主业务能力子类型o_cpsrvtype out number, --CP服务类型:0:CP+SP,1:CP,2:SP ;3:自营业务SPo_cancelproductid out varchar2, --被189替换的产品代码o_issecondproduct out number, --订购流程子类型 0:一般订购 1:业务订购 2:待生效订购关系订购 3:纯包量反复订购 6:可变价的反复订购 7:体验转正式的反复订购o_cancelfeaturecode out varchar2, --短信,彩信退订指令o_provincesend out number, --是否跨省赠送 0.否 1.跨省赠送 2.跨省受增o_cdrbegintime out varchar2, --话单计费开始工夫o_cdrendtime out varchar2, --话单计费完结工夫o_cnfmtype out number, --产品二次确认类型 0:一般 1:0资费 2:收费期o_validmode out number, --产品属性:订购失效形式:0-立刻失效,1-下一帐期失效,2-N周期后失效,3-指定日期失效o_mutiluserexit out number, --用户存在状况: 0 多DB分库用户不存在 1 多DB分库用户存在或者单DB用户存在o_popustop out varchar2, --推广期完结工夫o_popuexist out number, --长期寄存订购时是否存在推广期: 0目前存在收费推广期 1.目前存在计费推广期 2.目前不在推广期或无推广期 3. 订购工夫在推广期,失效工夫在推广期之外;o_freenoticenow out number, --长期寄存收费期揭示短信立即下发(首次订购收费期为1天的产品): 0否 1是o_freedays out number, --长期寄存收费期揭示短信立即下发(首次订购收费期为1天的产品): 0否 1是o_productpkgname out varchar2, --套餐名称o_freenotitype out number, --收费期揭示形式 dwFreeNotiType 0:调用收费n天的短息模板,1:收费到月底 2:收费n小时 3:试用到足月 默认为0o_needcharge out number, --是否须要扣费 0否 1是 (只用于赠送状况下的替换)o_cityid out varchar2, --用户表中的cityid--added by youqunxia 2013.02.18o_freenotify out number, --收费试用期到解决形式,0-到期主动免费,1-到期需用户确认订购,2-到期主动勾销,3-到期用户确认退订--added by youqunxia 20130818 Order3.02.01o_hassubscription out number, --可变价订购时,是否有订购关系,0-否,1-是o_rentfee out number, --周期性费用金额,0-无此类费用o_haswebgw out number, --是否是签约WEBGW业务能力的SP,0-否,1-是o_lastvarifee out number, --WEBGW可变价时,当存在订购关系时,保留上次订购关系表中的可变价格o_issynctooidd out number, --是否同步订购关系给OIDD,0-否,1-是o_isexperience out varchar2, --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0o_chargetime out varchar2 --首次扣费时间
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_sysdate8 char(8) := substr(v_sysdate14,1,8);v_sysmonth6 char(6) := substr(v_sysdate14,1,6);v_curmonth number(2) := to_number(substr(v_sysdate14,5,2)); --长期寄存以后月份v_curstrmonth char(2) := lpad(to_char(v_curmonth),2,'0'); --长期寄存以后月份,字符型v_curmonthendtime char(14) := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')),'yyyymmdd')||'235959';v_freenoticetime char(14) := '00000000000000';v_unsubenddate char(8) := substr(v_sysdate14,1,8);v_maincapability number(10) := 0; --长期寄存组合业务主业务能力类型v_submaincapability number(10) := 0; --长期寄存组合业务主业务能力子类型v_countrycode varchar2(5) := i_countrycode; --长期寄存国家码v_tempitem number(10) := 0; --长期寄存0或者推广期的计费子序号v_devexist number(3) := 1; --长期寄存是否存在对应设施v_isservicesub number(3) := 0; --长期寄存是否业务订购(189邮箱),是否依据serviceid查找定购关系,0:否,1:是v_hasrecord number(3) := 0; --长期寄存产品订购关系是否存在v_leftdays number(3) := 0; --长期寄存当月所剩天数v_monthdays number(3) := 30; --当月总天数v_subfee number(10) := 0; --长期寄存本次订购须要扣除的费用v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_usedamounts number(10) := 0; --长期寄存累计金额v_tmpint number(10) := 0; --长期寄存长期数值v_spaccesscode varchar2(40) := ' '; --长期寄存sp接入码v_nextrentfee number(10) := 0; --长期寄存待失效包月费v_rentfeevalidate char(6) := ' '; --长期寄存待失效包月费率失效月v_tag number(3) := 0; --长期寄存标记位 ,退订补款产品本月订购过 0:否 1:是v_totaldctemplate varchar2(500) :=' '; --长期寄存解析模板:产品分档费率v_dealtemplate varchar2(500) :=' '; --长期寄存解析模板:待解析的分档段v_totaldclength number(3) := 0; --长期寄存解析模板: 分档字符串的长度v_totaldcsum number(10) := 0; --长期寄存解析模板: 分档总费用v_index0 number(3) := 0; --长期寄存解析模板: 分档字符串中&的地位v_index1 number(3) := 0; --长期寄存解析模板: 分档字符串中;的地位v_popuexist number(3) := 2; --长期寄存订购时是否存在推广期: 0目前存在收费推广期 1.目前存在计费推广期 2.目前不在推广期或无推广期 3. 订购工夫在推广期,失效工夫在推广期之外;v_testuser number(3) := 0; --长期寄存产品属性:是否试用,0-否,1-是 仅400用户应用v_freeuseflag number(3) := 0; --sms,mms,wap,mvs产品含有该字段,收费体验标识0:无试用期1:有,试用到月底,2:依照freedays取值,单位为小时,3:依照freedays取值,单位为月,4:依照freedays取值,单位为天。其余不含改字段的产品只示意收费天数v_freenotitype number(3) := 0; --寄存流媒体产品收费期告诉类型v_rentday number(3) := i_rentday; --长期寄存帐期工夫,因为要转换,所以申请长期变量v_ismutidb number(3,0) := 0; ---0示意为单DB模式 1示意为多DB模式v_dblink varchar2(40) := ' '; ---仅在多DB模式下,返回对应号码的无效DBLINKv_oa zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存发起方/赠送方用户号码v_ua zxdbm_ismp.susr_basic.usercode%type := i_ua; --长期寄存应用方/受赠方用户号码v_srcmsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存发起方/赠送方用户号码v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存应用方/受赠方用户号码v_srcuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存发起方用户序号v_srcusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存发起方用户类型v_srcpaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存发起方用户付费类型v_srcblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存发起方是否进入黑名单v_srcwhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存发起方是否进入白名单v_srcredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存发起方是否进入红名单v_srcblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存发起方黑名单级别v_srcwhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存发起方白名单级别v_srcmsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存发起方号码类型v_srcuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存发起方状态v_srcactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存发起方激活状态v_srcoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存发起方话单专用付费类型v_srccorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存发起方团体序号v_srcusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存发起方上次应用工夫v_srcmaxlimitfee zxdbm_ismp.susr_basic.maxlimitfee%type := 0; --长期寄存发起方最大生产限额v_srcgraylist zxdbm_ismp.susr_basic.graylist%type := 0; --长期寄存发起方是否进入灰名单v_srcgraylevel zxdbm_ismp.susr_basic.graylevel%type := 0; --长期寄存发起方灰名单级别v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_useusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存应用方用户类型v_usepaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存应用方用户付费类型v_useblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存应用方是否进入黑名单v_usewhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存应用方是否进入白名单v_useredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存应用方是否进入红名单v_useblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存应用方黑名单级别v_usewhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存应用方白名单级别v_usemsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存应用方号码类型v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存应用方话单专用付费类型v_usecorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存应用方团体序号v_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫v_usemaxlimitfee zxdbm_ismp.susr_basic.maxlimitfee%type := 0; --长期寄存应用方最大生产限额v_usegraylist zxdbm_ismp.susr_basic.graylist%type := 0; --长期寄存应用方是否进入灰名单v_usegraylevel zxdbm_ismp.susr_basic.graylevel%type := 0; --长期寄存应用方灰名单级别v_paymsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存计费方v_paymsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存计费方号码类型v_cardtype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存用户付费类型0-后付费,1-预付费,2-准预付费v_srcusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存计费方号码类型v_useusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存计费方号码类型v_srctestcpindex zxdbm_ismp.susr_testgroup_member.cpindex%type := 0; --长期寄存CP/SP序号v_usetestcpindex zxdbm_ismp.susr_testgroup_member.cpindex%type := 0; --长期寄存CP/SP序号v_srccorpid zxdbm_ismp.susr_corp.corpid%type := ' '; --长期寄存团体代码v_srccorpstatus zxdbm_ismp.susr_corp.status%type := 0; --长期寄存团体状态v_srccorppaymsisdn zxdbm_ismp.susr_corp.paymsisdn%type := ' '; --长期寄存团体付费号码v_corpname zxdbm_ismp.susr_corp.corpcnshortname%type := ' '; --长期寄存团体中文名简写v_productindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存产品序号v_cancelproductindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存被189替换的产品序号v_needreplay zxdbm_200.s200_product.needreplay%type := 0; --长期寄存是否须要二次确认,0-不须要,1-须要v_validmode zxdbm_200.s200_product.validmode%type := 0; --长期寄存定购失效形式,0-立刻失效,1-下一帐期失效,2-n周期后失效,3-指定日期失效v_validcyctype zxdbm_200.s200_product.validcyctype%type := 0; --长期寄存周期形式0-非周期,1-天,2-周,3-月,定购失效形式为2时失效v_validcycparam zxdbm_200.s200_product.validcycparam%type := 0; --长期寄存周期参数,定购失效形式为2时失效v_validdate zxdbm_200.s200_product.validdate%type := v_sysdate14; --长期寄存指定失效日期v_subfeemode zxdbm_200.s200_product.subfeemode%type := 1; --长期寄存定购当月免费形式v_cancelsubfeemode zxdbm_200.s200_product.subfeemode%type := 1; --长期寄存被替换定购当月免费形式v_subfeedays zxdbm_200.s200_product.subfeedays%type := 0; --长期寄存免费日期取值范畴为0~28,0示意本月全副收费,其余示意 n号之后收费。v_freedays zxdbm_200.s200_product.freedays%type := 0; --长期寄存收费试用天数v_freenotify zxdbm_200.s200_product.freenotify%type := 0; --长期寄存收费试用期到解决形式,0-到期主动免费,1-到期需用户确认,2-到期主动勾销v_popustart zxdbm_200.s200_product.popularizestart%type := v_sysdate8; --长期寄存推广期开始工夫v_popustop zxdbm_200.s200_product.popularizestop%type := v_sysdate8; --长期寄存推广期完结工夫v_popuitem zxdbm_200.s200_product.popularizeitem%type := 0; --长期寄存推广期计费计划,0示意收费,1-推广期计划v_cancelpopustart zxdbm_200.s200_product.popularizestart%type := v_sysdate8; --长期寄存被替换产品推广期开始工夫v_cancelpopustop zxdbm_200.s200_product.popularizestop%type := v_sysdate8; --长期寄存被替换产品推广期完结工夫v_cancelpopuitem zxdbm_200.s200_product.popularizeitem%type := 0; --长期寄存被替换产品推广期计费计划,0示意收费,1-推广期计划v_needcharge zxdbm_200.s200_product.needcharge%type := 1; --长期寄存是否须要计费,0-收费,1-须要计费v_cancelneedcharge zxdbm_200.s200_product.needcharge%type := 1; --长期寄存是否须要计费,0-收费,1-须要计费v_productname zxdbm_200.s200_product.productname%type := ' '; --长期寄存产品名称v_productstatus zxdbm_200.s200_product.status%type := 0; --长期寄存产品状态v_onlyforcorp zxdbm_200.s200_product.onlyforcorp%type := 0; --长期寄存是否团体专用产品0:个人用户专用1:团体专用v_productstarttime zxdbm_200.s200_product.starttime%type := v_sysdate14; --长期寄存产品失效工夫v_productendtime zxdbm_200.s200_product.endtime%type := '99991231235959'; --长期寄存产品终止工夫v_workflow zxdbm_200.s200_product.workflow%type := 0; --长期寄存工作流状态v_workflowlife zxdbm_200.s200_product.workflowlife%type := 0; --长期寄存工作流流程状态v_cpindex zxdbm_200.s200_product.cpindex%type := 0; --长期寄存CP/SP序号v_serviceindex zxdbm_200.s200_product.serviceindex%type := 0; --长期寄存业务序号v_smschargingcn zxdbm_200.s200_product.smschargingcn%type := ' '; --长期寄存产品资费短信形容v_canbepresent zxdbm_200.s200_product.canbepresent%type := 0; --长期寄存是否可赠送,0-不可赠送,1-可赠送v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --长期寄存业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 1; --长期寄存业务能力子类型1-3G,2-PHS,3-ISAG,默认为3g业务能力(仅电信应用,其余营运商皆默认为1)v_srvprodid zxdbm_200.s200_product.productid%type := i_srvprodid; --长期寄存业务产品代码v_productid zxdbm_200.s200_product.productid%type := ' '; --长期寄存产品代码v_cancelproductid zxdbm_200.s200_product.productid%type := ' '; --长期寄存被189替换的产品代码v_onlyforpkg zxdbm_200.s200_product.onlyforpkg%type := 0; --长期寄存是否套餐专用产品v_ordertype zxdbm_200.s200_product.ordertype%type := 1; --长期寄存产品订购类型v_backfeemode zxdbm_200.s200_product.backfeemode%type := 0; --长期寄存退定补款形式,0-不补款,1-按帐期残余理论天数补款v_productsource zxdbm_200.s200_product.productsource%type := 0; --产品起源0:ISMP 公布的产品1:同步自全国SPMS 的产品2:提供给漫游用户的产品v_invalidmode zxdbm_200.s200_product.invalidmode%type := 0; --长期寄存退订失效形式,0 立刻失效,1-下一帐期失效 2-退定后可应用足月v_chargetype zxdbm_200.s200_product_fee.chargetype%type := 0; --长期寄存计费类型v_cancelchargetype zxdbm_200.s200_product_fee.chargetype%type := 0; --长期寄存被替换产品计费类型v_jbchargetype zxdbm_200.s200_product_fee.chargetype%type := 0; --长期寄存推广期产品的根本计费费率的计费类型v_subchargetype zxdbm_200.s200_product_fee.subchargetype%type := 0; --长期寄存计费子类型v_cyctype zxdbm_200.s200_product_fee.cyctype%type := 0; --长期寄存周期类型0-非周期,1-周期性v_cycunit zxdbm_200.s200_product_fee.cycunit%type := 0; --长期寄存周期单位 0-无,1-天,2-周,3-月,4-半年,5-年,6-小时,7-分钟,8-秒v_cycparam zxdbm_200.s200_product_fee.cycparam%type := 0; --长期寄存周期参数v_jbcyctype zxdbm_200.s200_product_fee.cyctype%type := 0; --长期寄存推广期产品的根本计费费率的周期类型0-非周期,1-周期性v_jbcycunit zxdbm_200.s200_product_fee.cycunit%type := 0; --长期寄存推广期产品的根本计费费率的周期单位 0-无,1-天,2-周,3-月,4-半年,5-年,6-小时,7-分钟,8-秒v_jbcycparam zxdbm_200.s200_product_fee.cycparam%type := 0; --长期寄存推广期产品的根本计费费率的周期参数v_rentfee zxdbm_200.s200_product_fee.rentfee%type := 0; --长期寄存周期性费用金额v_fixfee zxdbm_200.s200_product_fee.fixfee%type := 0; --长期寄存包量费用v_cancelfixfee zxdbm_200.s200_product_fee.fixfee%type := 0; --长期寄存被替换产品包量费用v_fixusetimes zxdbm_200.s200_product_fee.fixusetimes%type := 0; --长期寄存包量应用值,0-无限度v_autocontinue zxdbm_200.s200_product_fee.autocontinue%type := 0; --长期寄存周期性定购,是否主动续订v_minlimitfee zxdbm_200.s200_product_fee.minlimitfee%type := 0; --长期寄存保底费用,0-无保底费v_usecomfee zxdbm_200.s200_product_fee.usecomfee%type := 1; --长期寄存限度(量、工夫)外应用形式,1-应用根本费率,0-不容许持续应用v_totaldiscount zxdbm_200.s200_product_fee.totaldiscount%type := ' '; --长期寄存限度(量、工夫)外应用形式,1-应用根本费率,0-不容许持续应用v_cancelrentfee zxdbm_200.s200_product_fee.rentfee%type := 0; --长期寄存业务订购原产品的周期性费用金额v_cancelminlimitfee zxdbm_200.s200_product_fee.minlimitfee%type := 0; --长期寄存业务订购原产品的保底费用,0-无保底费v_description zxdbm_200.s200_product_fee.description%type := 0; --产品费率形容v_serviceid zxdbm_200.s200_service.serviceid%type := ' '; --长期寄存业务代码v_servicestatus zxdbm_200.s200_service.status%type := 0; --长期寄存业务状态v_srvcolorlist zxdbm_200.s200_service.colorlist%type := 0; --长期寄存是否有色彩列表,0-无,1-黑名单,2-白名单v_servicename zxdbm_200.s200_service.servicename%type := ' '; --长期寄存业务名称v_subsrvtype zxdbm_200.s200_service.subsrvtype%type := 0; --长期寄存业务子类型v_orderupdateurl zxdbm_200.s200_service.orderupdateurl%type := ' '; --长期寄存业务表中订购关系更新告诉URLv_srcopenstatus zxdbm_200.s200_service_useropen.status%type := 1; --长期寄存发起方集体能力开明,0-敞开,1-开明v_useopenstatus zxdbm_200.s200_service_useropen.status%type := 1; --长期寄存应用方集体能力开明,0-敞开,1-开明v_protocoltype zxdbm_200.s200_sp_service_type.protocoltype%type := 0; --长期寄存定购同步协定类型0-ismp(wbs形式),1-smgp2.0(cngp1.0),2-smgp3.0(cngp1.0扩大)--added by youqunxia 20130817 Order3.02.01v_spsrvstatus zxdbm_200.s200_sp_service_type.status%type := 1; --长期寄存SP业务能力状态v_spsrvstarttime zxdbm_200.s200_sp_service_type.starttime%type := '00000000000000'; --长期寄存业务能力签约失效工夫v_spsrvendtime zxdbm_200.s200_sp_service_type.endtime%type := '99991231235959'; --长期寄存业务能力签约生效工夫v_servicesort zxdbm_200.s200_service.servicesort%type := 0; --业务归属 0:一般业务、1:属于OIDD 2:属于定位v_isexperience zxdbm_200.s200_user_subscription.isexperience%type := to_char(i_isexperience); --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0v_chargetime zxdbm_200.s200_user_subscription.chargetime%type; --首次扣费时间v_isexperience1 zxdbm_200.s200_user_subscription.isexperience%type := '0'; --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0v_freetime zxdbm_200.s200_user_subscription.freetime%type := '00000000000000'; --长期寄存订购关系收费截止期v_substarttime zxdbm_200.s200_user_subscription.starttime%type := v_sysdate14; --长期寄存订购关系失效工夫v_subendtime zxdbm_200.s200_user_subscription.endtime%type := '99991231235959'; --长期寄存订购关系生效工夫v_substatus zxdbm_200.s200_user_subscription.status%type := 0; --长期寄存订购关系状态v_cursubstatus zxdbm_200.s200_user_subscription.status%type := 0; --长期寄存以后订购关系状态v_lastrenttime zxdbm_200.s200_user_subscription.lastrenttime%type := '00000000000000'; --长期寄存上次扣租工夫v_cancellastrenttime zxdbm_200.s200_user_subscription.lastrenttime%type := '00000000000000'; --长期寄存被189替换的产品上次扣租工夫v_cancelnextrentdate zxdbm_200.s200_user_subscription.lastrenttime%type := '99991231'; --长期寄存被189替换的产品下次扣租日期v_payfordate zxdbm_200.s200_user_subscription.payfordate%type := '00000000'; --长期寄存月租已付日期v_cancelpayfordate zxdbm_200.s200_user_subscription.payfordate%type := '00000000'; --长期寄存月租已付日期v_productpkgindex zxdbm_200.s200_user_subscription.productpkgindex%type := 0; --长期寄存套餐序号v_cancelfreetime zxdbm_200.s200_user_subscription.freetime%type := '00000000000000'; --长期寄存订购关系收费截止期--added by youqunxia20130907 order3.02.01v_lastvarifee zxdbm_200.s200_user_subscription.varifee%type := ''; --长期寄存以后订购关系中的前一次可变价格 v_nextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := '99991231'; --长期寄存下次扣租日期v_cancelisexperience zxdbm_200.s200_user_subscription.isexperience%type := '0'; --长期寄存被替换的产品订购类型 v_cpid zxdbm_ismp.scp_basic.cpid%type := ' '; --长期寄存CP/SP代码v_cpstatus zxdbm_ismp.scp_basic.status%type := 0; --长期寄存CP/SP代码v_cpsubscribeurl zxdbm_ismp.scp_basic.cpsubscribeurl%type := ' '; --长期寄存CP/SP订购URLv_hasblacklist zxdbm_ismp.scp_basic.hasblacklist%type := 0; --长期寄存是否有黑名单管制 0-无,1-有v_cptype zxdbm_ismp.scp_basic.cptype%type := 2; --长期寄存CP/SP类型v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_insubblacklist zxdbm_ismp.scp_basic.insubblacklist%type := 0; --长期寄存限度订购SP黑名单标识v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --长期寄存CP/SP中文名简写v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' '; --长期寄存CP/SP客服电话v_perssrvopen zxdbm_ismp.ssys_service_type.perssrvopen%type := 1; --长期寄存集体能力缺省开明,0-敞开,1-开明v_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := ' '; --长期寄存话单中的srvtypeidv_productsubmode zxdbm_ismp.ssrv_corp_product.subscribemode%type := 0; --长期寄存定购形式,0-必须团体管理员定购,1-团体管理员与团体成员均可定购v_productpayparty zxdbm_ismp.ssrv_corp_product.payparty%type := 2; --长期寄存团体专用产品付费方 1-团体付费 2-集体付费v_corpproductstatus zxdbm_ismp.ssrv_corp_product.status%type := 0; --长期寄存团体与产品关联状态 0-失常;1-删除v_phoneindex zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存号段序号v_phoneindexa zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存A省号段序号,跨省赠送v_phoneindexb zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存B省号段序号,跨省赠送v_attach zxdbm_ismp.ssys_phone.attach%type := 0; --长期寄存预付费归属,0-未知,1-OCS,2-RTBPv_expiredate zxdbm_ismp.ssrv_user_totalamount.expiredate%type := to_number(substr(v_curmonthendtime,1,8));--长期寄存过期日期v_srctypesrvopen zxdbm_ismp.ssrv_user_perssrvopen.perssrvopen%type := 1; --长期寄存发起方集体能力开明,0-敞开,1-开明v_usetypesrvopen zxdbm_ismp.ssrv_user_perssrvopen.perssrvopen%type := 1; --长期寄存应用方集体能力开明,0-敞开,1-开明
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_srcmsisdn := ' ';o_usemsisdn := ' ';o_paymsisdn := ' ';o_srcmsisdntype := 1;o_usemsisdntype := 1;o_userindex := 0;o_payuserindex := 0;o_needreplay := 0;o_paytype := 0;o_oppaytype := 0;o_scptype := 2;o_subfee := 0;o_colortype := 0;o_usertype := 0;o_producttype := 1;o_cpid := ' ';o_cpindex := 0;o_cpcnshortname := ' ';o_cpsubscribeurl := ' ';o_cptype := 0;o_protocoltype := 0;o_msgtosp := ' ';o_cnfmmsgtosp := ' ';o_customersrvtel := ' ';o_serviceid := ' ';o_serviceindex := 0;o_servicename := ' ';o_productid := ' ';o_productindex := 0;o_productname := ' ';o_smschargingcn := ' ';o_autocontinue := 0;o_servicetype := 0;o_subcapability := 0;o_srvtypeid := ' ';o_corpid := ' ';o_corpindex := 0;o_corpcnshortname := ' ';o_paymode := '集体付费';o_freetime := v_sysdate14;o_nextrentdate := '99991231';o_substarttime := v_sysdate14;o_subendtime := '99991231235959';o_substatus := 0;o_lastrenttime := '00000000000000';o_payfordate := '00000000';o_fixusetimes := 0;o_chargetype := 0;o_cyctype := 0;o_linknum := ' ';o_maxlimitfee := '0';o_pseudocode := '';o_pcodemsisdnswitch := 0;o_chanelplayerstate := 0;o_eventstate := 1;o_ordertype := 1;o_spaccesscode := i_spaccesscode;o_maincapability := 0;o_submaincapability := 0;o_cpsrvtype := 0;o_cancelproductid := ' ';o_issecondproduct := 0;o_cancelfeaturecode := ' ';o_cancelaccesscode := ' ';o_provincesend := 0;o_cdrbegintime := v_sysdate14;o_cdrendtime := v_curmonthendtime;o_cnfmtype := 0;o_validmode := 0;o_mutiluserexit := 1;o_popustop := v_popustop;o_popuexist := v_popuexist;o_freenoticenow := 0;o_freedays := 0;o_productpkgname := ' ';o_freenotitype := 0;o_needcharge := 0;o_cityid := '';--added by youqunxia 2013.02.18o_freenotify := 1;--added by youqunxia 20130818 Order3.02.01o_hassubscription := 0;o_rentfee := 0;o_haswebgw := 1;o_lastvarifee := '';o_issynctooidd := 0;o_isexperience := '0';o_chargetime := '';
/
--part-- --订购-- 预处理
*/
--批量操作不进行鉴权,由业务从用户表中查询处理--modied by youqunxia20130530 order2.07.10if i_oatype not in (1,2,3,4) then o_retcode := 107; o_debugpos := 1; o_debuginfo := 'i_oatype is not valid.'; return;end if;if v_rentday = 0 then v_rentday := to_number(substr(v_sysdate8,7,2)); if v_rentday >= 27 then v_rentday := v_rentday - 18; end if;end if;--发起方、应用方用户号码去前缀v_oa := ltrim(rtrim(nvl(i_oa,'0')));v_ua := ltrim(rtrim(nvl(i_ua,'0')));if v_oa like ('+' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 2);elsif v_oa like ('00' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 3);elsif v_oa like (v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 1);end if;if (substr(v_oa,1,1) <> '0') and (i_oatype = 4) then v_oa := '0' || v_oa;end if;if v_ua like ('+' || v_countrycode || '%') then v_ua := substr(v_ua, length(v_countrycode) + 2);elsif v_ua like ('00' || v_countrycode || '%') then v_ua := substr(v_ua, length(v_countrycode) + 3);elsif v_ua like (v_countrycode || '%') then v_ua := substr(v_ua, length(v_countrycode) + 1);end if;v_srcmsisdn := v_oa;if (i_isthird = 1) then v_usemsisdn := v_ua;else v_usemsisdn := v_oa;end if;o_srcmsisdn := v_srcmsisdn;o_usemsisdn := v_usemsisdn;o_paymsisdn := v_srcmsisdn;if (v_srcmsisdn = '0') or (v_usemsisdn = '0') then o_retcode := 1001; o_debugpos := 2; o_debuginfo := 'v_srcmsisdn or v_usemsisdn is not valid.'; return;end if;
/
--part-- --订购-- 是否跨省赠送的鉴权(依据号段鉴权是否本省用户)
--赠送他省不对DA鉴权,来自他省赠送不对OA鉴权
/
if i_provinceorder = 1 then if i_actiontype in (1,17) and (i_isfromnmsc = 1) then begin select phoneindex into v_phoneindexa from zxdbm_ismp.ssys_phone where startprefix <= substr(v_srcmsisdn,1,length(startprefix)) and endprefix >= substr(v_srcmsisdn,1,length(endprefix)); exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 3; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; begin select phoneindex into v_phoneindexb from zxdbm_ismp.ssys_phone where startprefix <= substr(v_usemsisdn,1,length(startprefix)) and endprefix >= substr(v_usemsisdn,1,length(endprefix)); exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_phoneindexa <> 0 and v_phoneindexb = 0 then o_provincesend := 1; v_usemsisdn := v_srcmsisdn; elsif v_phoneindexa = 0 and v_phoneindexb <> 0 then o_provincesend := 2; v_srcmsisdn := v_usemsisdn; end if; end if;end if;
/
--part-- --订购-- 发起方和应用方鉴权
/
if (i_needauthuser = 1) then if (i_isthird = 1) and (v_srcmsisdn <> v_usemsisdn) then --OA鉴权 begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,maxlimitfee, graylist,graylevel,cityid into v_srcuserindex,v_srcusertype,v_srcpaytype,v_srcblacklist,v_srcwhitelist, v_srcredlist,v_srcblacklevel,v_srcwhitelevel,v_srcmsisdntype,v_srcuserstatus, v_srcactivestatus,v_srcoppaytype,v_srccorpindex,v_srcusetime,v_srcmaxlimitfee, v_srcgraylist,v_srcgraylevel,v_srcusercityid from zxdbm_ismp.susr_basic where usercode = v_srcmsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 5; o_debuginfo := 'v_srcmsisdn do not exist;'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := 1; return; when others then o_retcode := 506; --数据库谬误 o_debugpos := 6; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := 1; return; end; o_srcmsisdntype := v_srcmsisdntype;
-- o_usemsisdntype := v_usemsisdntype;
-- o_userindex := v_useuserindex;
o_payuserindex := v_srcuserindex; o_paytype := v_srcpaytype; o_oppaytype := v_srcoppaytype; o_cityid := trim(v_srcusercityid);
-- o_usertype := v_useusertype;
if (i_cmdchannel in (7,32)) then if v_srcmsisdntype not in (1,2,3) then o_retcode := 100; o_debugpos := 7; o_debuginfo := 'v_srcmsisdntype is not valid in database.'; return; end if; end if; --OA更新用户表字段 if (v_srcactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 8; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 9; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_srcusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 10; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; --OA用户装他鉴权 if v_srcuserstatus in (1,3) then o_retcode := 1002; o_debugpos := 12; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', The subscriber status is 1 or 3.'; return; elsif v_srcuserstatus = 4 then o_retcode := 1008; o_debugpos := 13; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', The subscriber status is 4.'; return; end if; --DA鉴权 --****************************************************** begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,maxlimitfee, graylist,graylevel,cityid into v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist, v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus, v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_usemaxlimitfee, v_usegraylist,v_usegraylevel,v_useusercityid from zxdbm_ismp.susr_basic where usercode = v_usemsisdn; exception when no_data_found then if i_mutidbmode = 1 then o_mutiluserexit := 0; zxdbm_ismp.sp_getdblink(v_usemsisdn,v_usemsisdntype,v_ismutidb,v_dblink); v_sql := 'select userindex,usertype,paytype,blacklist,whitelist,'|| 'redlist,blacklevel,whitelevel,msisdntype,status,'|| 'activestatus,oppaytype,corpindex,lastusetime,maxlimitfee,'|| 'graylist,graylevel,cityid'|| ' from zxdbm_ismp.susr_basic'||'@'||v_dblink|| ' where usercode = :p1'; begin execute immediate v_sql into v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist, v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus, v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_usemaxlimitfee, v_usegraylist,v_usegraylevel,v_useusercityid using v_usemsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 16; o_debuginfo := 'v_usemsisdn do not exist;'; return; when others then o_retcode := 506; --数据库谬误 o_debugpos := 17; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else o_retcode := 1001; --用户不存在 o_debugpos := 18; o_debuginfo := 'v_usemsisdn do not exist;'; return; end if; when others then o_retcode := 506; --数据库谬误 o_debugpos := 19; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_usemsisdntype := v_usemsisdntype; o_userindex := v_useuserindex; o_usertype := v_useusertype; if (i_cmdchannel in (7,32)) then if (v_srcmsisdntype not in (1,2,3)) or (v_usemsisdntype not in (1,2,3)) then o_retcode := 100; o_debugpos := 20; o_debuginfo := 'v_srcmsisdntype or v_usemsisdntype is not valid in database.'; return; end if; end if; if o_mutiluserexit = 1 then --更新用户激活工夫 if (v_useactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 21; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 22; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_useusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 23; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 24; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; --应用方状态鉴权 if v_useuserstatus in (1,3) then o_retcode := 1002; o_debugpos := 25; o_debuginfo := 'v_useuserstatus='||v_useuserstatus||', The user status is 1 or 3.'; return; elsif v_useuserstatus = 4 then o_retcode := 1008; o_debugpos := 26; o_debuginfo := 'v_useuserstatus='||v_useuserstatus||', The user status is 4.'; return; end if; end if; else begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,maxlimitfee, graylist,graylevel,cityid into v_srcuserindex,v_srcusertype,v_srcpaytype,v_srcblacklist,v_srcwhitelist, v_srcredlist,v_srcblacklevel,v_srcwhitelevel,v_srcmsisdntype,v_srcuserstatus, v_srcactivestatus,v_srcoppaytype,v_srccorpindex,v_srcusetime,v_srcmaxlimitfee, v_srcgraylist,v_srcgraylevel,v_srcusercityid from zxdbm_ismp.susr_basic where usercode = v_srcmsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 27; o_debuginfo := 'v_srcmsisdn='||v_srcmsisdn||', user do not exist.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := o_srcmsisdntype; return; when others then o_retcode := 506; --数据库谬误 o_debugpos := 28; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := o_srcmsisdntype; return; end; v_useuserindex := v_srcuserindex; v_useusertype := v_srcusertype; v_usepaytype := v_srcpaytype; v_useblacklist := v_srcblacklist; v_usewhitelist := v_srcwhitelist; v_useredlist := v_srcredlist; v_useblacklevel := v_srcblacklevel; v_usewhitelevel := v_srcwhitelevel; v_usemsisdntype := v_srcmsisdntype; v_useuserstatus := v_srcuserstatus; v_useactivestatus := v_srcactivestatus; v_useoppaytype := v_srcoppaytype; v_usecorpindex := v_srccorpindex; v_useusetime := v_srcusetime; v_usemaxlimitfee := v_srcmaxlimitfee; v_usegraylist := v_srcgraylist; v_usegraylevel := v_srcgraylevel; o_srcmsisdntype := v_srcmsisdntype; o_usemsisdntype := v_usemsisdntype; o_userindex := v_useuserindex; o_payuserindex := v_srcuserindex; o_paytype := v_srcpaytype; o_oppaytype := v_srcoppaytype; o_usertype := v_useusertype; o_cityid := trim(v_srcusercityid); if (i_cmdchannel in (7,32)) then if v_srcmsisdntype not in (1,2,3) then o_retcode := 107; o_debugpos := 29; o_debuginfo := 'v_srcmsisdntype is not valid.'; return; end if; end if; if (v_srcactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 30; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 31; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_srcusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 32; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 33; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; --发起方状态鉴权 if v_srcuserstatus in (1,3) then o_retcode := 1002; o_debugpos := 34; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', subscriber status is 1 or 3.'; return; elsif v_srcuserstatus = 4 then o_retcode := 1008; o_debugpos := 35; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', subscriber status is 4.'; return; end if; end if;end if;
/
--part-- --订购-- 产品,产品费率鉴权
/
--产品存在性鉴权if (i_direct = 1) and (i_supportproductid = 0) then--反向订购,并且反对业务代码 if i_servicetype = 6 then --400用户的表构造不同,具备testuser、freeuseflag字段 v_sql := 'select productindex,needreplay,validmode,validcyctype,invalidmode,'|| 'validcycparam,validdate,subfeemode,subfeedays,freedays,freeuseflag,freenotify,'|| 'popularizestart,popularizestop,popularizeitem,needcharge,'|| 'productname,status,onlyforcorp,starttime,endtime,'|| 'workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent,'|| 'servicetype,subcapability,onlyforpkg,productid,ordertype,backfeemode,testuser,productsource '|| 'from zxdbm_200.s200_product where serviceid = :p1'; begin execute immediate v_sql into v_productindex,v_needreplay,v_validmode,v_validcyctype,v_invalidmode, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays,v_freeuseflag,v_freenotify, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_onlyforpkg,v_productid,v_ordertype,v_backfeemode,v_testuser,v_productsource using v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 36; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 37; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --modied by youqunxia20130530 order2.07.10 elsif i_servicetype in (1,2,3,5,33,98) then --200、300、500、600、1900、9800用户的表构造具备freeuseflag字段 v_sql := 'select productindex,needreplay,validmode,validcyctype,invalidmode,'|| 'validcycparam,validdate,subfeemode,subfeedays,freedays,freeuseflag,freenotify,'|| 'popularizestart,popularizestop,popularizeitem,needcharge,'|| 'productname,status,onlyforcorp,starttime,endtime,'|| 'workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent,'|| 'servicetype,subcapability,onlyforpkg,productid,ordertype,backfeemode,testuser,productsource '|| 'from zxdbm_200.s200_product where serviceid = :p1'; begin execute immediate v_sql into v_productindex,v_needreplay,v_validmode,v_validcyctype,v_invalidmode, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays,v_freeuseflag,v_freenotify, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_onlyforpkg,v_productid,v_ordertype,v_backfeemode,v_testuser,v_productsource using v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 38; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 39; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else v_sql := 'select productindex,needreplay,validmode,validcyctype,invalidmode,'|| 'validcycparam,validdate,subfeemode,subfeedays,freedays,freenotify,'|| 'popularizestart,popularizestop,popularizeitem,needcharge,'|| 'productname,status,onlyforcorp,starttime,endtime,'|| 'workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent,'|| 'servicetype,subcapability,onlyforpkg,productid,ordertype,backfeemode,productsource '|| 'from zxdbm_200.s200_product where serviceid = :p1'; begin execute immediate v_sql into v_productindex,v_needreplay,v_validmode,v_validcyctype,v_invalidmode, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays,v_freenotify, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_onlyforpkg,v_productid,v_ordertype,v_backfeemode,v_productsource using v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 40; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 41; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if;else if i_servicetype = 6 then --400用户的表构造不同,具备testuser、freeuseflag字段 v_sql := 'select productindex,needreplay,validmode,validcyctype,invalidmode,'|| 'validcycparam,validdate,subfeemode,subfeedays,freedays,freeuseflag,freenotify,'|| 'popularizestart,popularizestop,popularizeitem,needcharge,'|| 'productname,status,onlyforcorp,starttime,endtime,'|| 'workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent,'|| 'servicetype,subcapability,productid,ordertype,backfeemode,onlyforpkg,testuser,productsource '|| 'from zxdbm_200.s200_product where productid = :p1'; begin execute immediate v_sql into v_productindex,v_needreplay,v_validmode,v_validcyctype,v_invalidmode, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays,v_freeuseflag,v_freenotify, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_productid,v_ordertype,v_backfeemode,v_onlyforpkg,v_testuser,v_productsource using v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 42; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 43; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --modied by youqunxia20130530 order2.07.10 elsif i_servicetype in (1,2,3,5,33,98) then --200、300、500、600、1900、9800用户的表构造具备freeuseflag字段 v_sql := 'select productindex,needreplay,validmode,validcyctype,invalidmode,'|| 'validcycparam,validdate,subfeemode,subfeedays,freedays,freeuseflag,freenotify,'|| 'popularizestart,popularizestop,popularizeitem,needcharge,'|| 'productname,status,onlyforcorp,starttime,endtime,'|| 'workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent,'|| 'servicetype,subcapability,productid,ordertype,backfeemode,onlyforpkg,testuser,productsource '|| 'from zxdbm_200.s200_product where productid = :p1'; begin execute immediate v_sql into v_productindex,v_needreplay,v_validmode,v_validcyctype,v_invalidmode, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays,v_freeuseflag,v_freenotify, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_productid,v_ordertype,v_backfeemode,v_onlyforpkg,v_testuser,v_productsource using v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 44; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 45; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else v_sql := 'select productindex,needreplay,validmode,validcyctype,invalidmode,'|| 'validcycparam,validdate,subfeemode,subfeedays,freedays,freenotify,'|| 'popularizestart,popularizestop,popularizeitem,needcharge,'|| 'productname,status,onlyforcorp,starttime,endtime,'|| 'workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent,'|| 'servicetype,subcapability,productid,ordertype,backfeemode,onlyforpkg,productsource '|| 'from zxdbm_200.s200_product where productid = :p1'; begin execute immediate v_sql into v_productindex,v_needreplay,v_validmode,v_validcyctype,v_invalidmode, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays,v_freenotify, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_productid,v_ordertype,v_backfeemode,v_onlyforpkg,v_productsource using v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 46; o_debuginfo := 'The product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 47; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if;end if;o_productid := v_productid;o_productname := v_productname;o_productindex := v_productindex;o_serviceindex := v_serviceindex;o_cpindex := v_cpindex;o_smschargingcn := v_smschargingcn;o_servicetype := v_servicetype;o_subcapability := v_subcapability;o_ordertype := v_ordertype;o_popustop := v_popustop;o_freedays := v_freedays;
--added by youqunxia20130531 设置收费期短信提醒语 order2.07.10
if i_servicetype in (1,2,3,5,6,33,98) and v_freeuseflag <> 0 then if v_freeuseflag = 1 then v_freenotitype := 1; --sms,mms,wap,mvs,dls,pim,brew业务订购,将收费期到月底转换为收费时长(小时),以不便后续的判断 v_freedays := floor((to_date(v_curmonthendtime,'yyyymmddhh24miss')-to_date(v_sysdate14,'yyyymmddhh24miss'))*24); elsif v_freeuseflag = 2 then v_freenotitype := 2; elsif v_freeuseflag = 3 then v_freenotitype := 3; elsif v_freeuseflag = 4 then v_freenotitype := 0; end if;end if;o_freenotitype := v_freenotitype;--订购非订购类产品鉴权if v_ordertype <> 1 then if i_cmdchannel in (9,35,39,40) then o_retcode := 1001227; o_debugpos := 48; o_debuginfo := 'v_ordertype='||v_ordertype||', the product can not be subscriberd.'; return; else o_retcode := 2100; o_debugpos := 49; o_debuginfo := 'v_ordertype='||v_ordertype||', the product can not be subscriberd.'; return; end if;end if;--产品状态鉴权if (((v_productsource <> 3) and (v_productstatus in (0,2)) and (v_workflowlife = 3)) or ((v_productsource = 3) and (v_productstatus = 0))) then o_producttype := 2;elsif (v_productstatus <> 1) then o_retcode := 2101; o_debugpos := 50; o_debuginfo := 'productid='||v_srvprodid||', The Product status is abnormal.'; return;end if;--产品失效终止工夫判断if (v_sysdate14 < v_productstarttime) or (v_sysdate14 > v_productendtime) then o_retcode := 1011405; o_debugpos := 51; o_debuginfo := 'product is not valid any more.'; return;end if;--获取产品的计费信息if (v_popuitem = 2) then --无推广期 v_tempitem := 0;elsif v_popuitem in (0,1) then --推广期收费或者推广期计费 if (v_sysdate8 >= v_popustart) and (v_sysdate8 <= v_popustop) then if v_popuitem = 0 then --推广期收费 v_needcharge := 0; v_popuexist := 0; else v_needcharge := 1; v_popuexist := 1; v_tempitem := v_popuitem; end if; else v_tempitem := 0; end if;end if;o_needcharge := v_needcharge;if (v_needcharge = 1) then --欠费用户只能订购收费产品
-- if (o_mutiluserexit = 1) and (v_srcuserstatus = 2) then
if v_srcuserstatus = 2 then o_retcode := 1003; o_debugpos := 52; o_debuginfo := 'The user status is 2, do not allow to subscribe the product.'; return; end if; --费率存在性鉴权 if i_servicetype in (1,2) then v_sql := 'select chargetype,subchargetype,cyctype,cycunit,cycparam,rentfee,fixfee,fixusetimes,autocontinue,minlimitfee,usecomfee,nextrentfee,rentfeevalidate,totaldiscount,description '|| 'from zxdbm_200.s200_product_fee where productindex = :p1 and itemindex = :p2'; begin execute immediate v_sql into v_chargetype,v_subchargetype,v_cyctype,v_cycunit,v_cycparam,v_rentfee,v_fixfee,v_fixusetimes,v_autocontinue,v_minlimitfee,v_usecomfee,v_nextrentfee,v_rentfeevalidate,v_totaldiscount,v_description using v_productindex, v_tempitem; exception when no_data_found then o_retcode := 2100; o_debugpos := 53; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 54; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else begin select chargetype,subchargetype,cyctype,cycunit,cycparam,rentfee,fixfee,fixusetimes, autocontinue,minlimitfee,usecomfee,totaldiscount,description into v_chargetype,v_subchargetype,v_cyctype,v_cycunit,v_cycparam,v_rentfee,v_fixfee,v_fixusetimes, v_autocontinue,v_minlimitfee,v_usecomfee,v_totaldiscount,v_description from zxdbm_200.s200_product_fee where productindex = v_productindex and itemindex = v_tempitem; exception when no_data_found then o_retcode := 3103; o_debugpos := 55; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 56; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; o_chargetype := v_chargetype; o_cyctype := v_cyctype; o_fixusetimes := v_fixusetimes; o_autocontinue := v_autocontinue; o_rentfee := v_rentfee;end if;--推广期收费或者推广期计费,须要查问根本计费的费率信息if v_popuexist in (0,1) then o_smschargingcn := v_description; begin select chargetype,cyctype,cycunit,cycparam into v_jbchargetype,v_jbcyctype,v_jbcycunit,v_jbcycparam from zxdbm_200.s200_product_fee where productindex = v_productindex and itemindex = 0; exception when no_data_found then o_retcode := 3103; o_debugpos := 57; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 58; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--0资费判断,needchargeif v_needcharge = 0 then o_cnfmtype := 1;else if (v_rentfee = 0 and v_fixfee = 0 and v_minlimitfee = 0) then v_totaldctemplate := v_totaldiscount; loop v_index0 := instr(v_totaldctemplate,'&',1,1); v_dealtemplate := v_totaldctemplate; if v_index0 <> 0 then v_totaldclength := length(v_totaldctemplate); v_dealtemplate := substr(v_totaldctemplate, 1, v_index0-1); v_totaldctemplate := substr(v_totaldctemplate, 1+v_index0, v_totaldclength-v_index0); end if; v_totaldclength := length(v_dealtemplate); v_index1 := instr(v_dealtemplate,';',1,1); v_dealtemplate := substr(v_dealtemplate, 1+v_index1, v_totaldclength-v_index1); v_totaldclength := length(v_dealtemplate); v_index1 := instr(v_dealtemplate,';',1,1); v_dealtemplate := substr(v_dealtemplate, 1, v_index1-1); v_totaldcsum := to_number(v_dealtemplate); exit when (v_totaldcsum > 0 or v_index0 = 0); end loop; if v_totaldcsum = 0 then o_cnfmtype := 1; end if; end if;end if;--产品订购/赠送个性化鉴权if (v_onlyforpkg = 1) then o_retcode := 2201; o_debugpos := 59; o_debuginfo := 'The product can only be used by pkg.'; return;end if;--只有非帐期包量/包月/包周期产品和收费产品才能够赠送if (i_isthird = 1) then if (v_canbepresent = 0) then o_retcode := 1001212; o_debugpos := 60; o_debuginfo := 'The product can not be presented.'; else if (v_needcharge = 1) then if (v_chargetype not in (2,3,4,7,8)) or (v_cyctype <> 0) then o_retcode := 1001217; o_debugpos := 61; o_debuginfo := 'v_chargetype='||v_chargetype||'v_cyctype='||v_cyctype||', The product can not be presented.'; end if; end if; end if;end if;--赠送失败的短信模板须要上面两个参数if o_retcode in (1001212,1001217)then begin select cpcnshortname,customersrvtel into v_cpcnshortname,v_customersrvtel from zxdbm_ismp.scp_basic where cpindex = v_cpindex; exception when no_data_found then o_retcode := 2000; o_debugpos := 62; o_debuginfo := 'v_cpindex='||v_cpindex||', the sp does not exist.'; return; when others then o_retcode := 506; o_debugpos := 63; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_cpcnshortname := v_cpcnshortname; o_customersrvtel := v_customersrvtel; return;end if;--订购指令查问 add by chenfuzhong 2008.12.24begin select featurecode,accesscode into o_cancelfeaturecode,o_cancelaccesscode from zxdbm_ismp.ssrv_srvorder where productid = v_productid and cmdtype = 2 and rownum = 1;exception when no_data_found then null;when others then o_retcode := 506; o_debugpos := 64; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;
/**
--part-- --订购-- 业务鉴权
*/
--业务存在性鉴权(MPSS不须要鉴权)--modified by chenfuzhong 2008.10.09if i_servicetype = 101 then v_sql := 'select serviceid,status,colorlist,servicename,maincapability,submaincapability,cpid,orderupdateurl '|| 'from zxdbm_9900.s9900_service where serviceindex = :p1'; begin execute immediate v_sql into v_serviceid,v_servicestatus,v_srvcolorlist,v_servicename,v_maincapability,v_submaincapability,v_cpid,v_orderupdateurl using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 65; o_debuginfo := 'serviceindex='||v_serviceindex||', The service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 66; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;elsif i_servicetype in (1,2,3) then v_sql := 'select serviceid,status,colorlist,servicename,subsrvtype,cpid,isservicesub,orderupdateurl,servicesort '|| 'from zxdbm_200.s200_service where serviceindex = :p1'; begin execute immediate v_sql into v_serviceid,v_servicestatus,v_srvcolorlist,v_servicename,v_subsrvtype, v_cpid,v_isservicesub,v_orderupdateurl,v_servicesort using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 67; o_debuginfo := 'serviceindex='||v_serviceindex||', The service does not exist'; return; when others then o_retcode := 506; o_debugpos := 68; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;elsif i_servicetype <> 14 then begin select serviceid,status,colorlist,servicename,subsrvtype,cpid,orderupdateurl into v_serviceid,v_servicestatus,v_srvcolorlist,v_servicename,v_subsrvtype,v_cpid,v_orderupdateurl from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 69; o_debuginfo := 'serviceindex='||v_serviceindex||', The service does not exist'; return; when others then o_retcode := 506; o_debugpos := 70; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_serviceid := v_serviceid;o_servicename := v_servicename;o_maincapability := v_maincapability;o_submaincapability := v_submaincapability;o_cpid := v_cpid;--业务状态鉴权,mpss无业务if (i_servicetype <> 14 and v_servicestatus <> 1) then o_retcode := 1011510; o_debugpos := 71; o_debuginfo := 'v_servicestatus='||v_servicestatus||', The service status is abnormal.'; return;end if;--added by youqunxia20130906 order3.02.01--是否同步订购关系给OIDD,0-否,1-是if v_servicesort = 1 then o_issynctooidd := 1;end if;
/**
--part-- --订购-- CP/SP鉴权
**/
--CP/SP存在性鉴权begin select cpid,status,cpsubscribeurl,hasblacklist,cptype,insubblacklist,cpcnshortname,customersrvtel,cpsrvtype into v_cpid,v_cpstatus,v_cpsubscribeurl,v_hasblacklist,v_cptype,v_insubblacklist,v_cpcnshortname,v_customersrvtel,v_cpsrvtype from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 72; o_debuginfo := 'v_cpindex='||v_cpindex||', the sp does not exist.'; return;when others then o_retcode := 506; o_debugpos := 73; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_cpid := v_cpid;o_cptype := v_cptype;o_cpcnshortname := v_cpcnshortname;o_customersrvtel := v_customersrvtel;o_cpsrvtype := v_cpsrvtype;--按优先统提取同步URLif (trim(v_orderupdateurl) is null) or (length(trim(v_orderupdateurl)) < 8) then o_cpsubscribeurl := v_cpsubscribeurl;else o_cpsubscribeurl := v_orderupdateurl;end if;--CP/SP状态鉴权if (v_cpstatus <> 1) then o_retcode := 2001; o_debugpos := 74; o_debuginfo := 'v_cpstatus='||v_cpstatus||', The cp/sp status is abnormal.'; return;end if;--限度用户订购CP/SP黑名单鉴权if (v_insubblacklist <> 0) then o_retcode := 1011406; o_debugpos := 75; o_debuginfo := 'insubblacklist='||v_insubblacklist||', cp/sp is in limit blacklist'; return;end if;--SP接入码查问if (i_spaccesscode is null) or (length(trim(i_spaccesscode)) = 0) then begin select spaccesscode into v_spaccesscode from zxdbm_ismp.ssrv_srvorder where productindex = v_productindex and cmdtype = i_actiontype and servicetype = i_servicetype and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 76; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if trim(v_spaccesscode) is null then begin select accesscode into v_spaccesscode from zxdbm_ismp.ssrv_spaccesscode where cpid = v_cpid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 77; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; o_spaccesscode := v_spaccesscode;end if;
/*
--part-- --订购-- 业务能力开明鉴权
*/
--SP开明业务能力鉴权(MVS,MPSS,PIM,CPX不须要鉴权)if i_servicetype in (5,14,33,101) then o_protocoltype := 0;else begin select protocoltype into v_protocoltype from zxdbm_200.s200_sp_service_type where cpindex = v_cpindex and servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 2100; o_debugpos := 78; o_debuginfo := 'cp/sp serviceCapability is not open.'; return; when others then o_retcode := 506; o_debugpos := 79; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_protocoltype := v_protocoltype;end if;--added by youqunxia 20130817 Order3.02.01 鉴权是否开明webgw业务能力begin select status, starttime, endtime into v_spsrvstatus,v_spsrvstarttime,v_spsrvendtime from zxdbm_5000.s5000_sp_service_type where cpindex = v_cpindex and servicetype = 58;exception when no_data_found then o_haswebgw := 0;when others then o_retcode := 506; o_debugpos := 179; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;if v_spsrvstatus not in (1,3) then o_haswebgw := 0;elsif v_spsrvstarttime > v_sysdate14 or v_spsrvendtime < v_sysdate14 then o_haswebgw := 0;end if;--零碎业务能力开明鉴权(CPX查找主,子业务能力)if i_servicetype = 101 then begin select a.perssrvopen,b.srvtypeid into v_perssrvopen,v_srvtypeid from zxdbm_ismp.ssys_service_type a,zxdbm_ismp.ssys_service_type b where a.servicetype = v_servicetype and a.subcapability = v_subcapability and b.servicetype = v_maincapability and b.subcapability = v_submaincapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 80; o_debuginfo := 'CPX system serviceCapability is not open.'; return; when others then o_retcode := 506; o_debugpos := 81; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select perssrvopen,srvtypeid into v_perssrvopen,v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 82; o_debuginfo := 'servicetype='||v_servicetype||'subcapability='||v_subcapability||', System serviceCapability is not open.'; return; when others then o_retcode := 506; o_debugpos := 83; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_srvtypeid := v_srvtypeid;
/**
--part-- --订购-- 名单鉴权,用户业务能力开明鉴权
**/
-- if (o_mutiluserexit = 1) and (i_needauthuser = 1) then
if i_needauthuser = 1 then --应用方名单鉴权 if (v_useblacklist <> 0) then if bitand(v_useblacklevel,1) > 0 then --零碎级黑名单查看 v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 1 and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 84; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint > 0) then o_retcode := 1004; o_debugpos := 85; o_colortype := 1; o_debuginfo := 'colortype = 1 and colorlevel = 1 and userindex = '||v_useuserindex||', The user is in system level blacklist.'; return; end if; end if; --SP级黑名单查看 if v_hasblacklist = 1 and bitand(v_useblacklevel,2) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 2 and colorid = v_cpindex and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 86; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 87; o_colortype := 1; o_debuginfo := 'colortype = 1 and colorlevel = 2 and colorid = '||v_cpindex||', The user is in SP level blacklist.'; return; end if; end if; --业务能力级黑名单 if bitand(v_useblacklevel,4) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 3 and colorid = v_servicetype; exception when others then o_retcode := 506; o_debugpos := 88; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then if v_usegraylist > 0 and bitand(v_usegraylevel,2) > 0 then begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 3 and colorlevel = 2 and colorid = v_cpindex; exception when others then o_retcode := 506; o_debugpos := 89; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint = 0) then o_retcode := 1004; o_debugpos := 90; o_colortype := 1; o_debuginfo := 'colortype = 1 and colorlevel = 3 and colorid = '||v_servicetype||', The user is in serviceCapbility level blacklist.'; return; end if; else o_retcode := 1004; o_debugpos := 91; o_debuginfo := 'colortype = 1 and colorlevel = 3 and colorid = '||v_servicetype||', The user is in serviceCapbility level blacklist.'; o_colortype := 1; return; end if; end if; end if; if v_srvcolorlist = 1 and bitand(v_useblacklevel,8) > 0 then --业务级黑名单查看 v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 92; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 93; o_debuginfo := 'colortype = 1 and colorlevel = 4 and colorid = '||v_serviceindex||', The user is in service level blacklist.'; o_colortype := 1; return; end if; end if; end if; if (v_srvcolorlist = 2) then if (v_usewhitelist = 0) then o_retcode := 1100001; o_debugpos := 94; o_debuginfo := 'v_srvcolorlist = '||v_srvcolorlist||'v_usewhitelist = '||v_usewhitelist||', service has whitelist,but user is not in whitelist.'; return; end if; o_colortype := 2; v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 2 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 95; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint = 0 then o_retcode := 1109; o_debugpos := 96; o_debuginfo := 'userindex = '||v_useuserindex||', colortype = 2 and colorlevel = 4, colorid = '||v_serviceindex||',service has whitelist, but the user is not in service level whitelist.'; return; end if; end if; if (v_useredlist <> 0) then o_colortype := 4; end if; --应用方开明业务能力鉴权 begin -- select nvl(status,1) select status into v_useopenstatus from zxdbm_200.s200_service_useropen where userindex = v_useuserindex and servicetype = v_servicetype; exception when no_data_found then v_useopenstatus := 1; begin -- select nvl(perssrvopen,1) into v_usetypesrvopen select perssrvopen into v_usetypesrvopen from zxdbm_ismp.ssrv_user_perssrvopen where servicetype = v_servicetype and subcapability = v_subcapability and msisdntype =v_usemsisdntype; exception when no_data_found then v_usetypesrvopen := 1; if v_perssrvopen = 0 then o_retcode := 1100; o_debugpos := 97; o_debuginfo := 'the user service capabilty is closed.'; return; end if; when others then o_retcode := 506; o_debugpos := 98; o_debuginfo := 'the user service capabilty is closed.'; return; end; when others then o_retcode := 506; o_debugpos := 99; return; end; if v_useopenstatus = 0 or v_usetypesrvopen = 0 then if i_cmdchannel in (9,35,39,40) then o_retcode := 1001225; else o_retcode := 1100; end if; o_debugpos := 100; o_debuginfo := 'v_useopenstatus = '||v_useopenstatus||', the user service capabilty is closed.'; return; end if; if (v_srcmsisdn <> v_usemsisdn) then --发起方名单鉴权 if (v_srcblacklist <> 0) then if bitand(v_srcblacklevel,1) > 0 then --零碎级黑名单查看 v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 1 and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 101; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint > 0) then o_retcode := 1004; o_debugpos := 102; o_debuginfo := 'userindex = '||v_useuserindex||', colortype = 1 and colorlevel = 1'||', The user is in system level blacklist.'; return; end if; end if; --SP级黑名单查看 if v_hasblacklist = 1 and bitand(v_srcblacklevel,2) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 1 and colorlevel = 2 and colorid = v_cpindex and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 103; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 104; o_debuginfo := 'userindex = '||v_srcuserindex||', colortype = 1 and colorlevel = 2'||', colorid = '||v_cpindex||', the user is in SP level blacklist.'; return; end if; end if; --业务能力级黑名单 if bitand(v_srcblacklevel,4) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 1 and colorlevel = 3 and colorid = v_servicetype; exception when others then o_retcode := 506; o_debugpos := 105; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then if v_srcgraylist > 0 and bitand(v_srcgraylevel,2) > 0 then begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 3 and colorlevel = 2 and colorid = v_cpindex; exception when others then o_retcode := 506; o_debugpos := 106; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint = 0) then o_retcode := 1004; o_debugpos := 107; o_debuginfo := 'userindex = '||v_srcuserindex||', colortype = 1 and colorlevel = 3'||', colorid = '||v_servicetype||', the user is in service capbility level blacklist.'; o_colortype := 1; return; end if; else o_retcode := 1004; o_debugpos := 108; o_debuginfo := 'userindex = '||v_srcuserindex||', colortype = 1 and colorlevel = 3'||', colorid = '||v_servicetype||', The user is in service capbility level blacklist.'; o_colortype := 1; return; end if; end if; end if; if v_srvcolorlist = 1 and bitand(v_srcblacklevel,8) > 0 then --业务级黑名单查看 v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 1 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 109; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 110; o_debuginfo := 'userindex = '||v_srcuserindex||', colortype = 1 and colorlevel = 4'||', colorid = '||v_serviceindex||', the user is in service level blacklist.'; return; end if; end if; end if; if (v_srvcolorlist = 2) then if (v_srcwhitelist = 0) then o_retcode := 1100001; o_debugpos := 111; o_debuginfo := 'v_srvcolorlist = '||v_srvcolorlist||', v_srcwhitelist = '||v_srcwhitelist||', the service has whitelist, but the user is not in whitelist.'; return; end if; v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 2 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 112; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint = 0 then o_retcode := 1109; o_debugpos := 113; o_debuginfo := 'v_srvcolorlist = '||v_srvcolorlist||', the service has whitelist, but the user is not in service level whitelist.'; return; end if; end if; --发起方开明业务能力鉴权 begin
-- select nvl(status,1)
select status into v_srcopenstatus from zxdbm_200.s200_service_useropen where userindex = v_srcuserindex and servicetype = v_servicetype; exception when no_data_found then v_srcopenstatus := 1; begin -- select nvl(perssrvopen,1) into v_srctypesrvopen select perssrvopen into v_srctypesrvopen from zxdbm_ismp.ssrv_user_perssrvopen where servicetype = v_servicetype and subcapability = v_subcapability and msisdntype =v_srcmsisdntype; exception when no_data_found then v_srctypesrvopen := 1; if v_perssrvopen = 0 then o_retcode := 1100; o_debugpos := 114; o_debuginfo := 'The user service capability is not open and system capability is closed'; return; end if; when others then o_retcode := 506; o_debugpos := 115; o_debuginfo := 'Failed to query user ssrv_user_perssrvopen'; return; end; when others then o_retcode := 506; o_debugpos := 116; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_srcopenstatus = 0 or v_srctypesrvopen = 0 then if i_cmdchannel in (9,35,39,40) then o_retcode := 1001225; else o_retcode := 1100; end if; o_debugpos := 117; o_debuginfo := 'userindex = '||v_srcuserindex||'servicetype = '||v_servicetype||', the user service capabilty is closed.'; return; end if; end if;end if;
/
--part-- --订购-- 测试产品,测试用户鉴权
*/
--测试产品鉴权
-- if (o_mutiluserexit = 1) and (((v_productsource <> 3) and (v_productstatus in (0,2)) and (v_workflowlife = 3)) or
if (v_productsource <> 3 and v_productstatus in (0,2) and v_workflowlife = 3) or (v_productsource = 3 and v_productstatus = 0) then if (v_srcusertype <> 2) or (v_useusertype <> 2) then o_retcode := 1100; o_debugpos := 118; o_debuginfo := 'The normal user can not use test product.'; return; end if; --SP测试用户鉴权 --测试产品、测试用户(发起方、应用方)相干鉴权 begin select cpindex into v_srctestcpindex from zxdbm_ismp.susr_testgroup_member where userindex = v_srcuserindex; exception when no_data_found then o_retcode := 1100; o_debugpos := 119; o_debuginfo := 'userindex = '||v_srcuserindex||', the test product is not open to the subscriber.'; return; when others then o_retcode := 506; o_debugpos := 120; return; end; if (v_srctestcpindex > 0) then if (v_srctestcpindex <> v_cpindex) then o_retcode := 1001223; o_debugpos := 121; o_debuginfo := 'The test-user belongs to SP-A can not use test-product belonged to SP-B.'; return; end if; end if; begin select cpindex into v_usetestcpindex from zxdbm_ismp.susr_testgroup_member where userindex = v_useuserindex; exception when no_data_found then o_retcode := 1100; o_debugpos := 122; o_debuginfo := 'userindex = '||v_useuserindex||', the test product is not open to the subscriber.'; return; when others then o_retcode := 506; o_debugpos := 123; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_usetestcpindex > 0) then if (v_usetestcpindex <> v_cpindex) then o_retcode := 1001223; o_debugpos := 124; o_debuginfo := 'The test-user belongs to SP-A can not use test-product belonged to SP-B.'; return; end if; o_usertype := 3; end if;end if;
/*
--part-- --订购-- 团体相干鉴权(分DB用户不存在,不鉴权)
/
--团体产品、团体用户相干鉴权
-- if (o_mutiluserexit = 1) and (v_onlyforcorp = 1) then
if v_onlyforcorp = 1 then --团体产品不容许赠送 if (i_isthird = 1) then o_retcode := 1011407; o_debugpos := 125; o_debuginfo := 'v_onlyforcorp = '||v_onlyforcorp||'i_isthird = '||i_isthird||', the corp product can not to be presented.'; return; end if; --普通用户不能订购一个团体专用产品 if (v_srccorpindex <> v_usecorpindex) then o_retcode := 1100; o_debugpos := 126; o_debuginfo := 'v_onlyforcorp = '||v_onlyforcorp||'v_srccorpindex = '||v_srccorpindex||', the normal user can not subscrib corp product.'; return; end if; if (v_srccorpindex = 0) then o_retcode := 1204; o_debugpos := 127; o_debuginfo := 'v_onlyforcorp = '||v_onlyforcorp||'v_srccorpindex = '||v_srccorpindex||', the normal user can not subscrib corp product.'; return; end if; begin select corpid,status,paymsisdn,corpcnshortname into v_srccorpid,v_srccorpstatus,v_srccorppaymsisdn,v_corpname from zxdbm_ismp.susr_corp where corpindex = v_srccorpindex; exception when no_data_found then o_retcode := 1001301; --团体不存在 o_debugpos := 128; o_debuginfo := 'v_srccorpindex = '||v_srccorpindex||', the corp do not exist.'; return; when others then o_retcode := 506; o_debugpos := 129; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_corpcnshortname := v_corpname; o_corpid := v_srccorpid; o_corpindex := v_srccorpindex; if (v_srccorpstatus <> 1) then o_retcode := 1001302; o_debugpos := 130; o_debuginfo := 'v_srccorpindex = '||v_srccorpindex||', the corp status is abnormal.'; return; end if; --一个团体的产品只能由本团体的用户订购/赠送 begin select subscribemode,payparty,status into v_productsubmode,v_productpayparty,v_corpproductstatus from zxdbm_ismp.ssrv_corp_product where corpindex = v_srccorpindex and groupindex = 0 and productindex = v_productindex; exception when no_data_found then o_retcode := 1011300; o_debugpos := 131; o_debuginfo := 'productindex = '||v_productindex||', corpindex = '||v_srccorpindex||', the product is not binded with the corp.'; return; when others then o_retcode := 506; o_debugpos := 132; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_corpproductstatus <> 0) then o_retcode := 1011408; o_debugpos := 133; o_debuginfo := 'productindex = '||v_productindex||', corpindex = '||v_srccorpindex||', the binding relationship between the product and the corp is deleted.'; return; end if; if (v_productsubmode = 0) then --必须团体管理员订购 if (i_cmdchannel <> 4) then o_retcode := 1001216; --无权定购 o_debugpos := 134; o_debuginfo := 'i_cmdchannel = '||i_cmdchannel||', v_productsubmode = '||v_productsubmode||', the corp product can only be subscribed by corp managers.'; return; end if; end if;end if;
/*
--part-- --订购-- 计费方、预付费零碎鉴权
*/
--if o_mutiluserexit = 1 then if (v_productpayparty = 1) then v_paymsisdn := v_srccorpid; v_cardtype := 0; v_paymsisdntype := 1; o_paymsisdn := v_paymsisdn; o_paytype := v_cardtype; o_payuserindex := v_srccorpindex; o_paymode := '团体付费'; o_cityid := trim(' '); else v_paymsisdn := v_srcmsisdn; v_cardtype := v_srcpaytype; v_paymsisdntype := v_srcmsisdntype; o_paymsisdn := v_paymsisdn; o_paytype := v_cardtype; o_payuserindex := v_srcuserindex; o_paymode := '集体付费'; if (i_prepaidtype = 1) then o_scptype := 1; elsif i_prepaidtype = 2 then o_scptype := 2; else --attach 预付费归属,0-未知,1-OCS,2-RTBP begin select phoneindex,attach into v_phoneindex,v_attach from zxdbm_ismp.ssys_phone where startprefix <= substr(v_paymsisdn,1,length(startprefix)) and endprefix >= substr(v_paymsisdn,1,length(endprefix)); exception when no_data_found then o_scptype := 2; v_devexist := 0; --示意不存在对应号段对应设施配置 when others then o_retcode := 506; o_debugpos := 135; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_devexist = 1) then if (v_attach = 1) then o_scptype := 1; elsif (v_attach = 2) then o_scptype := 2; else begin select 1 into o_scptype from zxdbm_ismp.sdev_phone where phoneindex = v_phoneindex and devicetype = 5; exception when no_data_found then o_scptype := 2; when others then o_retcode := 506; o_debugpos := 136; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; end if;
-- end if;
/*
--part-- --订购-- 性能:订购关系鉴权(产品订购/业务订购)
阐明:跨省赠送,赠送音讯不鉴权订购关系/多DB赠送,不在OA库鉴权订购关系
*/
if (i_mutidbmode = 1 and i_isthird = 1) or (i_actiontype = 17 and i_isfromnmsc = 1) then null;else v_hasrecord := 1; begin --产品订购 select status,productid,productindex,lastrenttime,nextrentdate,payfordate,productpkgindex,endtime, varifee,isexperience into v_cursubstatus,v_cancelproductid,v_cancelproductindex,v_cancellastrenttime,v_cancelnextrentdate,v_cancelpayfordate,v_productpkgindex,v_subendtime, v_lastvarifee,v_isexperience1 from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid; exception when no_data_found then v_hasrecord := 0; when others then o_retcode := 506; o_debugpos := 137; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_hasrecord > 0) then if v_productpkgindex <> 0 then begin select trim(productpkgname) into o_productpkgname from zxdbm_ismp.ssrv_product_pkg where productpkgindex = v_productpkgindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 138; o_debuginfo := 'v_productpkgindex = '||v_productpkgindex||', the pkg do not exit.'; return; when others then o_retcode := 506; o_debugpos := 139; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_retcode := 1200; --该产品属于套餐,且用户已订购该套餐 o_debugpos := 140; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the user has subscribed pkg including this product.'; return; end if; if v_cursubstatus <> 4 and v_chargetype <> 4 then --(待生效订购关系 或 纯包量)能够反复订购 --added by youqunxia20130818 order3.02.01 if i_startcmdchannel = 45 then o_hassubscription := 1; --6、可变价的反复订购 o_issecondproduct := 6; elsif (i_cmdchannel = 40) then --added by youqunxia20131015 order3.02.01 v_isexperience1 := trim(v_isexperience1); if (v_isexperience1 = '1') and (i_isexperience = 3)then v_isexperience := '0'; --7:体验转正式的反复订购 o_issecondproduct := 7; else o_retcode := 1200; o_debugpos := 178; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the user has subscribed the product.'; return; end if; else o_retcode := 1200; o_debugpos := 141; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the user has subscribed the product.'; return; end if; elsif v_chargetype = 4 then --判断程序不能颠倒 o_issecondproduct := 3; --modied by youqunxia20130918 order3.02.01 --待生效订购关系的订购,不反对退订应用足月的产品待生效产品的订购 elsif v_cursubstatus = 4 and v_chargetype in (2,5,7) and v_invalidmode <> 2 then o_issecondproduct := 2; else o_retcode := 1200; o_debugpos := 181; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the user has subscribed the product.'; return; end if; end if; --业务订购(内容类业务有BREW、DLS、MVS) if i_servicetype not in (5,6,98) and v_hasrecord = 0 then o_issecondproduct := 1; v_hasrecord := 1; begin select productid,productindex,lastrenttime,payfordate,productpkgindex, freetime,isexperience into v_cancelproductid,v_cancelproductindex,v_cancellastrenttime,v_cancelpayfordate,v_productpkgindex, v_cancelfreetime,v_cancelisexperience from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and cpid = v_cpid and serviceid = v_serviceid; exception when no_data_found then o_issecondproduct := 0; v_hasrecord := 0; when others then o_retcode := 506; o_debugpos := 142; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (i_cmdchannel = 40) then --added by youqunxia20131018 order3.02.01 --订购激活申请中OperType为2:替换已有产品,则ISMP失常解决,将产品的订购关系进行替换,计费失常 --体验转正式,则ISMP失常解决,将产品订购关系转为失常,计费失常 v_cancelisexperience := trim(v_cancelisexperience); if (v_cancelisexperience = '1') and (i_isexperience = 0 or i_isexperience = 3)then v_isexperience := '0'; end if; end if; if v_hasrecord > 0 then if v_productpkgindex <> 0 then o_retcode := 1001210; --不能替换产品组合蕴含的产品 o_debugpos := 143; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productpkgindex = '||v_productpkgindex||', can not replace product in the pkg.'; return; end if; if(v_cancelproductid <> v_productid) then if i_servicetype in (1,2,3) and v_isservicesub = 1 then --sms,mms,wap业务订购 null; else o_retcode := 1001210; o_debugpos := 144; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', serviceid = '||v_serviceid||', the user has subscribed a product in the same service.'; return; end if; end if; end if; end if; o_cancelproductid := v_cancelproductid; o_lastvarifee := v_lastvarifee;end if;--业务订购/待生效订购关系只反对包月类产品--??应该在鉴权了订购关系的状况下,才有上面的鉴权,T02改if o_issecondproduct in (1,2) then if i_servicetype = 5 and o_issecondproduct = 2 and v_chargetype in (3,6,8) then --MVS的包周期产品在订购关系待生效状态时能够续订 null; else if v_chargetype in (2,5,7) or v_needcharge = 0 then --包月类产品、收费产品能够替换 null; else o_retcode := 9999; o_debugpos := 145; o_debuginfo := 'v_chargetype='||v_chargetype||', No_month_Product can not update subscription.'; end if; end if;end if;--added by youqunxia2013112 order3.02.01if v_isexperience = '3' then o_retcode := 1009023; o_debugpos := 180; o_debuginfo := 'There is not free user subscription.';end if;o_isexperience := v_isexperience;
/
--part-- --订购-- 设置订购关系失效工夫、状态
--0-立刻失效,1-下月失效,2-n周期后失效,3-指定日期失效
/
v_substatus := 0;--added by youqunxia20130910 order3.02.01--开关关上,VSOP侧发动捆绑类套餐、增值产品的订购激活、变更激活及退订,ISMP中增值子产品订购关系立刻失效(包含订购、退订及变更),不以增值产品属性判断失效工夫;if (i_cmdchannel = 40) and (i_effectiveswitch = 1)then v_validmode := 0;end if;if (v_validmode = 0) or (v_validmode = 3 and v_validdate <= v_sysdate14) then v_substarttime := v_sysdate14; v_validmode := 0; v_substatus := 1;elsif (v_validmode = 1) then v_substarttime := to_char((to_date(substr(v_curmonthendtime,1,8),'yyyymmdd') + 1),'yyyymmddhh24miss'); v_substatus := 0;elsif (v_validmode = 2) then--周期形式0-非周期形式,1-天,2-周,3-月 if (v_validcyctype = 1) then v_substarttime := to_char(to_date(v_sysdate14,'yyyymmddhh24miss') + v_validcycparam,'yyyymmddhh24miss'); v_substatus := 0; elsif (v_validcyctype = 2) then v_substarttime := to_char(to_date(v_sysdate14,'yyyymmddhh24miss') + 7 * v_validcycparam,'yyyymmddhh24miss'); v_substatus := 0; elsif (v_validcyctype = 3) then v_substarttime := to_char(add_months(to_date(v_sysdate14,'yyyymmddhh24miss'),v_validcycparam),'yyyymmddhh24miss'); v_substatus := 0; else v_substarttime := v_sysdate14; v_substatus := 1; end if;elsif (v_validmode = 3) and (v_validdate > v_sysdate14) then v_substarttime := v_validdate; v_substatus := 0;else v_substarttime := v_sysdate14; v_substatus := 1;end if;--modied by youqunxia20130601 order2.07.10 if i_servicetype = 5 and v_freeuseflag in (1,2) then --流媒体产品(天冀视讯业务)用户首次订购享受收费期的时候,须要将订购关系置为立刻失效 v_substarttime := v_sysdate14; v_validmode := 0; v_substatus := 1; --将之到期解决字段值置为0,以对代码进行爱护(天翼视讯MVS此字段门户应限度为0) v_freenotify := 0;end if;--失效工夫在推广期之外if v_popuexist in (0,1) and (to_char(to_date(v_substarttime, 'yyyymmddhh24miss'), 'yyyymmdd') >= v_popustop) then v_popuexist := 3;end if;o_popuexist := v_popuexist;
/**
--part-- --订购-- --计算产品订购关系收费期、产品订购关系下次扣租日期、产品订购关系上次扣租工夫、月租已扣日期
--从本月历史表中查问有没有退定记录
*/
v_hasrecord := 1;begin v_sql := 'select freetime,lastrenttime,payfordate from (select freetime,lastrenttime,payfordate from zxdbm_200.s200_user_subs_hist' || v_curstrmonth || ' where usercode = :p1 and productid = :p2 and substr(canceltime,1,6) = :p3 order by subscriptionindex desc) temp where rownum=1'; execute immediate v_sql into v_freetime,v_lastrenttime,v_payfordate using v_usemsisdn, v_productid, substr(v_sysdate14,1,6);exception when no_data_found then v_hasrecord := 0;when others then o_retcode := 506; o_debugpos := 147; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;--收费期产品和应用产品历史订购关系的查问if (v_freedays > 0 or v_testuser = 1) and v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist01 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then v_hasrecord := 0; when others then o_retcode := 506; o_debugpos := 148; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist02 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 149; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist03 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 150; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist04 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 151; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist05 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 152; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist06 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 153; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist07 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 154; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist08 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 155; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist09 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 156; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist10 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 157; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist11 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 158; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_hasrecord = 0 then begin select count(1) into v_hasrecord from zxdbm_200.s200_user_subs_hist12 where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 159; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if;end if;if v_testuser = 1 and v_hasrecord = 1 then o_retcode := 1001226; o_debugpos := 160; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the user has subscribed the test_product before.'; return;end if;o_lastrenttime := v_lastrenttime;o_payfordate := v_payfordate;--有收费期且为纯包量时,查问订购关系表if v_freedays > 0 and v_chargetype = 4 then begin select freetime into v_freetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 161; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --超过收费期订购时不享受收费期 if v_sysdate14 > v_freetime and v_freetime <> '00000000000000' then v_freedays := 0; end if;end if;--modied by youqunxia20130530 计算收费期到期日期 order2.07.10if (v_freedays > 0) and (v_hasrecord = 1) and (v_chargetype <> 4) then v_freetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') - 1,'yyyymmdd') || '235959';else --sms,mms,wap、mvs、dls、pim、brew业务到期日期计算 if i_servicetype in (1,2,3,5,6,33,98) then if v_freeuseflag = 1 then --试用到月底 v_freetime := to_char(last_day(to_date(v_substarttime,'yyyymmddhh24miss')),'yyyymmdd') || '235959'; elsif v_freeuseflag = 2 then --试用N小时 v_freetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_freedays/24 ,'yyyymmddhh24miss'); elsif v_freeuseflag = 3 then --试用足月 v_freetime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'), v_freedays ) - 1,'yyyymmdd') || '235959'; elsif v_freeuseflag = 4 then --试用N天 if (v_freedays = 3) then v_freetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 3,'yyyymmddhh24miss'); else v_freetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_freedays - 1,'yyyymmdd') || '235959'; end if; if (v_freedays > 0) and (i_freemodule = 1) and (v_freenotify in (0,1)) and (v_chargetype in (2,5,7)) then --包月类收费期 优惠形式 v_freetime := to_char(last_day(to_date(v_freetime,'yyyymmddhh24miss')),'yyyymmdd') || '235959'; end if; end if; else --其余业务能力计算收费日期 --added by youqunxia 2013.02.18 if (v_freedays = 3) then v_freetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 3,'yyyymmddhh24miss'); else v_freetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_freedays - 1,'yyyymmdd') || '235959'; end if; if (v_freedays > 0) and (i_freemodule = 1) and (v_freenotify in (0,1)) and (v_chargetype in (2,5,7)) then --包月类收费期 优惠形式 v_freetime := to_char(last_day(to_date(v_freetime,'yyyymmddhh24miss')),'yyyymmdd') || '235959'; end if; end if;end if;o_freetime := v_freetime;if (v_freetime > v_substarttime) and (v_hasrecord = 0) and (o_issecondproduct not in (1,2)) then --收费期 if v_freenotify in (1,2) then --取默认值'99991231'; null; else v_nextrentdate := to_char(to_date(o_freetime,'yyyymmddhh24miss') + 1,'yyyymmdd'); end if;elsif v_popuexist in (0,1,3) then --推广期 if v_popuexist = 0 then --推广期收费 v_nextrentdate := to_char(to_date(v_popustop,'yyyymmdd') + 1,'yyyymmdd'); elsif v_popuexist = 1 then --推广期计费 if v_chargetype = 1 then --按次 v_nextrentdate := to_char(to_date(v_popustop,'yyyymmdd') + 1,'yyyymmdd'); elsif v_chargetype = 2 then --包月 if v_validmode = 0 then if v_popustop = to_char(last_day(to_date(v_substarttime,'yyyymmddhh24miss')),'yyyymmdd') then if v_jbchargetype in (2,5,7) then v_nextrentdate := to_char(last_day(to_date(v_substarttime,'yyyymmddhh24miss')) + v_rentday,'yyyymmdd'); else v_nextrentdate := to_char(to_date(v_popustop,'yyyymmdd') + 1,'yyyymmdd'); end if; else v_nextrentdate := to_char(last_day(to_date(v_substarttime,'yyyymmddhh24miss')) + v_rentday,'yyyymmdd'); end if; else v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1,'yyyymmdd'); end if; end if; elsif v_popuexist = 3 then --订购在推广期内,失效在推广期之外 v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1,'yyyymmdd'); end if;elsif (v_subchargetype = 1) and (v_cyctype = 1) then if v_validmode = 0 then if v_chargetype in (2,5,7) then --added by youqunxia20130923 order3.02.01 if v_invalidmode = 2 then --上海院需要,退订应用足月的计算规定,退订后可应用到订购日(临界条件非凡解决) v_unsubenddate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),1), 'yyyymmdd'); if substr(v_substarttime,7,2) < substr(v_unsubenddate,7,2) then --实用2月28日订购(非平年)相似情景 v_unsubenddate :=substr(v_unsubenddate,1,6)||substr(v_substarttime,7,2); end if; v_nextrentdate := to_char(to_date(v_unsubenddate,'yyyymmdd') + 1,'yyyymmdd'); --广东院需要,退订应用足月的计算规定,退订后应用到订购日前一天(临界条件非凡解决) if i_fullmonthmode = 1 then v_nextrentdate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),1), 'yyyymmdd'); if substr(v_substarttime,7,2) < substr(v_nextrentdate,7,2) then --实用2月28日订购(非平年)相似情景 v_nextrentdate :=substr(v_nextrentdate,1,6)||substr(v_substarttime,7,2); elsif substr(v_substarttime,7,2) > substr(v_nextrentdate,7,2) then --实用1月31订购的相似情景,扣租日为下下个月的1号 v_nextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmdd'),1), 'yyyymm')||'01'; end if; end if; else v_nextrentdate := to_char(last_day(to_date(v_substarttime,'yyyymmddhh24miss')) + v_rentday,'yyyymmdd'); end if; elsif v_chargetype in (3,6,8) then if (v_cycunit = 1) then --包天 if i_servicetype = 5 and o_issecondproduct = 2 then --周期性MVS包天产品,待生效再次订购时调整下次扣租日期 v_nextrentdate := to_char(to_date(v_cancelnextrentdate,'yyyymmdd') + v_cycparam,'yyyymmdd'); else v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1 + v_cycparam,'yyyymmdd'); end if; elsif (v_cycunit = 2) then --包周 v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_cycparam * 7,'yyyymmdd'); elsif (v_cycunit = 3) then --包月 v_nextrentdate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam),'yyyymmdd'); elsif (v_cycunit = 4) then --包半年 v_nextrentdate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam * 6),'yyyymmdd'); elsif (v_cycunit = 5) then --包年 v_nextrentdate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam * 12),'yyyymmdd'); end if; end if; else v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1,'yyyymmdd'); end if;elsif (v_subchargetype = 1) and (v_cyctype = 0) then if v_chargetype in (3,6,8) then --非立刻失效,非周期性产品,在订购关系开始后进行扣租 if v_validmode <> 0 then v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1,'yyyymmdd'); end if; end if;elsif v_subchargetype in (2,3) then v_nextrentdate := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1,'yyyymmdd');end if;o_nextrentdate := v_nextrentdate;
/**
--part-- --订购-- 计算本次需扣费用 (业务下多个产品订购or订购关系待生效产品的订购 / 单个产品订购)
*/
if o_issecondproduct in (1,2) then --计算被189替换的原产品/订购关系待生效产品,本月是否扣租 begin select subfeemode,popularizestart,popularizestop,popularizeitem,needcharge into v_cancelsubfeemode,v_cancelpopustart,v_cancelpopustop,v_cancelpopuitem,v_cancelneedcharge from zxdbm_200.s200_product where productindex = v_cancelproductindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 162; o_debuginfo := 'v_cancelproductindex='||v_cancelproductindex||', The product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 163; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --获取产品的计费信息 if (v_cancelpopuitem = 2) then --无推广期 v_tempitem := 0; elsif v_cancelpopuitem in (0,1) then --推广期收费或者推广期计费 if (v_sysdate8 >= v_cancelpopustart) and (v_sysdate8 <= v_cancelpopustop) then if v_cancelpopuitem = 0 then --推广期收费 o_retcode := 9999; o_debugpos := 164; o_debuginfo := 'v_popuitem='||v_popuitem||', popu_free_product can not update the subscription.'; else v_tempitem := v_cancelpopuitem; end if; else v_tempitem := 0; end if; end if; if i_servicetype in (1,2) and v_cancelneedcharge <> 0 then v_sql := 'select rentfee,minlimitfee,chargetype,fixfee,nextrentfee,rentfeevalidate '|| 'from zxdbm_200.s200_product_fee where productindex = :p1 and itemindex = :p2'; begin execute immediate v_sql into v_cancelrentfee,v_cancelminlimitfee,v_cancelchargetype,v_cancelfixfee,v_nextrentfee,v_rentfeevalidate using v_cancelproductindex,v_tempitem; exception when no_data_found then o_retcode := 2100; o_debugpos := 165; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 166; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; elsif v_cancelneedcharge <> 0 then begin select rentfee,minlimitfee,chargetype,fixfee into v_cancelrentfee,v_cancelminlimitfee,v_cancelchargetype,v_cancelfixfee from zxdbm_200.s200_product_fee where productindex = v_cancelproductindex and itemindex = v_tempitem; exception when no_data_found then o_retcode := 3103; o_debugpos := 167; o_debuginfo := 'The product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 168; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if o_issecondproduct = 1 then --订购待生效产品后面曾经鉴过权,此外不需要反复再进行鉴权,否则会导致MVS业务续订出错 --订购待生效产品后面曾经鉴过权,此外不需要反复再进行鉴权,否则会导致MVS业务续订出错 if v_cancelchargetype in (2,5,7) or v_cancelneedcharge = 0 then --包月类产品、收费产品能够替换 null; else o_retcode := 9999; o_debugpos := 169; o_debuginfo := 'v_cancelchargetype='||v_cancelchargetype||', No_month_Product can not update the subscription.'; end if; end if; if v_cancelchargetype in (2,5,7) then if v_cancelfreetime < v_sysdate14 then if (substr(v_cancellastrenttime,1,6) = v_sysmonth6) then --本月租金已扣除 o_subfee := 0; o_lastrenttime := v_cancellastrenttime; o_payfordate := v_cancelpayfordate; elsif (substr(v_cancellastrenttime,1,6) < v_sysmonth6) then --本月租金未扣除 v_subfee := v_cancelfixfee; if i_servicetype in (1,2) then if (v_cancelrentfee <> v_nextrentfee) and (substr(v_rentfeevalidate,1,6) = v_sysmonth6) then v_cancelrentfee := v_nextrentfee; end if; end if; if (v_cancelsubfeemode = 1) then --收取本帐期全副费用 v_subfee := v_subfee + v_cancelrentfee; elsif (v_cancelsubfeemode = 2) then --上半月订购收取全月费用,下半月订购收取半月费用 if (to_number(substr(v_sysdate8,7,2)) - 15 > 0) then v_subfee := v_subfee + v_cancelrentfee/2; else v_subfee := v_subfee + v_cancelrentfee; end if; elsif (v_cancelsubfeemode = 3) then --n日全费含n日,n日后收费 if (v_subfeedays = 0) then --0示意本月全副收费,其余示意 N号之后收费。 null; elsif (to_number(substr(v_sysdate8,7,2)) - v_subfeedays <= 0) then v_subfee := v_subfee + v_cancelrentfee; else null; end if; elsif (v_cancelsubfeemode = 4) then --理论天数免费 v_leftdays := to_number(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')) - to_date(v_sysdate14,'yyyymmddhh24miss')) + 1; v_monthdays := to_number(substr(v_curmonthendtime,7,2)); v_subfee := v_subfee + v_cancelrentfee*(v_leftdays/v_monthdays); end if; o_subfee := v_subfee; if o_subfee < v_cancelminlimitfee then o_subfee := v_cancelminlimitfee; end if; o_lastrenttime := v_sysdate14; o_payfordate := v_sysdate8; end if; end if; else if i_servicetype = 5 and v_cancelchargetype in (3,6,8) then --MVS能够持续订购待生效状态的产品,只有MVS非包月的费率能够在待生效状态订购 o_subfee := v_cancelrentfee + v_cancelfixfee; o_lastrenttime := v_sysdate14; o_payfordate := v_sysdate8; end if; end if;else --计算本次订购须要扣取的费用 if (v_needcharge = 1) and ((o_freetime < v_sysdate14) or (v_freedays > 0 and v_hasrecord = 1)) and (v_validmode = 0) then if v_chargetype not in (2,3,4,5,6,7,8) then v_subfee := 0; else v_subfee := v_fixfee; if v_chargetype in (3,6,8) then --包周期产品 v_subfee := v_subfee + v_rentfee; elsif v_chargetype in (2,5,7) then --包月类产品 --added by youqunxia20130923 order3.02.01 --包月类产品,退订应用足月产品收取本月全副费用,与首月属性无关 if v_invalidmode = 2 then v_subfee := v_subfee + v_rentfee; else if v_subchargetype <> 1 then v_subfee := 0; elsif v_chargetype in (2,5) and (v_hasrecord = 1 and v_backfeemode = 0 and substr(v_lastrenttime,1,6) = v_sysmonth6) then --(包月,包月+单位费率)本月曾经订购过 v_subfee := 0; elsif (v_chargetype = 7) and (v_hasrecord = 1 and v_backfeemode = 0 and substr(v_lastrenttime,1,6) = v_sysmonth6) then --(包月+包量)本月曾经订购过 null; else if i_servicetype in (1,2) then if (v_rentfee <> v_nextrentfee) and (substr(v_rentfeevalidate,1,6) = v_sysmonth6) then v_rentfee := v_nextrentfee; end if; end if; if (v_hasrecord = 1 and v_backfeemode = 1 and substr(v_lastrenttime,1,6) = v_sysmonth6) then --退订须要补款产品本月曾经订购过 v_tag := 1; v_leftdays := to_number(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')) - to_date(v_sysdate14,'yyyymmddhh24miss')) + 1; v_monthdays := to_number(substr(v_curmonthendtime,7,2)); v_subfee := v_subfee + v_rentfee*(v_leftdays/v_monthdays); end if; if (v_subfeemode = 1) then --收取本帐期全副费用 if v_tag = 0 then v_subfee := v_subfee + v_rentfee; end if; elsif (v_subfeemode = 2) then --上半月订购收取全月费用,下半月订购收取半月费用 if v_tag = 0 then if (to_number(substr(v_sysdate8,7,2)) - 15 > 0) then v_subfee := v_subfee + v_rentfee/2; else v_subfee := v_subfee + v_rentfee; end if; end if; elsif (v_subfeemode = 3) then --n日全费含n日,n日后收费 if (v_subfeedays = 0) then --0示意本月全副收费,其余示意 N号之后收费。 null; elsif (to_number(substr(v_sysdate8,7,2)) - v_subfeedays <= 0) then if v_tag = 0 then v_subfee := v_subfee + v_rentfee; end if; else null; end if; elsif (v_subfeemode = 4) then --理论天数免费 if v_tag = 0 then v_leftdays := to_number(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')) - to_date(v_sysdate14,'yyyymmddhh24miss')) + 1; v_monthdays := to_number(substr(v_curmonthendtime,7,2)); v_subfee := v_subfee + v_rentfee*(v_leftdays/v_monthdays); end if; end if; end if; end if; end if; end if; end if; o_subfee := v_subfee; if o_subfee < v_minlimitfee then o_subfee := v_minlimitfee; end if; if o_subfee > 0 then o_lastrenttime := v_sysdate14; o_payfordate := v_sysdate8; if v_cyctype = 0 then o_nextrentdate := '99991231'; end if; end if;end if;--added by youqunxia 20130922 Order3.02.01if (i_cmdchannel = 40) then --收费体验和积分兑换,不填写chargetime if i_isexperience in(1,2) then null; --费用>0,填写零碎工夫 elsif (o_subfee > 0) then v_chargetime := v_sysdate14; --费用=0,填写下次扣租日 else v_chargetime := o_nextrentdate || '050000'; end if;end if;o_chargetime := v_chargetime;
/*
--part-- --订购-- 生产限额鉴权
*/
-- if (o_mutiluserexit = 1) and (v_subfee > 0) and (v_productpayparty <> 1) then
if (v_subfee > 0) and (v_productpayparty <> 1) then if (v_srcmaxlimitfee = 0) then v_srcmaxlimitfee := i_monthconsumedlimit; end if; if (v_srcmaxlimitfee > 0) then begin v_sql := 'select sum(usedamounts) from zxdbm_ismp.ssrv_user_totalamount' || v_curstrmonth || ' where userindex = :p1 and amounttype = 8 and amountindex = 0 and productindex = 0 and expiredate = :p2'; execute immediate v_sql into v_usedamounts using v_srcuserindex,v_expiredate; exception when no_data_found then v_usedamounts := 0; when others then o_retcode := 506; o_debugpos := 171; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_usedamounts > v_srcmaxlimitfee) then o_maxlimitfee := to_char(v_srcmaxlimitfee); o_retcode := 1006; --用户已达生产限额 o_debugpos := 172; o_debuginfo := 'v_usedamounts = '||v_usedamounts||', v_srcmaxlimitfee = '||v_srcmaxlimitfee||', the usr run out the limit fee.'; return; end if; end if;end if;
/*
--part-- --订购-- 设置订购关系完结工夫
*/
if v_popuexist in (0,1,3) then --推广期根本计费费率 v_chargetype := v_jbchargetype; v_cycunit := v_jbcycunit; v_cycparam := v_jbcycparam; v_cyctype := v_jbcyctype;end if;if (v_freedays > 0) and (v_hasrecord = 0) and (v_freenotify in (1,2)) then--modied by youqunxia2013.04.18 v_subendtime := o_freetime;else if v_chargetype in (1,4) then v_subendtime := v_productendtime; elsif v_chargetype in (2,5,7) then if v_cyctype = 1 then v_subendtime := v_productendtime; --added by youqunxia20130924 order3.02.01 elsif v_invalidmode = 2 then --上海院需要,退订应用足月的计算规定,退订后可应用到订购日(临界条件非凡解决) v_unsubenddate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),1), 'yyyymmdd'); if substr(v_substarttime,7,2) < substr(v_unsubenddate,7,2) then --实用2月28日订购(非平年)相似情景 v_unsubenddate :=substr(v_unsubenddate,1,6)||substr(v_substarttime,7,2); end if; v_nextrentdate := to_char(to_date(v_unsubenddate,'yyyymmdd') + 1,'yyyymmdd'); --广东院需要,退订应用足月的计算规定,退订后应用到订购日前一天(临界条件非凡解决) if i_fullmonthmode = 1 then v_nextrentdate := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),1), 'yyyymmdd'); if substr(v_substarttime,7,2) < substr(v_nextrentdate,7,2) then --实用2月28日订购(非平年)相似情景 v_nextrentdate :=substr(v_nextrentdate,1,6)||substr(v_substarttime,7,2); elsif substr(v_substarttime,7,2) > substr(v_nextrentdate,7,2) then --实用1月31订购的相似情景 v_nextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmdd'),1), 'yyyymm')||'01'; end if; end if; v_subendtime := to_char(to_date(v_nextrentdate,'yyyymmdd') -1,'yyyymmdd')||'235959'; else v_subendtime := to_char(last_day(to_date(v_substarttime,'yyyymmddhh24miss')),'yyyymmdd') || '235959'; end if; elsif v_chargetype in (3,6,8,9) then if (v_cycunit = 1) then --包天 --周期性 if v_cyctype = 1 then v_subendtime := v_productendtime; else if v_popuexist in (0,1) then --推广期存在 v_subendtime := to_char(to_date(v_popustop,'yyyymmdd') + v_cycparam, 'yyyymmdd')||'235959'; elsif (v_freedays > 0) and (v_hasrecord = 0) and (i_servicetype = 5) then --MVS业务包天非周期有收费期的场景 v_subendtime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_freedays/24 + v_cycparam,'yyyymmddhh24miss'); elsif (v_freedays > 0) and (v_hasrecord = 0) then --含收费期首次订购 v_subendtime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_freedays + v_cycparam - 1,'yyyymmdd')||'235959'; else if i_servicetype = 5 and v_cursubstatus = 4 then --MVS业务待生效反复订购时,在原有完结时上基本上进行周期累加 v_subendtime := to_char(to_date(v_subendtime,'yyyymmddhh24miss') + v_cycparam,'yyyymmdd')||'235959'; else v_subendtime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_cycparam,'yyyymmdd')||'235959'; end if; end if; end if; elsif (v_cycunit = 2) then --包周 --周期性 if v_cyctype = 1 then v_subendtime := v_productendtime; else if v_popuexist in (0,1) then v_subendtime := to_char(to_date(v_popustop,'yyyymmdd') + v_cycparam*7, 'yyyymmdd')||'235959'; elsif (v_freedays > 0) and (v_hasrecord = 0) then v_subendtime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_freedays + v_cycparam*7-1,'yyyymmdd')||'235959'; else v_subendtime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + v_cycparam*7-1,'yyyymmdd')||'235959'; end if; end if; elsif (v_cycunit = 3) then --包月 --周期性 if v_cyctype = 1 then v_subendtime := v_productendtime; else if v_popuexist in (0,1) then v_subendtime := to_char(add_months(to_date(v_popustop,'yyyymmdd'),v_cycparam), 'yyyymmdd')||'235959'; elsif (v_freedays > 0) and (v_hasrecord = 0) then v_subendtime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam) + v_freedays -1,'yyyymmdd')||'235959'; else v_subendtime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam) -1,'yyyymmdd')||'235959'; end if; end if; elsif (v_cycunit = 4) then --包半年 --周期性 if v_cyctype = 1 then v_subendtime := v_productendtime; else if v_popuexist in (0,1) then v_subendtime := to_char(add_months(to_date(v_popustop,'yyyymmdd'),v_cycparam*6), 'yyyymmdd')||'235959'; elsif (v_freedays > 0) and (v_hasrecord = 0) then v_subendtime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam*6) + v_freedays - 1,'yyyymmdd')||'235959'; else v_subendtime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam*6)-1,'yyyymmdd')||'235959'; end if; end if; elsif (v_cycunit = 5) then --包年 --周期性 if v_cyctype = 1 then v_subendtime := v_productendtime; else if v_popuexist in (0,1) then v_subendtime := to_char(add_months(to_date(v_popustop,'yyyymmdd'),v_cycparam*12), 'yyyymmdd')||'235959'; elsif (v_freedays > 0) and (v_hasrecord = 0) then v_subendtime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam*12)+ v_freedays - 1,'yyyymmdd')||'235959'; else v_subendtime := to_char(add_months(to_date(v_substarttime,'yyyymmddhh24miss'),v_cycparam*12)-1,'yyyymmdd')||'235959'; end if; end if; end if; else v_subendtime := v_productendtime; --订购终止工夫,临时定为产品终止工夫 end if;end if;o_substarttime := v_substarttime;o_subendtime := v_subendtime;o_substatus := v_substatus;
-- o_cdrbegintime := v_substarttime;
--added by youqunxia 2013.02.18o_freenotify := v_freenotify;--added by youqunxia 20130314o_validmode := v_validmode;
/*
--part-- --订购-- 设置话单中的begintime、endtime
*/
--added by youqunxia20130924 order3.02.01--退订应用足月产品:话单计费完结工夫为下次扣租前一天的"235959"if v_chargetype in (2,5,7) and v_nextrentdate <= substr(v_subendtime,1,8) then if v_invalidmode = 2 then o_cdrendtime := to_char(to_date(v_nextrentdate,'yyyymmdd')-1,'yyyymmdd')||'235959'; end if;end if;--收费期产品订购if (o_freetime > o_substarttime) and (o_subfee = 0) then o_cnfmtype := 2;end if;--EventID chanelPlayerID 状态查问if i_actiontype = 1 then begin select status into o_chanelplayerstate from zxdbm_ismp.channel_basic where cpid = i_channelid; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 173; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; begin select status into o_eventstate from zxdbm_ismp.ssys_event where eventid = i_eventid; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 174; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--伪码解决(反对伪码开关关上,非自营sp)--反对业务LCS,SMS,MVS,DLS,MMS,WAP,CPX--MOAT时,AuthPriceReq音讯中OA实在号码转化为伪码,同步SP应用
-- if (o_mutiluserexit = 1) and i_servicetype in (1,2,3,4,41,5,6,101) then
if i_servicetype in (1,2,3,4,41,5,6,101) then if i_checkpseudocode = 1 and v_cpsrvtype <> 3 then if i_serviceflowtype = 1 then begin select pseudocode into o_pseudocode from zxdbm_ismp.susr_basic where usercode = i_oa; exception when no_data_found then o_retcode := 1001; o_debugpos := 175; o_debuginfo := 'i_oa = '||i_oa||', the user does not exist.'; return; when others then o_retcode := 506; o_debugpos := 176; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_pcodemsisdnswitch := 1; end if; end if;end if;--是否需进行二次确认if (i_isnondreplay = 1) then o_needreplay := 0;else o_needreplay := v_needreplay; if (i_cmdchannel = 45) then if (i_webgwcnfmswitch = 1) and (v_cpsrvtype <> 3) then o_needreplay := v_needreplay; else o_needreplay := 0; end if; end if;end if;--是否立刻下发收费期揭示确认短息设置--added by youqunxia20130603 order2.07.10if (v_freetime > v_substarttime) and (v_hasrecord = 0) then if (i_actiontype in (1,17,102) and v_needreplay = 0) or i_actiontype = 10 then v_freenoticetime := to_char(to_date(v_substarttime,'yyyymmddhh24miss') + 1,'yyyymmdd') || '080000'; if (v_freetime < v_freenoticetime) then o_freenoticenow := 1; end if; end if;end if;--组装同步给SP的音讯if (o_needreplay = 0) then if (o_protocoltype <> 0) then if (i_supportproductid = 1) then --应用产品代码同步 if (o_protocoltype = 2) then o_msgtosp := 'DG' || ' ' || v_productid || ' ' || v_usemsisdn; elsif (o_protocoltype = 1) then --平台向sp发送的同步音讯 o_msgtosp := '1001' || ' ' || v_productid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; --平台向sp发送的确认音讯 o_cnfmmsgtosp := '1000' || ' ' || v_productid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; end if; else --应用业务代码同步 if (o_protocoltype = 2) then o_msgtosp := 'DG' || ' ' || v_serviceid || ' ' || v_usemsisdn; elsif (o_protocoltype = 1) then --平台向sp发送的同步音讯 o_msgtosp := '1001' || ' ' || v_serviceid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; --平台向sp发送的确认音讯 o_cnfmmsgtosp := '1000' || ' ' || v_serviceid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; end if; end if; end if;else --生成linknum begin v_tmpint := dbms_random.value(1,9999999999); o_linknum := v_sysdate14 || '655380' || lpad(to_char(v_tmpint),10,'0'); exception when others then o_retcode := 506; o_debugpos := 177; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;
end slp_200_telicomsubreq;
/
prompt zxdbm_200.slp_200_telicomsubresp
create or replace procedure zxdbm_200.slp_200_telicomsubresp
(
i_srcmsisdn in varchar2, --发起方/赠送方用户号码i_usemsisdn in varchar2, --应用方/受赠方用户号码i_paymsisdn in varchar2, --计费方用户号码i_payuserindex in number, --计费方号码序号i_mutidbmode in number, --零碎参数:是否多DB环境 0:否 1:是i_cmdchannel in number, --动作起源i_isthird in number, --0:一般订购 1:赠送i_servicetype in number, --产品业务能力类型i_subcapability in number, --产品业务能力子类型i_serviceindex in number, --业务序号i_serviceid in varchar2, --业务代码i_productindex in number, --产品序号i_productid in varchar2, --产品代码i_chargetype in number, --产品计费类型i_cyctype in number, --产品周期类型i_corpindex in number, --团体序号i_corpid in varchar2, --团体代码i_cpindex in number, --CP/SP序号i_cpid in varchar2, --CP/SP代码i_substatus in number, --产品订购关系状态i_autocontinue in number, --周期性订购是否主动续订i_substarttime in varchar2, --产品订购关系失效工夫i_subendtime in varchar2, --产品订购关系生效工夫i_lastrenttime in varchar2, --产品订购关系上次扣租工夫i_nextrentdate in varchar2, --产品订购关系下次扣租日期i_payfordate in varchar2, --月租已付日期i_fixusetimes in number, --产品包量值i_freetime in varchar2, --产品订购关系收费期i_opid in varchar2, --操作员工号i_subfee in number, --本次订购须要扣取的费用i_usemsisdntype in number, --应用方号码类型,1:msisdn,2:phs,3:pstni_pseudocode in varchar2, --用户伪码i_pcodemsisdnswitch in number, --若!=0,则将伪码入订购关系表i_cancelproductid in varchar2, --被189替换的产品代码i_issecondproduct in number, --订购流程子类型 0:一般订购 1:业务订购 2:待生效订购关系订购 3:纯包量反复订购 6:可变价的反复订购i_needcharge in number, --产品是否须要计费(只用于多db的跨db赠送)--addded by youqunxia20130604 order2.07.10i_freenoticenow in number, --是否立刻下发过收费期揭示短信 0-否,1-是i_pproductofferid in varchar2, --增值产品对应的捆绑类套餐ID--added by youqunxia20130818 order3.02.01i_varifee in varchar2, --可变价格i_eventid in varchar2, --事件IDi_isexperience in varchar2, --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0i_subscribetype in varchar2, --订购形式:0:非批量受理 1: 批量受理i_chargetime in varchar2, --首次扣费时间o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_productsubid out varchar2, --产品订购关系代码o_porductsubindex out number --产品订购关系序号
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_sysdate8 char(8) := substr(v_sysdate14,1,8);v_plantime char(8) := substr(v_sysdate14,1,8);v_sysmonth6 char(6) := substr(v_sysdate14,1,6);v_curmonth number(2) := to_number(substr(v_sysdate14,5,2)); --长期寄存以后月份v_curstrmonth char(2) := lpad(to_char(v_curmonth),2,'0'); --长期寄存以后月份,字符型v_curmonthendtime char(14) := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')),'yyyymmdd')||'235959';v_freenoticetime1 char(14) := '00000000000000';v_updateflag number(3) := 0; --长期寄存更新胜利标记v_retvalue number(10) := 0; --长期寄存序列值v_freemsisdntype number(3) := 1; --长期寄存收费期揭示的号码类型v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_hasrecord number(3) := 0; --长期寄存产品订购关系是否存在v_issecondproduct number(3) := i_issecondproduct; --订购流程子类型 0:一般订购 1:业务订购 2:待生效订购关系订购 3:纯包量反复订购 6:可变价的反复订购 7:体验转正式的反复订购v_isservicesub number(3) := 0; --长期寄存是否业务订购(189邮箱)v_temp number(10) := 0; --长期寄存变量v_productsubindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --长期寄存订购关系序号v_productsubid zxdbm_200.s200_user_subscription.subscriptionid%type := ' '; --长期寄存订购关系代码v_servicetype zxdbm_200.s200_user_subscription.servicetype%type := i_servicetype; --长期寄存业务能力类型v_subcapability zxdbm_200.s200_user_subscription.subcapability%type := i_subcapability; --长期寄存业务能力子类型v_serviceindex zxdbm_200.s200_user_subscription.serviceindex%type := i_serviceindex; --长期寄存业务序号v_serviceid zxdbm_200.s200_user_subscription.serviceid%type := i_serviceid; --长期寄存业务代码v_productindex zxdbm_200.s200_user_subscription.productindex%type := i_productindex; --长期寄存产品序号v_productid zxdbm_200.s200_user_subscription.productid%type := i_productid; --长期寄存产品代码v_propkgindex zxdbm_200.s200_user_subscription.productpkgindex%type := 0; --长期寄存套餐序号v_propkgid zxdbm_200.s200_user_subscription.productpkgid%type := ' '; --长期寄存套餐代码v_contentindex zxdbm_200.s200_user_subscription.contentindex%type := 0; --长期寄存内容序号v_contentid zxdbm_200.s200_user_subscription.contentid%type := ' '; --长期寄存内容代码v_corpindex zxdbm_200.s200_user_subscription.corpindex%type := i_corpindex; --长期寄存团体序号v_corpid zxdbm_200.s200_user_subscription.corpid%type := i_corpid; --长期寄存团体代码v_cpindex zxdbm_200.s200_user_subscription.cpindex%type := i_cpindex; --长期寄存CP/SP序号v_cpid zxdbm_200.s200_user_subscription.cpid%type := i_cpid; --长期寄存CP/SP代码v_srcmsisdn zxdbm_200.s200_user_subscription.subscriber%type := i_srcmsisdn; --发起方/赠送方用户号码v_usemsisdn zxdbm_200.s200_user_subscription.usercode%type := i_usemsisdn; --应用方/受赠方用户号码v_paymsisdn zxdbm_200.s200_user_subscription.payuser%type := i_paymsisdn; --计费方用户号码v_subscribemode zxdbm_200.s200_user_subscription.subscribemode%type := 1; --长期寄存订购形式v_subscribechannel zxdbm_200.s200_user_subscription.subscribechannel%type := 3; --长期寄存订购渠道v_subscribeoptype zxdbm_200.s200_user_subscription.subscribeoptype%type := 0; --长期寄存订购操作v_cancelmode zxdbm_200.s200_user_subscription.cancelmode%type := 0; --长期寄存订购形式v_cancelchannel zxdbm_200.s200_user_subscription.cancelchannel%type := 0; --长期寄存订购渠道v_canceloptype zxdbm_200.s200_user_subscription.canceloptype%type := 0; --长期寄存订购操作v_pausemode zxdbm_200.s200_user_subscription.pausemode%type := 0; --长期寄存产品暂停起因v_resumemode zxdbm_200.s200_user_subscription.resumemode%type := 0; --长期寄存产品复原起因v_substatus zxdbm_200.s200_user_subscription.status%type := i_substatus; --长期寄存产品订购关系状态v_autocontinue zxdbm_200.s200_user_subscription.autocontinue%type := i_autocontinue; --长期寄存周期性定购,是否主动续订v_pushid zxdbm_200.s200_user_subscription.pushid%type := ' '; --长期寄存推荐者IDv_substarttime zxdbm_200.s200_user_subscription.starttime%type := i_substarttime; --长期寄存定购失效工夫v_subendtime zxdbm_200.s200_user_subscription.endtime%type := i_subendtime; --长期寄存定购生效工夫v_lastrenttime zxdbm_200.s200_user_subscription.lastrenttime%type := i_lastrenttime; --长期寄存上次扣租工夫v_nextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := i_nextrentdate; --长期寄存下次扣租日期v_payfordate zxdbm_200.s200_user_subscription.payfordate%type := i_payfordate; --长期寄存月租已付日期v_returnvalues zxdbm_200.s200_user_subscription.returnvalues%type := 0; --长期寄存下一周期返还值v_returntype zxdbm_200.s200_user_subscription.returntype%type := 1; --长期寄存返还量类型v_returnstartdate zxdbm_200.s200_user_subscription.returnstartdate%type := '00000000'; --长期寄存返还值开始日期v_returnenddate zxdbm_200.s200_user_subscription.returnenddate%type := '00000000'; --长期寄存返还值完结日期v_fixusetimes zxdbm_200.s200_user_subscription.fixusetimes%type := i_fixusetimes; --长期寄存非周期包量容许应用值v_chargeparty zxdbm_200.s200_user_subscription.chargeparty%type := 0; --长期寄存定购时填入,扣月租应用,计费方 0:用户;1:SP;2:团体v_freetime zxdbm_200.s200_user_subscription.freetime%type := i_freetime; --长期寄存产品订购收费日期v_canceltime zxdbm_200.s200_user_subscription.canceltime%type := '00000000000000'; --长期寄存用户退定工夫v_firstusetime zxdbm_200.s200_user_subscription.firstusetime%type := '00000000000000'; --长期寄存用户首次应用工夫v_lastusetime zxdbm_200.s200_user_subscription.lastusetime%type := '00000000000000'; --长期寄存用户上次应用工夫v_tastestarttime zxdbm_200.s200_user_subscription.tastestarttime%type := '00000000000000'; --长期寄存体验期开始工夫v_tasteendtime zxdbm_200.s200_user_subscription.tasteendtime%type := '00000000000000'; --长期寄存体验期完结工夫v_pausetime zxdbm_200.s200_user_subscription.pausetime%type := '00000000000000'; --长期寄存暂停工夫v_resumetime zxdbm_200.s200_user_subscription.resumetime%type := '00000000000000'; --长期寄存暂停复原工夫v_subscribeopid zxdbm_200.s200_user_subscription.subscribeopid%type := i_opid; --长期寄存定购操作员工号v_cancelopid zxdbm_200.s200_user_subscription.cancelopid%type := ' '; --长期寄存退定操作员工号v_cancelreason zxdbm_200.s200_user_subscription.cancelreason%type := ' '; --长期寄存退定起因形容v_lastrent zxdbm_200.s200_user_subscription.lastrent%type := i_subfee; --长期寄存上次扣租金额v_msisdntype zxdbm_200.s200_user_subscription.msisdntype%type := i_usemsisdntype; --长期寄存用户号码类型 1-msisdn,2-phs,3-pstn,4-IPTV接入号,5-宽带接入号,6-固定IPv_beupdatedproductid zxdbm_200.s200_user_subscription.productid%type := i_cancelproductid; --长期寄存产品代码v_mdbsubstatus zxdbm_200.s200_user_subscription.status%type := 0; --长期寄存产品订购关系状态v_productpkgindex zxdbm_200.s200_user_subscription.productpkgindex%type := 0; --长期寄存产品订购关系状态v_pproductofferid zxdbm_200.s200_user_subscription.pproductofferid%type := ' '; --长期寄存增值产品对应的捆绑类套餐ID--added by youqunxia20130818 order3.02.01v_varifee zxdbm_200.s200_user_subscription.varifee%type := ''; --长期寄存以后订购关系中的可变价格v_eventid zxdbm_200.s200_user_subscription.eventid%type := ''; --长期寄存事件IDv_isexperience zxdbm_200.s200_user_subscription.isexperience%type := i_isexperience; --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0v_subscribetype zxdbm_200.s200_user_subscription.subscribetype%type := i_subscribetype; --订购形式:0:非批量受理 1: 批量受理 默认为0v_chargetime zxdbm_200.s200_user_subscription.chargetime%type := '00000000000000'; --首次扣费时间--被189替换的订购关系v_cancelproductsubindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --长期寄存订购关系序号v_cancelproductsubid zxdbm_200.s200_user_subscription.subscriptionid%type := ' '; --长期寄存订购关系代码v_cancelservicetype zxdbm_200.s200_user_subscription.servicetype%type := i_servicetype; --长期寄存业务能力类型v_cancelsubcapability zxdbm_200.s200_user_subscription.subcapability%type := i_subcapability; --长期寄存业务能力子类型v_cancelserviceindex zxdbm_200.s200_user_subscription.serviceindex%type := i_serviceindex; --长期寄存业务序号v_cancelserviceid zxdbm_200.s200_user_subscription.serviceid%type := i_serviceid; --长期寄存业务代码v_cancelproductindex zxdbm_200.s200_user_subscription.productindex%type := i_productindex; --长期寄存产品序号v_cancelproductid zxdbm_200.s200_user_subscription.productid%type := i_productid; --长期寄存产品代码v_cancelpropkgindex zxdbm_200.s200_user_subscription.productpkgindex%type := 0; --长期寄存套餐序号v_cancelpropkgid zxdbm_200.s200_user_subscription.productpkgid%type := ' '; --长期寄存套餐代码v_cancelcontentindex zxdbm_200.s200_user_subscription.contentindex%type := 0; --长期寄存内容序号v_cancelcontentid zxdbm_200.s200_user_subscription.contentid%type := ' '; --长期寄存内容代码v_cancelcorpindex zxdbm_200.s200_user_subscription.corpindex%type := i_corpindex; --长期寄存团体序号v_cancelcorpid zxdbm_200.s200_user_subscription.corpid%type := i_corpid; --长期寄存团体代码v_cancelcpindex zxdbm_200.s200_user_subscription.cpindex%type := i_cpindex; --长期寄存CP/SP序号v_cancelcpid zxdbm_200.s200_user_subscription.cpid%type := i_cpid; --长期寄存CP/SP代码v_cancelsubscriber zxdbm_200.s200_user_subscription.subscriber%type := i_srcmsisdn; --发起方/赠送方用户号码v_cancelusercode zxdbm_200.s200_user_subscription.usercode%type := i_usemsisdn; --应用方/受赠方用户号码v_cancelpayuser zxdbm_200.s200_user_subscription.payuser%type := i_paymsisdn; --计费方用户号码v_cancelsubscribemode zxdbm_200.s200_user_subscription.subscribemode%type := 1; --长期寄存订购形式v_cancelsubscribechannel zxdbm_200.s200_user_subscription.subscribechannel%type := 3; --长期寄存订购渠道v_cancelsubscribeoptype zxdbm_200.s200_user_subscription.subscribeoptype%type := 0; --长期寄存订购操作v_cancelcancelmode zxdbm_200.s200_user_subscription.cancelmode%type := 0; --长期寄存订购形式v_cancelcancelchannel zxdbm_200.s200_user_subscription.cancelchannel%type := 0; --长期寄存订购渠道v_cancelpausemode zxdbm_200.s200_user_subscription.pausemode%type := 0; --长期寄存产品暂停起因v_cancelresumemode zxdbm_200.s200_user_subscription.resumemode%type := 0; --长期寄存产品复原起因v_cancelsubstatus zxdbm_200.s200_user_subscription.status%type := i_substatus; --长期寄存产品订购关系状态v_cancelstatustime zxdbm_200.s200_user_subscription.statustime%type := '00000000000000';v_cancelautocontinue zxdbm_200.s200_user_subscription.autocontinue%type := i_autocontinue; --长期寄存周期性定购,是否主动续订v_cancelpushid zxdbm_200.s200_user_subscription.pushid%type := ' '; --长期寄存推荐者IDv_cancelsubstarttime zxdbm_200.s200_user_subscription.starttime%type := i_substarttime; --长期寄存定购失效工夫v_cancelsubendtime zxdbm_200.s200_user_subscription.endtime%type := i_subendtime; --长期寄存定购生效工夫v_cancellastrenttime zxdbm_200.s200_user_subscription.lastrenttime%type := i_lastrenttime; --长期寄存上次扣租工夫v_cancelnextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := i_nextrentdate; --长期寄存下次扣租日期v_cancelpayfordate zxdbm_200.s200_user_subscription.payfordate%type := i_payfordate; --长期寄存月租已付日期v_cancelreturnvalues zxdbm_200.s200_user_subscription.returnvalues%type := 0; --长期寄存下一周期返还值v_cancelreturntype zxdbm_200.s200_user_subscription.returntype%type := 1; --长期寄存返还量类型v_cancelreturnstartdate zxdbm_200.s200_user_subscription.returnstartdate%type := '00000000'; --长期寄存返还值开始日期v_cancelreturnenddate zxdbm_200.s200_user_subscription.returnenddate%type := '00000000'; --长期寄存返还值完结日期v_cancelfixusetimes zxdbm_200.s200_user_subscription.fixusetimes%type := i_fixusetimes; --长期寄存非周期包量容许应用值v_cancelchargeparty zxdbm_200.s200_user_subscription.chargeparty%type := 0; --长期寄存定购时填入,扣月租应用,计费方 0:用户;1:SP;2:团体v_cancelfreetime zxdbm_200.s200_user_subscription.freetime%type := i_freetime; --长期寄存产品订购收费日期v_cancelcreatetime zxdbm_200.s200_user_subscription.freetime%type := v_sysdate14; --长期寄存产品订购创立日期v_cancelcanceltime zxdbm_200.s200_user_subscription.canceltime%type := '00000000000000'; --长期寄存用户退定工夫v_cancelfirstusetime zxdbm_200.s200_user_subscription.firstusetime%type := '00000000000000'; --长期寄存用户首次应用工夫v_cancellastusetime zxdbm_200.s200_user_subscription.lastusetime%type := '00000000000000'; --长期寄存用户上次应用工夫v_canceltastestarttime zxdbm_200.s200_user_subscription.tastestarttime%type := '00000000000000'; --长期寄存体验期开始工夫v_canceltasteendtime zxdbm_200.s200_user_subscription.tasteendtime%type := '00000000000000'; --长期寄存体验期完结工夫v_cancelpausetime zxdbm_200.s200_user_subscription.pausetime%type := '00000000000000'; --长期寄存暂停工夫v_cancelresumetime zxdbm_200.s200_user_subscription.resumetime%type := '00000000000000'; --长期寄存暂停复原工夫v_cancelsubscribeopid zxdbm_200.s200_user_subscription.subscribeopid%type := i_opid; --长期寄存定购操作员工号v_cancelcancelopid zxdbm_200.s200_user_subscription.cancelopid%type := ' '; --长期寄存退定操作员工号v_cancelcancelreason zxdbm_200.s200_user_subscription.cancelreason%type := ' '; --长期寄存退定起因形容v_cancellastrent zxdbm_200.s200_user_subscription.lastrent%type := i_subfee; --长期寄存上次扣租金额v_cancelmsisdntype zxdbm_200.s200_user_subscription.msisdntype%type := i_usemsisdntype; --长期寄存用户号码类型 1-msisdn,2-phs,3-pstn,4-IPTV接入号,5-宽带接入号,6-固定IPv_cancelpseudocode zxdbm_200.s200_user_subscription.pseudocode%type := ' '; --长期寄存用户号码类型 1-msisdn,2-phs,3-pstn,4-IPTV接入号,5-宽带接入号,6-固定IPv_canceloldproductid zxdbm_200.s200_user_subscription.oldproductid%type := ' '; --长期寄存被替换产品IDv_cancelpproductofferid zxdbm_200.s200_user_subscription.pproductofferid%type := ' '; --长期寄存增值产品对应的捆绑类套餐ID--added by youqunxia20130818 order3.02.01v_cancelvarifee zxdbm_200.s200_user_subscription.varifee%type := ''; --长期寄存可变价格 v_canceleventid zxdbm_200.s200_user_subscription.eventid%type := ''; --长期寄存事件IDv_cancelisexperience zxdbm_200.s200_user_subscription.isexperience%type := i_isexperience; --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0v_cancelsubscribetype zxdbm_200.s200_user_subscription.subscribetype%type := i_subscribetype; --订购形式:0:非批量受理 1: 批量受理v_cancelchargetime zxdbm_200.s200_user_subscription.chargetime%type := '00000000000000'; --首次扣费时间v_unitvol zxdbm_200.s200_product_fee.unitvol%type := 10; --长期寄存绝对于目前最小计量单位的量,时长为百毫秒,流量为bytev_chargetype zxdbm_200.s200_product_fee.chargetype%type := 0; --长期寄存根本计费类型v_popuitem zxdbm_200.s200_product.popularizeitem%type := 2; --长期推广期计费类型v_popustart zxdbm_200.s200_product.popularizestart%type := v_sysdate8; --长期推广期计费类型v_popustop zxdbm_200.s200_product.popularizestop%type := v_sysdate8; --长期推广期计费类型v_needcharge zxdbm_200.s200_product.needcharge%type := 1; --长期是否须要计费v_fixtotalres zxdbm_ismp.ssrv_user_totalamount.fixtotalres%type := 0; --长期寄存包量最大容许应用资源,0-无限度v_pseudocode zxdbm_ismp.susr_basic.pseudocode%type := ' ';v_payuserindex zxdbm_ismp.susr_basic.userindex%type := i_payuserindex; --长期寄存计费方用户序号
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_productsubid := ' ';o_porductsubindex := 0;
/
多DB,赠送,订购关系鉴权 此局部鉴权可能有问题,后续再查看批改
*/
if (i_mutidbmode = 1 and i_isthird = 1) then v_hasrecord := 1; begin select status,productpkgindex into v_mdbsubstatus,v_productpkgindex from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid; exception when no_data_found then v_hasrecord := 0; when others then o_retcode := 506; o_debugpos := 1; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_hasrecord > 0) then if v_productpkgindex <> 0 then o_retcode := 1200; --该产品属于套餐,且用户已订购该套餐 o_debugpos := 2; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the user has subscribed pkg including this product.'; return; end if; if v_mdbsubstatus <> 4 and i_chargetype <> 4 then --(待生效订购关系 或 纯包量)能够反复订购 o_retcode := 1200; --用户曾经定购该产品 o_debugpos := 3; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||' mutidbmode, the user has subscribed the product.'; return; elsif i_chargetype = 4 then --判断程序不能颠倒 v_issecondproduct := 3; elsif v_mdbsubstatus = 4 then v_issecondproduct := 2; --待生效订购关系能够订购 end if; end if; --查看该产品所属的业务是否是互斥的(只有短彩WAP的该字段可能为1) begin select isservicesub into v_isservicesub from zxdbm_200.s200_service where serviceindex = i_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 4; o_debuginfo := 'i_serviceindex='||i_serviceindex||' mutidbmode, the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 5; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --业务订购关系鉴权(目前仅MVS,DLS,BREW为内容类业务) if i_servicetype not in (5,6,98) and v_hasrecord = 0 then v_issecondproduct := 1; v_hasrecord := 0; begin select productid,productpkgindex into v_beupdatedproductid,v_productpkgindex from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and cpid = v_cpid and serviceid = v_serviceid; exception when no_data_found then v_issecondproduct := 0; v_hasrecord := 0; when others then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_hasrecord > 0 then if v_productpkgindex <> 0 then o_retcode := 1001210; --不能替换产品组合蕴含的产品 o_debugpos := 7; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productpkgindex = '||v_productpkgindex||', can not replace product in the pkg.'; return; end if; if v_beupdatedproductid <> v_productid then if i_servicetype in (1,2,3) and v_isservicesub = 1 then --sms,mms,wap业务订购 null; else o_retcode := 1001210; o_debugpos := 8; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', serviceid = '||v_serviceid||' mutidbmode, the user has subscribed a product in the same service.'; return; end if; end if; end if; end if; --业务订购/待生效订购关系只反对包月类产品 if v_issecondproduct in (1,2) then if v_issecondproduct = 2 and i_servicetype = 5 and i_chargetype in (3,6,8) then --MVS的包周期产品在订购关系待生效状态时能够续订 null; else if i_chargetype in (2,5,7) or i_needcharge =0 then null; else o_retcode := 9999; o_debugpos := 9; o_debuginfo := 'i_chargetype='||i_chargetype||' mutidbmode, No_month_Product can not update this subscription.'; end if; end if; end if;end if;if (i_pcodemsisdnswitch <> 0) then v_pseudocode := i_pseudocode; --用户伪码end if;
/
--part-- --订购2-- 订购渠道、订购形式
*/
--设置订购形式if (i_isthird = 1) then v_subscribemode := 4;elsif (i_cmdchannel = 4) then v_subscribemode := 2;elsif (i_cmdchannel = 0) then v_subscribemode := 5;elsif (i_cmdchannel = 27) then v_subscribemode := 3;else v_subscribemode := 1;end if;--查问订购渠道begin select portalchannel into v_subscribechannel from zxdbm_ismp.ssrv_channel_map where innerchannel = i_cmdchannel;exception when no_data_found then v_subscribechannel := i_cmdchannel * 1000;when others then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;--设置计费方if (v_paymsisdn = v_corpid) then v_chargeparty := 2;else v_chargeparty := 0;end if;--解决定购操作员工号if v_subscribeopid is null then v_subscribeopid := ' ';end if;
/**
设置订购时产生订购关系替换时,填历史订购关系表中的字段
**/
--设置退订渠道v_cancelcancelchannel := v_subscribechannel;--设置退订形式if (i_cmdchannel = 6) then v_cancelcancelmode := 4;elsif (i_cmdchannel in (0,20)) then v_cancelcancelmode := 3;elsif (i_cmdchannel = 4) then v_cancelcancelmode := 5;else v_cancelcancelmode := 2;end if;
/**
--part-- --订购2-- 事务开始
**/
begin if v_issecondproduct not in (1,2,6,7) then --0:一般订购,3:纯包量反复订购 --产品订购落订购关系 if i_chargetype = 4 and i_cyctype = 0 and v_issecondproduct = 3 then --纯包量的订购关系更新 --将订购关系转入历史表 /* 20110525wyl 1.删除从订购关系表中读出cancelmode,cancelchannel两个字段。(在后面曾经赋值,再次读出会笼罩) */ begin select subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex, cpid,subscribemode,subscribechannel,subscribeoptype, pausemode,resumemode,status,statustime,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelopid,cancelreason,lastrent,msisdntype,pseudocode,oldproductid, pproductofferid,varifee,eventid,isexperience,subscribetype,chargetime into v_cancelproductsubindex,v_cancelproductsubid,v_cancelservicetype,v_cancelsubcapability, v_cancelserviceindex,v_cancelserviceid,v_cancelproductindex,v_cancelproductid,v_cancelpropkgindex, v_cancelpropkgid,v_cancelcontentindex,v_cancelcontentid,v_cancelcorpindex,v_cancelcorpid,v_cancelcpindex, v_cancelcpid,v_cancelsubscribemode,v_cancelsubscribechannel,v_cancelsubscribeoptype, v_cancelpausemode,v_cancelresumemode,v_cancelsubstatus,v_cancelstatustime,v_cancelautocontinue,v_cancelsubscriber,v_cancelusercode, v_cancelpayuser,v_cancelpushid,v_cancelsubstarttime,v_cancelsubendtime,v_cancellastrenttime, v_cancelnextrentdate,v_cancelpayfordate,v_cancelreturnvalues,v_cancelreturntype, v_cancelreturnstartdate,v_cancelreturnenddate,v_cancelfixusetimes,v_cancelchargeparty, v_cancelfreetime,v_cancelcreatetime,v_cancelcanceltime,v_cancelfirstusetime,v_cancellastusetime, v_canceltastestarttime,v_canceltasteendtime,v_cancelpausetime,v_cancelresumetime, v_cancelsubscribeopid,v_cancelcancelopid,v_cancelcancelreason,v_cancellastrent,v_cancelmsisdntype,v_cancelpseudocode,v_canceloldproductid, v_cancelpproductofferid,v_cancelvarifee,v_canceleventid,v_cancelisexperience,v_cancelsubscribetype,v_cancelchargetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_beupdatedproductid; exception when no_data_found then o_retcode := 1201; o_debugpos := 12; o_debuginfo := 'the subscription dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 13; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;
-- v_cancelcancelmode := 6;
-- v_cancelcancelchannel := 110;
v_cancelcanceltime := v_sysdate14; v_sql := 'insert into zxdbm_200.s200_user_subs_hist' || v_curstrmonth || ' (subscriptionindex,subscriptionid,servicetype,subcapability,'|| 'serviceindex,serviceid,productindex,productid,contentindex,contentid,'|| 'productpkgindex,productpkgid,corpindex,corpid,cpindex,cpid,subscribemode,'|| 'subscribechannel,subscribeoptype,cancelmode,cancelchannel,canceloptype,'|| 'pausemode,resumemode,status,statustime,autocontinue,subscriber,usercode,'|| 'payuser,pushid,starttime,endtime,lastrenttime,nextrentdate,payfordate,'|| 'returnvalues,returntype,returnstartdate,returnenddate,fixusetimes,'|| 'chargeparty,freetime,createtime,canceltime,firstusetime,lastusetime,'|| 'tastestarttime,tasteendtime,pausetime,resumetime,subscribeopid,'|| 'cancelopid,cancelreason,lastrent,msisdntype,pseudocode,oldproductid,pproductofferid,varifee,eventid,'|| 'isexperience,subscribetype,chargetime) '|| 'values(:p1,:p2,:p3,:p4,'|| ':p5,:p6,:p7,:p8,:p9,:p10,'|| ':p11,:p12,:p13,:p14,:p15,:p16,:p17,'|| ':p18,:p19,:p20,:p21,:p22,'|| ':p23,:p24,:p25,:p26,:p27,:p28,'|| ':p29,:p30,:p31,:p32,:p33,:p34,:p35,'|| ':p36,:p37,:p38,:p39,:p40,'|| ':p41,:p42,:p43,:p44,:p45,:p46,'|| ':p47,:p48,:p49,:p50,:p51,'|| ':p52,:p53,:p54,:p55,:p56,:p57,:p58,:p59,:p60,:p61,'|| ':p62,:p63,:p64)'; begin --插入历史订购关系 execute immediate v_sql using v_cancelproductsubindex,v_cancelproductsubid,v_cancelservicetype,v_cancelsubcapability, v_cancelserviceindex,v_cancelserviceid,v_cancelproductindex,v_cancelproductid,v_cancelcontentindex,v_cancelcontentid, v_cancelpropkgindex,v_cancelpropkgid,v_cancelcorpindex,v_cancelcorpid,v_cancelcpindex,v_cancelcpid,v_cancelsubscribemode, v_cancelsubscribechannel,v_cancelsubscribeoptype,v_cancelcancelmode,v_cancelcancelchannel,v_canceloptype, v_cancelpausemode,v_cancelresumemode,v_cancelsubstatus,v_cancelstatustime,v_cancelautocontinue,v_cancelsubscriber,v_cancelusercode, v_cancelpayuser,v_cancelpushid,v_cancelsubstarttime,v_cancelsubendtime,v_cancellastrenttime,v_cancelnextrentdate,v_cancelpayfordate, v_cancelreturnvalues,v_cancelreturntype,v_cancelreturnstartdate,v_cancelreturnenddate,v_cancelfixusetimes, v_cancelchargeparty,v_cancelfreetime,v_cancelcreatetime,v_cancelcanceltime,v_cancelfirstusetime,v_cancellastusetime, v_canceltastestarttime,v_canceltasteendtime,v_cancelpausetime,v_cancelresumetime,v_cancelsubscribeopid, v_cancelcancelopid,v_cancelcancelreason,v_cancellastrent,v_cancelmsisdntype,v_cancelpseudocode,v_canceloldproductid, v_cancelpproductofferid,v_cancelvarifee,v_canceleventid,v_cancelisexperience,v_cancelsubscribetype,v_cancelchargetime; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'no subs exist.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 15; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; --对于非周期包量的产品,间接更新订购关系 --生成新的订购关系ID zxdbm_ismp.sp_getmaxvalue ('slp_order_prdindex',1,v_productsubindex); if (v_productsubindex = 0) then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'get slp_order_prdindex failed.'; rollback; return; end if; begin select trunc(dbms_random.value(10000,99999)) into v_retvalue from dual; exception when others then o_retcode := 506; o_debugpos := 17; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; v_productsubid := v_usemsisdn || to_char(v_retvalue); begin update zxdbm_200.s200_user_subscription set subscriptionindex = v_productsubindex, subscriptionid = v_productsubid, --fixusetimes = fixusetimes + v_fixusetimes, starttime = v_substarttime, endtime = v_subendtime, status = v_substatus, --freetime = v_freetime, createtime = v_sysdate14, lastusetime = v_lastusetime, statustime = v_sysdate14, lastrenttime = decode(v_lastrent,0,lastrenttime,v_sysdate14), lastrent = v_lastrent, subscribemode = v_subscribemode, subscribechannel = v_subscribechannel, subscribeoptype = v_subscribeoptype, subscribeopid = v_subscribeopid where usercode = v_usemsisdn and productid = v_productid returning subscriptionindex,subscriptionid into v_productsubindex,v_productsubid; if (sql%rowcount = 0) then v_updateflag := 0; else v_updateflag := 1; end if; exception when others then o_retcode := 506; o_debugpos := 18; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; if (v_updateflag = 0) then --生成新的订购关系 zxdbm_ismp.sp_getmaxvalue ('slp_order_prdindex',1,v_productsubindex); if (v_productsubindex = 0) then o_retcode := 506; o_debugpos := 19; o_debuginfo := 'get slp_order_prdindex failes.'; rollback; return; end if; begin select trunc(dbms_random.value(10000,99999)) into v_retvalue from dual; exception when others then o_retcode := 506; o_debugpos := 20; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; v_productsubid := v_usemsisdn || to_char(v_retvalue); --added by youqunxia20130605 order2.07.10 --对于VSOP发动的订购申请,若ExtC5非空,则将其填入订购关系表 if trim(i_pproductofferid) is null then v_pproductofferid := ' '; else v_pproductofferid := i_pproductofferid; end if; --added by youqunxia 20130818 Order3.02.01 --如果fee值非空,将其填入订购关系表 v_varifee := to_number(i_varifee); --如果eventid值非空,将其填入订购关系表 if trim(i_eventid) is not null then v_eventid := i_eventid; else v_eventid := ''; end if; --如果chargetime值非空,将其填入订购关系表 if trim(i_chargetime) is not null then v_chargetime := i_chargetime; else v_chargetime := '00000000000000'; end if; begin insert into zxdbm_200.s200_user_subscription (subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex,cpid, subscribemode,subscribechannel,subscribeoptype, cancelmode,cancelchannel,canceloptype,pausemode, resumemode,status,statustime,autocontinue,subscriber, usercode,payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime, lastusetime,tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelopid,cancelreason,lastrent,msisdntype, pseudocode,pproductofferid,varifee,eventid,isexperience,subscribetype,chargetime) values (v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_propkgindex, v_propkgid,v_contentindex,v_contentid,v_corpindex,v_corpid,v_cpindex,v_cpid, v_subscribemode,v_subscribechannel,v_subscribeoptype, v_cancelmode,v_cancelchannel,v_canceloptype,v_pausemode, v_resumemode,v_substatus,v_sysdate14,v_autocontinue,v_srcmsisdn, v_usemsisdn,v_paymsisdn,v_pushid,v_substarttime,v_subendtime,v_lastrenttime, v_nextrentdate,v_payfordate,v_returnvalues,v_returntype, v_returnstartdate,v_returnenddate,0,v_chargeparty, v_freetime,v_sysdate14,v_canceltime,v_firstusetime, v_lastusetime,v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime, v_subscribeopid,v_cancelopid,v_cancelreason,v_lastrent,v_msisdntype, v_pseudocode,v_pproductofferid,v_varifee,v_eventid,v_isexperience,v_subscribetype,v_chargetime); exception when others then o_retcode := 506; o_debugpos := 21; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; --added by youqunxia 20130818 Order3.02.01 --可变价的反复订购订购,有定购关系时,按变更价格解决,更新订购关系 elsif v_issecondproduct = 6 then v_varifee := to_number(i_varifee); --如果eventid值非空,将其填入订购关系表 if trim(i_eventid) is not null then v_eventid := i_eventid; else v_eventid := ''; end if; begin update zxdbm_200.s200_user_subscription set status = v_substatus, statustime = v_sysdate14, starttime = v_substarttime, endtime = v_subendtime, lastrenttime = v_lastrenttime, nextrentdate = v_nextrentdate, payfordate = v_payfordate, freetime = v_freetime, subscribeopid = v_subscribeopid, lastrent = v_lastrent, varifee = v_varifee, eventid = v_eventid where usercode = v_usemsisdn and productid = v_productid; exception when others then o_retcode := 506; o_debugpos := 38; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; --added by youqunxia 20131015 Order3.02.01 --体验转正式的反复订购,更新订购关系 elsif v_issecondproduct = 7 then --对于VSOP发动的订购申请,若ExtC5非空,则将其填入订购关系表 if trim(i_pproductofferid) is null then v_pproductofferid := ' '; else v_pproductofferid := i_pproductofferid; end if; v_varifee := to_number(i_varifee); --如果eventid值非空,将其填入订购关系表 if trim(i_eventid) is not null then v_eventid := i_eventid; else v_eventid := ''; end if; --如果chargetime值非空,将其填入订购关系表 if trim(i_chargetime) is not null then v_chargetime := i_chargetime; else v_chargetime := '00000000000000'; end if; begin update zxdbm_200.s200_user_subscription set status = v_substatus, statustime = v_sysdate14, starttime = v_substarttime, endtime = v_subendtime, lastrenttime = v_lastrenttime, nextrentdate = v_nextrentdate, payfordate = v_payfordate, freetime = v_freetime, subscribeopid = v_subscribeopid, lastrent = v_lastrent, pproductofferid = v_pproductofferid, varifee = v_varifee, eventid = v_eventid, isexperience = v_isexperience, subscribetype = v_subscribetype, chargetime = v_chargetime where usercode = v_usemsisdn and productid = v_productid; exception when others then o_retcode := 506; o_debugpos := 39; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; else --产品替换:1:业务订购 2:待生效订购关系订购 /* 20110525wyl 1.删除从订购关系表中读出cancelmode,cancelchannel两个字段。(在后面曾经赋值,再次读出会笼罩) */ begin select subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex, cpid,subscribemode,subscribechannel,subscribeoptype, pausemode,resumemode,status,statustime,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelopid,cancelreason,lastrent,msisdntype,pseudocode,oldproductid, pproductofferid,varifee,eventid,isexperience,subscribetype,chargetime into v_cancelproductsubindex,v_cancelproductsubid,v_cancelservicetype,v_cancelsubcapability, v_cancelserviceindex,v_cancelserviceid,v_cancelproductindex,v_cancelproductid,v_cancelpropkgindex, v_cancelpropkgid,v_cancelcontentindex,v_cancelcontentid,v_cancelcorpindex,v_cancelcorpid,v_cancelcpindex, v_cancelcpid,v_cancelsubscribemode,v_cancelsubscribechannel,v_cancelsubscribeoptype, v_cancelpausemode,v_cancelresumemode,v_cancelsubstatus,v_cancelstatustime,v_cancelautocontinue,v_cancelsubscriber,v_cancelusercode, v_cancelpayuser,v_cancelpushid,v_cancelsubstarttime,v_cancelsubendtime,v_cancellastrenttime, v_cancelnextrentdate,v_cancelpayfordate,v_cancelreturnvalues,v_cancelreturntype, v_cancelreturnstartdate,v_cancelreturnenddate,v_cancelfixusetimes,v_cancelchargeparty, v_cancelfreetime,v_cancelcreatetime,v_cancelcanceltime,v_cancelfirstusetime,v_cancellastusetime, v_canceltastestarttime,v_canceltasteendtime,v_cancelpausetime,v_cancelresumetime, v_cancelsubscribeopid,v_cancelcancelopid,v_cancelcancelreason,v_cancellastrent,v_cancelmsisdntype,v_cancelpseudocode,v_canceloldproductid, v_cancelpproductofferid,v_cancelvarifee,v_canceleventid,v_cancelisexperience,v_cancelsubscribetype,v_cancelchargetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_beupdatedproductid; exception when no_data_found then o_retcode := 1201; o_debugpos := 22; o_debuginfo := 'the subscription dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 23; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; v_cancelcanceltime := v_sysdate14; v_sql := 'insert into zxdbm_200.s200_user_subs_hist' || v_curstrmonth || ' (subscriptionindex,subscriptionid,servicetype,subcapability,'|| 'serviceindex,serviceid,productindex,productid,contentindex,contentid,'|| 'productpkgindex,productpkgid,corpindex,corpid,cpindex,cpid,subscribemode,'|| 'subscribechannel,subscribeoptype,cancelmode,cancelchannel,canceloptype,'|| 'pausemode,resumemode,status,statustime,autocontinue,subscriber,usercode,'|| 'payuser,pushid,starttime,endtime,lastrenttime,nextrentdate,payfordate,'|| 'returnvalues,returntype,returnstartdate,returnenddate,fixusetimes,'|| 'chargeparty,freetime,createtime,canceltime,firstusetime,lastusetime,'|| 'tastestarttime,tasteendtime,pausetime,resumetime,subscribeopid,'|| 'cancelopid,cancelreason,lastrent,msisdntype,pseudocode,oldproductid,'|| 'pproductofferid,varifee,eventid,isexperience,subscribetype,chargetime) '|| 'values(:p1,:p2,:p3,:p4,'|| ':p5,:p6,:p7,:p8,:p9,:p10,'|| ':p11,:p12,:p13,:p14,:p15,:p16,:p17,'|| ':p18,:p19,:p20,:p21,:p22,'|| ':p23,:p24,:p25,:p26,:p27,:p28,'|| ':p29,:p30,:p31,:p32,:p33,:p34,:p35,'|| ':p36,:p37,:p38,:p39,:p40,'|| ':p41,:p42,:p43,:p44,:p45,:p46,'|| ':p47,:p48,:p49,:p50,:p51,'|| ':p52,:p53,:p54,:p55,:p56,:p57,:p58,'|| ':p59,:p60,:p61,:p62,:p63,:p64)'; begin --插入历史订购关系 execute immediate v_sql using v_cancelproductsubindex,v_cancelproductsubid,v_cancelservicetype,v_cancelsubcapability, v_cancelserviceindex,v_cancelserviceid,v_cancelproductindex,v_cancelproductid,v_cancelcontentindex,v_cancelcontentid, v_cancelpropkgindex,v_cancelpropkgid,v_cancelcorpindex,v_cancelcorpid,v_cancelcpindex,v_cancelcpid,v_cancelsubscribemode, v_cancelsubscribechannel,v_cancelsubscribeoptype,v_cancelcancelmode,v_cancelcancelchannel,v_canceloptype, v_cancelpausemode,v_cancelresumemode,v_cancelsubstatus,v_cancelstatustime,v_cancelautocontinue,v_cancelsubscriber,v_cancelusercode, v_cancelpayuser,v_cancelpushid,v_cancelsubstarttime,v_cancelsubendtime,v_cancellastrenttime,v_cancelnextrentdate,v_cancelpayfordate, v_cancelreturnvalues,v_cancelreturntype,v_cancelreturnstartdate,v_cancelreturnenddate,v_cancelfixusetimes, v_cancelchargeparty,v_cancelfreetime,v_cancelcreatetime,v_cancelcanceltime,v_cancelfirstusetime,v_cancellastusetime, v_canceltastestarttime,v_canceltasteendtime,v_cancelpausetime,v_cancelresumetime,v_cancelsubscribeopid, v_cancelcancelopid,v_cancelcancelreason,v_cancellastrent,v_cancelmsisdntype,v_cancelpseudocode,v_canceloldproductid, v_cancelpproductofferid,v_cancelvarifee,v_canceleventid,v_cancelisexperience,v_cancelsubscribetype,v_cancelchargetime; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 24; o_debuginfo := 'no subs exist.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 25; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; --生成新的订购关系ID zxdbm_ismp.sp_getmaxvalue ('slp_order_prdindex',1,v_productsubindex); if (v_productsubindex = 0) then o_retcode := 506; o_debugpos := 26; o_debuginfo := 'get slp_order_prdindex failed.'; rollback; return; end if; begin select trunc(dbms_random.value(10000,99999)) into v_retvalue from dual; exception when others then o_retcode := 506; o_debugpos := 27; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; v_productsubid := v_usemsisdn || to_char(v_retvalue); --added by youqunxia20130605 order2.07.10 --对于VSOP发动的订购申请,若ExtC5非空,则将其填入订购关系表 if trim(i_pproductofferid) is null then v_pproductofferid := ' '; else v_pproductofferid := i_pproductofferid; end if; --added by youqunxia 20130814 Order3.02.01 v_varifee := to_number(i_varifee); --如果eventid值非空,将其填入订购关系表 if trim(i_eventid) is not null then v_eventid := i_eventid; else v_eventid := ''; end if; --如果chargetime值非空,将其填入订购关系表 if trim(i_chargetime) is not null then v_chargetime := i_chargetime; else v_chargetime := '00000000000000'; end if; begin update zxdbm_200.s200_user_subscription set subscriptionindex = v_productsubindex, subscriptionid = v_productsubid, servicetype = v_servicetype, subcapability = v_subcapability, serviceindex = v_serviceindex, serviceid = v_serviceid, productindex = v_productindex, productid = v_productid, productpkgindex = v_propkgindex, productpkgid = v_propkgid, contentindex = v_contentindex, contentid = v_contentid, corpindex = v_corpindex, corpid = v_corpid, cpindex = v_cpindex, cpid = v_cpid, subscribemode = v_subscribemode, subscribechannel = v_subscribechannel, subscribeoptype = v_subscribeoptype, cancelmode = v_cancelmode, cancelchannel = v_cancelchannel, canceloptype = v_canceloptype, pausemode = v_pausemode, resumemode = v_resumemode, status = v_substatus, statustime = v_sysdate14, autocontinue = v_autocontinue, subscriber = v_srcmsisdn, --usercode = v_usemsisdn, payuser = v_paymsisdn, pushid = v_pushid, starttime = v_substarttime, endtime = v_subendtime, lastrenttime = v_lastrenttime, nextrentdate = v_nextrentdate, payfordate = v_payfordate, returnvalues = v_returnvalues, returntype = v_returntype, returnstartdate = v_returnstartdate, returnenddate = v_returnenddate, --fixusetimes = v_fixusetimes, chargeparty = v_chargeparty, freetime = v_freetime, createtime = v_sysdate14, canceltime = v_canceltime, firstusetime = v_firstusetime, lastusetime = v_lastusetime, tastestarttime = v_tastestarttime, tasteendtime = v_tasteendtime, pausetime = v_pausetime, resumetime = v_resumetime, subscribeopid = v_subscribeopid, cancelopid = v_cancelopid, cancelreason = v_cancelreason, lastrent = v_lastrent, msisdntype = v_msisdntype, pseudocode = v_pseudocode, oldproductid = v_cancelproductid, pproductofferid = v_pproductofferid, varifee = v_varifee, eventid = v_eventid, isexperience = v_isexperience, subscribetype = v_subscribetype, chargetime = v_chargetime where usercode = v_usemsisdn and productid = v_beupdatedproductid; exception when others then o_retcode := 506; o_debugpos := 28; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; if v_lastrent > 0 then --累计解决【生产累计;产品累计(纯包量)】 v_sql := 'update zxdbm_ismp.ssrv_user_totalamount' || v_curstrmonth || ' set usedamounts = usedamounts + :p1 where userindex = :p2' || ' and amounttype = 8 and amountindex = 0 and productindex = 0 and expiredate = :p3 and rownum = 1'; begin execute immediate v_sql using v_lastrent,v_payuserindex,to_number(substr(v_curmonthendtime,1,8)); if sql%rowcount = 0 then v_sql := 'insert into zxdbm_ismp.ssrv_user_totalamount' || v_curstrmonth || '(userindex,payuserindex,amounttype,usedamounts,amountindex,productindex,expiredate)' || ' values(:p1,:p2,8,:p3,0,0,:p4)'; begin execute immediate v_sql using v_payuserindex,v_payuserindex,v_lastrent,to_number(substr(v_curmonthendtime,1,8)); exception when others then o_retcode := 506; o_debugpos := 29; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; exception when others then o_retcode := 506; o_debugpos := 30; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if;
/*
推广期内订购/收费期内订购,根本计费为包量/查问产品累计,有累计,则跳过。无累计新增一条记录
*/
begin select popularizeitem,popularizestart,popularizestop,needcharge into v_popuitem,v_popustart,v_popustop,v_needcharge from zxdbm_200.s200_product where productindex = v_productindex; exception when others then o_retcode := 506; o_debugpos := 31; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_needcharge = 1 then begin select chargetype,fixusetimes,unitvol into v_chargetype,v_fixusetimes,v_unitvol from zxdbm_200.s200_product_fee where productindex = v_productindex and itemindex = 0; exception when others then o_retcode := 506; o_debugpos := 32; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; --根本计费为纯包量(包含含推广期) if (i_chargetype = 4) or (v_chargetype = 4) then v_fixtotalres := v_fixusetimes * v_unitvol; if (i_freetime > v_sysdate14) or (v_popuitem in (0,1) and (v_sysdate8 >= v_popustart) and (v_sysdate8 <= v_popustop)) then begin select count(1) into v_temp from zxdbm_ismp.ssrv_user_totalamount where userindex = v_payuserindex and amounttype = 0 and amountindex = v_productindex and productindex = 0; exception when others then o_retcode := 506; o_debugpos := 33; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; if v_temp = 0 then begin update zxdbm_ismp.ssrv_user_totalamount set fixtotalres = fixtotalres + v_fixtotalres, expiredate = to_number(to_char(to_date(v_subendtime,'yyyymmddhh24miss'),'yyyymmdd')) where userindex = v_payuserindex and amounttype = 0 and amountindex = v_productindex and productindex = 0; if (sql%rowcount = 0) then begin insert into zxdbm_ismp.ssrv_user_totalamount(userindex,amounttype,amountindex,productindex,payuserindex,fixtotalres,servicetype,expiredate) values(v_payuserindex,0,v_productindex,0,v_payuserindex,v_fixtotalres,v_servicetype,to_number(to_char(to_date(v_subendtime,'yyyymmddhh24miss'),'yyyymmdd'))); exception when others then o_retcode := 506; o_debugpos := 34; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; exception when others then o_retcode := 506; o_debugpos := 35; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; end if; end if; commit; --事务完结end;o_productsubid := v_productsubid;o_porductsubindex := v_productsubindex;--added by youqunxia20130604 order2.07.10if (v_freetime > v_substarttime) and (i_freenoticenow = 0) then --设置定时工作表中的号码类型 if (v_msisdntype <> 1) then v_freemsisdntype := '4'; end if; v_freenoticetime1 := to_char(to_date(v_freetime,'yyyymmddhh24miss'),'yyyymmdd') || '080000'; if (v_freetime < v_freenoticetime1) then v_plantime := to_char(to_date(v_freetime,'yyyymmddhh24miss') - 1,'yyyymmdd'); begin --革除定时工作表原有记录 delete from zxdbm_ismp.freenotice_task where usercode = v_usemsisdn and productid = v_productid; --插入定时工作 insert into zxdbm_ismp.freenotice_task(plantime,createtime,usercode,msisdntype,spid,serviceid,productid) values(v_plantime, v_sysdate14, v_usemsisdn, v_freemsisdntype, v_cpid, v_serviceid, v_productid); exception when others then o_retcode := 506; o_debugpos := 36; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; commit; else begin --革除定时工作表原有记录 delete from zxdbm_ismp.freenotice_task where usercode = v_usemsisdn and productid = v_productid; --插入定时工作 insert into zxdbm_ismp.freenotice_task(plantime,createtime,usercode,msisdntype,spid,serviceid,productid) values(substr(v_freetime,1,8), v_sysdate14, v_usemsisdn, v_freemsisdntype, v_cpid, v_serviceid, v_productid); exception when others then o_retcode := 506; o_debugpos := 37; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; commit; end if;end if;
end slp_200_telicomsubresp;
/
prompt zxdbm_200.slp_200_telicomusercheck
create or replace procedure zxdbm_200.slp_200_telicomusercheck
(
i_srcmsisdn in varchar2, --发起方/赠送方用户号码i_usemsisdn in varchar2, --应用方/受赠方用户号码i_oatype in number, --发起方地址类型i_servicetype in number, --业务能力类型i_cmdchannel in number, --动作起源i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_isthird in number, --0:一般订购 1:赠送i_supportproductid in number, --同步SP、SP下发应用service还是productid 0-serviceid 1-productidi_srvprodid in varchar2, --业务/产品代码i_direct in number, --订购方向 0:正向订购 1:SP反向定购i_prepaidtype in number, --预付费接口类型 1-OCS 2-非OCS 3-依据号段抉择是OCS或者非OCSi_checkpseudocode in number, --零碎开关:是否反对伪码 0-不反对 1-反对i_serviceflowtype in number, --业务流程类型o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_srcmsisdntype out number, --发起方号码类型,1:msisdn,2:phs,3:pstno_usemsisdntype out number, --应用方号码类型,1:msisdn,2:phs,3:pstno_userindex out number, --应用方号码序号o_payuserindex out number, --付费方号码序号o_paytype out number, --计费号码的付费类型 0:后付费 1:预付费 2:准预付费o_oppaytype out number, --话单专用付费类型o_colortype out number, --应用方号码名单类型 0-普通用户,1-黑名单,2-白名单, 3-灰名单,4-红名单o_usertype out number, --应用方类型 1-普通用户 2-运营商测试用户 3-SP测试用户o_scptype out number, --对预付费扣费的设施类型 1:OCS;2:非OCSo_paymode out varchar2, --团体付费模式 团体付费/集体付费o_corpid out varchar2, --团体代码o_corpindex out number, --团体序号o_corpcnshortname out varchar2, --团体名称o_paymsisdn out varchar2, --去掉前缀的计费方号码o_pcodemsisdnswitch out number, --伪码和实在号码之间是否有转换: 0否 1实在号码转化伪码 2伪码转化为实在号码o_pseudocode out varchar2 --伪码
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_sysdate8 char(8) := substr(v_sysdate14,1,8);v_curmonth number(2) := to_number(substr(v_sysdate14,5,2)); --长期寄存以后月份v_curstrmonth char(2) := lpad(to_char(v_curmonth),2,'0'); --长期寄存以后月份,字符型v_maincapability number(10) := 0; --长期寄存组合业务主业务能力类型v_submaincapability number(10) := 0; --长期寄存组合业务主业务能力子类型v_devexist number(3) := 1; --长期寄存是否存在对应设施v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_tmpint number(10) := 0; --长期寄存长期数值v_srcmsisdn zxdbm_ismp.susr_basic.usercode%type := i_srcmsisdn; --长期寄存发起方/赠送方用户号码v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := i_usemsisdn; --长期寄存应用方/受赠方用户号码v_srcuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存发起方用户序号v_srcusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存发起方用户类型v_srcpaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存发起方用户付费类型v_srcblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存发起方是否进入黑名单v_srcwhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存发起方是否进入白名单v_srcredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存发起方是否进入红名单v_srcblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存发起方黑名单级别v_srcwhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存发起方白名单级别v_srcmsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存发起方号码类型v_srcuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存发起方状态v_srcactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存发起方激活状态v_srcoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存发起方话单专用付费类型v_srccorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存发起方团体序号v_srcusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存发起方上次应用工夫v_srcmaxlimitfee zxdbm_ismp.susr_basic.maxlimitfee%type := 0; --长期寄存发起方最大生产限额v_srcgraylist zxdbm_ismp.susr_basic.graylist%type := 0; --长期寄存发起方是否进入灰名单v_srcgraylevel zxdbm_ismp.susr_basic.graylevel%type := 0; --长期寄存发起方灰名单级别v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_useusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存应用方用户类型v_usepaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存应用方用户付费类型v_useblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存应用方是否进入黑名单v_usewhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存应用方是否进入白名单v_useredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存应用方是否进入红名单v_useblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存应用方黑名单级别v_usewhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存应用方白名单级别v_usemsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存应用方号码类型v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存应用方话单专用付费类型v_usecorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存应用方团体序号v_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫v_usemaxlimitfee zxdbm_ismp.susr_basic.maxlimitfee%type := 0; --长期寄存应用方最大生产限额v_usegraylist zxdbm_ismp.susr_basic.graylist%type := 0; --长期寄存应用方是否进入灰名单v_usegraylevel zxdbm_ismp.susr_basic.graylevel%type := 0; --长期寄存应用方灰名单级别v_paymsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存计费方v_paymsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存计费方号码类型v_cardtype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存用户付费类型0-后付费,1-预付费,2-准预付费v_srctestcpindex zxdbm_ismp.susr_testgroup_member.cpindex%type := 0; --长期寄存CP/SP序号v_usetestcpindex zxdbm_ismp.susr_testgroup_member.cpindex%type := 0; --长期寄存CP/SP序号v_srccorpid zxdbm_ismp.susr_corp.corpid%type := ' '; --长期寄存团体代码v_srccorpstatus zxdbm_ismp.susr_corp.status%type := 0; --长期寄存团体状态v_srccorppaymsisdn zxdbm_ismp.susr_corp.paymsisdn%type := ' '; --长期寄存团体付费号码v_corpname zxdbm_ismp.susr_corp.corpcnshortname%type := ' '; --长期寄存团体中文名简写v_productindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存产品序号v_needcharge zxdbm_200.s200_product.needcharge%type := 1; --长期寄存是否须要计费,0-收费,1-须要计费v_onlyforcorp zxdbm_200.s200_product.onlyforcorp%type := 0; --长期寄存是否团体专用产品0:个人用户专用1:团体专用v_cpindex zxdbm_200.s200_product.cpindex%type := 0; --长期寄存CP/SP序号v_serviceindex zxdbm_200.s200_product.serviceindex%type := 0; --长期寄存业务序号v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --长期寄存业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 1; --长期寄存业务能力子类型1-3G,2-PHS,3-ISAG,默认为3g业务能力(仅电信应用,其余营运商皆默认为1)v_srvprodid zxdbm_200.s200_product.productid%type := i_srvprodid; --长期寄存业务产品代码v_productstatus zxdbm_200.s200_product.status%type := 0; --长期寄存产品状态v_onlyforpkg zxdbm_200.s200_product.onlyforpkg%type := 0; --长期寄存是否套餐专用产品v_ordertype zxdbm_200.s200_product.ordertype%type := 1; --长期寄存产品订购类型v_workflowlife zxdbm_200.s200_product.workflowlife%type := 0; --长期寄存工作流流程状态v_productsource zxdbm_200.s200_product.productsource%type := 0; --产品起源0:ISMP 公布的产品1:同步自全国SPMS 的产品2:提供给漫游用户的产品v_serviceid zxdbm_200.s200_service.serviceid%type := ' '; --长期寄存业务代码v_servicestatus zxdbm_200.s200_service.status%type := 0; --长期寄存业务状态v_srvcolorlist zxdbm_200.s200_service.colorlist%type := 0; --长期寄存是否有色彩列表,0-无,1-黑名单,2-白名单v_servicename zxdbm_200.s200_service.servicename%type := ' '; --长期寄存业务名称v_subsrvtype zxdbm_200.s200_service.subsrvtype%type := 0; --长期寄存业务子类型v_orderupdateurl zxdbm_200.s200_service.orderupdateurl%type := ' '; --长期寄存业务表中订购关系更新告诉URLv_useopenstatus zxdbm_200.s200_service_useropen.status%type := 1; --长期寄存应用方集体能力开明,0-敞开,1-开明v_perssrvopen zxdbm_ismp.ssys_service_type.perssrvopen%type := 1; --长期寄存集体能力缺省开明,0-敞开,1-开明v_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := ' '; --长期寄存话单中的srvtypeidv_srcopenstatus zxdbm_200.s200_service_useropen.status%type := 1; --长期寄存发起方集体能力开明,0-敞开,1-开明v_productsubmode zxdbm_ismp.ssrv_corp_product.subscribemode%type := 0; --长期寄存定购形式,0-必须团体管理员定购,1-团体管理员与团体成员均可定购v_productpayparty zxdbm_ismp.ssrv_corp_product.payparty%type := 2; --长期寄存团体专用产品付费方 1-团体付费 2-集体付费v_corpproductstatus zxdbm_ismp.ssrv_corp_product.status%type := 0; --长期寄存团体与产品关联状态 0-失常;1-删除v_phoneindex zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存号段序号v_phoneindexa zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存A省号段序号,跨省赠送v_phoneindexb zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存B省号段序号,跨省赠送v_attach zxdbm_ismp.ssys_phone.attach%type := 0; --长期寄存预付费归属,0-未知,1-OCS,2-RTBPv_cpid zxdbm_ismp.scp_basic.cpid%type := ' '; --长期寄存CP/SP代码v_cpstatus zxdbm_ismp.scp_basic.status%type := 0; --长期寄存CP/SP代码v_cpsubscribeurl zxdbm_ismp.scp_basic.cpsubscribeurl%type := ' '; --长期寄存CP/SP订购URLv_hasblacklist zxdbm_ismp.scp_basic.hasblacklist%type := 0; --长期寄存是否有黑名单管制 0-无,1-有v_cptype zxdbm_ismp.scp_basic.cptype%type := 2; --长期寄存CP/SP类型v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_insubblacklist zxdbm_ismp.scp_basic.insubblacklist%type := 0; --长期寄存限度订购SP黑名单标识v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --长期寄存CP/SP中文名简写v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' '; --长期寄存CP/SP客服电话
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_paymsisdn := ' ';o_srcmsisdntype := 1;o_usemsisdntype := 1;o_userindex := 0;o_payuserindex := 0;o_paytype := 0;o_oppaytype := 0;o_scptype := 2;o_colortype := 0;o_usertype := 0;o_corpid := ' ';o_corpindex := 0;o_corpcnshortname := ' ';o_paymode := '集体付费';o_pcodemsisdnswitch := 0;o_pseudocode := '';
/
*1.用户鉴权
*/
--发起方和应用方存在性鉴权if (i_needauthuser = 1) then if (i_isthird = 1) and (v_srcmsisdn <> v_usemsisdn) then begin select a.userindex,a.usertype,a.paytype,a.blacklist,a.whitelist,a.redlist,a.blacklevel,a.whitelevel,a.msisdntype,a.status,a.activestatus,a.oppaytype,a.corpindex,a.lastusetime,a.maxlimitfee,a.graylist,a.graylevel, b.userindex,b.usertype,b.paytype,b.blacklist,b.whitelist,b.redlist,b.blacklevel,b.whitelevel,b.msisdntype,b.status,b.activestatus,b.oppaytype,b.corpindex,b.lastusetime,b.maxlimitfee,b.graylist,b.graylevel into v_srcuserindex,v_srcusertype,v_srcpaytype,v_srcblacklist,v_srcwhitelist,v_srcredlist,v_srcblacklevel,v_srcwhitelevel,v_srcmsisdntype,v_srcuserstatus,v_srcactivestatus,v_srcoppaytype,v_srccorpindex,v_srcusetime,v_srcmaxlimitfee,v_srcgraylist,v_srcgraylevel, v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist,v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus,v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_usemaxlimitfee,v_usegraylist,v_usegraylevel from zxdbm_ismp.susr_basic a, zxdbm_ismp.susr_basic b where a.usercode = v_srcmsisdn and b.usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 1; o_debuginfo := 'v_srcmsisdn or v_usemsisdn is not exist.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := 1; return; when others then o_retcode := 506; o_debugpos := 2; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := 1; return; end; o_srcmsisdntype := v_srcmsisdntype; o_usemsisdntype := v_usemsisdntype; o_userindex := v_useuserindex; o_payuserindex := v_srcuserindex; o_paytype := v_srcpaytype; o_oppaytype := v_srcoppaytype; o_usertype := v_useusertype; --批量操作用户号码类型由用户表查问后鉴权 if (i_cmdchannel in (7,32)) then if (v_srcmsisdntype not in (1,2,3)) or (v_usemsisdntype not in (1,2,3)) then o_retcode := 107; o_debugpos := 3; o_debuginfo := 'v_srcmsisdntype='||v_srcmsisdntype||', v_usemsisdntype='||v_usemsisdntype||', v_srcmsisdntype or v_usemsisdntype not in (1,2,3,4).'; return; end if; end if; --发起方状态鉴权 if v_srcuserstatus in (1,3) then o_retcode := 1002; o_debugpos := 4; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', the subscriber status is 1 or 3.'; return; elsif v_srcuserstatus = 4 then o_retcode := 1008; o_debugpos := 5; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', the subscriber status is 4.'; return; end if; --应用方状态鉴权 if v_useuserstatus in (1,3) then o_retcode := 1110; o_debugpos := 6; o_debuginfo := 'v_useuserstatus='||v_useuserstatus||', the user status is 1 or 3.'; return; elsif v_useuserstatus = 4 then o_retcode := 1110; o_debugpos := 7; o_debuginfo := 'v_useuserstatus='||v_useuserstatus||', the user status is 4.'; return; end if; else begin select userindex,usertype,paytype,blacklist,whitelist,redlist,blacklevel,whitelevel,msisdntype,status,activestatus,oppaytype,corpindex,lastusetime,maxlimitfee,graylist,graylevel into v_srcuserindex,v_srcusertype,v_srcpaytype,v_srcblacklist,v_srcwhitelist,v_srcredlist,v_srcblacklevel,v_srcwhitelevel,v_srcmsisdntype,v_srcuserstatus,v_srcactivestatus,v_srcoppaytype,v_srccorpindex,v_srcusetime,v_srcmaxlimitfee,v_srcgraylist,v_srcgraylevel from zxdbm_ismp.susr_basic where usercode = v_srcmsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 8; o_debuginfo := 'v_srcmsisdn='||v_srcmsisdn||', the user is not exist.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := o_srcmsisdntype; return; when others then o_retcode := 506; o_debugpos := 9; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_srcmsisdntype := 2; else o_srcmsisdntype := 1; end if; o_usemsisdntype := o_srcmsisdntype; return; end; v_useuserindex := v_srcuserindex; v_useusertype := v_srcusertype; v_usepaytype := v_srcpaytype; v_useblacklist := v_srcblacklist; v_usewhitelist := v_srcwhitelist; v_useredlist := v_srcredlist; v_useblacklevel := v_srcblacklevel; v_usewhitelevel := v_srcwhitelevel; v_usemsisdntype := v_srcmsisdntype; v_useuserstatus := v_srcuserstatus; v_useactivestatus := v_srcactivestatus; v_useoppaytype := v_srcoppaytype; v_usecorpindex := v_srccorpindex; v_useusetime := v_srcusetime; v_usemaxlimitfee := v_srcmaxlimitfee; v_usegraylist := v_srcgraylist; v_usegraylevel := v_srcgraylevel; o_srcmsisdntype := v_srcmsisdntype; o_usemsisdntype := v_usemsisdntype; o_userindex := v_useuserindex; o_payuserindex := v_srcuserindex; o_paytype := v_srcpaytype; o_oppaytype := v_srcoppaytype; o_usertype := v_useusertype; --add by cfz 2008.08.20 批量操作用户号码类型由用户表查问后鉴权 if (i_cmdchannel in (7,32)) then if v_srcmsisdntype not in (1,2,3) then o_retcode := 107; o_debugpos := 10; o_debuginfo := 'v_srcmsisdntype='||v_srcmsisdntype||', v_srcmsisdntype is not valid.'; return; end if; end if; --发起方状态鉴权 if v_srcuserstatus in (1,3) then o_retcode := 1002; o_debugpos := 11; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', the user status is 1 or 3.'; return; elsif v_srcuserstatus = 4 then o_retcode := 1008; o_debugpos := 12; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', the user status is 4.'; return; end if; end if;end if;
/
2.产品,产品费率鉴权
/
--产品存在性鉴权if (i_direct = 1) and (i_supportproductid = 0) then--反向订购,并且反对业务代码 begin select productindex,needcharge,onlyforcorp,cpindex,serviceindex, servicetype,subcapability,onlyforpkg,status,workflowlife,productsource into v_productindex,v_needcharge,v_onlyforcorp,v_cpindex,v_serviceindex, v_servicetype,v_subcapability,v_onlyforpkg,v_productstatus,v_workflowlife,v_productsource from zxdbm_200.s200_product where serviceid = v_srvprodid and ordertype = 1; exception when no_data_found then o_retcode := 2100; o_debugpos := 13; o_debuginfo := 'serviceid='||v_srvprodid||', the product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select productindex,needcharge,onlyforcorp,cpindex,serviceindex, servicetype,subcapability,onlyforpkg,status,workflowlife,productsource into v_productindex,v_needcharge,v_onlyforcorp,v_cpindex,v_serviceindex, v_servicetype,v_subcapability,v_onlyforpkg,v_productstatus,v_workflowlife,v_productsource from zxdbm_200.s200_product where productid = v_srvprodid and ordertype = 1; exception when no_data_found then o_retcode := 2100; o_debugpos := 15; o_debuginfo := 'productid='||v_srvprodid||', the product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;if (v_needcharge = 1) then --欠费用户只能订购收费产品 if (v_srcuserstatus = 2) then o_retcode := 1003; o_debugpos := 17; o_debuginfo := 'v_srcuserstatus='||v_srcuserstatus||', the user owes money, does not allow to subscribe the product.'; return; end if;end if;
/**
3.业务鉴权
*/
--业务存在性鉴权(MPSS不须要鉴权)--modified by chenfuzhong 2008.10.09if i_servicetype = 101 then v_sql := 'select serviceid,status,colorlist,servicename,maincapability,submaincapability,cpid,orderupdateurl '|| 'from zxdbm_9900.s9900_service where serviceindex = :p1'; begin execute immediate v_sql into v_serviceid,v_servicestatus,v_srvcolorlist,v_servicename,v_maincapability,v_submaincapability,v_cpid,v_orderupdateurl using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 18; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 19; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;elsif i_servicetype in (1,2,3) then v_sql := 'select serviceid,status,colorlist,servicename,subsrvtype,cpid,orderupdateurl '|| 'from zxdbm_200.s200_service where serviceindex = :p1'; begin execute immediate v_sql into v_serviceid,v_servicestatus,v_srvcolorlist,v_servicename,v_subsrvtype,v_cpid,v_orderupdateurl using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 20; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 21; return; end;elsif i_servicetype <> 14 then begin select serviceid,status,colorlist,servicename,subsrvtype,cpid,orderupdateurl into v_serviceid,v_servicestatus,v_srvcolorlist,v_servicename,v_subsrvtype,v_cpid,v_orderupdateurl from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 22; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 23; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;
/**
4.CP/SP鉴权
**/
--CP/SP存在性鉴权begin select cpid,status,cpsubscribeurl,hasblacklist,cptype,insubblacklist,cpcnshortname,customersrvtel,cpsrvtype into v_cpid,v_cpstatus,v_cpsubscribeurl,v_hasblacklist,v_cptype,v_insubblacklist,v_cpcnshortname,v_customersrvtel,v_cpsrvtype from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 24; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return;when others then o_retcode := 506; o_debugpos := 25; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;
/*
5.业务能力开明鉴权
*/
if i_servicetype = 101 then begin select a.perssrvopen,b.srvtypeid into v_perssrvopen,v_srvtypeid from zxdbm_ismp.ssys_service_type a,zxdbm_ismp.ssys_service_type b where a.servicetype = v_servicetype and a.subcapability = v_subcapability and b.servicetype = v_maincapability and b.subcapability = v_submaincapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 26; o_debuginfo := 'servicetype='||v_servicetype||', subcapability='||v_subcapability||', maincapability='||v_maincapability||', submaincapability='||v_submaincapability||', CPX system serviceCapability is not open.'; return; when others then o_retcode := 506; o_debugpos := 27; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select perssrvopen,srvtypeid into v_perssrvopen,v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 28; o_debuginfo := 'servicetype='||v_servicetype||', subcapability='||v_subcapability||', System serviceCapability is not open.'; return; when others then o_retcode := 506; o_debugpos := 29; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;
/**
6.名单鉴权,用户业务能力开明鉴权
**/
if (i_needauthuser = 1) then --应用方名单鉴权 if (v_useblacklist <> 0) then if bitand(v_useblacklevel,1) > 0 then --零碎级黑名单查看 v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 1 and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 30; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint > 0) then o_retcode := 1004; o_debugpos := 31; o_colortype := 1; o_debuginfo := 'userindex = '||v_useuserindex||', the user is in system level blacklist.'; return; end if; end if; --SP级黑名单查看 if v_hasblacklist = 1 and bitand(v_useblacklevel,2) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 2 and colorid = v_cpindex and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 32; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 33; o_colortype := 1; o_debuginfo := 'colorid = '||v_cpindex||', the user is in SP level blacklist.'; return; end if; end if; --业务能力级黑名单 if bitand(v_useblacklevel,4) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 3 and colorid = v_servicetype; exception when others then o_retcode := 506; o_debugpos := 34; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then if v_usegraylist > 0 and bitand(v_usegraylevel,2) > 0 then begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 3 and colorlevel = 2 and colorid = v_cpindex; exception when others then o_retcode := 506; o_debugpos := 35; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint = 0) then o_retcode := 1004; o_debugpos := 36; o_colortype := 1; o_debuginfo := 'colorid = '||v_servicetype||', the user is in serviceCapbility level blacklist.'; return; end if; else o_retcode := 1004; o_debugpos := 37; o_debuginfo := 'colorid = '||v_servicetype||', the user is in serviceCapbility level blacklist.'; o_colortype := 1; return; end if; end if; end if; if v_srvcolorlist = 1 and bitand(v_useblacklevel,8) > 0 then --业务级黑名单查看 v_tmpint := 0; begin select count(1) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 38; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 39; o_debuginfo := 'colorid = '||v_serviceindex||', the user is in service level blacklist.'; o_colortype := 1; return; end if; end if; end if; if (v_srvcolorlist = 2) then if (v_usewhitelist = 0) then o_retcode := 1100001; o_debugpos := 40; o_debuginfo := 'v_srvcolorlist = '||v_srvcolorlist||', v_usewhitelist = '||v_usewhitelist||', user is not in whitelist.'; return; end if; o_colortype := 2; v_tmpint := 0; begin select count(1) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 2 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 41; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint = 0 then o_retcode := 1109; o_debugpos := 42; o_debuginfo := 'userindex = '||v_useuserindex||', colorid = '||v_serviceindex||', user is not in service level whitelist.'; return; end if; end if; if (v_useredlist <> 0) then o_colortype := 4; end if; --应用方开明业务能力鉴权 begin select nvl(status,1) into v_useopenstatus from zxdbm_200.s200_service_useropen where userindex = v_useuserindex and servicetype = v_servicetype; exception when no_data_found then if (v_perssrvopen = 0) then o_retcode := 1100; o_debugpos := 43; o_debuginfo := 'v_useopenstatus = '||v_useopenstatus||', v_perssrvopen = '||v_perssrvopen||', the service capabilty is closed.'; return; end if; when others then o_retcode := 506; o_debugpos := 44; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_useopenstatus = 0) then if i_cmdchannel in (9,35,39,40) then o_retcode := 1001225; else o_retcode := 1100; end if; o_debugpos := 45; o_debuginfo := 'v_useopenstatus = '||v_useopenstatus||', the user service capabilty is closed.'; return; end if; if (v_srcmsisdn <> v_usemsisdn) then --发起方名单鉴权 if (v_srcblacklist <> 0) then if bitand(v_srcblacklevel,1) > 0 then --零碎级黑名单查看 v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_useuserindex and colortype = 1 and colorlevel = 1 and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 46; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint > 0) then o_retcode := 1004; o_debugpos := 47; o_debuginfo := 'userindex = '||v_useuserindex||', the user is in system level blacklist.'; return; end if; end if; --SP级黑名单查看 if v_hasblacklist = 1 and bitand(v_srcblacklevel,2) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 1 and colorlevel = 2 and colorid = v_cpindex and inuretime <= v_sysdate14 and abatetime >= v_sysdate14; exception when others then o_retcode := 506; o_debugpos := 48; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 49; o_debuginfo := 'userindex = '||v_srcuserindex||', colorid = '||v_cpindex||', the user is in SP level blacklist.'; return; end if; end if; --业务能力级黑名单 if bitand(v_srcblacklevel,4) > 0 then v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 1 and colorlevel = 3 and colorid = v_servicetype; exception when others then o_retcode := 506; o_debugpos := 50; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then if v_srcgraylist > 0 and bitand(v_srcgraylevel,2) > 0 then begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 3 and colorlevel = 2 and colorid = v_cpindex; exception when others then o_retcode := 506; o_debugpos := 51; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_tmpint = 0) then o_colortype := 1; o_retcode := 1004; o_debugpos := 52; o_debuginfo := 'userindex = '||v_srcuserindex||', colorid = '||v_servicetype||', te user is in service capbility level blacklist.'; return; end if; else o_retcode := 1004; o_debugpos := 53; o_debuginfo := 'userindex = '||v_srcuserindex||', colorid = '||v_servicetype||', the user is in service capbility level blacklist.'; o_colortype := 1; return; end if; end if; end if; if v_srvcolorlist = 1 and bitand(v_srcblacklevel,8) > 0 then --业务级黑名单查看 v_tmpint := 0; begin select count(1) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 1 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 54; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint > 0 then o_retcode := 1004; o_debugpos := 55; o_debuginfo := 'userindex = '||v_srcuserindex||', colorid = '||v_serviceindex||', the user is in service level blacklist.'; return; end if; end if; end if; if (v_srvcolorlist = 2) then if (v_srcwhitelist = 0) then o_retcode := 1100001; o_debugpos := 56; o_debuginfo := 'v_srvcolorlist = '||v_srvcolorlist||', v_srcwhitelist = '||v_srcwhitelist||', the user is not in whitelist.'; return; end if; v_tmpint := 0; begin select count(*) into v_tmpint from zxdbm_ismp.susr_colorlist where userindex = v_srcuserindex and colortype = 2 and colorlevel = 4 and colorid = v_serviceindex; exception when others then o_retcode := 506; o_debugpos := 57; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_tmpint = 0 then o_retcode := 1109; o_debugpos := 58; o_debuginfo := 'v_srvcolorlist = '||v_srvcolorlist||',the user is not in service level whitelist.'; return; end if; end if; --发起方开明业务能力鉴权 begin select nvl(status,1) into v_srcopenstatus from zxdbm_200.s200_service_useropen where userindex = v_srcuserindex and servicetype = v_servicetype; exception when no_data_found then if (v_perssrvopen = 0) then o_retcode := 1100; o_debugpos := 59; o_debuginfo := 'userindex = '||v_srcuserindex||', servicetype = '||v_servicetype||', the user service capabilty is not exist, and system service capabiltyis is closed.'; return; end if; when others then o_retcode := 506; o_debugpos := 60; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_srcopenstatus = 0) then if i_cmdchannel in (9,35,39,40) then o_retcode := 1001225; else o_retcode := 1100; end if; o_debugpos := 61; o_debuginfo := 'userindex = '||v_srcuserindex||', servicetype = '||v_servicetype||', the user service capabilty is closed.'; return; end if; end if;end if;
/
*测试产品,测试用户鉴权
*/
--测试产品鉴权-- if (v_productstatus in (0,2)) and (v_workflowlife = 3) thenif (((v_productsource <> 3) and (v_productstatus in (0,2)) and (v_workflowlife = 3)) or ((v_productsource = 3) and (v_productstatus = 0))) then if (v_srcusertype <> 2) or (v_useusertype <> 2) then o_retcode := 1100; o_debugpos := 62; o_debuginfo := 'The normal user can not use test product.'; return; end if; --SP测试用户鉴权 --测试产品、测试用户(发起方、应用方)相干鉴权 begin select cpindex into v_srctestcpindex from zxdbm_ismp.susr_testgroup_member where userindex = v_srcuserindex; exception when no_data_found then o_retcode := 1100; o_debugpos := 63; o_debuginfo := 'userindex = '||v_srcuserindex||', the test product is not open to the subscriber.'; return; when others then o_retcode := 506; o_debugpos := 64; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_srctestcpindex > 0) then if (v_srctestcpindex <> v_cpindex) then o_retcode := 1001223; o_debugpos := 65; o_debuginfo := 'The test-user belongs to SP-A can not use test-product belonged to SP-B.'; return; end if; end if; begin select cpindex into v_usetestcpindex from zxdbm_ismp.susr_testgroup_member where userindex = v_useuserindex; exception when no_data_found then o_retcode := 1100; o_debugpos := 66; o_debuginfo := 'userindex = '||v_useuserindex||', the test product is not open to the subscriber.'; return; when others then o_retcode := 506; o_debugpos := 67; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_usetestcpindex > 0) then if (v_usetestcpindex <> v_cpindex) then o_retcode := 1001223; o_debugpos := 68; o_debuginfo := 'The test-user belongs to SP-A can not use test-product belonged to SP-B.'; return; end if; o_usertype := 3; end if;end if;
/*
团体相干鉴权
/
--团体产品、团体用户相干鉴权if (v_onlyforcorp = 1) then --团体产品不容许赠送 if (i_isthird = 1) then o_retcode := 1011407; o_debugpos := 69; o_debuginfo := 'v_onlyforcorp = '||v_onlyforcorp||', i_isthird = '||i_isthird||',the corp product can not to be presented.'; return; end if; --普通用户不能订购一个团体专用产品 if (v_srccorpindex <> v_usecorpindex) then o_retcode := 1100; o_debugpos := 70; o_debuginfo := 'v_onlyforcorp = '||v_onlyforcorp||', v_srccorpindex = '||v_srccorpindex||', the normal user can not subscribe corp product.'; return; end if; if (v_srccorpindex = 0) then o_retcode := 1204; o_debugpos := 71; o_debuginfo := 'v_onlyforcorp = '||v_onlyforcorp||', v_srccorpindex = '||v_srccorpindex||', the normal user can not subscribe corp product.'; return; end if; begin select corpid,status,paymsisdn,corpcnshortname into v_srccorpid,v_srccorpstatus,v_srccorppaymsisdn,v_corpname from zxdbm_ismp.susr_corp where corpindex = v_srccorpindex; exception when no_data_found then o_retcode := 1001301; --团体不存在 o_debugpos := 72; o_debuginfo := 'v_srccorpindex = '||v_srccorpindex||', the corp is not exist.'; return; when others then o_retcode := 506; o_debugpos := 73; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_corpcnshortname := v_corpname; o_corpid := v_srccorpid; o_corpindex := v_srccorpindex; if (v_srccorpstatus <> 1) then o_retcode := 1001302; o_debugpos := 74; o_debuginfo := 'v_srccorpindex = '||v_srccorpindex||', the Corp status is abnormal.'; return; end if; --一个团体的产品只能由本团体的用户订购/赠送 begin select subscribemode,payparty,status into v_productsubmode,v_productpayparty,v_corpproductstatus from zxdbm_ismp.ssrv_corp_product where corpindex = v_srccorpindex and groupindex = 0 and productindex = v_productindex; exception when no_data_found then o_retcode := 1011300; o_debugpos := 75; o_debuginfo := 'productindex = '||v_productindex||', corpindex = '||v_srccorpindex||', the product is not binded with the corp.'; return; when others then o_retcode := 506; o_debugpos := 76; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_corpproductstatus <> 0) then o_retcode := 1011408; o_debugpos := 77; o_debuginfo := 'productindex = '||v_productindex||', corpindex = '||v_srccorpindex||', the binding relationship between the product and the corp is deleted.'; return; end if; if (v_productsubmode = 0) then --必须团体管理员订购 if (i_cmdchannel <> 4) then o_retcode := 1001216; --无权定购 o_debugpos := 78; o_debuginfo := 'v_productsubmode = '||v_productsubmode||', the corp product can only be subscribed by Corp managers.'; return; end if; end if;end if;
/*
--计费方、预付费零碎鉴权
*/
if (v_productpayparty = 1) then v_paymsisdn := v_srccorpid; v_cardtype := 0; v_paymsisdntype := 1; o_paymsisdn := v_paymsisdn; o_paytype := v_cardtype; o_payuserindex := v_srccorpindex; o_paymode := '团体付费';else v_paymsisdn := v_srcmsisdn; v_cardtype := v_srcpaytype; v_paymsisdntype := v_srcmsisdntype; o_paymsisdn := v_paymsisdn; o_paytype := v_cardtype; o_payuserindex := v_srcuserindex; o_paymode := '集体付费'; if (i_prepaidtype = 1) then o_scptype := 1; elsif i_prepaidtype = 2 then o_scptype := 2; else --attach 预付费归属,0-未知,1-OCS,2-RTBP begin select phoneindex,attach into v_phoneindex,v_attach from zxdbm_ismp.ssys_phone where startprefix <= substr(v_paymsisdn,1,length(startprefix)) and endprefix >= substr(v_paymsisdn,1,length(endprefix)); exception when no_data_found then o_scptype := 2; v_devexist := 0; --示意不存在对应号段对应设施配置 when others then o_retcode := 506; o_debugpos := 79; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_devexist = 1) then if (v_attach = 1) then o_scptype := 1; elsif (v_attach = 2) then o_scptype := 2; else begin select 1 into o_scptype from zxdbm_ismp.sdev_phone where phoneindex = v_phoneindex and devicetype = 5; exception when no_data_found then o_scptype := 2; when others then o_retcode := 506; o_debugpos := 80; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if;end if;--伪码解决(反对伪码开关关上,非自营sp)--反对业务LCS,SMS,MVS,DLS,MMS,WAP,CPX--MOAT时,AuthPriceReq音讯中OA实在号码转化为伪码,同步SP应用begin select cpsrvtype into v_cpsrvtype from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 81; o_debuginfo := 'v_cpindex='||v_cpindex||', the sp does not exist.'; return;when others then o_retcode := 506; o_debugpos := 82; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;if i_servicetype in (1,2,3,4,41,5,6,101) then if i_checkpseudocode = 1 and v_cpsrvtype <> 3 then if i_serviceflowtype = 1 then begin select pseudocode into o_pseudocode from zxdbm_ismp.susr_basic where usercode = i_srcmsisdn; exception when no_data_found then o_retcode := 1001; o_debugpos := 83; o_debuginfo := 'i_srcmsisdn = '||i_srcmsisdn||', the user does not exist.'; return; when others then o_retcode := 506; o_debugpos := 84; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_pcodemsisdnswitch := 1; end if; end if;end if;
end slp_200_telicomusercheck;
/
--多DB,收费期揭示定时工作,用户更新工夫解决。
prompt zxdbm_200.slp_200_telicommaindb
create or replace procedure zxdbm_200.slp_200_telicommaindb
(
i_srcmsisdn in varchar2, --发起方/赠送方用户号码i_usemsisdn in varchar2, --应用方/受赠方用户号码i_usemsisdntype in number, --应用方号码类型,1:msisdn,2:phs,3:pstni_actiontype in number, --动作类型i_startactiontype in number, --二次确认流程中的第一次动作类型i_cmdchannel in number, --动作起源i_productid in varchar2, --产品代码i_serviceid in varchar2, --业务代码i_cpid in varchar2, --CP/SP代码i_freetime in varchar2, --产品订购关系收费期i_rollback in number, --是否回滚订购关系 0-不回滚 1-回滚i_isthird in number, --0:一般订购 1:赠送i_silent in number, --缄默去激活开关i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_provinceorder in number, --零碎开关:是否反对跨省赠送 0-不反对 1-反对i_isfromnmsc in number, --是否nmsc过去的音讯 0:否 1:是i_substarttime in varchar2, --产品订购关系失效工夫o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2 --调试信息
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_sysdate8 char(8) := substr(v_sysdate14,1,8);v_curmonth number(2) := to_number(substr(v_sysdate14,5,2)); --长期寄存以后月份v_curstrmonth char(2) := lpad(to_char(v_curmonth),2,'0'); --长期寄存以后月份,字符型v_freetime zxdbm_200.s200_user_subscription.freetime%type := i_freetime; --长期寄存产品订购收费日期v_srcmsisdn zxdbm_200.s200_user_subscription.subscriber%type := i_srcmsisdn; --发起方/赠送方用户号码v_usemsisdn zxdbm_200.s200_user_subscription.usercode%type := i_usemsisdn; --应用方/受赠方用户号码v_productid zxdbm_200.s200_user_subscription.productid%type := i_productid; --长期寄存产品代码v_msisdntype zxdbm_200.s200_user_subscription.msisdntype%type := i_usemsisdntype; --长期寄存用户号码类型 1-msisdn,2-phs,3-pstn,4-IPTV接入号,5-宽带接入号,6-固定IPv_cpid zxdbm_200.s200_user_subscription.cpid%type := i_cpid; --长期寄存CP/SP代码v_serviceid zxdbm_200.s200_user_subscription.serviceid%type := i_serviceid; --长期寄存业务代码v_phoneindex zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存号段序号v_phoneindexa zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存A省号段序号,跨省赠送v_phoneindexb zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存B省号段序号,跨省赠送v_attach zxdbm_ismp.ssys_phone.attach%type := 0; --长期寄存预付费归属,0-未知,1-OCS,2-RTBPv_srcuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存发起方用户序号v_srcuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存发起方状态v_srcactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存发起方激活状态v_srcusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存发起方上次应用工夫v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';--订购流程,更新用户上次应用工夫/*if (i_actiontype in (1,17,102)) or (i_startactiontype in (1,17,102)) then --是否跨省赠送的鉴权(依据号段鉴权是否本省用户) --赠送他省不对DA鉴权,来自他省赠送不对OA鉴权 if i_provinceorder = 1 then if i_actiontype in (1,17) and (i_isfromnmsc = 1) then begin select phoneindex into v_phoneindexa from zxdbm_ismp.ssys_phone where startprefix <= substr(v_srcmsisdn,1,length(startprefix)) and endprefix >= substr(v_srcmsisdn,1,length(endprefix)); exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 1; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; begin select phoneindex into v_phoneindexb from zxdbm_ismp.ssys_phone where startprefix <= substr(v_usemsisdn,1,length(startprefix)) and endprefix >= substr(v_usemsisdn,1,length(endprefix)); exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 2; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_phoneindexa <> 0 and v_phoneindexb = 0 then v_usemsisdn := v_srcmsisdn; elsif v_phoneindexa = 0 and v_phoneindexb <> 0 then v_srcmsisdn := v_usemsisdn; end if; end if; end if; --发起方和应用方存在性鉴权 if i_needauthuser = 1 then if (i_isthird = 1) and (v_srcmsisdn <> v_usemsisdn) then begin select a.userindex,a.status,a.activestatus,a.lastusetime, b.userindex,b.status,b.activestatus,b.lastusetime into v_srcuserindex,v_srcuserstatus,v_srcactivestatus,v_srcusetime, v_useuserindex,v_useuserstatus,v_useactivestatus,v_useusetime from zxdbm_ismp.susr_basic a, zxdbm_ismp.susr_basic b where a.usercode = v_srcmsisdn and b.usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 3; o_debuginfo := 'user do not exist.'; return; when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_srcactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 5; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_srcusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 7; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 8; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; if (v_useactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 9; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 10; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_useusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 12; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; --发起方状态鉴权 else begin select userindex,status,activestatus,lastusetime into v_srcuserindex,v_srcuserstatus,v_srcactivestatus,v_srcusetime from zxdbm_ismp.susr_basic where usercode = v_srcmsisdn; exception when no_data_found then o_retcode := 1001; --用户不存在 o_debugpos := 13; o_debuginfo := 'user do not exist.'; return; when others then o_retcode := 506; --数据库谬误 o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_srcactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 15; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_srcusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_srcuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 17; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 18; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; end if; end if;end if;*/--退订流程,更新退订方上次应用工夫,删除收费期定时工作
-- if (i_actiontype in (2,18,103)) or (i_startactiontype in (2,18,103)) then
if (i_needauthuser = 1) then begin select userindex,status,activestatus,lastusetime into v_useuserindex,v_useuserstatus,v_useactivestatus,v_useusetime from zxdbm_ismp.susr_basic where usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; o_debugpos := 19; o_debuginfo := 'user do not exist.'; return; when others then o_retcode := 506; o_debugpos := 20; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_useactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 21; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 22; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_useusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 23; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 24; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; end if;
-- end if;
end slp_200_telicommaindb;
/
--退订入库
prompt zxdbm_200.slp_200_telicomcancelreq
create or replace procedure zxdbm_200.slp_200_telicomcancelreq
(
i_oa in varchar2, --发起方用户号码i_oatype in number, --发起方地址类型i_srvprodid in varchar2, --业务/产品代码i_serviceid in varchar2, --业务代码i_actiontype in number, --动作类型i_cmdchannel in number, --动作起源i_lallindex in number, --流程分支:1鉴权批价 91二次确认超时i_servicetype in number, --业务能力类型i_countrycode in varchar2, --国家码i_spaccesscode in varchar2, --antuprice音讯中的SP接入码i_silent in number, --缄默去激活开关i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_needreplay in number, --产品退订是否须要二次确认i_direct in number, --订购方向 0:正向退订 1:SP反向退订i_supportproductid in number, --同步SP、SP下发应用service还是productid 0-serviceid 1-productidi_prepaidtype in number, --预付费接口类型 1-OCS 2-非OCS 3-依据号段抉择是OCS或者非OCSi_opid in varchar2, --操作员工号i_rollback in number, --是否回滚订购关系 0-不回滚 1-回滚i_catchflag in number, --二次确认类型 1-订购 2,3-退订 4-改号i_checkpseudocode in number, --零碎开关:是否反对伪码 0-不反对 1-反对i_mutidbmode in number, --是否多DB环境 0:否 1:是i_eventid in varchar2, --事件IDi_channelid in varchar2, --渠道商IDi_cancelproductid in varchar2, --被替换的产品代码i_issecondproduct in number, --订购流程子类型 0:一般订购 1:业务订购 2:待生效订购关系订购 3:纯包量反复订购 6:可变价的反复订购 7:体验转正式的反复订购--added by youqunxia 20131010 Order3.02.01i_effectiveswitch in number, --VSOP发动的订购退订立刻失效开关是否关上,0-敞开,1-关上o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_usemsisdn out varchar2, --去掉前缀的应用方用户号码o_paymsisdn out varchar2, --去掉前缀的计费方号码o_usemsisdntype out number, --应用方号码类型,1:msisdn,2:phs,3:pstno_paymsisdntype out number, --付费方号码类型,1:msisdn,2:phs,3:pstno_userindex out number, --应用方号码序号o_paytype out number, --计费号码的付费类型 0:后付费 1:预付费 2:准预付费o_oppaytype out number, --话单专用付费类型o_scptype out number, --对预付费扣费的设施类型 1:OCS;2:非OCSo_subfee out number, --本次退订须要扣取/补回的费用o_feemode out number, --1:扣费 2:补款o_colortype out number, --应用方号码名单类型 0-普通用户,1-黑名单,2-白名单,3-灰名单,4-红名单o_cpid out varchar2, --CP/SP代码o_cpindex out number, --CP/SP序号o_cpcnshortname out varchar2, --CP/SP名称o_cpunsubscribeurl out varchar2, --CP/SP退订URLo_cptype out number, --CP/SP类型 0:本省 1:是全国业务o_protocoltype out number, --定购同步协定类型0-ismp(wbs形式),1-smgp2.0(cngp1.0),2-smgp3.0o_msgtosp out varchar2, --SMGP/CNGP同步sp的音讯内容o_customersrvtel out varchar2, --CP/SP客服电话o_serviceid out varchar2, --业务代码o_serviceindex out number, --业务序号o_servicename out varchar2, --业务名称o_productid out varchar2, --产品代码o_productindex out number, --产品序号o_productname out varchar2, --产品名称o_smschargingcn out varchar2, --产品资费短信形容o_servicetype out number, --产品业务能力类型o_subcapability out number, --产品业务能力子类型o_srvtypeid out varchar2, --业务能力编码,对应ssys_service_type表中的srvtypeido_corpid out varchar2, --团体代码o_corpindex out number, --团体序号o_corpcnshortname out varchar2, --团体名称o_subendtime out varchar2, --产品订购关系生效工夫o_linknum out varchar2, --业务话单中同一个流程中二次确认前后话单的关联o_productsubid out varchar2, --产品订购关系代码o_productsubindex out number, --产品订购关系序号o_neednotifysp out number, --是否有必要告诉SPo_pseudocode out varchar2, --伪码o_pcodemsisdnswitch out number, --伪码和实在号码之间是否有转换: 0否 1实在号码转化伪码 2伪码转化为实在号码o_chanelplayerstate out number, --cp/sp状态,0-申请,1-失常,2-暂停(暂停代收费),3-预登记,4-登记,5-解冻,21-暂停端口o_eventstate out number, --0,失常 1,登记o_spaccesscode out varchar2, --SP接入码o_maincapability out number, --组合业务主业务能力类型o_submaincapability out number, --组合业务主业务能力子类型o_cpsrvtype out number, --CP服务类型:0:CP+SP,1:CP,2:SP ;3:自营业务SPo_orderfeaturecode out varchar2, --短信,彩信订购指令o_cdrbegintime out varchar2, --话单计费开始工夫o_cdrendtime out varchar2, --话单计费完结工夫o_producttype out number, --产品类型 1-失常产品 2-测试产品o_cnfmtype out number, --产品零扣费类型 0:非零扣费 1:产品收费或者费率设置为0 2:收费期无费用o_invalidmode out number, --退订失效形式,0 立刻失效,1-下一帐期失效 2-退定后可应用足月o_cityid out varchar2, --用户表中的cityid--added by youqunxia 2013.01.17o_orderaccesscode out varchar2, --短信,彩信订购接入码--added by youqunxia20130906 Order3.02.01o_issynctooidd out number --是否同步订购关系给OIDD,0-否,1-是
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_sysdate8 char(8) := substr(v_sysdate14,1,8);v_sysmonth6 char(6) := substr(v_sysdate14,1,6);v_curmonth number(2) := to_number(substr(v_sysdate14,5,2)); --长期寄存以后月份v_curstrmonth char(2) := lpad(to_char(v_curmonth),2,'0'); --长期寄存以后月份,字符型v_curmonthendtime char(14) := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')),'yyyymmdd')||'235959';v_nextmonthstarttime char(14) := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')) + 1,'yyyymmdd')||'000000';v_maincapability number(10) := 0; --长期寄存组合业务主业务能力类型v_submaincapability number(10) := 0; --长期寄存组合业务主业务能力子类型v_countrycode varchar2(5) := i_countrycode; --长期寄存国家码v_tempitem number(10) := 0; --长期寄存0或者推广期的计费子序号v_cmdchannel number(10) := i_cmdchannel; --长期寄存动作起源v_tmpint number(10) := 0; --长期寄存长期数值v_devexist number(3) := 1; --长期寄存是否存在对应设施v_leftdays number(10) := 0; --本月残余天数v_monthdays number(10) := 0; --本月无效免费天数v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_isservicesub number(3) := 0; --长期寄存是否业务订购v_spaccesscode varchar2(40) := ' '; --长期寄存sp接入码v_silentdays number(10) := 0; --缄默用户天数v_nextrentfee number(10) := 0; --长期寄存待失效包月费v_rentfeevalidate char(6) := ' '; --长期寄存待失效包月费率失效月v_totaldctemplate varchar2(500) := ' '; --长期寄存解析模板:产品分档费率v_dealtemplate varchar2(500) := ' '; --长期寄存解析模板:待解析的分档段v_totaldclength number(3) := 0; --长期寄存解析模板: 分档字符串的长度v_totaldcsum number(10) := 0; --长期寄存解析模板: 分档总费用v_index0 number(3) := 0; --长期寄存解析模板: 分档字符串中&的地位v_index1 number(3) := 0; --长期寄存解析模板: 分档字符串中;的地位v_nextrentdatecycle char(14) := v_sysdate14; --长期寄存包周期产品的下次打算扣租工夫v_freeuseflag number(3) := 0; --长期存入流媒体业务的试用期属性v_hasrecord number(3) := 0; --寄存须要退订的产品是否蕴含在捆绑销售品中(0,不蕴含;1,蕴含)v_templockmonth number(5,2) := 0; --长期寄存退订时与订购时相差的月份数v_oa zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存发起方用户号码v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存应用方用户号码v_paymsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存计费方用户号码v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_payuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存计费方用户序号v_useusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存应用方用户类型v_usepaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存应用方用户付费类型v_paypaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存付费方用户付费类型v_useblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存应用方是否进入黑名单v_usewhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存应用方是否进入白名单v_useredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存应用方是否进入红名单v_useblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存应用方黑名单级别v_usewhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存应用方白名单级别v_usemsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存应用方号码类型v_paymsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存付费方号码类型v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存应用方话单专用付费类型v_payoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存付费方话单专用付费类型v_usecorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存应用方团体序号v_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫v_useusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存计费方号码类型v_payusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存计费方号码类型v_usecorpid zxdbm_ismp.susr_corp.corpid%type := ' '; --长期寄存团体代码v_productindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存产品序号v_invalidmode zxdbm_200.s200_product.invalidmode%type := 0; --退订失效形式,0 立刻失效,1-下一帐期失效 2-退定后可应用足月v_validcyctype zxdbm_200.s200_product.validcyctype%type := 0; --长期寄存周期形式0-非周期,1-天,2-周,3-月,定购失效形式为2时失效v_validcycparam zxdbm_200.s200_product.validcycparam%type := 0; --长期寄存周期参数,定购失效形式为2时失效v_validdate zxdbm_200.s200_product.validdate%type := v_sysdate14; --长期寄存指定失效日期v_subfeemode zxdbm_200.s200_product.subfeemode%type := 1; --长期寄存定购当月免费形式v_subfeedays zxdbm_200.s200_product.subfeedays%type := 0; --长期寄存免费日期取值范畴为0~28,0示意本月全副收费,其余示意 n号之后收费。v_freedays zxdbm_200.s200_product.freedays%type := 0; --长期寄存收费试用天数v_popustart zxdbm_200.s200_product.popularizestart%type := v_sysdate8; --长期寄存推广期开始工夫v_popustop zxdbm_200.s200_product.popularizestop%type := v_sysdate8; --长期寄存推广期完结工夫v_popuitem zxdbm_200.s200_product.popularizeitem%type := 0; --长期寄存推广期计费计划,0示意收费,1-推广期计划v_needcharge zxdbm_200.s200_product.needcharge%type := 1; --长期寄存是否须要计费,0-收费,1-须要计费v_productname zxdbm_200.s200_product.productname%type := ' '; --长期寄存产品名称v_productstatus zxdbm_200.s200_product.status%type := 0; --长期寄存产品状态v_onlyforcorp zxdbm_200.s200_product.onlyforcorp%type := 0; --长期寄存是否团体专用产品0:个人用户专用1:团体专用v_productstarttime zxdbm_200.s200_product.starttime%type := v_sysdate14; --长期寄存产品失效工夫v_productendtime zxdbm_200.s200_product.endtime%type := '99991231235959'; --长期寄存产品终止工夫v_workflow zxdbm_200.s200_product.workflow%type := 0; --长期寄存工作流状态v_workflowlife zxdbm_200.s200_product.workflowlife%type := 0; --长期寄存工作流流程状态v_cpindex zxdbm_200.s200_product.cpindex%type := 0; --长期寄存CP/SP序号v_serviceindex zxdbm_200.s200_product.serviceindex%type := 0; --长期寄存业务序号v_smschargingcn zxdbm_200.s200_product.smschargingcn%type := ' '; --长期寄存产品资费短信形容v_canbepresent zxdbm_200.s200_product.canbepresent%type := 0; --长期寄存是否可赠送,0-不可赠送,1-可赠送v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --长期寄存业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 1; --长期寄存业务能力子类型1-3G,2-PHS,3-ISAG,默认为3g业务能力(仅电信应用,其余营运商皆默认为1)v_srvprodid zxdbm_200.s200_product.productid%type := i_srvprodid; --长期寄存业务产品代码v_productid zxdbm_200.s200_product.productid%type := ' '; --长期寄存产品代码v_onlyforpkg zxdbm_200.s200_product.onlyforpkg%type := 0; --长期寄存是否套餐专用产品v_backfeemode zxdbm_200.s200_product.backfeemode%type := 0; --长期寄存退定补款形式,0-不补款,1-按帐期残余理论天数补款--added by youqunxia20130924 order3.02.01v_lockmonth zxdbm_200.s200_product.lockmonth%type := 0; --长期存产品放协定期,单位月份,为0时按无协定期解决v_chargetype zxdbm_200.s200_product_fee.chargetype%type := 0; --长期寄存计费类型v_subchargetype zxdbm_200.s200_product_fee.subchargetype%type := 0; --长期寄存计费子类型v_cyctype zxdbm_200.s200_product_fee.cyctype%type := 0; --长期寄存周期类型0-非周期,1-周期性v_cycunit zxdbm_200.s200_product_fee.cycunit%type := 0; --长期寄存周期单位 0-无,1-天,2-周,3-月,4-半年,5-年,6-小时,7-分钟,8-秒v_cycparam zxdbm_200.s200_product_fee.cycparam%type := 0; --长期寄存周期参数v_rentfee zxdbm_200.s200_product_fee.rentfee%type := 0; --长期寄存周期性费用金额v_fixfee zxdbm_200.s200_product_fee.fixfee%type := 0; --长期寄存包量费用v_fixusetimes zxdbm_200.s200_product_fee.fixusetimes%type := 0; --长期寄存包量应用值,0-无限度v_unitvol zxdbm_200.s200_product_fee.unitvol%type := 10; --长期寄存绝对于目前最小计量单位的量,时长为百毫秒,流量为bytev_autocontinue zxdbm_200.s200_product_fee.autocontinue%type := 0; --长期寄存周期性定购,是否主动续订v_minlimitfee zxdbm_200.s200_product_fee.minlimitfee%type := 0; --长期寄存保底费用,0-无保底费v_usecomfee zxdbm_200.s200_product_fee.usecomfee%type := 1; --长期寄存限度(量、工夫)外应用形式,1-应用根本费率,0-不容许持续应用v_totaldiscount zxdbm_200.s200_product_fee.totaldiscount%type := ' '; --长期寄存限度(量、工夫)外应用形式,1-应用根本费率,0-不容许持续应用v_cpid zxdbm_ismp.scp_basic.cpid%type := ' '; --长期寄存CP/SP代码v_cpstatus zxdbm_ismp.scp_basic.status%type := 0; --长期寄存CP/SP代码v_cpsubscribeurl zxdbm_ismp.scp_basic.cpsubscribeurl%type := ' '; --长期寄存CP/SP订购URLv_cpunsubscribeurl zxdbm_ismp.scp_basic.cpunsubscribeurl%type := ' '; --长期寄存CP/SP退订URLv_hasblacklist zxdbm_ismp.scp_basic.hasblacklist%type := 0; --长期寄存是否有黑名单管制 0-无,1-有v_cptype zxdbm_ismp.scp_basic.cptype%type := 2; --长期寄存CP/SP类型v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_insubblacklist zxdbm_ismp.scp_basic.insubblacklist%type := 0; --长期寄存限度订购SP黑名单标识v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --长期寄存CP/SP中文名简写v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' '; --长期寄存CP/SP客服电话v_protocoltype zxdbm_200.s200_sp_service_type.protocoltype%type := 0; --长期寄存定购同步协定类型0-ismp(wbs形式),1-smgp2.0(cngp1.0),2-smgp3.0(cngp1.0扩大)v_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := ' '; --长期寄存话单中的srvtypeidv_productcancelmode zxdbm_ismp.ssrv_corp_product.unsubscribemode%type := 0; --长期寄存退订形式,0-必须团体管理员退订,1-团体管理员与团体成员均可退订v_productpayparty zxdbm_ismp.ssrv_corp_product.payparty%type := 2; --长期寄存团体专用产品付费方 1-团体付费 2-集体付费v_productsubindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --长期寄存订购关系序号v_productsubid zxdbm_200.s200_user_subscription.subscriptionid%type := ' '; --长期寄存订购关系代码v_serviceid zxdbm_200.s200_user_subscription.serviceid%type := i_serviceid; --长期寄存业务代码v_propkgindex zxdbm_200.s200_user_subscription.productpkgindex%type := 0; --长期寄存套餐序号v_propkgid zxdbm_200.s200_user_subscription.productpkgid%type := ' '; --长期寄存套餐代码v_contentindex zxdbm_200.s200_user_subscription.contentindex%type := 0; --长期寄存内容序号v_contentid zxdbm_200.s200_user_subscription.contentid%type := ' '; --长期寄存内容代码v_corpindex zxdbm_200.s200_user_subscription.corpindex%type := 0; --长期寄存团体序号v_corpid zxdbm_200.s200_user_subscription.corpid%type := ' '; --长期寄存团体代码v_subscriber zxdbm_200.s200_user_subscription.subscriber%type := ' '; --发起方用户号码v_usercode zxdbm_200.s200_user_subscription.usercode%type := ' '; --应用方用户号码v_payuser zxdbm_200.s200_user_subscription.payuser%type := ' '; --计费方用户号码v_subscribemode zxdbm_200.s200_user_subscription.subscribemode%type := 1; --长期寄存订购形式v_subscribechannel zxdbm_200.s200_user_subscription.subscribechannel%type := 3; --长期寄存订购渠道v_subscribeoptype zxdbm_200.s200_user_subscription.subscribeoptype%type := 0; --长期寄存订购操作v_cancelmode zxdbm_200.s200_user_subscription.cancelmode%type := 0; --长期寄存订购形式v_cancelchannel zxdbm_200.s200_user_subscription.cancelchannel%type := 0; --长期寄存订购渠道v_canceloptype zxdbm_200.s200_user_subscription.canceloptype%type := 0; --长期寄存订购操作v_pausemode zxdbm_200.s200_user_subscription.pausemode%type := 0; --长期寄存产品暂停起因v_resumemode zxdbm_200.s200_user_subscription.resumemode%type := 0; --长期寄存产品复原起因v_substatus zxdbm_200.s200_user_subscription.status%type := 0; --长期寄存产品订购关系状态v_pushid zxdbm_200.s200_user_subscription.pushid%type := ' '; --长期寄存推荐者IDv_substarttime zxdbm_200.s200_user_subscription.starttime%type := v_sysdate14; --长期寄存定购失效工夫v_cursubendtime zxdbm_200.s200_user_subscription.endtime%type := v_sysdate14; --长期寄存以后定购关系生效工夫v_subendtime zxdbm_200.s200_user_subscription.endtime%type := '99991231235959'; --长期寄存定购生效工夫v_lastrenttime zxdbm_200.s200_user_subscription.lastrenttime%type := '00000000000000'; --长期寄存上次扣租工夫v_nextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := v_sysdate8; --长期寄存下次扣租日期v_nextnextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := v_sysdate8; --长期寄存下下次扣租日期v_payfordate zxdbm_200.s200_user_subscription.payfordate%type := '00000000'; --长期寄存月租已付日期v_returnvalues zxdbm_200.s200_user_subscription.returnvalues%type := 0; --长期寄存下一周期返还值v_returntype zxdbm_200.s200_user_subscription.returntype%type := 1; --长期寄存返还量类型v_returnstartdate zxdbm_200.s200_user_subscription.returnstartdate%type := '00000000'; --长期寄存返还值开始日期v_returnenddate zxdbm_200.s200_user_subscription.returnenddate%type := '00000000'; --长期寄存返还值完结日期v_chargeparty zxdbm_200.s200_user_subscription.chargeparty%type := 0; --长期寄存定购时填入,扣月租应用,计费方 0:用户;1:SP;2:团体v_freetime zxdbm_200.s200_user_subscription.freetime%type := '00000000000000'; --长期寄存产品订购收费日期v_createtime zxdbm_200.s200_user_subscription.createtime%type := '00000000000000'; --长期寄存用户订购工夫v_canceltime zxdbm_200.s200_user_subscription.canceltime%type := '00000000000000'; --长期寄存用户退定工夫v_firstusetime zxdbm_200.s200_user_subscription.firstusetime%type := '00000000000000'; --长期寄存用户首次应用工夫v_lastusetime zxdbm_200.s200_user_subscription.lastusetime%type := '00000000000000'; --长期寄存用户上次应用工夫v_tastestarttime zxdbm_200.s200_user_subscription.tastestarttime%type := '00000000000000'; --长期寄存体验期开始工夫v_tasteendtime zxdbm_200.s200_user_subscription.tasteendtime%type := '00000000000000'; --长期寄存体验期完结工夫v_pausetime zxdbm_200.s200_user_subscription.pausetime%type := '00000000000000'; --长期寄存暂停工夫v_resumetime zxdbm_200.s200_user_subscription.resumetime%type := '00000000000000'; --长期寄存暂停复原工夫v_subscribeopid zxdbm_200.s200_user_subscription.subscribeopid%type := ' '; --长期寄存定购操作员工号v_cancelopid zxdbm_200.s200_user_subscription.cancelopid%type := i_opid; --长期寄存退定操作员工号v_cancelreason zxdbm_200.s200_user_subscription.cancelreason%type := ' '; --长期寄存退定起因形容v_lastrent zxdbm_200.s200_user_subscription.lastrent%type := 0; --长期寄存上次扣租金额v_rollbacklastrent zxdbm_200.s200_user_subscription.lastrent%type := 0; --长期寄存上次扣租金额(订购关系待生效产品的订购失败回滚)v_msisdntype zxdbm_200.s200_user_subscription.msisdntype%type := 1; --长期寄存用户号码类型 1-msisdn,2-phs,3-pstn,4-IPTV接入号,5-宽带接入号,6-固定IPv_productsubstatus zxdbm_200.s200_user_subscription.status%type := 0;v_pseudocode zxdbm_200.s200_user_subscription.pseudocode%type := ' '; --长期寄存订购关系表中伪码v_oldproductid zxdbm_200.s200_user_subscription.oldproductid%type := ' '; --长期寄存产品代码--added by youqunxia20130608 order2.07.10v_pproductofferid zxdbm_200.s200_user_subscription.pproductofferid%type := ' '; --长期寄存增值产品对应的捆绑类套餐ID--added by youqunxia20130906 order3.02.01v_varifee zxdbm_200.s200_user_subscription.varifee%type := ''; --长期寄存以后订购关系中的可变价格 v_eventid zxdbm_200.s200_user_subscription.eventid%type := ''; --长期寄存事件ID v_servicesort zxdbm_200.s200_service.servicesort%type := 0; --业务归属 0:一般业务、1:属于OIDD 2:属于定位v_servicename zxdbm_200.s200_service.servicename%type := ' '; --长期寄存业务表中的业务名称v_isexperience zxdbm_200.s200_user_subscription.isexperience%type := '0'; --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0v_subscribetype zxdbm_200.s200_user_subscription.subscribetype%type := '0'; --订购形式:0:非批量受理 1: 批量受理 默认为0v_chargetime zxdbm_200.s200_user_subscription.chargetime%type := '00000000000000'; --首次扣费时间v_orderupdateurl zxdbm_200.s200_service.orderupdateurl%type := ' '; --长期寄存业务表中v_subsrvtype zxdbm_200.s200_service.subsrvtype%type := 1; --长期寄存业务子类型,1-wap pull,2-wap push,3-op wap push,4-wap pull 下载,101-试用业务(也示意 wap pull试用业务) ;102:wap push 试用业务;1001 - 根本通道费;1002v_phoneindex zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存号段序号v_attach zxdbm_ismp.ssys_phone.attach%type := 0; --长期寄存预付费归属,0-未知,1-OCS,2-RTBP
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_usemsisdn := ' ';o_paymsisdn := ' ';o_usemsisdntype := 1;o_paymsisdntype := 1;o_userindex := 0;o_paytype := 0;o_oppaytype := 0;o_scptype := 2;o_subfee := 0;o_feemode := 1;o_colortype := 0;o_cpid := ' ';o_cpindex := 0;o_cpcnshortname := ' ';o_cpunsubscribeurl := ' ';o_cptype := 0;o_protocoltype := 0;o_msgtosp := ' ';o_customersrvtel := ' ';o_serviceid := ' ';o_serviceindex := 0;o_servicename := ' ';o_productid := ' ';o_productindex := 0;o_productname := ' ';o_smschargingcn := ' ';o_servicetype := 0;o_subcapability := 1;o_srvtypeid := ' ';o_corpid := ' ';o_corpindex := 0;o_corpcnshortname := ' ';o_subendtime := '99991231235959';o_linknum := ' ';o_productsubid := ' ';o_productsubindex := 0;o_neednotifysp := 0;o_pseudocode :='';o_pcodemsisdnswitch :=0;o_chanelplayerstate :=0;o_eventstate :=1;o_spaccesscode := i_spaccesscode;o_maincapability := 0;o_submaincapability := 0;o_cpsrvtype :=0;o_orderfeaturecode := ' ';o_cdrbegintime := substr(v_sysdate8,1,6) || '01000000';o_cdrendtime := v_curmonthendtime;o_producttype := 1;o_cnfmtype := 0;o_invalidmode := 0;o_cityid := '';--added by youqunxia 2013.01.17o_orderaccesscode := ' ';o_issynctooidd := 0;if v_cancelopid is null then v_cancelopid := ' ';end if;
/**
--part-- --telicomcancelreq-- 1.预鉴权
发起方地址类型 发起方用户号码去前缀
**/
--发起方地址类型鉴权 现网局点可思考正文.--批量操作不进行鉴权,由业务从用户表中查询处理--modied by youqunxia20130709 Order2.07.10if (i_actiontype <> 17 and i_lallindex <> 91) then if i_oatype not in (1,2,3,4) then o_retcode := 107; o_debugpos := 1; o_debuginfo := 'i_oatype='||i_oatype||', not in (1,2,3,4).'; return; end if;end if;--发起方用户号码去前缀v_oa := ltrim(rtrim(nvl(i_oa,'0')));if v_oa like ('+' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 2);elsif v_oa like ('00' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 3);elsif v_oa like (v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 1);end if;if (substr(v_oa,1,1) <> '0') and (i_oatype = 4) then v_oa := '0' || v_oa;end if;v_usemsisdn := v_oa;o_usemsisdn := v_usemsisdn;if (v_usemsisdn = '0') then o_retcode := 1001; o_debugpos := 2; o_debuginfo := 'v_usemsisdn='||v_usemsisdn||', v_usemsisdn is 0.'; return;end if;
/**
--part-- --telicomcancelreq-- 2.应用方号码存在性鉴权
**/
if (i_needauthuser = 1) then begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,cityid into v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist, v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus, v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_useusercityid from zxdbm_ismp.susr_basic where usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; o_debugpos := 3; o_debuginfo := 'usercode do not exist.'; if (i_oatype = 4) then v_usemsisdntype := 2; else v_usemsisdntype := 1; end if; return; when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_usemsisdntype := 2; else o_usemsisdntype := 1; end if; return; end; v_paymsisdn := v_usemsisdn; v_paymsisdntype := v_usemsisdntype; v_payuserindex := v_useuserindex; o_paymsisdn := v_paymsisdn; o_usemsisdntype := v_usemsisdntype; o_paymsisdntype := v_paymsisdntype; o_userindex := v_useuserindex; o_paytype := v_usepaytype; o_oppaytype := v_useoppaytype; o_corpindex := v_usecorpindex; o_cityid := trim(v_useusercityid); --批量操作用户号码类型由用户表查问后鉴权 if (i_cmdchannel in (7,32)) then if v_usemsisdntype not in (1,2,3) then o_retcode := 100; o_debugpos := 5; o_debuginfo := 'v_usemsisdntype='||v_usemsisdntype||', not in (1,2,3);'; return; end if; end if; if (v_useredlist = 1) then o_colortype := 4; else o_colortype := 0; end if; if i_mutidbmode = 0 then if (v_useactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'usercode do not exist.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 7; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_useusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 8; o_debuginfo := 'usercode do not exist.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 9; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; end if;end if;
/**
--part-- --telicomcancelreq-- 3.产品存在性鉴权
**/
--产品互斥时,ESMGP传21个0在productid字段当中,同时传进来业务ID,此时以业务ID来获取实在的产品IDif v_srvprodid = '000000000000000000000' then v_sql := 'select isservicesub from zxdbm_200.s200_service where serviceid = :p1'; begin execute immediate v_sql into v_isservicesub using v_serviceid; exception when no_data_found then o_retcode := 2100; o_debugpos := 10; o_debuginfo := 'serviceindex='||v_serviceid||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_isservicesub <> 1 then o_retcode := 505; o_debugpos := 12; o_debuginfo := 'esmgp parse error.'; return; end if; --获取实在的产品ID,用于后续的操作 begin select productid into v_srvprodid from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and serviceid = v_serviceid; exception when no_data_found then o_retcode := 1201; o_debugpos := 13; o_debuginfo := o_debuginfo ||'v_usemsisdn = '||v_usemsisdn||'v_serviceid = '||v_serviceid||'the subscription dose not exist;'; return; when others then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;if (i_direct = 1 and i_supportproductid = 0) then--反向订购并且反对业务ID的退订 begin select productindex,invalidmode,validcyctype, validcycparam,validdate,subfeemode,subfeedays,freedays, popularizestart,popularizestop,popularizeitem,needcharge, productname,status,onlyforcorp,starttime,endtime, workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent, servicetype,subcapability,onlyforpkg,productid,backfeemode,lockmonth into v_productindex,v_invalidmode,v_validcyctype, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_onlyforpkg,v_productid,v_backfeemode,v_lockmonth from zxdbm_200.s200_product where serviceid = v_srvprodid and ordertype = 1; exception when no_data_found then o_retcode := 2100; o_debugpos := 15; o_debuginfo := 'serviceid='||v_srvprodid||', ordertype = 1'||', the product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select productindex,invalidmode,validcyctype, validcycparam,validdate,subfeemode,subfeedays,freedays, popularizestart,popularizestop,popularizeitem,needcharge, productname,status,onlyforcorp,starttime,endtime, workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent, servicetype,subcapability,productid,backfeemode,serviceid,lockmonth into v_productindex,v_invalidmode,v_validcyctype, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_productid,v_backfeemode,v_serviceid,v_lockmonth from zxdbm_200.s200_product where productid = v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 17; o_debuginfo := 'productid='||v_srvprodid||', the product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 18; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_productid := v_productid;o_productname := v_productname;o_productindex := v_productindex;o_serviceindex := v_serviceindex;o_serviceid := v_serviceid;o_cpindex := v_cpindex;o_smschargingcn := v_smschargingcn;o_servicetype := v_servicetype;o_subcapability := v_subcapability;if i_servicetype = 5 then v_sql := 'select freeuseflag,freedays from zxdbm_200.s200_product where productindex = :p1'; begin execute immediate v_sql into v_freeuseflag,v_freedays using v_productindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 19; o_debuginfo := 'The product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 20; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--产品状态鉴权if (v_productstatus in (0,2) and (v_workflowlife = 3)) then o_producttype := 2;end if;--added by youqunxia20130925 order3.02.01--产品状态为登记/预登记时,按失常解决,产品登记的优先级高于协定期v_templockmonth := months_between(sysdate,to_date(v_productstarttime,'yyyymmddhh24miss'));if v_productstatus in (3,4) then null;elsif v_templockmonth < v_lockmonth then --产品协定期内不容许退订 o_retcode := 1009017; o_debugpos := 89; o_debuginfo := 'The product is in the bargaining,can not cancel.'; return;else null;end if;--获取产品的计费信息if (v_popuitem = 2) then --无推广期 v_tempitem := 0;elsif v_popuitem in (0,1) then --推广期收费或者推广期计费 if (v_sysdate8 >= v_popustart) and (v_sysdate8 <= v_popustop) then if v_popuitem = 0 then --推广期收费 v_needcharge := 0; else v_needcharge := 1; v_tempitem := v_popuitem; end if; else v_tempitem := 0; end if;end if;if (v_needcharge = 1) then --费率存在性鉴权 if i_servicetype in (1,2) then v_sql := 'select chargetype,subchargetype,cyctype,cycunit,cycparam,rentfee,fixfee,fixusetimes,unitvol,autocontinue,minlimitfee,usecomfee,nextrentfee,rentfeevalidate,totaldiscount '|| 'from zxdbm_200.s200_product_fee where productindex = :p1 and itemindex = :p2'; begin execute immediate v_sql into v_chargetype,v_subchargetype,v_cyctype,v_cycunit,v_cycparam,v_rentfee,v_fixfee,v_fixusetimes,v_unitvol,v_autocontinue,v_minlimitfee,v_usecomfee,v_nextrentfee,v_rentfeevalidate,v_totaldiscount using v_productindex, v_tempitem; exception when no_data_found then o_retcode := 3103; o_debugpos := 21; o_debuginfo := 'productindex='||v_productindex||', itemindex='||v_tempitem||', the product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 22; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else begin select chargetype,subchargetype,cyctype,cycunit,cycparam, rentfee,fixfee,fixusetimes,unitvol,autocontinue,minlimitfee,usecomfee,totaldiscount into v_chargetype,v_subchargetype,v_cyctype,v_cycunit,v_cycparam, v_rentfee,v_fixfee,v_fixusetimes,v_unitvol,v_autocontinue,v_minlimitfee,v_usecomfee,v_totaldiscount from zxdbm_200.s200_product_fee where productindex = v_productindex and itemindex = v_tempitem; exception when no_data_found then o_retcode := 3103; o_debugpos := 23; o_debuginfo := 'productindex='||v_productindex||', itemindex='||v_tempitem||', the product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 24; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; --0资费判断,needcharge if v_needcharge = 0 then o_cnfmtype := 1; else if (v_rentfee = 0 and v_fixfee = 0 and v_minlimitfee = 0) then v_totaldctemplate := v_totaldiscount; loop v_index0 := instr(v_totaldctemplate,'&',1,1); v_dealtemplate := v_totaldctemplate; if v_index0 <> 0 then v_totaldclength := length(v_totaldctemplate); v_dealtemplate := substr(v_totaldctemplate, 1, v_index0-1); v_totaldctemplate := substr(v_totaldctemplate, 1+v_index0, v_totaldclength-v_index0); end if; v_totaldclength := length(v_dealtemplate); v_index1 := instr(v_dealtemplate,';',1,1); v_dealtemplate := substr(v_dealtemplate, 1+v_index1, v_totaldclength-v_index1); v_totaldclength := length(v_dealtemplate); v_index1 := instr(v_dealtemplate,';',1,1); v_dealtemplate := substr(v_dealtemplate, 1, v_index1-1); v_totaldcsum := to_number(v_dealtemplate); exit when (v_totaldcsum > 0 or v_index0 = 0); end loop; if v_totaldcsum = 0 then o_cnfmtype := 1; end if; end if; end if;end if;--是否业务退订if i_servicetype in (1,2,3) then v_sql := 'select isservicesub,servicesort from zxdbm_200.s200_service where serviceindex = :p1'; begin execute immediate v_sql into v_isservicesub,v_servicesort using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 25; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 26; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--added by youqunxia20130906 order3.02.01--是否同步订购关系给OIDD,0-否,1-是if v_servicesort = 1 then o_issynctooidd := 1;end if;if i_servicetype <> 14 then begin select orderupdateurl,subsrvtype,servicename into v_orderupdateurl,v_subsrvtype,v_servicename from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 27; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 28; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_servicename := v_servicename;if i_servicetype = 101 then v_sql := 'select maincapability,submaincapability '|| 'from zxdbm_9900.s9900_service where serviceindex = :p1'; begin execute immediate v_sql into v_maincapability,v_submaincapability using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 29; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 30; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_maincapability := v_maincapability; o_submaincapability := v_submaincapability;end if;--包月类退订形式解决if v_needcharge = 1 and v_chargetype in (2,5,7) then if i_cmdchannel in (1,2,36,14) then if i_servicetype in (1,2) or (i_servicetype = 3 and v_subsrvtype = 2) then v_invalidmode := 0; elsif i_servicetype = 3 and v_subsrvtype = 1 then v_invalidmode := 1; else null; end if; end if;end if;
/*
--part-- --telicomcancelreq-- 4.零碎业务能力鉴权
*/
--零碎业务能力鉴权if i_servicetype = 101 then begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_maincapability and subcapability = v_submaincapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 31; o_debuginfo := 'servicetype='||v_maincapability||', subcapability='||v_submaincapability||', the system service capbility does not exist.'; return; when others then o_retcode := 506; o_debugpos := 32; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 33; o_debuginfo := 'servicetype='||v_servicetype||', subcapability='||v_subcapability||', the system service capbility does not exist.'; return; when others then o_retcode := 506; o_debugpos := 34; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_srvtypeid := v_srvtypeid;
/*
--part-- --telicomcancelreq-- 5.CP/SP存在性及sp相干鉴权
*/
--CP/SP存在性鉴权begin select cpid,cpsrvtype,status,cpsubscribeurl,cpunsubscribeurl,hasblacklist,cptype,insubblacklist,cpcnshortname,customersrvtel into v_cpid,v_cpsrvtype,v_cpstatus,v_cpsubscribeurl,v_cpunsubscribeurl,v_hasblacklist,v_cptype,v_insubblacklist,v_cpcnshortname,v_customersrvtel from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 35; o_debuginfo := 'cpindex='||v_cpindex||', the cp/sp does not exist.'; return;when others then o_retcode := 506; o_debugpos := 36; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;if (v_cpunsubscribeurl is null) or (v_cpunsubscribeurl = ' ') then v_cpunsubscribeurl := v_cpsubscribeurl;end if;o_cpid := v_cpid;o_cptype := v_cptype;o_cpsrvtype := v_cpsrvtype;o_cpcnshortname := v_cpcnshortname;o_customersrvtel := v_customersrvtel;if (trim(v_orderupdateurl) is null) or (length(trim(v_orderupdateurl)) < 8) then o_cpunsubscribeurl := v_cpunsubscribeurl;else o_cpunsubscribeurl := v_orderupdateurl;end if;--SP开明业务能力鉴权(MVS,MPSS,PIM,CPX不须要鉴权)if i_servicetype in (5,14,33,101) then o_protocoltype := 0;else begin select protocoltype into v_protocoltype from zxdbm_200.s200_sp_service_type where cpindex = v_cpindex and servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 2100; o_debugpos := 37; o_debuginfo := 'v_cpindex='||v_cpindex||', v_servicetype='||v_servicetype||', v_subcapability='||v_subcapability||', the opened service capability of the SP does not exist.'; return; when others then o_retcode := 506; o_debugpos := 38; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_protocoltype := v_protocoltype;end if;--SP接入码查问if (i_spaccesscode is null) or (length(trim(i_spaccesscode)) = 0) then begin select spaccesscode into v_spaccesscode from zxdbm_ismp.ssrv_srvorder where productindex = v_productindex and cmdtype = i_actiontype and servicetype = i_servicetype and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 39; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if trim(v_spaccesscode) is null then begin select accesscode into v_spaccesscode from zxdbm_ismp.ssrv_spaccesscode where cpid = v_cpid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 40; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; o_spaccesscode := v_spaccesscode;end if;--订购指令查问begin--modified by youqunxia 2013.01.17 added accesscode select featurecode,accesscode into o_orderfeaturecode,o_orderaccesscode from zxdbm_ismp.ssrv_srvorder where productid = v_productid and cmdtype = 1 and rownum = 1;exception when no_data_found then null;when others then o_retcode := 506; o_debugpos := 41; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;--EventID和ChanelPlayerID 状态查问if i_actiontype = 2 then begin select status into o_chanelplayerstate from zxdbm_ismp.channel_basic where cpid = i_channelid; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 42; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; begin select status into o_eventstate from zxdbm_ismp.ssys_event where eventid = i_eventid; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 43; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;
--伪码解决(反对伪码开关关上,非自营sp)--反对业务LCS,SMS,MVS,DLS,MMS,WAP,CPX
--退订时,AuthPriceReq音讯中OA(DA)实在号码转化为伪码,同步SP
--这里订购业务的回滚订购关系不做解决
if i_servicetype in (1,2,3,4,41,5,6,101) then if i_actiontype <> 1 and i_catchflag <> 1 then if i_checkpseudocode = 1 and v_cpsrvtype <> 3 then begin select pseudocode into o_pseudocode from zxdbm_ismp.susr_basic where usercode = i_oa; exception when no_data_found then o_retcode := 1001; o_debugpos := 44; o_debuginfo := 'i_oa = '||i_oa||', the user dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 45; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_pcodemsisdnswitch := 1; end if; end if;end if;--如果团体专用产品属性为:必须团体管理员退定,则必须在团体门户上退定if (v_onlyforcorp = 1) then begin select corpid into v_usecorpid from zxdbm_ismp.susr_corp where corpindex = v_usecorpindex; exception when no_data_found then o_retcode := 1001301; --团体不存在 o_debugpos := 46; o_debuginfo := 'v_usecorpindex = '||v_usecorpindex||', the corp dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 47; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_corpid := v_usecorpid; --本团体的产品只能由本团体的用户退订 begin select unsubscribemode,payparty into v_productcancelmode,v_productpayparty from zxdbm_ismp.ssrv_corp_product where corpindex = v_usecorpindex and groupindex = 0 and productindex = v_productindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 48; o_debuginfo := 'corpindex = '||v_usecorpindex||', productindex = '||v_productindex||', the product of the corp dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 49; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_productcancelmode = 0 and i_rollback = 0) then --必须团体管理员退订 if (v_cmdchannel <> 4) then o_retcode := 1001214; --无权退订 o_debugpos := 50; o_debuginfo := 'v_productcancelmode = '||v_productcancelmode||', v_cmdchannel = '||v_cmdchannel||', the operator has no privilege to cancel the subscription.'; return; end if; end if;else v_usecorpindex := 0; o_corpindex := v_usecorpindex;end if;
/*
--part-- --telicomcancelreq-- 产品订购关系存在性鉴权(是否业务退订)
/
if i_issecondproduct = 1 or v_isservicesub = 1 then begin select subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex, cpid,subscribemode,subscribechannel,subscribeoptype, pausemode,resumemode,status,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelreason,lastrent,msisdntype,pseudocode, oldproductid,pproductofferid,varifee,eventid, isexperience,subscribetype,chargetime into v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_propkgindex, v_propkgid,v_contentindex,v_contentid,v_corpindex,v_corpid,v_cpindex, v_cpid,v_subscribemode,v_subscribechannel,v_subscribeoptype, v_pausemode,v_resumemode,v_productsubstatus,v_autocontinue,v_subscriber,v_usercode, v_payuser,v_pushid,v_substarttime,v_cursubendtime,v_lastrenttime, v_nextrentdate,v_payfordate,v_returnvalues,v_returntype, v_returnstartdate,v_returnenddate,v_fixusetimes,v_chargeparty, v_freetime,v_createtime,v_canceltime,v_firstusetime,v_lastusetime, v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime, v_subscribeopid,v_cancelreason,v_lastrent,v_msisdntype,v_pseudocode, v_oldproductid,v_pproductofferid,v_varifee,v_eventid, v_isexperience,v_subscribetype,v_chargetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and serviceid = v_serviceid; exception when no_data_found then o_retcode := 1201; o_debugpos := 51; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_serviceid = '||v_serviceid||', the subscription dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 52; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex, cpid,subscribemode,subscribechannel,subscribeoptype, pausemode,resumemode,status,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelreason,lastrent,msisdntype,pseudocode, oldproductid,pproductofferid,varifee,eventid, isexperience,subscribetype,chargetime into v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_propkgindex, v_propkgid,v_contentindex,v_contentid,v_corpindex,v_corpid,v_cpindex, v_cpid,v_subscribemode,v_subscribechannel,v_subscribeoptype, v_pausemode,v_resumemode,v_productsubstatus,v_autocontinue,v_subscriber,v_usercode, v_payuser,v_pushid,v_substarttime,v_cursubendtime,v_lastrenttime, v_nextrentdate,v_payfordate,v_returnvalues,v_returntype, v_returnstartdate,v_returnenddate,v_fixusetimes,v_chargeparty, v_freetime,v_createtime,v_canceltime,v_firstusetime,v_lastusetime, v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime, v_subscribeopid,v_cancelreason,v_lastrent,v_msisdntype,v_pseudocode, v_oldproductid,v_pproductofferid,v_varifee,v_eventid, v_isexperience,v_subscribetype,v_chargetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid; exception when no_data_found then o_retcode := 1201; o_debugpos := 53; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the subscription dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 54; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;if v_productsubstatus in (4,5) then o_retcode := 1202; o_debugpos := 55; o_debuginfo := 'status of the subscription is abnormal.'; return;elsif (v_productsubstatus = 6) or (v_cursubendtime < v_sysdate14) then o_retcode := 1201; o_debugpos := 56; o_debuginfo := 'The subscription does not exist.'; return;end if;--added by youqunxia20130609 order2.07.10--判断是否属于捆绑品if trim(v_pproductofferid) is not null and i_cmdchannel <> 40 then if i_actiontype = 10 then null; else o_retcode := 1001229; o_debugpos := 58; o_debuginfo := 'The product is binding,unsubscribe illegal .'; return; end if;end if;if (v_freetime > v_substarttime) and (v_freetime > v_sysdate14) then v_invalidmode := 0;elsif (i_servicetype = 5) then v_invalidmode := 1; --MVS业务门户上不显示该字段,缺省退订都为下帐期失效end if;--added by youqunxia20130910 order3.02.01--VSOP侧发动捆绑类套餐、增值产品的订购激活、变更激活及退订,ISMP中增值子产品订购关系立刻失效(包含订购、退订及变更),不以增值产品属性判断失效工夫; if (i_cmdchannel = 40) and (i_effectiveswitch = 1)then v_invalidmode := 0;end if;o_invalidmode := v_invalidmode;--缄默用户清理订购关系判断if i_cmdchannel = 20 then if v_lastusetime = '00000000000000' then v_silentdays := to_date(v_sysdate14,'yyyymmddhh24miss') - to_date(v_substarttime,'yyyymmddhh24miss'); else v_silentdays := to_date(v_sysdate14,'yyyymmddhh24miss') - to_date(v_lastusetime,'yyyymmddhh24miss'); end if; if (v_silentdays < 30) then o_retcode := 1001224; --不满足缄默用户清理订购关系条件 o_debugpos := 59; o_debuginfo := 'v_lastusetime = '||v_lastusetime||', it is not allowed to delete subscription of silent user.'; return; end if;end if;--(除CRM发动的退订)套餐下的产品不容许独自退订if (v_propkgindex <> 0 and i_cmdchannel not in (9,35,39,40)) then o_retcode := 1001214; o_debugpos := 60; o_debuginfo := 'the product in pkg is not allowed to be unsubscribed alone.'; return;end if;o_paymsisdn := v_payuser;o_productsubindex := v_productsubindex;o_productsubid := v_productsubid;--依据i_needreplay决定鉴权是否持续if (i_needreplay = 1) then begin v_tmpint := dbms_random.value(1,9999999999); o_linknum := v_sysdate14 || '655380' || lpad(to_char(v_tmpint),10,'0'); exception when others then o_retcode := 506; o_debugpos := 61; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; return;end if;
/*
--part-- --telicomcancelreq-- 6.计费方设置
*/
if (v_productpayparty = 1) then v_paymsisdn := v_usecorpid; o_paytype := 0; o_paymsisdn := v_paymsisdn; v_payuserindex := v_corpindex; o_cityid := trim(' ');else --赠送时,订购关系只能由应用方退订,此时须要将付费方的信息带出存储过程 if (v_payuser <> v_usemsisdn) then v_paymsisdn := v_payuser; o_paymsisdn := v_paymsisdn; begin select msisdntype,paytype,oppaytype,cityid into v_paymsisdntype,v_paypaytype,v_payoppaytype,v_payusercityid from zxdbm_ismp.susr_basic where usercode = v_payuser; exception when no_data_found then o_retcode := 1001; o_debugpos := 62; o_debuginfo := 'v_payuser = '||v_payuser||', user dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 63; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_paytype := v_paypaytype; o_oppaytype := v_payoppaytype; o_paymsisdntype := v_paymsisdntype; o_cityid := trim(v_payusercityid); end if; if (i_prepaidtype = 1) then o_scptype := 1; elsif i_prepaidtype = 2 then o_scptype := 2; else --attach 预付费归属,0-未知,1-OCS,2-RTBP begin select phoneindex,attach into v_phoneindex,v_attach from zxdbm_ismp.ssys_phone where startprefix <= substr(v_paymsisdn,1,length(startprefix)) and endprefix >= substr(v_paymsisdn,1,length(endprefix)); exception when no_data_found then o_scptype := 2; v_devexist := 0; --示意不存在对应号段对应设施配置 when others then o_retcode := 506; o_debugpos := 64; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_devexist = 1) then if (v_attach = 1) then o_scptype := 1; elsif (v_attach = 2) then o_scptype := 2; else begin select 1 into o_scptype from zxdbm_ismp.sdev_phone where phoneindex = v_phoneindex and devicetype = 5; exception when no_data_found then o_scptype := 2; when others then o_retcode := 506; o_debugpos := 65; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if;end if;
/**
--part-- --telicomcancelreq 本次退订须要扣取或者补回的费用,退订立刻失效订购业务才扣费
**/
if v_chargetype in (3,6,8) then --包周期补款;(包周期产品退订不须要扣费,业务或者月租在周期第一天曾经扣取) --门户申请包周期的产品时,退订都是立刻失效的,所以没有对退订失效形式进行判断 if (v_backfeemode = 1) and (v_lastrenttime <> '00000000000000') then if v_cycunit = 1 then v_nextrentdatecycle := to_char(to_date(v_lastrenttime,'YYYYMMDDHH24MISS') + v_cycparam,'YYYYMMDDHH24MISS'); elsif v_cycunit = 2 then v_nextrentdatecycle := to_char(to_date(v_lastrenttime,'YYYYMMDDHH24MISS') + v_cycparam * 7,'YYYYMMDDHH24MISS'); elsif v_cycunit = 3 then v_nextrentdatecycle := to_char(add_months(to_date(v_lastrenttime,'YYYYMMDDHH24MISS'), v_cycparam),'YYYYMMDDHH24MISS'); elsif v_cycunit = 4 then v_nextrentdatecycle := to_char(add_months(to_date(v_lastrenttime,'YYYYMMDDHH24MISS'), v_cycparam * 6),'YYYYMMDDHH24MISS'); elsif v_cycunit = 5 then v_nextrentdatecycle := to_char(add_months(to_date(v_lastrenttime,'YYYYMMDDHH24MISS'), v_cycparam * 12),'YYYYMMDDHH24MISS'); end if; if v_nextrentdatecycle > v_sysdate14 then v_monthdays := floor(to_date(v_nextrentdatecycle, 'YYYYMMDDHH24MISS') - to_date(v_lastrenttime, 'YYYYMMDDHH24MISS')); v_leftdays := floor(to_date(v_nextrentdatecycle, 'YYYYMMDDHH24MISS') - to_date(v_sysdate14, 'YYYYMMDDHH24MISS')); end if; o_subfee := v_lastrent * v_leftdays / v_monthdays; o_feemode := 2; end if;elsif v_chargetype in (2,5,7) then if (substr(v_lastrenttime,1,6) = v_sysmonth6) then --本月租金已扣除 --对包月类产品和纯包量产品都会补款 if v_backfeemode = 1 then if (v_productsubstatus in (0,2) or (v_productsubstatus in (1,3) and v_invalidmode = 0)) then --0-待失效;1-失常;2:暂停+待失效;3:暂停;4:待生效;5:暂停+待生效;6:登记 v_leftdays := to_number(substr(v_curmonthendtime,1,8)) - to_number(v_sysdate8); if (substrb(v_sysdate14,1,6) = substrb(v_substarttime,1,6)) then
-- v_monthdays := to_number(substr(v_curmonthendtime,1,8)) - to_number(substr(v_substarttime,1,8)) + 1;
v_monthdays := to_number(substr(v_curmonthendtime,7,2)); if v_subfeemode in (1,-1) then o_subfee := v_lastrent * v_leftdays / v_monthdays; o_feemode := 2; end if; else v_monthdays := to_number(substr(v_curmonthendtime,7,2)); o_subfee := v_lastrent * v_leftdays / v_monthdays; o_feemode := 2; end if; /* v_leftdays := to_number(substr(v_curmonthendtime,1,8)) - to_number(v_sysdate8); if (substrb(v_sysdate14,1,6) = substrb(v_substarttime,1,6)) then v_monthdays := to_number(substr(v_curmonthendtime,1,8)) - to_number(substr(v_substarttime,1,8)) + 1; else v_monthdays := to_number(substr(v_curmonthendtime,7,2)); end if; o_subfee := v_lastrent * v_leftdays / v_monthdays; o_feemode := 2; */ end if; end if; elsif (substr(v_lastrenttime,1,6) < v_sysmonth6) then --本月租金未扣除 o_feemode := 1; if (v_productsubstatus in (0,2) or (v_productsubstatus in (1,3) and v_invalidmode = 0)) then if (substr(v_substarttime,1,6) = v_sysmonth6) then --产品订购工夫在当月 if (v_needcharge = 1) and (v_freetime < v_sysdate14) and (v_substarttime < v_sysdate14) then if v_chargetype not in (2,3,4,5,6,7,8) or (v_isservicesub = 1 and trim(v_oldproductid) is not null and v_productid <> v_oldproductid) then o_subfee := 0; else o_subfee := v_fixfee; if v_chargetype in (2,5,7) then if i_servicetype in (1,2) then if (v_rentfee <> v_nextrentfee) and (substr(v_rentfeevalidate,1,6) = v_sysmonth6) then v_rentfee := v_nextrentfee; end if; end if; if v_backfeemode = 1 and v_subfeemode = 1 then v_subfeemode := 4; end if; if (v_subfeemode = 1) then --收取本帐期全副费用 o_subfee := o_subfee + v_rentfee; elsif (v_subfeemode = 2) then --上半月订购收取全月费用,下半月订购收取半月费用 if (to_number(substr(v_substarttime,7,2)) - 15 > 0) then o_subfee := o_subfee + v_rentfee/2; else o_subfee := o_subfee + v_rentfee; end if; elsif (v_subfeemode = 3) then --n日全费含n日,n日后收费 if (v_subfeedays = 0) then --0示意本月全副收费,其余示意 N号之后收费。 null; elsif (to_number(substr(v_substarttime,7,2)) - v_subfeedays <= 0) then o_subfee := o_subfee + v_rentfee; else null; end if; elsif (v_subfeemode = 4) then --理论天数免费 v_leftdays := floor(to_number(to_date(v_sysdate14,'yyyymmddhh24miss') - to_date(v_freetime,'yyyymmddhh24miss')))+1; v_monthdays := to_number(substr(v_curmonthendtime,7,2)); o_subfee := o_subfee + v_rentfee*(v_leftdays/v_monthdays); end if; end if; end if; end if; else if (v_needcharge = 1) and (v_freetime < v_sysdate14) and (v_substarttime < v_sysdate14) then if v_chargetype not in (2,3,4,5,6,7,8) then o_subfee := 0; else o_subfee := v_fixfee; if v_chargetype in (2,5,7) then --产品订购工夫不在当月 if i_servicetype in (1,2) then if (v_rentfee <> v_nextrentfee) and (substr(v_rentfeevalidate,1,6) = v_sysmonth6) then v_rentfee := v_nextrentfee; end if; end if; if (v_backfeemode = 1) then v_leftdays := to_number(substr(v_sysdate8,7,2)); v_monthdays := to_number(substr(v_curmonthendtime,7,2)); o_subfee := o_subfee + v_rentfee * v_leftdays / v_monthdays; else o_subfee := o_subfee + v_rentfee; end if; end if; end if; end if; end if; end if; end if;else if (substr(v_lastrenttime,1,6) = v_sysmonth6) then --本月租金已扣除 --对包月类产品和纯包量产品都会补款 if (v_backfeemode = 1) then if (v_productsubstatus in (0,2) or (v_productsubstatus in (1,3) and v_invalidmode = 0)) then --0-待失效;1-失常;2:暂停+待失效;3:暂停;4:待生效;5:暂停+待生效;6:登记 v_leftdays := to_number(substr(v_curmonthendtime,1,8)) - to_number(v_sysdate8); if (substrb(v_sysdate14,1,6) = substrb(v_substarttime,1,6)) then v_monthdays := to_number(substr(v_curmonthendtime,1,8)) - to_number(substr(v_substarttime,1,8)) + 1; else v_monthdays := to_number(substr(v_curmonthendtime,7,2)); end if; o_subfee := v_lastrent * v_leftdays / v_monthdays; o_feemode := 2; end if; end if; elsif (substr(v_lastrenttime,1,6) < v_sysmonth6) then --本月租金未扣除 o_feemode := 1; if (v_productsubstatus in (0,2) or (v_productsubstatus in (1,3) and v_invalidmode = 0)) then if (substr(v_substarttime,1,6) = v_sysmonth6) then --产品订购工夫在当月 if (v_needcharge = 1) and (v_freetime < v_sysdate14) and (v_substarttime < v_sysdate14) then if v_chargetype not in (2,3,4,5,6,7,8) then o_subfee := 0; else o_subfee := v_fixfee; if v_chargetype in (2,5,7) then if i_servicetype in (1,2) then if (v_rentfee <> v_nextrentfee) and (substr(v_rentfeevalidate,1,6) = v_sysmonth6) then v_rentfee := v_nextrentfee; end if; end if; if (v_backfeemode = 1) then v_subfeemode := 4; end if; if (v_subfeemode = 1) then --收取本帐期全副费用 o_subfee := o_subfee + v_rentfee; elsif (v_subfeemode = 2) then --上半月订购收取全月费用,下半月订购收取半月费用 if (to_number(substr(v_substarttime,7,2)) - 15 > 0) then o_subfee := o_subfee + v_rentfee/2; else o_subfee := o_subfee + v_rentfee; end if; elsif (v_subfeemode = 3) then --n日全费含n日,n日后收费 if (v_subfeedays = 0) then --0示意本月全副收费,其余示意 N号之后收费。 null; elsif (to_number(substr(v_substarttime,7,2)) - v_subfeedays <= 0) then o_subfee := o_subfee + v_rentfee; else null; end if; elsif (v_subfeemode = 4) then --理论天数免费 v_leftdays := floor(to_number(to_date(v_sysdate14,'yyyymmddhh24miss') - to_date(v_freetime,'yyyymmddhh24miss')))+1; v_monthdays := to_number(substr(v_curmonthendtime,7,2)); o_subfee := o_subfee + v_rentfee*(v_leftdays/v_monthdays); end if; end if; end if; end if; else if (v_needcharge = 1) and (v_freetime < v_sysdate14) and (v_substarttime < v_sysdate14) then if v_chargetype not in (2,3,4,5,6,7,8) then o_subfee := 0; else o_subfee := v_fixfee; if v_chargetype in (2,5,7) then --产品订购工夫不在当月 if i_servicetype in (1,2) then if (v_rentfee <> v_nextrentfee) and (substr(v_rentfeevalidate,1,6) = v_sysmonth6) then v_rentfee := v_nextrentfee; end if; end if; if (v_backfeemode = 1) then v_leftdays := to_number(substr(v_sysdate8,7,2)); v_monthdays := to_number(substr(v_curmonthendtime,7,2)); o_subfee := o_subfee + v_rentfee * v_leftdays / v_monthdays; else o_subfee := o_subfee + v_rentfee; end if; end if; end if; end if; end if; end if; end if;end if;--首次应用扣费然而未应用/在线包月然而本月未应用的状况不扣费if (substr(v_lastrenttime,1,6) < v_sysmonth6) then if (v_subchargetype = 2 and v_firstusetime = '00000000000000') or (v_subchargetype = 3 and substr(v_lastusetime,1,6) <> v_sysmonth6) then o_subfee := 0; end if;end if;if (o_subfee < v_minlimitfee) and (o_feemode = 1) then o_subfee := v_minlimitfee;end if;--用户状态为用户被动停机(用户状态为1)、用户被动停机及欠费停机(用户状态为3)两种时,不计费if v_useuserstatus in (1,3) then o_subfee := 0; o_feemode := 1;end if;if (o_subfee > 0) and (o_feemode = 1) and (v_chargetype in (2,5,7)) then v_lastrenttime := v_sysdate14; v_payfordate := v_sysdate8;end if;if (v_freetime > v_sysdate14 and o_subfee = 0) then o_cnfmtype := 2;end if;
/**
--part-- --telicomcancelreq-- 形式、退订渠道
**/
v_canceloptype := 0;--设置退订形式if (i_cmdchannel = 6) then v_cancelmode := 4;elsif (i_cmdchannel in (0,20)) then v_cancelmode := 3;elsif (i_cmdchannel = 4) then v_cancelmode := 5;else v_cancelmode := 2;end if;--设置退订渠道begin select portalchannel into v_cancelchannel from zxdbm_ismp.ssrv_channel_map where innerchannel = i_cmdchannel;exception when no_data_found then v_cancelchannel := i_cmdchannel * 1000;when others then o_retcode := 506; o_debugpos := 66; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;
/**
--part-- --telicomcancelreq-- 订购关系完结工夫
**/
if i_servicetype = 5 then --对MVS业务的订购关系生效工夫做非凡解决 if v_chargetype in (3,6,8) and v_cyctype = 0 then --如果为非周期性 v_subendtime := v_cursubendtime; elsif v_chargetype in (3,6,8) then --如果为周期性(MVS的包周期计费只存在包天形式) v_subendtime := to_char(to_date(v_nextrentdate,'yyyymmdd') - 1,'yyyymmdd') || '235959'; elsif v_chargetype in (2,5,7) then if v_invalidmode = 0 then v_subendtime := v_sysdate14; elsif v_invalidmode = 1 then v_subendtime := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')),'yyyymmdd') || '235959'; end if; end if;else if (v_invalidmode = 0) then v_subendtime := v_sysdate14; --对于非立刻失效的产品依照v_chargetype别离解决 elsif v_chargetype in (2,5,7) then --added by youqunxia20130924 order3.02.01 if v_invalidmode = 2 and v_cyctype = 1 then if v_lastrenttime ='00000000000000' and v_freetime > v_substarttime then --如果为收费期内退订,已将v_invalidmode置0,此处解决收费期后,扣租前的退订的工夫计算 v_nextnextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmdd') ,1 ),'yyyymmdd'); if substr(v_nextrentdate,7,2) < substr(v_nextnextrentdate,7,2) then v_nextnextrentdate := substr(v_nextnextrentdate,1,6) || substr(v_nextrentdate,7,2); elsif substr(v_nextrentdate,7,2) > substr(v_nextnextrentdate,7,2) then v_nextnextrentdate := to_char(add_months(to_date(v_nextnextrentdate,'yyyymmdd') ,1 ),'yyyymm')||'01'; end if; v_subendtime := to_char(to_date(v_nextnextrentdate,'YYYYMMDD') - 1,'YYYYMMDD')||'235959'; else v_subendtime := to_char((to_date(v_nextrentdate,'YYYYMMDD') -1 ),'YYYYMMDD')||'235959'; end if; elsif v_invalidmode = 2 and v_cyctype = 0 then v_subendtime := v_cursubendtime; else v_subendtime := v_curmonthendtime; end if; elsif v_chargetype in (3,6,8) then if v_cyctype = 0 then v_subendtime := v_cursubendtime; elsif v_cyctype = 1 then if v_lastrenttime ='00000000000000' and v_freetime > v_substarttime then --如果为收费期内退订,已将v_invalidmode置0,此处解决收费期后,扣租前的退订的工夫计算 --包周期的产品的试用期都在账期外 --收费产品是没有试用期的 if (v_cycunit = 1) then --包天 v_nextnextrentdate := to_char(to_date(v_nextrentdate,'yyyymmddhh24miss') + v_cycparam,'yyyymmdd'); elsif (v_cycunit = 2) then --包周 v_nextnextrentdate := to_char(to_date(v_nextrentdate,'yyyymmddhh24miss') + v_cycparam * 7,'yyyymmdd'); elsif (v_cycunit = 3) then --包月(如果目标月份没有31号,add_month函数会主动取月最初一天) v_nextnextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmddhh24miss'),v_cycparam),'yyyymmdd'); elsif (v_cycunit = 4) then --包半年 v_nextnextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmddhh24miss'),v_cycparam * 6),'yyyymmdd'); elsif (v_cycunit = 5) then --包年 v_nextnextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmddhh24miss'),v_cycparam * 12),'yyyymmdd'); elsif (v_cycunit = 9) then --包季度 v_nextnextrentdate := to_char(add_months(to_date(v_nextrentdate,'yyyymmddhh24miss'),v_cycparam * 3),'yyyymmdd'); end if; v_subendtime := to_char(to_date(v_nextnextrentdate,'YYYYMMDD') - 1,'YYYYMMDD')||'235959'; else v_subendtime := to_char(to_date(v_nextrentdate,'YYYYMMDD') -1 ,'YYYYMMDD')||'235959'; end if; end if; --若本周期的完结工夫超过本月,则默认为本月月底失效。 if v_subendtime > v_curmonthendtime then v_subendtime := v_curmonthendtime; end if; else --对于v_chargetype为(0/1/4),如果非立刻失效,默认设置为下月失效。 v_subendtime := v_curmonthendtime; end if; /* if (v_invalidmode = 0) then v_subendtime := v_sysdate14; else v_subendtime := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')) + 1,'yyyymmdd') || '000000'; end if; */end if;o_subendtime := v_subendtime;
/**
--part-- --telicomcancelreq-- 退订后的状态设置
**/
--modied by youqunxia20130924 order3.02.01if (v_productsubstatus = 1) and (v_invalidmode in (1,2)) then--失常+下一帐期实效/退定后可应用足月, 间接更新订购关系为待生效 v_substatus := 4;elsif (v_productsubstatus = 3) and (v_invalidmode in (1,2)) then--暂停+下一帐期实效/退定后可应用足月,间接更新订购关系为暂停+待生效 v_substatus := 5;else v_substatus := 6;end if;--added by youqunxia20130820 order3.02.01--订购关系状态失常和暂停时退订时,把下次扣租日期改为订购关系完结的后一天,防止月租再次扣租if (v_productsubstatus in (1,3)) and (v_invalidmode = 2) then v_nextrentdate := to_char(to_date(v_subendtime,'yyyymmddhh24miss') + 1,'yyyymmdd');end if;
/**
--part-- --telicomcancelreq-- 设置话单中的begintime、endtime
**/
if substr(v_substarttime,1,6) = substr(v_sysdate8,1,6) then o_cdrbegintime := v_substarttime;else if(v_subendtime < o_cdrendtime) then o_cdrendtime := v_subendtime; end if;end if;v_subscribeoptype := 3;
/**
--part-- --telicomcancelreq-- 事务开始
**/
if (v_productsubstatus in(1,3)) and (v_invalidmode in(1,2)) and (i_rollback = 0) then--处于失常或者暂停状态,并且下一帐期生效的产品订购关系:更新订购关系 begin update zxdbm_200.s200_user_subscription set endtime = v_subendtime, status = v_substatus, subscribeoptype = v_subscribeoptype, canceltime = v_sysdate14, statustime = v_sysdate14, cancelmode = v_cancelmode, cancelchannel = v_cancelchannel, canceloptype = v_canceloptype, cancelopid = v_cancelopid, nextrentdate = v_nextrentdate where usercode = v_usemsisdn and productid = v_productid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 67; o_debuginfo := 'v_usemsisdn='||v_usemsisdn||', v_productid='||v_productid||', the record of user_subscription do not exist.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 68; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; commit; o_neednotifysp := 1;else begin --事务开始 if (i_rollback = 0) then v_sql := 'insert into zxdbm_200.s200_user_subs_hist' || v_curstrmonth || '(subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,contentindex,contentid, productpkgindex,productpkgid,corpindex,corpid,cpindex,cpid,subscribemode, subscribechannel,subscribeoptype,cancelmode,cancelchannel,canceloptype, pausemode,resumemode,status,statustime,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime,nextrentdate,payfordate, returnvalues,returntype,returnstartdate,returnenddate,fixusetimes, chargeparty,freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime,subscribeopid, cancelopid,cancelreason,lastrent,msisdntype,pseudocode,pproductofferid, varifee,eventid,isexperience,subscribetype,chargetime) values(:p1,:p2,:p3,:p4, :p5,:p6,:p7,:p8,:p9,:p10, :p11,:p12,:p13,:p14,:p15,:p16,:p17, :p18,:p19,:p20,:p21,:p22, :p23,:p24,:p25,:p26,:p27,:p28, :p29,:p30,:p31,:p32,:p33,:p34,:p35, :p36,:p37,:p38,:p39,:p40, :p41,:p42,:p43,:p44,:p45,:p46, :p47,:p48,:p49,:p50,:p51, :p52,:p53,:p54,:p55,:p56,:p57,:p58, :p59,:p60,:p61,:p62,:p63)'; begin --插入历史订购关系 execute immediate v_sql using v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_contentindex,v_contentid, v_propkgindex,v_propkgid,v_corpindex,v_corpid,v_cpindex,v_cpid,v_subscribemode, v_subscribechannel,v_subscribeoptype,v_cancelmode,v_cancelchannel,v_canceloptype, v_pausemode,v_resumemode,v_substatus,v_sysdate14,v_autocontinue,v_subscriber,v_usercode, v_payuser,v_pushid,v_substarttime,v_subendtime,v_lastrenttime,v_nextrentdate,v_payfordate, v_returnvalues,v_returntype,v_returnstartdate,v_returnenddate,v_fixusetimes, v_chargeparty,v_freetime,v_createtime,v_sysdate14,v_firstusetime,v_lastusetime, v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime,v_subscribeopid, v_cancelopid,v_cancelreason,v_lastrent,v_msisdntype,v_pseudocode,v_pproductofferid, v_varifee,v_eventid,v_isexperience,v_subscribetype,v_chargetime; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 69; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 70; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; if (i_rollback = 1) and (i_issecondproduct in (1,2,3)) then --业务订购/待生效/纯包量订购关系产品的订购--回滚 v_rollbacklastrent := v_lastrent; v_sql := 'select subscriptionindex,subscriptionid,servicetype,subcapability,'|| 'serviceindex,serviceid,productindex,productid,contentindex,contentid,'|| 'productpkgindex,productpkgid,corpindex,corpid,cpindex,cpid,subscribemode,'|| 'subscribechannel,subscribeoptype,cancelmode,cancelchannel,canceloptype,'|| 'pausemode,resumemode,status,statustime,autocontinue,subscriber,usercode,'|| 'payuser,pushid,starttime,endtime,lastrenttime,nextrentdate,payfordate,'|| 'returnvalues,returntype,returnstartdate,returnenddate,fixusetimes,'|| 'chargeparty,freetime,createtime,canceltime,firstusetime,lastusetime,'|| 'tastestarttime,tasteendtime,pausetime,resumetime,subscribeopid,'|| 'cancelopid,cancelreason,lastrent,msisdntype,pseudocode,pproductofferid,'|| 'varifee,eventid,isexperience,subscribetype,chargetime'|| ' from zxdbm_200.s200_user_subs_hist' || v_curstrmonth || ' where usercode = :p1 and productid = :p2 and to_number(statustime) in '|| '(select max(to_number(statustime)) from zxdbm_200.s200_user_subs_hist'|| v_curstrmonth || ' where usercode = :p3 and productid = :p4)'; begin execute immediate v_sql into v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_contentindex,v_contentid, v_propkgindex,v_propkgid,v_corpindex,v_corpid,v_cpindex,v_cpid,v_subscribemode, v_subscribechannel,v_subscribeoptype,v_cancelmode,v_cancelchannel,v_canceloptype, v_pausemode,v_resumemode,v_substatus,v_sysdate14,v_autocontinue,v_subscriber,v_usercode, v_payuser,v_pushid,v_substarttime,v_subendtime,v_lastrenttime,v_nextrentdate,v_payfordate, v_returnvalues,v_returntype,v_returnstartdate,v_returnenddate,v_fixusetimes, v_chargeparty,v_freetime,v_createtime,v_canceltime,v_firstusetime,v_lastusetime, v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime,v_subscribeopid, v_cancelopid,v_cancelreason,v_lastrent,v_msisdntype,v_pseudocode,v_pproductofferid, v_varifee,v_eventid,v_isexperience,v_subscribetype,v_chargetime using v_usercode,i_cancelproductid,v_usercode,i_cancelproductid; exception when no_data_found then o_retcode := 1201; o_debugpos := 71; o_debuginfo := 'v_usercode='||v_usercode||', i_cancelproductid='||i_cancelproductid||', user_subs_hist does not exist.'; return; when others then o_retcode := 506; o_debugpos := 72; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --更新订购关系表,删除历史订购关系表中同一业务的原订购关系 if i_issecondproduct = 1 then --业务订购失败后的回滚 v_canceltime := '00000000000000'; begin update zxdbm_200.s200_user_subscription set subscriptionindex = v_productsubindex, subscriptionid = v_productsubid, servicetype = v_servicetype, subcapability = v_subcapability, serviceindex = v_serviceindex, --serviceid = v_serviceid, productindex = v_productindex, productid = v_productid, productpkgindex = v_propkgindex, productpkgid = v_propkgid, contentindex = v_contentindex, contentid = v_contentid, corpindex = v_corpindex, corpid = v_corpid, cpindex = v_cpindex, cpid = v_cpid, subscribemode = v_subscribemode, subscribechannel = v_subscribechannel, subscribeoptype = v_subscribeoptype, cancelmode = v_cancelmode, cancelchannel = v_cancelchannel, canceloptype = v_canceloptype, pausemode = v_pausemode, resumemode = v_resumemode, status = v_substatus, statustime = v_sysdate14, autocontinue = v_autocontinue, subscriber = v_subscriber, usercode = v_usercode, payuser = v_payuser, pushid = v_pushid, starttime = v_substarttime, endtime = v_subendtime, lastrenttime = v_lastrenttime, nextrentdate = v_nextrentdate, payfordate = v_payfordate, returnvalues = v_returnvalues, returntype = v_returntype, returnstartdate = v_returnstartdate, returnenddate = v_returnenddate, fixusetimes = v_fixusetimes, chargeparty = v_chargeparty, freetime = v_freetime, createtime = v_createtime, canceltime = v_canceltime, firstusetime = v_firstusetime, lastusetime = v_lastusetime, tastestarttime = v_tastestarttime, tasteendtime = v_tasteendtime, pausetime = v_pausetime, resumetime = v_resumetime, subscribeopid = v_subscribeopid, cancelopid = v_cancelopid, cancelreason = v_cancelreason, lastrent = v_lastrent, msisdntype = v_msisdntype, pseudocode = v_pseudocode, pproductofferid = v_pproductofferid, varifee = v_varifee, eventid = v_eventid, isexperience = v_isexperience, subscribetype = v_subscribetype, chargetime = v_chargetime where usercode = v_usemsisdn and serviceid = v_serviceid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 73; o_debuginfo := 'usercode='||v_useuserindex||', serviceid='||v_serviceid||', user subsription do not exist.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 74; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; elsif i_issecondproduct in (2,3) then --待生效订购关系订购失败后的回滚 以及 纯包量产品再次订购失改后的回滚 begin update zxdbm_200.s200_user_subscription set subscriptionindex = v_productsubindex, subscriptionid = v_productsubid, servicetype = v_servicetype, subcapability = v_subcapability, serviceindex = v_serviceindex, serviceid = v_serviceid, productindex = v_productindex, -- productid = v_productid, productpkgindex = v_propkgindex, productpkgid = v_propkgid, contentindex = v_contentindex, contentid = v_contentid, corpindex = v_corpindex, corpid = v_corpid, cpindex = v_cpindex, cpid = v_cpid, subscribemode = v_subscribemode, subscribechannel = v_subscribechannel, subscribeoptype = v_subscribeoptype, cancelmode = v_cancelmode, cancelchannel = v_cancelchannel, canceloptype = v_canceloptype, pausemode = v_pausemode, resumemode = v_resumemode, status = v_substatus, statustime = v_sysdate14, autocontinue = v_autocontinue, subscriber = v_subscriber, usercode = v_usercode, payuser = v_payuser, pushid = v_pushid, starttime = v_substarttime, endtime = v_subendtime, lastrenttime = v_lastrenttime, nextrentdate = v_nextrentdate, payfordate = v_payfordate, returnvalues = v_returnvalues, returntype = v_returntype, returnstartdate = v_returnstartdate, returnenddate = v_returnenddate, fixusetimes = v_fixusetimes, chargeparty = v_chargeparty, freetime = v_freetime, createtime = v_createtime, canceltime = v_canceltime, firstusetime = v_firstusetime, lastusetime = v_lastusetime, tastestarttime = v_tastestarttime, tasteendtime = v_tasteendtime, pausetime = v_pausetime, resumetime = v_resumetime, subscribeopid = v_subscribeopid, cancelopid = v_cancelopid, cancelreason = v_cancelreason, lastrent = v_lastrent, msisdntype = v_msisdntype, pseudocode = v_pseudocode, pproductofferid = v_pproductofferid, varifee = v_varifee, eventid = v_eventid, isexperience = v_isexperience, subscribetype = v_subscribetype, chargetime = v_chargetime where usercode = v_usemsisdn and productid = i_cancelproductid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 75; o_debuginfo := 'usercode='||v_usemsisdn||', productid='||i_cancelproductid||', user subsription do not exist.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 76; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; if i_issecondproduct in (1,2,3) then --将订购时扣除的费用累积减去 v_sql := 'update zxdbm_ismp.ssrv_user_totalamount' || v_curstrmonth || ' set usedamounts = usedamounts - :p1 where userindex = :p2' || ' and amounttype = 8 and amountindex = 0 and productindex = 0'; begin execute immediate v_sql using v_rollbacklastrent,v_payuserindex; if sql%rowcount = 0 then o_retcode := 506; o_debugpos := 77; o_debuginfo := 'payuserindex='||v_payuserindex||', user is not exist.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 78; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; if i_issecondproduct = 3 then if v_sysdate14 > v_freetime or v_sysdate8 < v_popustart or v_sysdate8 > v_popustop then --将订购时纯包量产生的累积减去(收费期外) 推广期只有单位费率与包月,所以如果有推广期则必定是收费的 begin update zxdbm_ismp.ssrv_user_totalamount set fixtotalres = greatest(fixtotalres - v_fixusetimes*v_unitvol,0), expiredate = to_number(to_char(to_date(v_subendtime,'yyyymmddhh24miss'),'yyyymmdd')) where userindex = v_payuserindex and amounttype = 0 and amountindex = v_productindex and productindex = 0; if (sql%rowcount = 0) then o_retcode := 0; o_debugpos := 79; o_debuginfo := 'produt amount info do not exist.'; end if; exception when others then o_retcode := 506; o_debugpos := 80; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; end if; --删除历史表中转移到正式订购关系表后的订购关系 v_sql := 'delete from zxdbm_200.s200_user_subs_hist' || v_curstrmonth || ' where to_number(statustime) in (select max(to_number(statustime)) from zxdbm_200.s200_user_subs_hist'|| v_curstrmonth || ' where usercode = :p1 and productid = :p2)'; begin execute immediate v_sql using v_usercode,i_cancelproductid; exception when no_data_found then o_retcode := 2100; o_debugpos := 81; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 82; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; --added by youqunxia20131118 order3.02.01 对于预付费用户,体验转正式到OCS扣费失败的解决,把isexperience更新为1 elsif (i_rollback = 1) and (i_issecondproduct = 7) then v_rollbacklastrent := v_lastrent; begin update zxdbm_200.s200_user_subscription set isexperience = 1 where usercode = v_usemsisdn and productid = v_productid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 89; o_debuginfo := 'usercode='||v_usemsisdn||', productid='||v_productid||', user subsription do not exist.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 90; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; --将订购时扣除的费用累积减去 v_sql := 'update zxdbm_ismp.ssrv_user_totalamount' || v_curstrmonth || ' set usedamounts = usedamounts - :p1 where userindex = :p2' || ' and amounttype = 8 and amountindex = 0 and productindex = 0'; begin execute immediate v_sql using v_rollbacklastrent,v_payuserindex; if sql%rowcount = 0 then o_retcode := 506; o_debugpos := 91; o_debuginfo := 'payuserindex='||v_payuserindex||', user is not exist.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 92; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; else --失常退订或失常订购关系的回滚 --产品退订或者产品订购回滚或者业务退订,均须要删除订购关系和累计 if v_isservicesub = 1 then begin delete from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and serviceid = v_serviceid; exception when others then o_retcode := 506; o_debugpos := 83; o_debuginfo := 'v_usemsisdn='||v_usemsisdn||', v_serviceid='||v_serviceid||', failed to delete user_subscription.'; rollback; return; end; else begin delete from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid; exception when others then o_retcode := 506; o_debugpos := 84; o_debuginfo := 'v_usemsisdn='||v_usemsisdn||', v_productid='||v_productid||', failed to delete user_subscription.'; rollback; return; end; end if; --革除累计 begin delete from zxdbm_ismp.ssrv_user_totalamount where userindex = v_payuserindex and amounttype = 0 and amountindex = v_productindex and productindex = 0; exception when others then o_retcode := 506; o_debugpos := 85; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; v_sql := 'delete from zxdbm_ismp.ssrv_user_totalamount'|| v_curstrmonth || ' where userindex = :p1 and amounttype = 0 and amountindex = :p2 and productindex = 0 '; begin execute immediate v_sql using v_payuserindex,v_productindex; if (sql%rowcount = 0) then o_retcode := 0; o_debugpos := 86; o_debuginfo := 'no data in zxdbm_ismp.ssrv_user_totalamount'|| v_curstrmonth ||'.'; end if; exception when others then o_retcode := 506; o_debugpos := 87; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end; end if; commit; --事务完结 end; o_neednotifysp := 1;end if;--订购回滚 或者 退订删除收费期定时工作。begin delete from zxdbm_ismp.freenotice_task where usercode = v_usemsisdn and productid = v_productid;exception when others then o_retcode := 506; o_debugpos := 88; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return;end;commit;--组装同步给SP的音讯if (v_protocoltype <> 0) then if (i_supportproductid = 1) then --应用产品代码同步 if (v_protocoltype = 2) then o_msgtosp := 'QX' || ' ' || v_productid || ' ' ||v_usemsisdn; elsif (o_protocoltype = 1) then --0:正向退订 1:SP反向退订 if (i_direct = 1) then o_msgtosp := '2002' || ' ' || '0' || ' ' || v_productid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; else o_msgtosp := '1002' || ' ' || v_productid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; end if; end if; else --应用业务代码同步 if (v_protocoltype = 2) then o_msgtosp := 'QX' || ' ' || v_serviceid || ' ' || v_usemsisdn; elsif (o_protocoltype = 1) then --0:正向退订 1:SP反向退订 if (i_direct = 1) then o_msgtosp := '2002' || ' ' || '0' || ' ' || v_serviceid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; else o_msgtosp := '1002' || ' ' || v_serviceid || ' ' || v_usemsisdn || ' ' || v_paymsisdn; end if; end if; end if;end if;
end slp_200_telicomcancelreq;
/
--产品收费期揭示
prompt zxdbm_200.slp_200_telicomfreenotify
create or replace procedure zxdbm_200.slp_200_telicomfreenotify
(
i_oa in varchar2, --发起方用户号码i_oatype in number, --发起方地址类型i_servicetype in number, --业务能力类型i_productid in varchar2, --产品代码i_actiontype in number, --动作类型i_countrycode in varchar2, --国家码i_spaccesscode in varchar2, --antuprice音讯中的SP接入码i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_status in number, --取缓存订购关系状态;i_endtime in varchar2, --取缓存产品订购关系完结工夫i_freenotice in number, --收费期到期主动续订和主动勾销是否下发短信:0否 1是;i_cmdchannel in number, --外部渠道o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_usemsisdn out varchar2, --去掉前缀的应用方用户号码o_paymsisdn out varchar2, --去掉前缀的计费方号码o_usemsisdntype out number, --应用方号码类型,1:msisdn,2:phs,3:pstno_userindex out number, --应用方号码序号o_freenotify out number, --收费试用期到短信告诉形式,0-到期主动免费揭示,1-到期需用户确认订购揭示,2-到期主动勾销揭示,3-到期确认订购胜利 4-收费期到期主动续订和主动勾销不下发短信,5-到期需用户确认退订揭示,6-到期确认退订超时,超时订购胜利揭示o_paytype out number, --计费号码的付费类型 0:后付费 1:预付费 2:准预付费o_oppaytype out number, --话单专用付费类型o_colortype out number, --应用方号码名单类型 0-普通用户,1-黑名单,2-白名单,3-灰名单,4-红名单o_cpid out varchar2, --CP/SP代码o_cpindex out number, --CP/SP序号o_cpcnshortname out varchar2, --CP/SP名称o_cptype out number, --CP/SP类型o_customersrvtel out varchar2, --CP/SP客服电话o_serviceid out varchar2, --业务代码--o_serviceindex out number, --业务序号o_servicename out varchar2, --业务名称o_productid out varchar2, --产品代码--o_productindex out number, --产品序号o_productname out varchar2, --产品名称o_smschargingcn out varchar2, --产品资费短信形容o_servicetype out number, --产品业务能力类型o_subcapability out number, --产品业务能力子类型o_srvtypeid out varchar2, --业务能力编码o_freetime out varchar2, --产品订购关系收费期o_linknum out varchar2, --业务话单中同一个流程中二次确认前后话单的关联o_productsubid out varchar2, --产品订购关系代码o_productsubindex out varchar2, --产品订购关系序号o_spaccesscode out varchar2, --SP接入码o_maincapability out number, --组合业务主业务能力类型o_submaincapability out number, --组合业务主业务能力子类型o_cpsrvtype out number, --CP服务类型:0:CP+SP,1:CP,2:SP ;3:自营业务SPo_buffertime out number, --收费期揭示缓存工夫o_status out number, --订购关系状态;o_endtime out varchar2, --产品订购关系完结工夫o_cityid out varchar2, --产品订购关系完结工夫--added by youqunxia20130526 order2.07.10o_cancelaccesscode out varchar2, --产品退订接入码o_cancelfeaturecode out varchar2 --短信,彩信退订指令
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_tmpint number(10) := 0; --长期寄存长期数值v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_maincapability number(10) := 0; --长期寄存组合业务主业务能力类型v_submaincapability number(10) := 0; --长期寄存组合业务主业务能力子类型v_countrycode varchar2(5) := i_countrycode; --长期寄存国家码v_oa zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存发起方用户号码v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存应用方用户号码v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_useusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存应用方用户类型v_usepaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存应用方用户付费类型v_useblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存应用方是否进入黑名单v_usewhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存应用方是否进入白名单v_useredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存应用方是否进入红名单v_useblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存应用方黑名单级别v_usewhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存应用方白名单级别v_usemsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存应用方号码类型v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存应用方话单专用付费类型v_usecorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存应用方团体序号v_useusercityid zxdbm_ismp.susr_basic.cityid%type := 0; --长期寄存用户所属的城市IDv_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫v_productid zxdbm_200.s200_product.productid%type := i_productid; --长期寄存产品代码v_productindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存产品序号v_productname zxdbm_200.s200_product.productname%type := ' '; --长期寄存产品名称v_smschargingcn zxdbm_200.s200_product.smschargingcn%type := ' '; --长期寄存产品资费短信形容v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --长期寄存产品业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 1; --长期寄存产品业务能力子类型v_freenotify zxdbm_200.s200_product.freenotify%type := 0; --收费期到是否发送告诉,0-不发送,1-发送v_productendtime zxdbm_200.s200_product.endtime%type := '99991231235959'; --长期寄存产品终止工夫v_serviceid zxdbm_200.s200_service.serviceid%type := ' '; --长期寄存业务代码v_serviceindex zxdbm_200.s200_service.serviceindex%type := 0; --长期寄存业务序号v_servicename zxdbm_200.s200_service.servicename%type := ' '; --长期寄存业务名称v_cpid zxdbm_ismp.scp_basic.cpid%type := ' '; --长期寄存CP/SP代码v_cptype zxdbm_ismp.scp_basic.cptype%type := 2; --长期寄存CP/SP类型v_cpindex zxdbm_ismp.scp_basic.cpindex%type := 0; --长期寄存CP/SP序号v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --长期寄存CP/SP中文名简写v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' '; --长期寄存CP/SP客服电话v_productsubindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --长期寄存订购关系序号v_productsubid zxdbm_200.s200_user_subscription.subscriptionid%type := ' '; --长期寄存订购关系代码v_status zxdbm_200.s200_user_subscription.status%type := 0; --订购关系状态状态,0-待失效,1-失常,2-暂停,待生效,登记v_subscribechannel zxdbm_200.s200_user_subscription.subscribechannel%type := 1; --长期寄存订购关系订购渠道v_freetime zxdbm_200.s200_user_subscription.freetime%type := '00000000000000'; --长期寄存产品订购收费日期v_endtime zxdbm_200.s200_user_subscription.endtime%type := '99991231235959';v_nextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := '99991231'; --长期寄存下次扣租日期v_subendtime zxdbm_200.s200_user_subscription.endtime%type := '99991231235959'; --长期寄存订购关系生效工夫v_chargetype zxdbm_200.s200_product_fee.chargetype%type := 0;v_cyctype zxdbm_200.s200_product_fee.cyctype%type := 0; --长期寄存周期类型0-非周期,1-周期性v_cycunit zxdbm_200.s200_product_fee.cycunit%type := 0; --长期寄存周期单位 0-无,1-天,2-周,3-月,4-半年,5-年,6-小时,7-分钟,8-秒v_cycparam zxdbm_200.s200_product_fee.cycparam%type := 0; --长期寄存周期参数v_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := ' '; --长期寄存话单中的srvtypeidv_spaccesscode zxdbm_ismp.ssrv_srvorder.spaccesscode%type := ' '; --长期寄存sp接入码--added by youqunxia20130526 order2.07.10v_cancelaccesscode zxdbm_ismp.ssrv_srvorder.accesscode%type := ' '; --长期寄存退订接入码v_cancelfeaturecode zxdbm_ismp.ssrv_srvorder.featurecode%type := ' '; --长期寄存退订特色码
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_usemsisdn := ' ';o_paymsisdn := ' ';o_usemsisdntype := 1;o_userindex := 0;o_freenotify := 1;o_paytype := 0;o_oppaytype := 0;o_colortype := 0;o_cpid := ' ';o_cpindex := 0;o_cpcnshortname := ' ';o_cptype := 0;o_customersrvtel := ' ';o_serviceid := ' ';--o_serviceindex := 0;o_servicename := ' ';o_productid := ' ';--o_productindex := 0;o_productname := ' ';o_smschargingcn := ' ';o_servicetype := 0;o_subcapability := 1;o_srvtypeid := ' ';o_freetime := '00000000000000';o_linknum := ' ';o_productsubid := ' ';o_productsubindex := 0;o_spaccesscode := i_spaccesscode;o_maincapability := 0;o_submaincapability := 0;o_cpsrvtype := 0;o_buffertime := 0;o_endtime := v_endtime;o_cityid := '';--added by youqunxia20130526o_cancelaccesscode := '';o_cancelfeaturecode := '';--发起方用户号码去前缀v_oa := ltrim(rtrim(nvl(i_oa,'0')));if v_oa like ('+' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 2);elsif v_oa like ('00' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 3);elsif v_oa like (v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 1);end if;if (substr(v_oa,1,1) <> '0') and (i_oatype = 4) then v_oa := '0' || v_oa;end if;v_usemsisdn := v_oa;o_usemsisdn := v_usemsisdn;if (v_usemsisdn = '0') then o_retcode := 1001; o_debugpos := 2; o_debuginfo := 'v_usemsisdn error.'; return;end if;--应用方号码存在性鉴权if (i_needauthuser = 1) then begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,cityid into v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist, v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus, v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_useusercityid from zxdbm_ismp.susr_basic where usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; o_debugpos := 3; o_debuginfo := 'user info do not exist.'; if (i_oatype = 4) then v_usemsisdntype := 2; else v_usemsisdntype := 1; end if; return; when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_usemsisdntype := 2; else o_usemsisdntype := 1; end if; return; end; o_usemsisdntype := v_usemsisdntype; o_userindex := v_useuserindex; o_paymsisdn := v_usemsisdn; o_paytype := v_usepaytype; o_oppaytype := v_useoppaytype; o_cityid := trim(v_useusercityid); if (v_useredlist = 1) then o_colortype := 4; else o_colortype := 0; end if;end if;--产品存在性鉴权begin select productindex,productname,smschargingcn,serviceindex,servicetype, subcapability,cpindex,freenotify,endtime into v_productindex,v_productname,v_smschargingcn,v_serviceindex,v_servicetype, v_subcapability,v_cpindex,v_freenotify,v_productendtime from zxdbm_200.s200_product where productid = v_productid;exception when no_data_found then o_retcode := 2100; o_debugpos := 5; o_debuginfo := 'product info do not exist.'; return;when others then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_productid := v_productid;--o_productindex := v_productindex;o_productname := v_productname;o_smschargingcn := v_smschargingcn;--o_serviceindex := v_serviceindex;o_servicetype := v_servicetype;o_subcapability := v_subcapability;o_cpindex := v_cpindex;begin select chargetype,cyctype,cycunit,cycparam into v_chargetype,v_cyctype,v_cycunit,v_cycparam from zxdbm_200.s200_product_fee where productindex = v_productindex and itemindex = 0;exception when no_data_found then o_retcode := 3103; o_debugpos := 7; o_debuginfo := 'product fee do not exist.'; return;when others then o_retcode := 506; o_debugpos := 8; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;--业务存在性鉴权(MPSS不须要鉴权)if i_servicetype = 101 then v_sql := 'select serviceid,servicename,maincapability,submaincapability '|| 'from zxdbm_9900.s9900_service where serviceindex = :p1'; begin execute immediate v_sql into v_serviceid,v_servicename,v_maincapability,v_submaincapability using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 9; o_debuginfo := 'cpx service do not exist.'; return; when others then o_retcode := 506; o_debugpos := 10; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;elsif i_servicetype <> 14 then begin select serviceid,servicename into v_serviceid,v_servicename from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 11; o_debuginfo := 'service do not exist.'; return; when others then o_retcode := 506; o_debugpos := 12; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_serviceid := v_serviceid;o_servicename := v_servicename;o_maincapability := v_maincapability;o_submaincapability := v_submaincapability;--零碎业务能力鉴权if i_servicetype = 101 then begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_maincapability and subcapability = v_submaincapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 13; o_debuginfo := 'cpx info in ssys_service_type do not exist.'; return; when others then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 15; o_debuginfo := 'info in ssys_service_type do not exist.'; return; when others then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_srvtypeid := v_srvtypeid;--CP/SP存在性鉴权begin select cpid,cptype,cpcnshortname,customersrvtel,cpsrvtype into v_cpid,v_cptype,v_cpcnshortname,v_customersrvtel,v_cpsrvtype from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 17; o_debuginfo := 'sp do not exist.'; return;when others then o_retcode := 506; o_debugpos := 18; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_cpid := v_cpid;o_cptype := v_cptype;o_cpsrvtype := v_cpsrvtype;o_cpcnshortname := v_cpcnshortname;o_customersrvtel := v_customersrvtel;--added by youqunxia20130526 order2.07.10--产品退订指令查问begin select featurecode,accesscode into v_cancelfeaturecode,v_cancelaccesscode from zxdbm_ismp.ssrv_srvorder where productid = v_productid and cmdtype = 2 and rownum = 1;exception when no_data_found then null;when others then o_retcode := 506; o_debugpos := 28; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_cancelaccesscode := v_cancelaccesscode;o_cancelfeaturecode := v_cancelfeaturecode;--SP接入码查问if (i_spaccesscode is null) or (length(trim(i_spaccesscode)) = 0) then begin select spaccesscode into v_spaccesscode from zxdbm_ismp.ssrv_srvorder where productindex = v_productindex and cmdtype in (1,2) and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 19; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if trim(v_spaccesscode) is null then begin select accesscode into v_spaccesscode from zxdbm_ismp.ssrv_spaccesscode where cpid = v_cpid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 20; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; o_spaccesscode := v_spaccesscode;end if;--产品订购关系存在性鉴权begin select subscriptionindex,subscriptionid,freetime,subscribechannel,status, endtime into v_productsubindex,v_productsubid,v_freetime,v_subscribechannel,v_status, v_endtime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid;exception when no_data_found then o_retcode := 1201; o_debugpos := 21; o_debuginfo := 'subscription do not exist.'; return;when others then o_retcode := 506; o_debugpos := 22; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_freetime := v_freetime;o_productsubindex := v_productsubindex;o_productsubid := v_productsubid;o_status := v_status;o_endtime := v_endtime;--设置o_freenotify--added by youqunxia20130526 order2.07.10if i_actiontype =10 then --到期确认订购胜利揭示 o_freenotify := 3;elsif i_cmdchannel = 1001 then --到期确认退订超时揭示,订购胜利 o_freenotify := 6;else o_freenotify := v_freenotify; if v_freenotify = 3 then --到期确认退订揭示 o_freenotify := 5; end if; if (i_freenotice = 0) and v_freenotify in (0,2) then --收费期到期主动续订和主动勾销时不下发短信 o_freenotify := 4; end if;end if;--收费期确认订购胜利,或者确认退订超时订购胜利,批改订购关系if i_actiontype = 10 or i_cmdchannel = 1001 then --批改下次扣租工夫和订购关系生效工夫 v_nextrentdate := to_char(to_date(v_freetime,'yyyymmddhh24miss') + 1,'yyyymmdd'); if v_chargetype in (1,4) then v_subendtime := v_productendtime; elsif v_chargetype in (2,5,7) then if v_cyctype = 1 then v_subendtime := v_productendtime; else v_subendtime := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')),'yyyymmdd') || '235959'; end if; elsif v_chargetype in (3,6,8,9) then if (v_cycunit = 1) then --包天 if v_cyctype = 1 then v_subendtime := v_productendtime; else v_subendtime := to_char(to_date(v_sysdate14,'yyyymmddhh24miss') + v_cycparam,'yyyymmdd')||'235959'; end if; elsif (v_cycunit = 2) then --包周 if v_cyctype = 1 then v_subendtime := v_productendtime; else v_subendtime := to_char(to_date(v_sysdate14,'yyyymmddhh24miss') + v_cycparam*7,'yyyymmdd')||'235959'; end if; elsif (v_cycunit = 3) then --包月 if v_cyctype = 1 then v_subendtime := v_productendtime; else v_subendtime := to_char(add_months(to_date(v_sysdate14,'yyyymmddhh24miss'),v_cycparam),'yyyymmdd')||'235959'; end if; elsif (v_cycunit = 4) then --包半年 if v_cyctype = 1 then v_subendtime := v_productendtime; else v_subendtime := to_char(add_months(to_date(v_sysdate14,'yyyymmddhh24miss'),v_cycparam*6),'yyyymmdd')||'235959'; end if; elsif (v_cycunit = 5) then --包年 if v_cyctype = 1 then v_subendtime := v_productendtime; else v_subendtime := to_char(add_months(to_date(v_sysdate14,'yyyymmddhh24miss'),v_cycparam*12),'yyyymmdd')||'235959'; end if; end if; else --订购终止工夫,临时定为产品终止工夫 v_subendtime := v_productendtime; end if; if i_cmdchannel = 46 then --查问订购渠道 begin select portalchannel into v_subscribechannel from zxdbm_ismp.ssrv_channel_map where innerchannel = i_cmdchannel; exception when no_data_found then v_subscribechannel := i_cmdchannel * 1000; when others then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; begin update zxdbm_200.s200_user_subscription set endtime = v_subendtime, nextrentdate = v_nextrentdate, subscribechannel = v_subscribechannel where usercode = v_usemsisdn and productid = v_productid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 23; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 24; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_chargetype = 4 then --对于纯包量有收费期的状况,须要更新累积表的过期工夫到新的订购关系完结工夫 begin update zxdbm_ismp.ssrv_user_totalamount set expiredate = to_number(substr(v_subendtime,1,8)) where userindex = v_useuserindex and amounttype = 0 and amountindex = v_productindex and rownum = 1; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 25; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end if; exception when others then o_retcode := 506; o_debugpos := 26; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; commit;end if;--added by youqunxia20130526 order2.07.10--收费期到期需用户确认订购/退订 缓存工夫设置if o_freenotify in (1,5) then --cache工夫计算 o_buffertime := 3600*24*ABS(to_date('235959', 'HH24MISS') - to_date(substr(v_sysdate14,9,6), 'HH24MISS')); --生成o_linknum begin v_tmpint := dbms_random.value(1,9999999999); o_linknum := v_sysdate14 || '655380' || lpad(to_char(v_tmpint),10,'0'); exception when others then o_retcode := 506; o_debugpos := 27; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;
end slp_200_telicomfreenotify;
/
--暂停/激活产品订购关系鉴权
prompt zxdbm_200.slp_200_telicomsubchangereq
create or replace procedure zxdbm_200.slp_200_telicomsubchangereq
(
i_oa in varchar2, --发起方用户号码i_oatype in number, --发起方地址类型i_servicetype in number, --业务能力类型i_productid in varchar2, --产品代码i_actiontype in number, --动作类型i_cmdchannel in number, --动作起源i_countrycode in varchar2, --国家码i_spaccesscode in varchar2, --antuprice音讯中的SP接入码i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_checkpseudocode in number, --零碎开关:是否反对伪码 0-不反对 1-反对o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_usemsisdn out varchar2, --去掉前缀的应用方用户号码o_paymsisdn out varchar2, --去掉前缀的计费方号码o_usemsisdntype out number, --应用方号码类型,1:msisdn,2:phs,3:pstno_userindex out number, --应用方号码序号o_paytype out number, --计费号码的付费类型 0:后付费 1:预付费 2:准预付费o_oppaytype out number, --话单专用付费类型o_colortype out number, --应用方号码名单类型 0-普通用户,1-黑名单,2-白名单,3-灰名单,4-红名单o_cpid out varchar2, --CP/SP代码o_cpindex out number, --CP/SP序号o_cpcnshortname out varchar2, --CP/SP名称o_cpsubscribeurl out varchar2, --CP/SP订购URLo_cptype out number, --CP/SP类型o_customersrvtel out varchar2, --CP/SP客服电话o_serviceid out varchar2, --业务代码o_serviceindex out number, --业务序号o_servicename out varchar2, --业务名称o_productid out varchar2, --产品代码o_productindex out number, --产品序号o_productname out varchar2, --产品名称o_smschargingcn out varchar2, --产品资费短信形容o_servicetype out number, --产品业务能力类型o_subcapability out number, --产品业务能力子类型o_srvtypeid out varchar2, --业务能力编码o_productsubid out varchar2, --产品订购关系代码o_productsubindex out varchar2, --产品订购关系序号o_productsubstatus out number, --产品订购关系状态o_neednotifysp out number, --是否有必要告诉SPo_pseudocode out varchar2, --伪码o_pcodemsisdnswitch out number, --伪码和实在号码之间是否有转换: 0否 1实在号码转化伪码 2伪码转化为实在号码o_spaccesscode out varchar2, --SP接入码o_maincapability out number, --组合业务主业务能力类型o_submaincapability out number, --组合业务主业务能力子类型o_cpsrvtype out number, --CP服务类型:0:CP+SP,1:CP,2:SP ;3:自营业务SPo_cityid out varchar2, --用户所属城市ID--added by youqunxia20130906 order3.02.01o_issynctooidd out number --是否同步订购关系给OIDD,0-否,1-是
)
as
v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_countrycode varchar2(5) := i_countrycode; --长期寄存国家码v_maincapability number(10) := 0; --长期寄存组合业务主业务能力类型v_submaincapability number(10) := 0; --长期寄存组合业务主业务能力子类型v_oa zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存发起方用户号码v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存应用方用户号码v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_useusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存应用方用户类型v_usepaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存应用方用户付费类型v_useblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存应用方是否进入黑名单v_usewhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存应用方是否进入白名单v_useredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存应用方是否进入红名单v_useblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存应用方黑名单级别v_usewhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存应用方白名单级别v_usemsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存应用方号码类型v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存应用方话单专用付费类型v_usecorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存应用方团体序号v_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫v_useusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存应用方所属城市IDv_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := ' '; --长期寄存话单中的srvtypeidv_cpid zxdbm_ismp.scp_basic.cpid%type := ' '; --长期寄存CP/SP代码v_cptype zxdbm_ismp.scp_basic.cptype%type := 2; --长期寄存CP/SP类型v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_cpindex zxdbm_ismp.scp_basic.cpindex%type := 0; --长期寄存CP/SP序号v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --长期寄存CP/SP中文名简写v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' '; --长期寄存CP/SP客服电话v_cpsubscribeurl zxdbm_ismp.scp_basic.cpsubscribeurl%type := ' '; --长期寄存CP/SP订购URLv_productid zxdbm_200.s200_product.productid%type := i_productid; --长期寄存产品代码v_productindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存产品序号v_productname zxdbm_200.s200_product.productname%type := ' '; --长期寄存产品名称v_smschargingcn zxdbm_200.s200_product.smschargingcn%type := ' '; --长期寄存产品资费短信形容v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --长期寄存产品业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 1; --长期寄存产品业务能力子类型v_serviceid zxdbm_200.s200_service.serviceid%type := ' '; --长期寄存业务代码v_serviceindex zxdbm_200.s200_service.serviceindex%type := 0; --长期寄存业务序号v_servicename zxdbm_200.s200_service.servicename%type := ' '; --长期寄存业务名称v_orderupdateurl zxdbm_200.s200_service.orderupdateurl%type := ' '; --长期寄存业务表中订购关系更新告诉URLv_productsubindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --长期寄存订购关系序号v_productsubid zxdbm_200.s200_user_subscription.subscriptionid%type := ' '; --长期寄存订购关系代码v_productsubstatus zxdbm_200.s200_user_subscription.status%type := 0; --长期寄存订购关系状态v_spaccesscode zxdbm_ismp.ssrv_srvorder.spaccesscode%type := ' '; --长期寄存sp接入码--added by youqunxia20130906 order3.02.01v_servicesort zxdbm_200.s200_service.servicesort%type := 0; --业务归属 0:一般业务、1:属于OIDD 2:属于定位
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_usemsisdn := ' ';o_paymsisdn := ' ';o_usemsisdntype := 1;o_userindex := 0;o_paytype := 0;o_oppaytype := 0;o_colortype := 0;o_cpid := ' ';o_cpindex := 0;o_cpcnshortname := ' ';o_cpsubscribeurl := ' ';o_cptype := 0;o_customersrvtel := ' ';o_serviceid := ' ';o_serviceindex := 0;o_servicename := ' ';o_productid := ' ';o_productindex := 0;o_productname := ' ';o_smschargingcn := ' ';o_servicetype := 0;o_subcapability := 1;o_srvtypeid := ' ';o_productsubid := ' ';o_productsubindex := 0;o_productsubstatus := 0;o_neednotifysp := 0;o_pseudocode :='';o_pcodemsisdnswitch :=0;o_spaccesscode := i_spaccesscode;o_maincapability := 0;o_submaincapability := 0;o_cpsrvtype := 0;o_cityid := '';o_issynctooidd := 0;--发起方地址类型鉴权if i_oatype not in (1,2,3,4) then o_retcode := 107; o_debugpos := 1; o_debuginfo := 'i_oatype is not valid.'; return;end if;--发起方用户号码去前缀v_oa := ltrim(rtrim(nvl(i_oa,'0')));if v_oa like ('+' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 2);elsif v_oa like ('00' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 3);elsif v_oa like (v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 1);end if;if (substr(v_oa,1,1) <> '0') and (i_oatype = 4) then v_oa := '0' || v_oa;end if;v_usemsisdn := v_oa;o_usemsisdn := v_usemsisdn;if (v_usemsisdn = '0') then o_retcode := 1001; o_debugpos := 2; o_debuginfo := 'v_usemsisdn error.'; return;end if;--应用方号码存在性鉴权if (i_needauthuser = 1) then begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,cityid into v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist, v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus, v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_useusercityid from zxdbm_ismp.susr_basic where usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; o_debugpos := 3; o_debuginfo := 'user info do not exist.'; if (i_oatype = 4) then v_usemsisdntype := 2; else v_usemsisdntype := 1; end if; return; when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_usemsisdntype := 2; else o_usemsisdntype := 1; end if; return; end; o_usemsisdntype := v_usemsisdntype; o_userindex := v_useuserindex; o_paymsisdn := v_usemsisdn; o_paytype := v_usepaytype; o_oppaytype := v_useoppaytype; o_cityid := trim(v_useusercityid); if (v_useredlist = 1) then o_colortype := 4; else o_colortype := 0; end if;end if;--产品存在性鉴权begin select productindex,productname,smschargingcn,serviceindex,servicetype, subcapability,cpindex into v_productindex,v_productname,v_smschargingcn,v_serviceindex,v_servicetype, v_subcapability,v_cpindex from zxdbm_200.s200_product where productid = v_productid;exception when no_data_found then o_retcode := 2100; o_debugpos := 5; o_debuginfo := 'product info do not exist.'; return;when others then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_productid := v_productid;o_productindex := v_productindex;o_productname := v_productname;o_smschargingcn := v_smschargingcn;o_serviceindex := v_serviceindex;o_servicetype := v_servicetype;o_subcapability := v_subcapability;o_cpindex := v_cpindex;--业务存在性鉴权(MPSS不须要鉴权)if i_servicetype = 101 then v_sql := 'select serviceid,servicename,maincapability,submaincapability,orderupdateurl '|| 'from zxdbm_9900.s9900_service where serviceindex = :p1'; begin execute immediate v_sql into v_serviceid,v_servicename,v_maincapability,v_submaincapability,v_orderupdateurl using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 7; o_debuginfo := 'cpx service info do not exist.'; return; when others then o_retcode := 506; o_debugpos := 8; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;--added by youqunxia20130906 order3.02.01elsif i_servicetype in(1,2,3) then begin select serviceid,servicename,orderupdateurl,servicesort into v_serviceid,v_servicename,v_orderupdateurl,v_servicesort from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 26; o_debuginfo := 'service info do not exist.'; return; when others then o_retcode := 506; o_debugpos := 27; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;elsif i_servicetype <> 14 then begin select serviceid,servicename,orderupdateurl into v_serviceid,v_servicename,v_orderupdateurl from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 9; o_debuginfo := 'service info do not exist.'; return; when others then o_retcode := 506; o_debugpos := 10; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_serviceid := v_serviceid;o_servicename := v_servicename;o_maincapability := v_maincapability;o_submaincapability := v_submaincapability;--added by youqunxia20130906 order3.02.01--是否同步订购关系给OIDD,0-否,1-是if v_servicesort = 1 then o_issynctooidd := 1;end if;--零碎业务能力鉴权if i_servicetype = 101 then begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_maincapability and subcapability = v_submaincapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 11; o_debuginfo := 'cpx ssys_service_type do not exist.'; return; when others then o_retcode := 506; o_debugpos := 12; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 13; o_debuginfo := 'ssys_service_type do not exist.'; return; when others then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_srvtypeid := v_srvtypeid;--CP/SP存在性鉴权begin select cpid,cpsrvtype,cptype,cpcnshortname,customersrvtel,cpsubscribeurl into v_cpid,v_cpsrvtype,v_cptype,v_cpcnshortname,v_customersrvtel,v_cpsubscribeurl from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 15; o_debuginfo := 'sp info do not exist.'; return;when others then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_cpid := v_cpid;o_cptype := v_cptype;o_cpsrvtype := v_cpsrvtype;o_cpcnshortname := v_cpcnshortname;o_customersrvtel := v_customersrvtel;if (trim(v_orderupdateurl) is null) or (length(trim(v_orderupdateurl)) < 8) then o_cpsubscribeurl := v_cpsubscribeurl;else o_cpsubscribeurl := v_orderupdateurl;end if;--SP接入码查问if (i_spaccesscode is null) or (length(trim(i_spaccesscode)) = 0) then begin select spaccesscode into v_spaccesscode from zxdbm_ismp.ssrv_srvorder where productindex = v_productindex and cmdtype in (1,2) and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 17; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if trim(v_spaccesscode) is null then begin select accesscode into v_spaccesscode from zxdbm_ismp.ssrv_spaccesscode where cpid = v_cpid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 18; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; o_spaccesscode := v_spaccesscode;end if;
--
--伪码解决(反对伪码开关关上,非自营sp)--反对业务LCS,SMS,MVS,DLS,MMS,WAP,CPX
--退订时,AuthPriceReq音讯中OA(DA)实在号码转化为伪码,同步SP
--这里订购业务的回滚订购关系不做解决
if i_servicetype in (1,2,3,4,41,5,6,101) then if i_checkpseudocode = 1 and v_cpsrvtype <> 3 then begin select pseudocode into o_pseudocode from zxdbm_ismp.susr_basic where usercode = v_oa; exception when no_data_found then o_retcode := 1001; o_debugpos := 19; o_debuginfo := 'userinfo do not exist.'; return; when others then o_retcode := 506; o_debugpos := 20; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_pcodemsisdnswitch := 1; end if;end if;
-- */
--产品订购关系存在性鉴权begin select subscriptionindex,subscriptionid,status into v_productsubindex,v_productsubid,v_productsubstatus from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid;exception when no_data_found then o_retcode := 1201; o_debugpos := 21; o_debuginfo := 'subscription info do not exist.'; return;when others then o_retcode := 506; o_debugpos := 22; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_productsubindex := v_productsubindex;o_productsubid := v_productsubid;o_productsubstatus := v_productsubstatus;if (i_actiontype = 3) then if v_productsubstatus not in (0,1,4) then o_retcode := 505; o_debugpos := 23; o_debuginfo := 'product status is 0,1,4.'; o_neednotifysp := 0; return; elsif v_productsubstatus = 1 then o_neednotifysp := 1; else o_neednotifysp := 0; end if;elsif (i_actiontype = 4) then if v_productsubstatus not in (2,3,5) then o_retcode := 505; o_debugpos := 24; o_debuginfo := 'product status is 2,3,5.'; o_neednotifysp := 0; return; elsif v_productsubstatus = 3 then o_neednotifysp := 1; else o_neednotifysp := 0; end if;else o_retcode := 505; o_debugpos := 25; o_debuginfo := 'cmd error.'; o_neednotifysp := 0; return;end if;
end slp_200_telicomsubchangereq;
/
--暂停/激活产品订购关系更新
prompt zxdbm_200.slp_200_telicomsubchangeresp
create or replace procedure zxdbm_200.slp_200_telicomsubchangeresp
(
i_usemsisdn in varchar2, --应用方用户号码i_productid in varchar2, --产品代码i_actiontype in number, --动作类型i_cmdchannel in number, --动作起源i_productsubstatus in number, --产品订购关系状态o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2 --调试信息
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := i_usemsisdn; --长期寄存应用方用户号码v_productid zxdbm_200.s200_user_subscription.productid%type := i_productid; --长期寄存产品代码v_productsubstatus zxdbm_200.s200_user_subscription.status%type := i_productsubstatus; --长期寄存订购关系状态v_cancelchannel zxdbm_200.s200_user_subscription.cancelchannel%type := 0; --长期寄存暂停复原渠道
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';--设置退订渠道begin select portalchannel into v_cancelchannel from zxdbm_ismp.ssrv_channel_map where innerchannel = i_cmdchannel;exception when no_data_found then v_cancelchannel := i_cmdchannel * 1000;when others then o_retcode := 506; o_debugpos := 1; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;--设置更新后产品订购关系的状态if (i_actiontype = 3) then if (v_productsubstatus = 0) then v_productsubstatus := 2; elsif (v_productsubstatus = 1) then v_productsubstatus := 3; elsif (v_productsubstatus = 4) then v_productsubstatus := 5; else o_retcode := 505; o_debugpos := 2; o_debuginfo := 'product status error.'; return; end if; begin update zxdbm_200.s200_user_subscription set status = v_productsubstatus, statustime = v_sysdate14, subscribeoptype = 1, pausetime = v_sysdate14, cancelchannel = v_cancelchannel where usercode = v_usemsisdn and productid = v_productid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 3; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; end if; exception when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end;elsif (i_actiontype = 4) then if (v_productsubstatus = 2) then v_productsubstatus := 0; elsif (v_productsubstatus = 3) then v_productsubstatus := 1; elsif (v_productsubstatus = 5) then v_productsubstatus := 4; else o_retcode := 505; o_debugpos := 5; o_debuginfo := 'product status error.'; return; end if; begin update zxdbm_200.s200_user_subscription set status = v_productsubstatus, statustime = v_sysdate14, subscribeoptype = 2, resumetime = v_sysdate14, cancelchannel = v_cancelchannel where usercode = v_usemsisdn and productid = v_productid; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; end if; exception when others then o_retcode := 506; o_debugpos := 7; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; rollback; return; end;else o_retcode := 505; o_debugpos := 8; o_debuginfo := 'cmd error.'; return;end if;commit;
end slp_200_telicomsubchangeresp;
/
--批改从号码, msp专用流程
--本存储过程将无需确认的批改从号码和需二次确认的告诉流程和确认批改从号码流程合一
prompt zxdbm_200.slp_200_telicommodifysubreq
create or replace procedure zxdbm_200.slp_200_telicommodifysubreq
(
i_msisdn in varchar2, --订购用户i_productid in varchar2, --产品idi_countrycode in varchar2, --国家代码i_prepaidtype in number, --预付费接口类型 1-OCS 2-非OCS 3-依据号段抉择是OCS或者非OCSo_retcode out number, --返回后果 0:胜利;9999:透传到下以节点;other:失败o_debugpos out number, --用来定位谬误具体位置o_debuginfo out varchar2, --调试信息o_accesscode out varchar2, --音讯的源号码;o_cpsubscribeurl out varchar2, --SP订购urlo_paytype out number, --用户付费类型,0,后付费;1,预付费。o_oppaytype out number, --用户付费类型(话单)o_servicename out varchar2, --业务名称o_cpid out varchar2, --cp代码o_cpname out varchar2, --cp名称o_serviceid out varchar2, --业务IDo_subscriptionindex out number, -- 订购关系IDo_scptype out number, --对预付费扣费的设施类型:1:OCS;2:RTBPo_productname out varchar2, --产品名称o_customersrvtel out varchar2, --客服电话o_msisdntype out number, --用户号码类型o_smschargingcn out varchar2, --产品资费短信形容o_servicetype out number, --业务能力类型o_subcapability out number, --业务能力子类型1-3G,2-PHS,3-ISAGo_subscriptionid out varchar2, --订购关系ido_cptype out number, --cp/sp类型 0:是本省 1:是全国业务o_srvtypeid out varchar2, --业务能力编码,ssys_service_type表中的srvtypeido_cdrtsuserindex out number, --流程话单中的用户编号o_cdrtsusercode out varchar2, --流程话单中的用户号码o_cpindex out number, --cpindex索引o_corpindex out number, --corpindex索引o_corpid out varchar2, --corpido_cpsrvtype out number --CP服务类型:0:CP+SP,1:CP,2:SP ;3:自营业务SP
)
is
v_dev_exist number(3,0) := 1; --是否在平台ssys_phone表中存在号段信息,0:不存在,1:存在v_msisdn zxdbm_ismp.susr_basic.usercode%type := ' ';v_userindex zxdbm_ismp.susr_basic.userindex%type := 0; --用户号码序号v_oppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0;v_paytype zxdbm_ismp.susr_basic.oppaytype%type := 0;v_msisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --用户号码类型v_productid zxdbm_200.s200_product.productid%type := i_productid;v_productindex zxdbm_200.s200_product.productindex%type := 0;v_serviceindex zxdbm_200.s200_product.serviceindex%type := 0; --业务编码v_cpindex zxdbm_200.s200_product.cpindex%type := 0; --cp/sp编码v_productname zxdbm_200.s200_product.productname%type := ' ';v_smschargingcn zxdbm_200.s200_product.smschargingcn%type := ' ';v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 0;v_servicename zxdbm_200.s200_service.servicename%type := ' '; --业务名称v_serviceid zxdbm_200.s200_service.serviceid%type := ' '; --业务代码v_orderupdateurl zxdbm_200.s200_service.orderupdateurl%type := ' ';v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --cp/sp中文名简写v_cpid zxdbm_ismp.scp_basic.cpid%type := ' ';v_cpsubscribeurl zxdbm_ismp.scp_basic.cpsubscribeurl%type := ' ';v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' ';v_cptype zxdbm_ismp.scp_basic.cptype%type := 0; --cp/sp类型 1:全网sp 2: 省(本地) 3: 市v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_subscriptionindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --订购关系顺序号v_subscriptionid zxdbm_200.s200_user_subscription.subscriptionid%type := ' ';v_corpindex zxdbm_200.s200_user_subscription.corpindex%type := 0; --所属团体标识,0-示意不属于任何团体v_corpid zxdbm_200.s200_user_subscription.corpid%type := ' ';v_payuser zxdbm_200.s200_user_subscription.payuser%type := ' ';v_phoneindex zxdbm_ismp.ssys_phone.phoneindex%type := 0;v_attach zxdbm_ismp.ssys_phone.attach%type := 0; --预付费归属,0-未知,1-OCS,2-RTBPv_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := '';v_accesscode zxdbm_ismp.ssrv_spaccesscode.accesscode%type := ' ';
begin
o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_accesscode := ' ';o_cpsubscribeurl := ' ';o_paytype := 0;o_oppaytype := 0;o_servicename := ' ';o_cpid := ' ';o_cpname := ' ';o_serviceid := ' ';o_subscriptionindex := 0;o_scptype := i_prepaidtype;o_productname := ' ';o_customersrvtel := ' ';o_msisdntype := 1;o_smschargingcn := ' ';o_servicetype := 1;o_subcapability := 1;o_subscriptionid := ' ';o_cptype := 0;o_srvtypeid := ' ';o_cdrtsuserindex := 0;o_cdrtsusercode := ' ';o_cpindex := 0;o_corpindex := 0;o_corpid := ' ';o_cpsrvtype := 0;/**************************************************** 用户鉴权*****************************************************/v_msisdn := ltrim(rtrim(nvl(i_msisdn,'0')));if (substr(v_msisdn,1,lengthb(i_countrycode)) = i_countrycode) then v_msisdn := substr(v_msisdn, lengthb(i_countrycode)+1);elsif substr(v_msisdn,1,lengthb(i_countrycode)+1) = concat('+',i_countrycode) then v_msisdn := substr(v_msisdn, lengthb(i_countrycode)+2);end if;o_cdrtsusercode := v_msisdn;--用户鉴权if (v_msisdn <> '0') then begin select userindex,oppaytype,paytype,msisdntype into v_userindex,v_oppaytype,v_paytype,v_msisdntype from zxdbm_ismp.susr_basic where usercode = v_msisdn; exception when no_data_found then o_retcode := 0; --1001; o_debugpos := 1; o_debuginfo := 'user do not exist.'; when others then o_retcode := 506; o_debugpos := 2; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_cdrtsuserindex := v_userindex;o_oppaytype := v_oppaytype;o_paytype := v_paytype;o_msisdntype := v_msisdntype;--取产品信息begin select productindex,serviceindex,cpindex, productname,smschargingcn,servicetype,subcapability into v_productindex,v_serviceindex,v_cpindex, v_productname,v_smschargingcn,v_servicetype,v_subcapability from zxdbm_200.s200_product where productid = v_productid;exception when no_data_found then o_retcode := 2100; o_debugpos := 3; o_debuginfo := 'product do not exist.'; return;when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_cpindex := v_cpindex;o_productname := v_productname;o_smschargingcn := v_smschargingcn;o_servicetype := v_servicetype;o_subcapability := v_subcapability;--话单用内部业务能力编码begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability;exception when others then o_retcode := 506; o_debugpos := 5; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_srvtypeid := v_srvtypeid;--取得业务相干信息begin select servicename,serviceid,orderupdateurl into v_servicename,v_serviceid,v_orderupdateurl from zxdbm_200.s200_service where serviceindex = v_serviceindex;exception when no_data_found then o_retcode := 2100; o_debugpos := 6; o_debuginfo := 'service do not exist.'; return;when others then o_retcode :=506; o_debugpos := 7; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_servicename:=v_servicename;o_serviceid := v_serviceid;--取得cp中文简称begin select cpcnshortname,cpid,cpsubscribeurl,customersrvtel,cptype,cpsrvtype into v_cpcnshortname,v_cpid,v_cpsubscribeurl,v_customersrvtel,v_cptype,v_cpsrvtype from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 8; o_debuginfo := 'sp do not exist.'; return;when others then o_retcode :=506; o_debugpos := 9; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_cpname :=v_cpcnshortname;o_cpid := v_cpid;o_customersrvtel := v_customersrvtel;o_cpsrvtype := v_cpsrvtype;o_cptype := v_cptype;if (trim(v_orderupdateurl) is null) or (length(trim(v_orderupdateurl)) < 8) then o_cpsubscribeurl := v_cpsubscribeurl;else o_cpsubscribeurl := v_orderupdateurl;end if;--SP接入码查问begin select spaccesscode into v_accesscode from zxdbm_ismp.ssrv_srvorder where productindex = v_productindex and rownum = 1;exception when no_data_found then begin select accesscode into v_accesscode from zxdbm_ismp.ssrv_spaccesscode where cpid = v_cpid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 10; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;when others then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_accesscode := v_accesscode;--查看订购关系begin select subscriptionindex,subscriptionid,corpindex,corpid,payuser into v_subscriptionindex,v_subscriptionid,v_corpindex,v_corpid,v_payuser from zxdbm_200.s200_user_subscription where usercode = v_msisdn and productid = v_productid;exception when no_data_found then o_retcode := 1201; o_debugpos := 12; o_debuginfo := 'subscription do not exist.'; return;when others then o_retcode := 506; o_debugpos := 13; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;o_subscriptionindex := v_subscriptionindex;o_subscriptionid := v_subscriptionid;o_corpindex := v_corpindex;o_corpid := v_corpid;----依据用户手机所在号段抉择扣费设施是ocs还是rtbp ,1:OCS;2:RTBP;if (i_prepaidtype not in (1,2)) then --attach 预付费归属,0-未知,1-OCS,2-RTBP begin select phoneindex,attach into v_phoneindex,v_attach from zxdbm_ismp.ssys_phone where startprefix <= substr(v_payuser,1,length(startprefix)) and endprefix >= substr(v_payuser,1,length(endprefix)) and phonetype = 1; exception when no_data_found then o_scptype := 2; v_dev_exist := 0; --示意不存在对应号段对应设施配置 when others then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_dev_exist = 1) then if (v_attach = 1) then o_scptype := 1; elsif (v_attach = 2) then o_scptype := 2; else begin select 1 into o_scptype from zxdbm_ismp.sdev_phone where phoneindex = v_phoneindex and devicetype = 5; exception when no_data_found then o_scptype := 2; when others then o_retcode := 506; o_debugpos := 15; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if;end if;
end slp_200_telicommodifysubreq;
/
/*
反对退订过程是否先同步订购关系再退订( 0-先退订后同步 1-先同步后退订)两种模式
减少存储过程 slp_200_telicomprecancel
*/
prompt zxdbm_200.slp_200_telicomprecancel
create or replace procedure zxdbm_200.slp_200_telicomprecancel
(
i_oa in varchar2, --发起方用户号码i_oatype in number, --发起方地址类型i_srvprodid in varchar2, --业务/产品代码i_serviceid in varchar2, --业务代码i_actiontype in number, --动作类型i_cmdchannel in number, --动作起源i_lallindex in number, --流程分支:1鉴权批价 91二次确认超时i_servicetype in number, --业务能力类型i_countrycode in varchar2, --国家码i_spaccesscode in varchar2, --antuprice音讯中的SP接入码i_silent in number, --缄默去激活开关i_needauthuser in number, --是否须要鉴权用户 0-不须要 1-须要i_needreplay in number, --产品退订是否须要二次确认i_direct in number, --订购方向 0:正向退订 1:SP反向退订i_supportproductid in number, --同步SP、SP下发应用service还是productid 0-serviceid 1-productid--i_prepaidtype in number, --预付费接口类型 1-OCS 2-非OCS 3-依据号段抉择是OCS或者非OCSi_catchflag in number, --二次确认类型 1-订购 2,3-退订 4-改号i_checkpseudocode in number, --零碎开关:是否反对伪码 0-不反对 1-反对i_mutidbmode in number, --是否多DB环境 0:否 1:是i_eventid in varchar2, --事件IDi_channelid in varchar2, --渠道商ID--added by youqunxia 20130815 Order3.02.01--i_effectiveswitch in number, --VSOP发动的订购退订立刻失效开关是否关上,0-敞开,1-关上o_retcode out number, --鉴权返回码 0代表胜利,否则代表错误码o_debugpos out number, --进口程序标识o_debuginfo out varchar2, --调试信息o_usemsisdn out varchar2, --去掉前缀的应用方用户号码o_paymsisdn out varchar2, --去掉前缀的计费方号码o_usemsisdntype out number, --应用方号码类型,1:msisdn,2:phs,3:pstno_paymsisdntype out number, --付费方号码类型,1:msisdn,2:phs,3:pstno_paytype out number, --计费号码的付费类型 0:后付费 1:预付费 2:准预付费o_oppaytype out number, --话单专用付费类型o_cpid out varchar2, --CP/SP代码o_cpcnshortname out varchar2, --CP/SP名称o_cpunsubscribeurl out varchar2, --CP/SP退订URLo_cptype out number, --CP/SP类型 0:本省 1:是全国业务o_customersrvtel out varchar2, --CP/SP客服电话o_serviceid out varchar2, --业务代码o_productid out varchar2, --产品代码o_productname out varchar2, --产品名称o_smschargingcn out varchar2, --产品资费短信形容o_subcapability out number, --产品业务能力子类型o_srvtypeid out varchar2, --业务能力编码,对应ssys_service_type表中的srvtypeido_subendtime out varchar2, --产品订购关系生效工夫o_linknum out varchar2, --业务话单中同一个流程中二次确认前后话单的关联o_pseudocode out varchar2, --伪码o_pcodemsisdnswitch out number, --伪码和实在号码之间是否有转换: 0否 1实在号码转化伪码 2伪码转化为实在号码o_chanelplayerstate out number, --cp/sp状态,0-申请,1-失常,2-暂停(暂停代收费),3-预登记,4-登记,5-解冻,21-暂停端口o_eventstate out number, --0,失常 1,登记o_cpsrvtype out number, --CP服务类型:0:CP+SP,1:CP,2:SP ;3:自营业务SPo_cdrbegintime out varchar2, --话单计费开始工夫o_cdrendtime out varchar2, --话单计费完结工夫o_producttype out number, --产品类型 1-失常产品 2-测试产品o_cityid out varchar2, --话单计费完结工夫--added by youqunxia20130906 Order3.02.01o_issynctooidd out number --是否同步订购关系给OIDD,0-否,1-是
)
as
--新增上面几个对于工夫的参数,尽量减少sysdate的调用,所有用到sysdate的中央,以to_date(v_sysdate14,'yyyymmddhh24miss')进行代替v_sysdate14 char(14) := to_char(sysdate ,'yyyymmddhh24miss');v_sysdate8 char(8) := substr(v_sysdate14,1,8);v_curmonth number(2) := to_number(substr(v_sysdate14,5,2)); --长期寄存以后月份v_curstrmonth char(2) := lpad(to_char(v_curmonth),2,'0'); --长期寄存以后月份,字符型v_curmonthendtime char(14) := to_char(last_day(to_date(v_sysdate14,'yyyymmddhh24miss')),'yyyymmdd')||'235959';v_maincapability number(10) := 0; --长期寄存组合业务主业务能力类型v_submaincapability number(10) := 0; --长期寄存组合业务主业务能力子类型v_countrycode varchar2(5) := i_countrycode; --长期寄存国家码v_tempitem number(10) := 0; --长期寄存0或者推广期的计费子序号v_cmdchannel number(10) := i_cmdchannel; --长期寄存动作起源v_tmpint number(10) := 0; --长期寄存长期数值v_devexist number(3) := 1; --长期寄存是否存在对应设施v_leftdays number(10) := 0; --本月残余天数v_monthdays number(10) := 0; --本月无效免费天数v_sql varchar2(3072) := ' '; --长期寄存动静sqlv_isservicesub number(3) := 0; --长期寄存是否业务订购v_spaccesscode varchar2(40) := ' '; --长期寄存sp接入码v_silentdays number(10) := 0; --缄默用户天数v_nextrentfee number(10) := 0; --长期寄存待失效包月费v_rentfeevalidate char(6) := ' '; --长期寄存待失效包月费率失效月v_totaldctemplate varchar2(500) := ' '; --长期寄存解析模板:产品分档费率v_dealtemplate varchar2(500) := ' '; --长期寄存解析模板:待解析的分档段v_totaldclength number(3) := 0; --长期寄存解析模板: 分档字符串的长度v_totaldcsum number(10) := 0; --长期寄存解析模板: 分档总费用v_index0 number(3) := 0; --长期寄存解析模板: 分档字符串中&的地位v_index1 number(3) := 0; --长期寄存解析模板: 分档字符串中;的地位v_nextrentdatecycle char(14) := v_sysdate14; --长期寄存包周期产品的下次打算扣租工夫v_freeuseflag number(3) := 0; --长期存入流媒体业务的试用期属性v_hasrecord number(3) := 0; --寄存须要退订的产品是否蕴含在捆绑销售品中(0,不蕴含;1,蕴含)v_oa zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存发起方用户号码v_usemsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存应用方用户号码v_paymsisdn zxdbm_ismp.susr_basic.usercode%type := ' '; --长期寄存计费方用户号码v_useuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存应用方用户序号v_payuserindex zxdbm_ismp.susr_basic.userindex%type := 0; --长期寄存计费方用户序号v_useusertype zxdbm_ismp.susr_basic.usertype%type := 1; --长期寄存应用方用户类型v_usepaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存应用方用户付费类型v_paypaytype zxdbm_ismp.susr_basic.paytype%type := 0; --长期寄存付费方用户付费类型v_useblacklist zxdbm_ismp.susr_basic.blacklist%type := 0; --长期寄存应用方是否进入黑名单v_usewhitelist zxdbm_ismp.susr_basic.whitelist%type := 0; --长期寄存应用方是否进入白名单v_useredlist zxdbm_ismp.susr_basic.redlist%type := 0; --长期寄存应用方是否进入红名单v_useblacklevel zxdbm_ismp.susr_basic.blacklevel%type := 0; --长期寄存应用方黑名单级别v_usewhitelevel zxdbm_ismp.susr_basic.whitelevel%type := 0; --长期寄存应用方白名单级别v_usemsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存应用方号码类型v_paymsisdntype zxdbm_ismp.susr_basic.msisdntype%type := 1; --长期寄存付费方号码类型v_useuserstatus zxdbm_ismp.susr_basic.status%type := 0; --长期寄存应用方状态v_useactivestatus zxdbm_ismp.susr_basic.activestatus%type := 0; --长期寄存应用方激活状态v_useoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存应用方话单专用付费类型v_payoppaytype zxdbm_ismp.susr_basic.oppaytype%type := 0; --长期寄存付费方话单专用付费类型v_usecorpindex zxdbm_ismp.susr_basic.corpindex%type := 0; --长期寄存应用方团体序号v_useusetime zxdbm_ismp.susr_basic.lastusetime%type := '00000000000000'; --长期寄存应用方上次应用工夫v_useusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存计费方号码类型v_payusercityid zxdbm_ismp.susr_basic.cityid%type := ' '; --长期寄存计费方号码类型v_usecorpid zxdbm_ismp.susr_corp.corpid%type := ' '; --长期寄存团体代码v_productindex zxdbm_200.s200_product.productindex%type := 0; --长期寄存产品序号v_invalidmode zxdbm_200.s200_product.invalidmode%type := 0; --退定 0-立刻失效,1-下月失效v_validcyctype zxdbm_200.s200_product.validcyctype%type := 0; --长期寄存周期形式0-非周期,1-天,2-周,3-月,定购失效形式为2时失效v_validcycparam zxdbm_200.s200_product.validcycparam%type := 0; --长期寄存周期参数,定购失效形式为2时失效v_validdate zxdbm_200.s200_product.validdate%type := v_sysdate14; --长期寄存指定失效日期v_subfeemode zxdbm_200.s200_product.subfeemode%type := 1; --长期寄存定购当月免费形式v_subfeedays zxdbm_200.s200_product.subfeedays%type := 0; --长期寄存免费日期取值范畴为0~28,0示意本月全副收费,其余示意 n号之后收费。v_freedays zxdbm_200.s200_product.freedays%type := 0; --长期寄存收费试用天数v_popustart zxdbm_200.s200_product.popularizestart%type := v_sysdate8; --长期寄存推广期开始工夫v_popustop zxdbm_200.s200_product.popularizestop%type := v_sysdate8; --长期寄存推广期完结工夫v_popuitem zxdbm_200.s200_product.popularizeitem%type := 0; --长期寄存推广期计费计划,0示意收费,1-推广期计划v_needcharge zxdbm_200.s200_product.needcharge%type := 1; --长期寄存是否须要计费,0-收费,1-须要计费v_productname zxdbm_200.s200_product.productname%type := ' '; --长期寄存产品名称v_productstatus zxdbm_200.s200_product.status%type := 0; --长期寄存产品状态v_onlyforcorp zxdbm_200.s200_product.onlyforcorp%type := 0; --长期寄存是否团体专用产品0:个人用户专用1:团体专用v_productstarttime zxdbm_200.s200_product.starttime%type := v_sysdate14; --长期寄存产品失效工夫v_productendtime zxdbm_200.s200_product.endtime%type := '99991231235959'; --长期寄存产品终止工夫v_workflow zxdbm_200.s200_product.workflow%type := 0; --长期寄存工作流状态v_workflowlife zxdbm_200.s200_product.workflowlife%type := 0; --长期寄存工作流流程状态v_cpindex zxdbm_200.s200_product.cpindex%type := 0; --长期寄存CP/SP序号v_serviceindex zxdbm_200.s200_product.serviceindex%type := 0; --长期寄存业务序号v_smschargingcn zxdbm_200.s200_product.smschargingcn%type := ' '; --长期寄存产品资费短信形容v_canbepresent zxdbm_200.s200_product.canbepresent%type := 0; --长期寄存是否可赠送,0-不可赠送,1-可赠送v_servicetype zxdbm_200.s200_product.servicetype%type := 0; --长期寄存业务能力类型v_subcapability zxdbm_200.s200_product.subcapability%type := 1; --长期寄存业务能力子类型1-3G,2-PHS,3-ISAG,默认为3g业务能力(仅电信应用,其余营运商皆默认为1)v_srvprodid zxdbm_200.s200_product.productid%type := i_srvprodid; --长期寄存业务产品代码v_productid zxdbm_200.s200_product.productid%type := ' '; --长期寄存产品代码v_onlyforpkg zxdbm_200.s200_product.onlyforpkg%type := 0; --长期寄存是否套餐专用产品v_backfeemode zxdbm_200.s200_product.backfeemode%type := 0; --长期寄存退定补款形式,0-不补款,1-按帐期残余理论天数补款v_chargetype zxdbm_200.s200_product_fee.chargetype%type := 0; --长期寄存计费类型v_subchargetype zxdbm_200.s200_product_fee.subchargetype%type := 0; --长期寄存计费子类型v_cyctype zxdbm_200.s200_product_fee.cyctype%type := 0; --长期寄存周期类型0-非周期,1-周期性v_cycunit zxdbm_200.s200_product_fee.cycunit%type := 0; --长期寄存周期单位 0-无,1-天,2-周,3-月,4-半年,5-年,6-小时,7-分钟,8-秒v_cycparam zxdbm_200.s200_product_fee.cycparam%type := 0; --长期寄存周期参数v_rentfee zxdbm_200.s200_product_fee.rentfee%type := 0; --长期寄存周期性费用金额v_fixfee zxdbm_200.s200_product_fee.fixfee%type := 0; --长期寄存包量费用v_fixusetimes zxdbm_200.s200_product_fee.fixusetimes%type := 0; --长期寄存包量应用值,0-无限度v_unitvol zxdbm_200.s200_product_fee.unitvol%type := 10; --长期寄存绝对于目前最小计量单位的量,时长为百毫秒,流量为bytev_autocontinue zxdbm_200.s200_product_fee.autocontinue%type := 0; --长期寄存周期性定购,是否主动续订v_minlimitfee zxdbm_200.s200_product_fee.minlimitfee%type := 0; --长期寄存保底费用,0-无保底费v_usecomfee zxdbm_200.s200_product_fee.usecomfee%type := 1; --长期寄存限度(量、工夫)外应用形式,1-应用根本费率,0-不容许持续应用v_totaldiscount zxdbm_200.s200_product_fee.totaldiscount%type := ' '; --长期寄存限度(量、工夫)外应用形式,1-应用根本费率,0-不容许持续应用v_cpid zxdbm_ismp.scp_basic.cpid%type := ' '; --长期寄存CP/SP代码v_cpstatus zxdbm_ismp.scp_basic.status%type := 0; --长期寄存CP/SP代码v_cpsubscribeurl zxdbm_ismp.scp_basic.cpsubscribeurl%type := ' '; --长期寄存CP/SP订购URLv_cpunsubscribeurl zxdbm_ismp.scp_basic.cpunsubscribeurl%type := ' '; --长期寄存CP/SP退订URLv_hasblacklist zxdbm_ismp.scp_basic.hasblacklist%type := 0; --长期寄存是否有黑名单管制 0-无,1-有v_cptype zxdbm_ismp.scp_basic.cptype%type := 2; --长期寄存CP/SP类型v_cpsrvtype zxdbm_ismp.scp_basic.cpsrvtype%type := 0; --长期寄存CP服务类型v_insubblacklist zxdbm_ismp.scp_basic.insubblacklist%type := 0; --长期寄存限度订购SP黑名单标识v_cpcnshortname zxdbm_ismp.scp_basic.cpcnshortname%type := ' '; --长期寄存CP/SP中文名简写v_customersrvtel zxdbm_ismp.scp_basic.customersrvtel%type := ' '; --长期寄存CP/SP客服电话v_protocoltype zxdbm_200.s200_sp_service_type.protocoltype%type := 0; --长期寄存定购同步协定类型0-ismp(wbs形式),1-smgp2.0(cngp1.0),2-smgp3.0(cngp1.0扩大)v_srvtypeid zxdbm_ismp.ssys_service_type.srvtypeid%type := ' '; --长期寄存话单中的srvtypeidv_productcancelmode zxdbm_ismp.ssrv_corp_product.unsubscribemode%type := 0; --长期寄存退订形式,0-必须团体管理员退订,1-团体管理员与团体成员均可退订v_productpayparty zxdbm_ismp.ssrv_corp_product.payparty%type := 2; --长期寄存团体专用产品付费方 1-团体付费 2-集体付费v_productsubindex zxdbm_200.s200_user_subscription.subscriptionindex%type := 0; --长期寄存订购关系序号v_productsubid zxdbm_200.s200_user_subscription.subscriptionid%type := ' '; --长期寄存订购关系代码v_serviceid zxdbm_200.s200_user_subscription.serviceid%type := i_serviceid; --长期寄存业务代码v_propkgindex zxdbm_200.s200_user_subscription.productpkgindex%type := 0; --长期寄存套餐序号v_propkgid zxdbm_200.s200_user_subscription.productpkgid%type := ' '; --长期寄存套餐代码v_contentindex zxdbm_200.s200_user_subscription.contentindex%type := 0; --长期寄存内容序号v_contentid zxdbm_200.s200_user_subscription.contentid%type := ' '; --长期寄存内容代码v_corpindex zxdbm_200.s200_user_subscription.corpindex%type := 0; --长期寄存团体序号v_corpid zxdbm_200.s200_user_subscription.corpid%type := ' '; --长期寄存团体代码v_subscriber zxdbm_200.s200_user_subscription.subscriber%type := ' '; --发起方用户号码v_usercode zxdbm_200.s200_user_subscription.usercode%type := ' '; --应用方用户号码v_payuser zxdbm_200.s200_user_subscription.payuser%type := ' '; --计费方用户号码v_subscribemode zxdbm_200.s200_user_subscription.subscribemode%type := 1; --长期寄存订购形式v_subscribechannel zxdbm_200.s200_user_subscription.subscribechannel%type := 3; --长期寄存订购渠道v_subscribeoptype zxdbm_200.s200_user_subscription.subscribeoptype%type := 0; --长期寄存订购操作v_pausemode zxdbm_200.s200_user_subscription.pausemode%type := 0; --长期寄存产品暂停起因v_resumemode zxdbm_200.s200_user_subscription.resumemode%type := 0; --长期寄存产品复原起因v_pushid zxdbm_200.s200_user_subscription.pushid%type := ' '; --长期寄存推荐者IDv_substarttime zxdbm_200.s200_user_subscription.starttime%type := v_sysdate14; --长期寄存定购失效工夫v_cursubendtime zxdbm_200.s200_user_subscription.endtime%type := v_sysdate14; --长期寄存以后定购关系生效工夫v_subendtime zxdbm_200.s200_user_subscription.endtime%type := '99991231235959'; --长期寄存定购生效工夫v_lastrenttime zxdbm_200.s200_user_subscription.lastrenttime%type := '00000000000000'; --长期寄存上次扣租工夫v_nextrentdate zxdbm_200.s200_user_subscription.nextrentdate%type := v_sysdate8; --长期寄存下次扣租日期v_payfordate zxdbm_200.s200_user_subscription.payfordate%type := '00000000'; --长期寄存月租已付日期v_returnvalues zxdbm_200.s200_user_subscription.returnvalues%type := 0; --长期寄存下一周期返还值v_returntype zxdbm_200.s200_user_subscription.returntype%type := 1; --长期寄存返还量类型v_returnstartdate zxdbm_200.s200_user_subscription.returnstartdate%type := '00000000'; --长期寄存返还值开始日期v_returnenddate zxdbm_200.s200_user_subscription.returnenddate%type := '00000000'; --长期寄存返还值完结日期v_chargeparty zxdbm_200.s200_user_subscription.chargeparty%type := 0; --长期寄存定购时填入,扣月租应用,计费方 0:用户;1:SP;2:团体v_freetime zxdbm_200.s200_user_subscription.freetime%type := '00000000000000'; --长期寄存产品订购收费日期v_createtime zxdbm_200.s200_user_subscription.createtime%type := '00000000000000'; --长期寄存用户订购工夫v_canceltime zxdbm_200.s200_user_subscription.canceltime%type := '00000000000000'; --长期寄存用户退定工夫v_firstusetime zxdbm_200.s200_user_subscription.firstusetime%type := '00000000000000'; --长期寄存用户首次应用工夫v_lastusetime zxdbm_200.s200_user_subscription.lastusetime%type := '00000000000000'; --长期寄存用户上次应用工夫v_tastestarttime zxdbm_200.s200_user_subscription.tastestarttime%type := '00000000000000'; --长期寄存体验期开始工夫v_tasteendtime zxdbm_200.s200_user_subscription.tasteendtime%type := '00000000000000'; --长期寄存体验期完结工夫v_pausetime zxdbm_200.s200_user_subscription.pausetime%type := '00000000000000'; --长期寄存暂停工夫v_resumetime zxdbm_200.s200_user_subscription.resumetime%type := '00000000000000'; --长期寄存暂停复原工夫v_subscribeopid zxdbm_200.s200_user_subscription.subscribeopid%type := ' '; --长期寄存定购操作员工号v_cancelreason zxdbm_200.s200_user_subscription.cancelreason%type := ' '; --长期寄存退定起因形容v_lastrent zxdbm_200.s200_user_subscription.lastrent%type := 0; --长期寄存上次扣租金额v_rollbacklastrent zxdbm_200.s200_user_subscription.lastrent%type := 0; --长期寄存上次扣租金额(订购关系待生效产品的订购失败回滚)v_msisdntype zxdbm_200.s200_user_subscription.msisdntype%type := 1; --长期寄存用户号码类型 1-msisdn,2-phs,3-pstn,4-IPTV接入号,5-宽带接入号,6-固定IPv_productsubstatus zxdbm_200.s200_user_subscription.status%type := 0;v_pseudocode zxdbm_200.s200_user_subscription.pseudocode%type := ' '; --长期寄存订购关系表中伪码--added by youqunxia20130608 order2.07.10v_pproductofferid zxdbm_200.s200_user_subscription.pproductofferid%type := ' '; --长期寄存增值产品对应的捆绑类套餐IDv_varifee zxdbm_200.s200_user_subscription.varifee%type := ''; --长期寄存以后订购关系中的可变价格 v_eventid zxdbm_200.s200_user_subscription.eventid%type := ''; --长期寄存事件IDv_isexperience zxdbm_200.s200_user_subscription.isexperience%type := 0; --订购类型:0:失常订购 1:收费体验 2:积分兑换 3:体验转正式 默认为0v_subscribetype zxdbm_200.s200_user_subscription.subscribetype%type := 0; --订购形式:0:非批量受理 1: 批量受理 默认为0v_chargetime zxdbm_200.s200_user_subscription.chargetime%type := '00000000000000'; --首次扣费时间v_orderupdateurl zxdbm_200.s200_service.orderupdateurl%type := ' '; --长期寄存业务表中v_subsrvtype zxdbm_200.s200_service.subsrvtype%type := 1; --长期寄存业务子类型,1-wap pull,2-wap push,3-op wap push,4-wap pull 下载,101-试用业务(也示意 wap pull试用业务) ;102:wap push 试用业务;1001 - 根本通道费;1002v_servicesort zxdbm_200.s200_service.servicesort%type := 0; --业务归属 0:一般业务、1:属于OIDD 2:属于定位v_phoneindex zxdbm_ismp.ssys_phone.phoneindex%type := 0; --长期寄存号段序号v_attach zxdbm_ismp.ssys_phone.attach%type := 0; --长期寄存预付费归属,0-未知,1-OCS,2-RTBP
begin
--出参初始化o_retcode := 0;o_debugpos := 0;o_debuginfo := ' ';o_usemsisdn := ' ';o_paymsisdn := ' ';o_usemsisdntype := 1;o_paymsisdntype := 1;o_paytype := 0;o_oppaytype := 0;o_cpid := ' ';o_cpcnshortname := ' ';o_cpunsubscribeurl := ' ';o_cptype := 0;o_customersrvtel := ' ';o_serviceid := ' ';o_productid := ' ';o_productname := ' ';o_smschargingcn := ' ';o_subcapability := 1;o_srvtypeid := ' ';o_subendtime := '99991231235959';o_linknum := ' ';o_pseudocode :='';o_pcodemsisdnswitch :=0;o_chanelplayerstate :=0;o_eventstate :=1;o_cpsrvtype :=0;o_cdrbegintime := substr(v_sysdate8,1,6) || '01000000';o_cdrendtime := v_curmonthendtime;o_producttype := 1;o_cityid := '';o_issynctooidd := 0;
/**
1.预鉴权
发起方地址类型 发起方用户号码去前缀
**/
--发起方地址类型鉴权 现网局点可思考正文.--批量操作不进行鉴权,由业务从用户表中查询处理--modied by youqunxia20130709 Order2.07.10if (i_actiontype <> 17 and i_lallindex <> 91) then if i_oatype not in (1,2,3,4) then o_retcode := 107; o_debugpos := 1; o_debuginfo := 'i_oatype='||i_oatype||', not in (1,2,3,4).'; return; end if;end if;--发起方用户号码去前缀v_oa := ltrim(rtrim(nvl(i_oa,'0')));if v_oa like ('+' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 2);elsif v_oa like ('00' || v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 3);elsif v_oa like (v_countrycode || '%') then v_oa := substr(v_oa, length(v_countrycode) + 1);end if;if (substr(v_oa,1,1) <> '0') and (i_oatype = 4) then v_oa := '0' || v_oa;end if;v_usemsisdn := v_oa;o_usemsisdn := v_usemsisdn;if (v_usemsisdn = '0') then o_retcode := 1001; o_debugpos := 2; o_debuginfo := 'v_usemsisdn='||v_usemsisdn||', v_usemsisdn is 0.'; return;end if;
/**
2.应用方号码存在性鉴权
**/
if (i_needauthuser = 1) then begin select userindex,usertype,paytype,blacklist,whitelist, redlist,blacklevel,whitelevel,msisdntype,status, activestatus,oppaytype,corpindex,lastusetime,cityid into v_useuserindex,v_useusertype,v_usepaytype,v_useblacklist,v_usewhitelist, v_useredlist,v_useblacklevel,v_usewhitelevel,v_usemsisdntype,v_useuserstatus, v_useactivestatus,v_useoppaytype,v_usecorpindex,v_useusetime,v_useusercityid from zxdbm_ismp.susr_basic where usercode = v_usemsisdn; exception when no_data_found then o_retcode := 1001; o_debugpos := 3; o_debuginfo := 'usercode do not exist.'; if (i_oatype = 4) then v_usemsisdntype := 2; else v_usemsisdntype := 1; end if; return; when others then o_retcode := 506; o_debugpos := 4; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; if (i_oatype = 4) then o_usemsisdntype := 2; else o_usemsisdntype := 1; end if; return; end; v_paymsisdn := v_usemsisdn; v_paymsisdntype := v_usemsisdntype; v_payuserindex := v_useuserindex; o_paymsisdn := v_paymsisdn; o_usemsisdntype := v_usemsisdntype; o_paymsisdntype := v_paymsisdntype; o_paytype := v_usepaytype; o_oppaytype := v_useoppaytype; o_cityid := trim(v_useusercityid); --批量操作用户号码类型由用户表查问后鉴权 if (i_cmdchannel in (7,32)) then if v_usemsisdntype not in (1,2,3) then o_retcode := 100; o_debugpos := 5; o_debuginfo := 'v_usemsisdntype='||v_usemsisdntype||', not in (1,2,3);'; return; end if; end if; if i_mutidbmode = 0 then if (v_useactivestatus = 0) then --待激活用户激活操作 begin update zxdbm_ismp.susr_basic set activestatus = 1, activetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 6; o_debuginfo := 'usercode do not exist.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 7; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else --已激活用户更新最近一次应用工夫 if (i_silent = 1) then if (substr(v_useusetime,1,8) <> v_sysdate8) then begin update zxdbm_ismp.susr_basic set lastusetime = v_sysdate14 where userindex = v_useuserindex; if (sql%rowcount = 0) then o_retcode := 506; o_debugpos := 8; o_debuginfo := 'usercode do not exist.'; rollback; return; end if; commit; exception when others then o_retcode := 506; o_debugpos := 9; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if; end if; end if; end if;end if;
/**
3.产品存在性鉴权
**/
--产品互斥时,ESMGP传21个0在productid字段当中,同时传进来业务ID,此时以业务ID来获取实在的产品IDif v_srvprodid = '000000000000000000000' then v_sql := 'select isservicesub from zxdbm_200.s200_service where serviceid = :p1'; begin execute immediate v_sql into v_isservicesub using v_serviceid; exception when no_data_found then o_retcode := 2100; o_debugpos := 10; o_debuginfo := 'serviceindex='||v_serviceid||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 11; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if v_isservicesub <> 1 then o_retcode := 505; o_debugpos := 12; o_debuginfo := 'esmgp parse error.'; return; end if; --获取实在的产品ID,用于后续的操作 begin select productid into v_srvprodid from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and serviceid = v_serviceid; exception when no_data_found then o_retcode := 1201; o_debugpos := 13; o_debuginfo := o_debuginfo ||'v_usemsisdn = '||v_usemsisdn||'v_serviceid = '||v_serviceid||'the subscription dose not exist;'; return; when others then o_retcode := 506; o_debugpos := 14; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;if (i_direct = 1 and i_supportproductid = 0) then--反向订购并且反对业务ID的退订 begin select productindex,invalidmode,validcyctype, validcycparam,validdate,subfeemode,subfeedays,freedays, popularizestart,popularizestop,popularizeitem,needcharge, productname,status,onlyforcorp,starttime,endtime, workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent, servicetype,subcapability,onlyforpkg,productid,backfeemode into v_productindex,v_invalidmode,v_validcyctype, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_onlyforpkg,v_productid,v_backfeemode from zxdbm_200.s200_product where serviceid = v_srvprodid and ordertype = 1; exception when no_data_found then o_retcode := 2100; o_debugpos := 15; o_debuginfo := 'serviceid='||v_srvprodid||', ordertype = 1'||', the product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 16; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select productindex,invalidmode,validcyctype, validcycparam,validdate,subfeemode,subfeedays,freedays, popularizestart,popularizestop,popularizeitem,needcharge, productname,status,onlyforcorp,starttime,endtime, workflow,workflowlife,cpindex,serviceindex,smschargingcn,canbepresent, servicetype,subcapability,productid,backfeemode,serviceid into v_productindex,v_invalidmode,v_validcyctype, v_validcycparam,v_validdate,v_subfeemode,v_subfeedays,v_freedays, v_popustart,v_popustop,v_popuitem,v_needcharge, v_productname,v_productstatus,v_onlyforcorp,v_productstarttime,v_productendtime, v_workflow,v_workflowlife,v_cpindex,v_serviceindex,v_smschargingcn,v_canbepresent, v_servicetype,v_subcapability,v_productid,v_backfeemode,v_serviceid from zxdbm_200.s200_product where productid = v_srvprodid; exception when no_data_found then o_retcode := 2100; o_debugpos := 17; o_debuginfo := 'productid='||v_srvprodid||', the product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 18; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_productid := v_productid;o_productname := v_productname;o_serviceid := v_serviceid;o_smschargingcn := v_smschargingcn;o_subcapability := v_subcapability;if i_servicetype = 5 then v_sql := 'select freeuseflag,freedays from zxdbm_200.s200_product where productindex = :p1'; begin execute immediate v_sql into v_freeuseflag,v_freedays using v_productindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 19; o_debuginfo := 'The product does not exist.'; return; when others then o_retcode := 506; o_debugpos := 20; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--产品状态鉴权if (v_productstatus in (0,2) and (v_workflowlife = 3)) then o_producttype := 2;end if;--获取产品的计费信息if (v_popuitem = 2) then --无推广期 v_tempitem := 0;elsif v_popuitem in (0,1) then --推广期收费或者推广期计费 if (v_sysdate8 >= v_popustart) and (v_sysdate8 <= v_popustop) then if v_popuitem = 0 then --推广期收费 v_needcharge := 0; else v_needcharge := 1; v_tempitem := v_popuitem; end if; else v_tempitem := 0; end if;end if;if (v_needcharge = 1) then --费率存在性鉴权 if i_servicetype in (1,2) then v_sql := 'select chargetype,subchargetype,cyctype,cycunit,cycparam,rentfee,fixfee,fixusetimes,unitvol,autocontinue,minlimitfee,usecomfee,nextrentfee,rentfeevalidate,totaldiscount '|| 'from zxdbm_200.s200_product_fee where productindex = :p1 and itemindex = :p2'; begin execute immediate v_sql into v_chargetype,v_subchargetype,v_cyctype,v_cycunit,v_cycparam,v_rentfee,v_fixfee,v_fixusetimes,v_unitvol,v_autocontinue,v_minlimitfee,v_usecomfee,v_nextrentfee,v_rentfeevalidate,v_totaldiscount using v_productindex, v_tempitem; exception when no_data_found then o_retcode := 3103; o_debugpos := 21; o_debuginfo := 'productindex='||v_productindex||', itemindex='||v_tempitem||', the product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 22; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; else begin select chargetype,subchargetype,cyctype,cycunit,cycparam, rentfee,fixfee,fixusetimes,unitvol,autocontinue,minlimitfee,usecomfee,totaldiscount into v_chargetype,v_subchargetype,v_cyctype,v_cycunit,v_cycparam, v_rentfee,v_fixfee,v_fixusetimes,v_unitvol,v_autocontinue,v_minlimitfee,v_usecomfee,v_totaldiscount from zxdbm_200.s200_product_fee where productindex = v_productindex and itemindex = v_tempitem; exception when no_data_found then o_retcode := 3103; o_debugpos := 23; o_debuginfo := 'productindex='||v_productindex||', itemindex='||v_tempitem||', the product fee does not exist.'; return; when others then o_retcode := 506; o_debugpos := 24; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if;end if;--是否业务退订if i_servicetype in (1,2,3) then v_sql := 'select isservicesub,servicesort from zxdbm_200.s200_service where serviceindex = :p1'; begin execute immediate v_sql into v_isservicesub,v_servicesort using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 25; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 26; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--added by youqunxia20130906 order3.02.01--是否同步订购关系给OIDD,0-否,1-是if v_servicesort = 1 then o_issynctooidd := 1;end if;if i_servicetype <> 14 then begin select orderupdateurl,subsrvtype into v_orderupdateurl,v_subsrvtype from zxdbm_200.s200_service where serviceindex = v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 27; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 28; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;if i_servicetype = 101 then v_sql := 'select maincapability,submaincapability '|| 'from zxdbm_9900.s9900_service where serviceindex = :p1'; begin execute immediate v_sql into v_maincapability,v_submaincapability using v_serviceindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 29; o_debuginfo := 'serviceindex='||v_serviceindex||', the service does not exist.'; return; when others then o_retcode := 506; o_debugpos := 30; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;--包月类退订形式解决if v_needcharge = 1 and v_chargetype in (2,5,7) then if i_cmdchannel in (1,2,36,14) then if i_servicetype in (1,2) or (i_servicetype = 3 and v_subsrvtype = 2) then v_invalidmode := 0; elsif i_servicetype = 3 and v_subsrvtype = 1 then v_invalidmode := 1; else null; end if; end if;end if;
/*
*4.零碎业务能力鉴权
*/
--零碎业务能力鉴权if i_servicetype = 101 then begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_maincapability and subcapability = v_submaincapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 31; o_debuginfo := 'servicetype='||v_maincapability||', subcapability='||v_submaincapability||', the system service capbility does not exist.'; return; when others then o_retcode := 506; o_debugpos := 32; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select srvtypeid into v_srvtypeid from zxdbm_ismp.ssys_service_type where servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 1100; o_debugpos := 33; o_debuginfo := 'servicetype='||v_servicetype||', subcapability='||v_subcapability||', the system service capbility does not exist.'; return; when others then o_retcode := 506; o_debugpos := 34; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;o_srvtypeid := v_srvtypeid;
/*
*5.CP/SP存在性及sp相干鉴权
*/
--CP/SP存在性鉴权begin select cpid,cpsrvtype,status,cpsubscribeurl,cpunsubscribeurl,hasblacklist,cptype,insubblacklist,cpcnshortname,customersrvtel into v_cpid,v_cpsrvtype,v_cpstatus,v_cpsubscribeurl,v_cpunsubscribeurl,v_hasblacklist,v_cptype,v_insubblacklist,v_cpcnshortname,v_customersrvtel from zxdbm_ismp.scp_basic where cpindex = v_cpindex;exception when no_data_found then o_retcode := 2000; o_debugpos := 35; o_debuginfo := 'cpindex='||v_cpindex||', the cp/sp does not exist.'; return;when others then o_retcode := 506; o_debugpos := 36; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return;end;if (v_cpunsubscribeurl is null) or (v_cpunsubscribeurl = ' ') then v_cpunsubscribeurl := v_cpsubscribeurl;end if;o_cpid := v_cpid;o_cptype := v_cptype;o_cpsrvtype := v_cpsrvtype;o_cpcnshortname := v_cpcnshortname;o_customersrvtel := v_customersrvtel;if (trim(v_orderupdateurl) is null) or (length(trim(v_orderupdateurl)) < 8) then o_cpunsubscribeurl := v_cpunsubscribeurl;else o_cpunsubscribeurl := v_orderupdateurl;end if;
--SP开明业务能力鉴权(MVS,MPSS,PIM,CPX不须要鉴权)
if i_servicetype in (5,14,33,101) then null;
-- o_protocoltype := 0;
else begin select protocoltype into v_protocoltype from zxdbm_200.s200_sp_service_type where cpindex = v_cpindex and servicetype = v_servicetype and subcapability = v_subcapability; exception when no_data_found then o_retcode := 2100; o_debugpos := 37; o_debuginfo := 'v_cpindex='||v_cpindex||', v_servicetype='||v_servicetype||', v_subcapability='||v_subcapability||', the opened service capability of the SP does not exist.'; return; when others then o_retcode := 506; o_debugpos := 38; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;
-- o_protocoltype := v_protocoltype;
end if;--SP接入码查问if (i_spaccesscode is null) or (length(trim(i_spaccesscode)) = 0) then begin select spaccesscode into v_spaccesscode from zxdbm_ismp.ssrv_srvorder where productindex = v_productindex and cmdtype = i_actiontype and servicetype = i_servicetype and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 39; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if trim(v_spaccesscode) is null then begin select accesscode into v_spaccesscode from zxdbm_ismp.ssrv_spaccesscode where cpid = v_cpid and rownum = 1; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 40; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; end if;end if;--EventID和ChanelPlayerID 状态查问if i_actiontype = 2 then begin select status into o_chanelplayerstate from zxdbm_ismp.channel_basic where cpid = i_channelid; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 41; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; begin select status into o_eventstate from zxdbm_ismp.ssys_event where eventid = i_eventid; exception when no_data_found then null; when others then o_retcode := 506; o_debugpos := 42; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;
--伪码解决(反对伪码开关关上,非自营sp)--反对业务LCS,SMS,MVS,DLS,MMS,WAP,CPX
--退订时,AuthPriceReq音讯中OA(DA)实在号码转化为伪码,同步SP
--这里订购业务的回滚订购关系不做解决
if i_servicetype in (1,2,3,4,41,5,6,101) then if i_actiontype <> 1 and i_catchflag <> 1 then if i_checkpseudocode = 1 and v_cpsrvtype <> 3 then begin select pseudocode into o_pseudocode from zxdbm_ismp.susr_basic where usercode = i_oa; exception when no_data_found then o_retcode := 1001; o_debugpos := 43; o_debuginfo := 'i_oa = '||i_oa||', the user dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 44; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_pcodemsisdnswitch := 1; end if; end if;end if;--如果团体专用产品属性为:必须团体管理员退定,则必须在团体门户上退定if (v_onlyforcorp = 1) then begin select corpid into v_usecorpid from zxdbm_ismp.susr_corp where corpindex = v_usecorpindex; exception when no_data_found then o_retcode := 1001301; --团体不存在 o_debugpos := 45; o_debuginfo := 'v_usecorpindex = '||v_usecorpindex||', the corp dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 46; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;
-- o_corpid := v_usecorpid;
--本团体的产品只能由本团体的用户退订 begin select unsubscribemode,payparty into v_productcancelmode,v_productpayparty from zxdbm_ismp.ssrv_corp_product where corpindex = v_usecorpindex and groupindex = 0 and productindex = v_productindex; exception when no_data_found then o_retcode := 2100; o_debugpos := 47; o_debuginfo := 'corpindex = '||v_usecorpindex||', productindex = '||v_productindex||', the product of the corp dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 48; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; if (v_productcancelmode = 0 ) then --必须团体管理员退订 if (v_cmdchannel <> 4) then o_retcode := 1001214; --无权退订 o_debugpos := 49; o_debuginfo := 'v_productcancelmode = '||v_productcancelmode||', v_cmdchannel = '||v_cmdchannel||', the operator has no privilege to cancel the subscription.'; return; end if; end if;else v_usecorpindex := 0;end if;--产品订购关系存在性鉴权(是否业务退订)if v_isservicesub = 1 then begin select subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex, cpid,subscribemode,subscribechannel,subscribeoptype, pausemode,resumemode,status,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelreason,lastrent,msisdntype,pseudocode,pproductofferid, varifee,eventid,isexperience,subscribetype,chargetime into v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_propkgindex, v_propkgid,v_contentindex,v_contentid,v_corpindex,v_corpid,v_cpindex, v_cpid,v_subscribemode,v_subscribechannel,v_subscribeoptype, v_pausemode,v_resumemode,v_productsubstatus,v_autocontinue,v_subscriber,v_usercode, v_payuser,v_pushid,v_substarttime,v_cursubendtime,v_lastrenttime, v_nextrentdate,v_payfordate,v_returnvalues,v_returntype, v_returnstartdate,v_returnenddate,v_fixusetimes,v_chargeparty, v_freetime,v_createtime,v_canceltime,v_firstusetime,v_lastusetime, v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime, v_subscribeopid,v_cancelreason,v_lastrent,v_msisdntype,v_pseudocode,v_pproductofferid, v_varifee,v_eventid,v_isexperience,v_subscribetype,v_chargetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and serviceid = v_serviceid; exception when no_data_found then o_retcode := 1201; o_debugpos := 50; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_serviceid = '||v_serviceid||', the subscription dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 51; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;else begin select subscriptionindex,subscriptionid,servicetype,subcapability, serviceindex,serviceid,productindex,productid,productpkgindex, productpkgid,contentindex,contentid,corpindex,corpid,cpindex, cpid,subscribemode,subscribechannel,subscribeoptype, pausemode,resumemode,status,autocontinue,subscriber,usercode, payuser,pushid,starttime,endtime,lastrenttime, nextrentdate,payfordate,returnvalues,returntype, returnstartdate,returnenddate,fixusetimes,chargeparty, freetime,createtime,canceltime,firstusetime,lastusetime, tastestarttime,tasteendtime,pausetime,resumetime, subscribeopid,cancelreason,lastrent,msisdntype,pseudocode,pproductofferid, varifee,eventid,isexperience,subscribetype,chargetime into v_productsubindex,v_productsubid,v_servicetype,v_subcapability, v_serviceindex,v_serviceid,v_productindex,v_productid,v_propkgindex, v_propkgid,v_contentindex,v_contentid,v_corpindex,v_corpid,v_cpindex, v_cpid,v_subscribemode,v_subscribechannel,v_subscribeoptype, v_pausemode,v_resumemode,v_productsubstatus,v_autocontinue,v_subscriber,v_usercode, v_payuser,v_pushid,v_substarttime,v_cursubendtime,v_lastrenttime, v_nextrentdate,v_payfordate,v_returnvalues,v_returntype, v_returnstartdate,v_returnenddate,v_fixusetimes,v_chargeparty, v_freetime,v_createtime,v_canceltime,v_firstusetime,v_lastusetime, v_tastestarttime,v_tasteendtime,v_pausetime,v_resumetime, v_subscribeopid,v_cancelreason,v_lastrent,v_msisdntype,v_pseudocode,v_pproductofferid, v_varifee,v_eventid,v_isexperience,v_subscribetype,v_chargetime from zxdbm_200.s200_user_subscription where usercode = v_usemsisdn and productid = v_productid; exception when no_data_found then o_retcode := 1201; o_debugpos := 52; o_debuginfo := 'v_usemsisdn = '||v_usemsisdn||', v_productid = '||v_productid||', the subscription dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 53; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end;end if;if v_productsubstatus in (4,5) then o_retcode := 1202; o_debugpos := 54; o_debuginfo := 'status of the subscription is abnormal.'; return;elsif (v_productsubstatus = 6) or (v_cursubendtime < v_sysdate14) then o_retcode := 1201; o_debugpos := 55; o_debuginfo := 'The subscription does not exist.'; return;end if;--added by youqunxia20130609 order2.07.10--判断是否属于捆绑品if trim(v_pproductofferid) is not null and i_cmdchannel <> 40 then if i_actiontype = 10 then null; else o_retcode := 1001229; o_debugpos := 58; o_debuginfo := 'The product is binding,unsubscribe illegal .'; return; end if;end if;--如果流媒体(天翼视讯业务)产品在试用期内退订,须要立刻失效;试用期外退订,则按产品属性判断if (i_servicetype = 5) and v_freeuseflag in (1,2) and (v_freetime > v_sysdate14) then v_invalidmode := 0;elsif (i_servicetype = 5) then v_invalidmode := 1; --MVS业务门户上不显示该字段,缺省退订都为下帐期失效end if;--added by youqunxia20130910 order3.02.01--VSOP侧发动捆绑类套餐、增值产品的订购激活、变更激活及退订,ISMP中增值子产品订购关系立刻失效(包含订购、退订及变更),不以增值产品属性判断失效工夫; /*if (i_cmdchannel = 40) and (i_effectiveswitch = 1)then v_invalidmode := 0;end if;*/--缄默用户清理订购关系判断if i_cmdchannel = 20 then if v_lastusetime = '00000000000000' then v_silentdays := to_date(v_sysdate14,'yyyymmddhh24miss') - to_date(v_substarttime,'yyyymmddhh24miss'); else v_silentdays := to_date(v_sysdate14,'yyyymmddhh24miss') - to_date(v_lastusetime,'yyyymmddhh24miss'); end if; if (v_silentdays < 30) then o_retcode := 1001224; --不满足缄默用户清理订购关系条件 o_debugpos := 58; o_debuginfo := 'v_lastusetime = '||v_lastusetime||', it is not allowed to delete subscription of silent user.'; return; end if;end if;--(除CRM发动的退订)套餐下的产品不容许独自退订if (v_propkgindex <> 0 and i_cmdchannel not in (9,35,39,40)) then o_retcode := 1001214; o_debugpos := 59; o_debuginfo := 'the product in pkg is not allowed to be unsubscribed alone.'; return;end if;o_paymsisdn := v_payuser;--依据i_needreplay决定鉴权是否持续if (i_needreplay = 1) then begin v_tmpint := dbms_random.value(1,9999999999); o_linknum := v_sysdate14 || '655380' || lpad(to_char(v_tmpint),10,'0'); exception when others then o_retcode := 506; o_debugpos := 60; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; return;end if;--获取计费方if (v_productpayparty = 1) then v_paymsisdn := v_usecorpid; o_paytype := 0; o_paymsisdn := v_paymsisdn; v_payuserindex := v_corpindex; o_cityid := trim(' ');else --赠送时,订购关系只能由应用方退订,此时须要将付费方的信息带出存储过程 if (v_payuser <> v_usemsisdn) then v_paymsisdn := v_payuser; o_paymsisdn := v_paymsisdn; begin select msisdntype,paytype,oppaytype,cityid into v_paymsisdntype,v_paypaytype,v_payoppaytype,v_payusercityid from zxdbm_ismp.susr_basic where usercode = v_payuser; exception when no_data_found then o_retcode := 1001; o_debugpos := 61; o_debuginfo := 'v_payuser = '||v_payuser||', user dose not exist.'; return; when others then o_retcode := 506; o_debugpos := 62; o_debuginfo := 'db error'||',sqlcode='||to_char(sqlcode)||'.'; return; end; o_paytype := v_paypaytype; o_oppaytype := v_payoppaytype; o_paymsisdntype := v_paymsisdntype; o_cityid := trim(v_payusercityid); end if;end if;--设置产品订购关系生效工夫、产品订购关系状态if i_servicetype = 5 then --对MVS业务的订购关系生效工夫做非凡解决 if v_chargetype in (3,6,8) and v_cyctype = 0 then --如果为非周期性 v_subendtime := v_cursubendtime; elsif v_chargetype in (3,6,8) then --如果为周期性(MVS的包周期计费只存在包天形式) v_subendtime := to_char(to_date(v_nextrentdate,'yyyymmdd') - 1,'yyyymmdd') || '235959'; elsif v_chargetype in (2,5,7) then if v_invalidmode = 0 then v_subendtime := v_sysdate14; elsif v_invalidmode = 1 then v_subendtime := v_curmonthendtime; end if; end if;else if (v_invalidmode = 0) then v_subendtime := v_sysdate14; else v_subendtime := v_curmonthendtime; end if;end if;o_subendtime := v_subendtime;--设置话单计费开始,完结工夫if substr(v_substarttime,1,6) = substr(v_sysdate8,1,6) then o_cdrbegintime := v_substarttime;else if(v_subendtime < o_cdrendtime) then o_cdrendtime := v_subendtime; end if;end if;
end slp_200_telicomprecancel;
/
clear buffer;
spool off;
exit;