假設有兩種計費模式:每秒計費以及月租費,若用戶為月租費模式,當用戶撥號後,系統不會提示餘額,若為每秒計費者,系統必須提示餘額。
原理:系統應該要自動辨識該用戶的 Call Plan 自動選擇並選擇正確的 agi-conf 檔。
此方案的限制:
[a2billing-callplan] exten => _X.,1,NoOp("--------- Connect to MySQL -----------") exten => _X.,n,Set(CARDNO=${CDR(accountcode)}) exten => _X.,n,NoOp("-- Account code is ${CARDNO} --") ;----------- DB connection variables ---------- exten => _X.,n,Set(DBHOST="localhost") exten => _X.,n,Set(DBUSER="a2billinguser") exten => _X.,n,Set(DBPASS="a2billing") exten => _X.,n,Set(DBNAME="mya2billing") exten => _X.,n,MYSQL(Connect connid ${DBHOST} ${DBUSER} ${DBPASS} ${DBNAME}) exten => _X.,n,GotoIf($["${connid}" = ""]?error,1) exten => _X.,n,NoOp("------ Connected MySQL -------") ;----------- Get tariff ID ----------- exten => _X.,n,Set(SQL="SELECT tariff FROM cc_card WHERE username=${CARDNO}") exten => _X.,n,MYSQL(Query resultid ${connid} ${SQL}) exten => _X.,n,MYSQL(Fetch fetchid ${resultid} TARIFF) exten => _X.,n,NoOp(-- TARIFF => ${TARIFF} --) ;----------- Get Call Plan(CP) ------------- exten => _X.,n,Set(SQL="SELECT tariffgroupname FROM cc_tariffgroup WHERE id=${TARIFF}") exten => _X.,n,MYSQL(Query resultid ${connid} ${SQL}) exten => _X.,n,MYSQL(Fetch fetchid ${resultid} CP) exten => _X.,n,MYSQL(Disconnect ${connid}) exten => _X.,n,NoOp(-- Call Plan => ${CP} --) ;----------- Add the rule for Call Plan ----------- exten => _X.,n,GotoIf($["${CP}" = "CP1"]?conf1,1) exten => _X.,n,GotoIf($["${CP}" = "CP2"]?conf2,1) exten => _X.,n,Hangup exten => h,1,Hangup exten => error,1,NoOp(MySQL connection error!! Please check the dialplan...) exten => error,n,Hangup exten => conf1,1,NoOp("----- Starting A2Billing with agi-conf-1 ------") exten => conf1,n,DeadAgi(a2billing.php,1) exten => conf1,n,Hangup exten => conf2,1,NoOp("----- Starting A2Billing with agi-conf-2 ------") exten => conf2,n,DeadAgi(a2billing.php,2) exten => conf2,n,Hangup
Images 0 | ||
---|---|---|
No images to display in the gallery. |