现在的位置: 首页 > 综合 > 正文

电信计费帐务系统中-月租费计算程序分析

2013年08月01日 ⁄ 综合 ⁄ 共 6205字 ⁄ 字号 评论关闭

以下内容为通过分析某省电信计费帐务系统中月租费计算程序的源码,来透析目前国内计算固定电话月租费的业务情况。

租费处理 rent.pc

1业务规则描述

以下伪代码描述中,出现的日期为数字的,均为目前程序写死的部分

变量名 及其 解释
Completed_Date 竣工日期
Cycle_Begin_Date 帐务周期开始时间
Cycle_End_Date 帐务周期结束时间
State_Date 状态日期
NSC_DATE 新装机时间
Stop_Date 停保日期
Reserve_Date 复机日期
Pay_Date 复机缴费日期

1 取新装机用户租费 GetNewServCharge
a 计算租费统计类型
i. if( Completed_Date的年月 等于 Cycle_Begin_Date的年月)
and ( Completed_Date的天数>=21号 )
Stat_Type_ID = 2;

ii .if( Completed_Date的年月 等于 Cycle_End_Date的年月)
and ( Completed_Date的天数>15号 )
Stat_Type_ID = 4;

iii.其他情况Stat_Type_ID = 3

b 计算租费
i. 取用户租费计算规则RentCalcRuleID(SERV_RENT_CALC_RULE )

ii. 取Completed_Date的天数DayOffset

iii. 根据上述规则标识RentCalcRuleID和日期偏移DayOffset来取规则描述表
(rent_calc_rule_detail )中的租费比率iRate

if(iRate!=-2) and (iRate!=-1)
lCharge * iRate/100;

iiii. if(iRate==-2) , 则按天计算租费

iiiii. if(iRate==-1) , 则按RentCalcRuleID分7种情况来处理

switch(iRentCalcRuleID)
{
case 1 : lCharge = lCharge

case 2 : lCharge = lCharge + lCharge/2 租费加半个月

case 3 : if( Completed_Date的年月 等于 Cycle_End_Date的年月)
and ( Completed_Date的天数>15号 )
lCharge = lCharge + lCharge/2

else
lCharge = lCharge * 2

case 4 : if( Completed_Date的年月 等于 Cycle_End_Date的年月)
and ( Completed_Date的天数>15号 )
lCharge = lCharge/2;

else
lCharge = lCharge;

case 5 : if( Completed_Date的年月 等于 Cycle_Begin_Date的年月)
and ( Completed_Date的天数>=21号 )
lCharge = lCharge*3/2;

if( Completed_Date的年月 等于 Cycle_End_Date年月)
and ( Completed_Date的天数>15号 )
lCharge = lCharge/2;

case 6 : if( Completed_Date的年月 等于 Cycle_Begin_Date的年月)
and ( Completed_Date的天数>=21号 )
lCharge = lCharge + lCharge*3/2;

if( Completed_Date的年月 等于 Cycle_End_Date的年月)
and ( Completed_Date的天数>15号 )
lCharge = lCharge + lCharge/2;

else
lCharge = lCharge * 2;

case 7 : lCharge = 0;

default: lCharge = lCharge;
}

2 取拆机用户或取消服务用户的租费 GetDestroyCharge
a 如果不是真正的拆机用户不计算租费

b 如果为同一帐期装机拆机或者同一帐期装机暂停用户,计算方式如下
i. 应收0.5个月月租的情况:
Completed_Date 在21 ~ 32之间 并且 State_Date 在21 ~ 32之间
或者 Completed_Date 在01 ~ 16之间 并且 State_Date 在01 ~ 16之间
或者 Completed_Date 在16 ~ 21之间 并且 State_Date 在16 ~ 21之间

ii. 应收1个月月租的情况:
Completed_Date 在21 ~ 32之间 并且 State_Date 在01 ~ 16之间
或者 Completed_Date 在01 ~ 16之间 并且 State_Date 在16 ~ 21之间

iii. 应收1.5个月月租的情况:
Completed_Date 在21 ~ 32之间 并且 State_Date 在16 ~ 21之间

c 如果为正常拆机或者正常暂停,计算方式如下
i. 取本周期拆机用户租费计算规则RentID(表destroy_rent_calc_rule )

ii. 取State_Date的天数DayOffset

iii. 根据上述规则标识RentID和日期偏移DayOffset来取规则描述表
(rent_calc_rule_detail )中的租费比率Rate

iiii.如果取出来的Rate=-2,则按天计算租费

3 租费处理
a 根据计费性质判断是否进行免费处理(表free_billing_type)

b 取欠费租费比率
(注 : 某分局规定欠费(归为停机)3个月以上做呆帐处理,但不拆机,
帐务系统在第四个月后计费不产生月租)

c 取实际使用天数

d 取障碍折扣比率

e 装机时间在周期之前,正常资费,分别计算serv和产品租费

if( Method == 'F' )
{
if( 是否为拆机用户,或者有记录在停机保号档案表)
and ( 不是拆机状态F1X)
{
判断是否在停机保号档案表中有记录
if( 不是停机保号用户 )
{
if(Completed_Date >= Cycle_Begin_Date )
and(Completed_Date < Cycle_End_Date )
{
lCharge = GetNewServCharge
}
if(NSC_DATE >= Cycle_End_Date )
and(Completed_Date >= Cycle_End_Date )
{
lCharge = 0;
}
}
else(是停机保号用户)
{
if( 判断是否为拆机状态,如果是,则更新其状态为拆机 )
{
UPDATE SERV_STOP_RESERVE
SET STATE_BAK=STATE,STATE='F1X',
BILL_TASK_ID=:BillTaskID
WHERE AREA_CODE=:sAreaCode
AND ACC_NBR=:sAccNbr ;
}

if ( 判断是否为停机保号状态 )
{
判断是否为本月停机保号
if ( Stop_Date>= Cycle_Begin_Date )
and(Stop_Date < Cycle_End_Date )
{
暂保收月租,不收保号费,
原文:是本月停机保号用户要收本月月租和停机保号费用

State_Date = Stop_Date;
lCharge = GetDestroyCharge;
}
以前帐期暂保
else if( Stop_Date < Cycle_Begin_Date )
{
if(本帐期拆机,不退不收)
lCharge = 0;
else 历史停机保号用户收保号费
没有配置该业务的停机保号费计算规则,默认按15元每3月收取
}

}
else 是已复机状态
{
判断是否为本月复机用户
if(Reserve_Date>= Cycle_Begin_Date )
and(Reserve_Date < Cycle_End_Date )
{
if( 本帐期复机之后拆机的租费收取 )
{
Completed_Date = Reserve_Date
lCharge = GetDestroyCharge;
}
else
{
if ( ( Cycle_End_Date - Pay_Date) >= (3*28) )
{
if ( Reserve_Date-Stop_Date > 1 ) &&
( Stop_Date的天数 在 21~31之间 ) && ( Reserve_Date的天数 在1~20之间 )
{
if(没有配置该业务的停机保号费计算规则)
计算暂保费15元
else
找到该业务的停机保号费计算规则(表stop_reserve_calc_rule)
}

}
else if ( ( Cycle_End_Date - Pay_Date) < (3*28) )
{
if ( Reserve_Date-Stop_Date = 0 ) && ( Stop_Date的天数 在 1~20之间 )
{
if(没有配置该业务的停机保号费计算规则)
退暂保费15元
else
找到该业务的停机保号费计算规则(表stop_reserve_calc_rule)
}
}
停机保号申请复机:
1 假设有一个号码:0351-6263678,
在1月17号由正常状态转为停保状态,
在1月21号月租费计费时,应该不收不退月租
(停保费在申请停保的下个月收取)

2 假设在1月23号又申请复机,
在2月21号计算月租费时,会按照新装处理,
收1月23-31号之间的半个月月租,
收取2月一个月 月租,收取3月一个月月租。
此时多收了一月半个月的月租。

3 所以应该加一个判断,如果停机与复机
在一个自然月的下半个月,则竣工时间可考虑
用下个月的1号,
即strgCurRentInfo.sCompletedDate=2月1号

if(Reserve_Date,Stop_Date是不是在同一个自然月的下半月)
Completed_Date = 这个自然月的下个月的1号

停机保号用户复机(如2003/01/25)后,
后来又增加了新的来显((如2003/02/08)),
则应该按增加的时间(2003/02/08)来计算
月租否则多计算了半个月的费用

if(CompletedDate < Reserve_Date)
CompletedDate = Reserve_Date

lCharge = GetNewServCharge

if (iState == 1 || iState == 2)
lCharge = 0;
}
}
}

}

}
else
{
lCharge = GetDestroyCharge;
Stat_Type_ID = 7;
}
}
else
{
按天计算 租费

 

2

租费主要是从serv表取客户资料信息,根据客户装机的竣工时间,还有拆机的状态时间来计算客户的基本租费
根据serv_product表来取客户的附加产品资料信息,来计算客户的附加产品租费
例如,来电显示,呼叫转移就属于附加产品,也要收取一定的租费

计算租费比较复杂的情况在新装机,和拆机,停机保号这几种情况

上面的流程就是描述了这几种情况

否则按正常租费收取(即按租费配置表中配置的费率来收)

3租费相关表

select * from product_rent_tariff --产品租费费率
select * from product_rent_calc_rule --新增产品租费规则关系表
select * from serv_type_rent_tariff --服务类型租费费率
select * from serv_rent_calc_rule --新装机用户租费计算规则表
select * from destroy_rent_calc_rule --拆机用户租费计算规则表
select * from destroy_product_calc_rule --拆机附属产品租费计算规则表
select * from rent_calc_rule --租费规则
select * from rent_calc_rule_detail --租费规则详情
select * from free_billing_type --部分免费对照表
select * from serv_stop_reserve --停机保号
select * from stop_reserve_calc_rule --停机保号计算规则表
select * from product_reserve_calc_rule --产品复机计算规则表
select * from fault_record --故障记录
select * from fault_type --故障类型
select * from owe_rent_calc_rule --欠费租费计算规则
select * from rent_circuit
select * from rent_circuit_bill
select * from serv_type_product
select * from acct_item_total_rt_103
select * from report_rent
select * from redo_log
select * from serv_product
select * from domain where domain in ('F0J','F0X','F1X','F0H','H0A','H0X','F0K','F0M')
select * from acct_item a,acct_item_type b where a.acct_item_type_id=b.acct_item_type_id
select * from acct_item_type
select * from product where product_name

4

1 对于新装机的用户
对于过渡期7月21日 ~ 7月31日的用户,都需要加上年月的判断
可以考虑在取DayOffset的时候加上以下判断,这样地市可以配置
7月21日 ~ 7月31日新装用户的DayOffset为33~43,这样也可以取到费率
if( Completed_Date的年月 等于 Cycle_Begin_Date的年月)
and ( Completed_Date的天数>=21号 )
{
DayOffset = Completed_Date的天数
}

if( Completed_Date的年月 等于 Cycle_End_Date的年月)
//这个Cycle_End_Date应该是21号,如果是31号的话,还需要考虑如何判断,
//7月21日 ~ 7月31日,是否要写死在程序中,作为过渡
and ( Completed_Date的天数>15号 )
and ( Completed_Date的天数<21号 )
{
DayOffset = Completed_Date的天数
}

if( Completed_Date的年月 等于 Cycle_End_Date的年月)
and ( Completed_Date的天数>=21号 )
and ( Completed_Date的天数<=31号 )
{
DayOffset = Completed_Date的天数 + 12
}

2 对于拆机用户或取消服务用户的租费
a 对于正常拆机的用户,通过State_Date的天数取DayOffset也可以
参考上述新装用户的处理办法

b 如果为同一帐期装机拆机或者同一帐期装机暂停用户
i. 应收0.5个月月租的情况:
Completed_Date 在21 ~ 32之间 并且 State_Date 在21 ~ 32之间
或者 Completed_Date 在01 ~ 16之间 并且 State_Date 在01 ~ 16之间
或者 Completed_Date 在16 ~ 21之间 并且 State_Date 在16 ~ 21之间

ii. 应收1个月月租的情况:
Completed_Date 在21 ~ 32之间 并且 State_Date 在01 ~ 16之间
或者 Completed_Date 在01 ~ 16之间 并且 State_Date 在16 ~ 21之间

iii. 应收1.5个月月租的情况:
Completed_Date 在21 ~ 32之间 并且 State_Date 在16 ~ 21之间

在这个基础上应该加上对Completed_Date,State_Date年月的判断,
这个需要讨论后决定具体算法

抱歉!评论已关闭.