跳到主要内容

CGRateS 目的地配置

本指南解释了如何在 CGRateS 中为 OmniCRM 配置目的地。目的地定义了余额可以使用的地方 - 无论是拨打特定号码(地理)还是在特定网络上使用数据/语音(PLMN)。

概述

CGRateS 使用 目的地 来控制客户可以在哪里使用他们的余额:

  • 地理目的地 - 拨打特定位置的电话/SMS 的号码前缀(例如,英国号码、美国免费电话)
  • PLMN 目的地 - 用于特定网络的数据使用和漫游的网络代码(例如,Verizon、Vodafone UK)

当客户使用服务时,CGRateS 匹配:

  • 语音/SMS:拨打的号码前缀 → 地理目的地
  • 数据:网络 PLMN 代码 → PLMN 目的地

关键规则

  • 语音/SMS 余额 → 使用地理目的地(拨打的号码)
  • 数据余额 → 使用 PLMN 目的地(客户连接的网络)

前提条件

import cgrateshttpapi
import time

OCS_Obj = cgrateshttpapi.CGRateS("ocs.example.com", "2080")
tenant = "your_tenant_name"
tpid = str(tenant) + "_" + str(int(time.time()))

第 1 部分:地理目的地(拨打到地方)

地理目的地定义了拨打特定位置的语音电话和 SMS 的号码前缀。

国内目的地

# ===================================================================
# DOMESTIC DESTINATIONS (US/Canada - NANP)
# ===================================================================

# US/Canada Mobile & Fixed (share area codes)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_Domestic_All",
"Prefixes": ["1"] # NANP (US/Canada)
}]
})

# US Toll-Free
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_Domestic_TollFree",
"Prefixes": ["1800", "1888", "1877", "1866", "1855", "1844", "1833"]
}]
})

# US Premium Rate
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_Domestic_Premium",
"Prefixes": ["1900"]
}]
})

国际目的地

# ===================================================================
# INTERNATIONAL DESTINATIONS (By Country)
# ===================================================================

# United Kingdom
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_International_UK",
"Prefixes": ["44"]
}]
})

# China
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_International_China",
"Prefixes": ["86"]
}]
})

# Australia - Mobile
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_AU_Mobile",
"Prefixes": ["614"] # Australian mobiles (04xx dialed as 614xx)
}]
})

# Australia - Fixed Line
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_AU_Fixed",
"Prefixes": [
"612", # NSW (Sydney)
"613", # VIC (Melbourne)
"617", # TAS (Hobart)
"618" # SA, WA, NT (Adelaide, Perth, Darwin)
]
}]
})

# Australia - Toll-Free
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_AU_TollFree",
"Prefixes": [
"611800", # Toll-free
"611300" # Local rate
]
}]
})

# Australia - Premium Rate
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_AU_Premium",
"Prefixes": ["6119"] # Premium rate services
}]
})

# Europe (grouped)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_International_Europe",
"Prefixes": [
"33", # France
"49", # Germany
"39", # Italy
"34", # Spain
"31", # Netherlands
"32", # Belgium
"41" # Switzerland
]
}]
})

# International - All (catch-all, excludes domestic)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_International_All",
"Prefixes": ["2", "3", "4", "5", "6", "7", "8", "9"] # All except "1" (NANP)
}]
})

用例:

  • 国内计划:“无限拨打美国/加拿大号码” → Dest_Domestic_All
  • 英国拨打附加包:“100分钟拨打英国” → Dest_International_UK
  • 澳大利亚计划:“3000分钟拨打澳大利亚手机和固定电话” → Dest_AU_Mobile, Dest_AU_Fixed, Dest_AU_TollFree
  • 国际套餐:“50分钟拨打任何国际号码” → Dest_International_All

第 2 部分:PLMN 目的地(使用来自地方 - 漫游/数据使用)

PLMN 目的地定义了数据使用和漫游场景的网络代码。使用格式 mccXXX.mncYYY,其中:

  • MCC = 移动国家代码(3 位数字)
  • MNC = 移动网络代码(2-3 位数字)

PLMN 格式规则

  • 特定网络"mcc310.mnc004" → 仅 Verizon 网络 004
  • 国家内所有网络"mcc310" → 任何美国网络
  • 示例mcc310.mnc004mcc234.mnc015mcc505.mnc057

本网(您的本地网络)

重要:定义您特定的网络,您的 SIM 卡已在该网络上配置。

# On-Net (Your Home Network)
# This is YOUR operator's PLMN - the network where YOUR customers' SIMs are active
# All domestic on-net data balances should use this destination

OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_OnNet",
"Prefixes": ["mcc505.mnc057"] # Example: MCC 505, MNC 57 if this is your home network
}]
})
# Replace mcc505.mnc057 with YOUR actual operator's PLMN code
# All domestic on-net data balances should use the prefixes set out here
# Otherwise they're considered roaming

美国漫游 PLMN 目的地

# ===================================================================
# US ROAMING PLMN DESTINATIONS
# ===================================================================

# Verizon Wireless
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_US_Verizon",
"Prefixes": [
"mcc310.mnc004", "mcc310.mnc010", "mcc310.mnc012", "mcc310.mnc013",
"mcc311.mnc480", "mcc311.mnc481", "mcc311.mnc482", "mcc311.mnc483"
]
}]
})

# All US PLMNs (catch-all)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_US_All",
"Prefixes": ["mcc310", "mcc311", "mcc312", "mcc313", "mcc316"]
}]
})
# Note: This matches ANY network with these MCCs (310, 311, etc.)
# Customer on mcc310.mnc004 (Verizon), mcc310.mnc410 (AT&T), mcc311.mnc580 (US Cellular)
# would ALL match this destination

英国漫游 PLMN 目的地

# ===================================================================
# UK ROAMING PLMN DESTINATIONS
# ===================================================================

# Vodafone UK
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_UK_Vodafone",
"Prefixes": ["mcc234.mnc015"]
}]
})

# EE (Everything Everywhere)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_UK_EE",
"Prefixes": ["mcc234.mnc030", "mcc234.mnc033"]
}]
})

# All UK PLMNs
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_UK_All",
"Prefixes": ["mcc234"]
}]
})

漫游区(多国组)

非常适合区域漫游套餐,如“欧洲漫游”或“亚太漫游”。

# ===================================================================
# ROAMING ZONES (Multi-Country Groups)
# ===================================================================

# Zone 1: North America
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_Zone_NorthAmerica",
"Prefixes": [
"mcc310", "mcc311", "mcc312", "mcc313", "mcc316", # USA
"mcc302", "mcc334" # Canada
]
}]
})
# Using MCC-only prefixes provides coverage on ANY network in these countries
# Great for "North America roaming" packages that work on all carriers

# Zone 2: Europe
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_Zone_Europe",
"Prefixes": [
"mcc234", # United Kingdom
"mcc208", # France
"mcc262", # Germany
"mcc222", # Italy
"mcc214", # Spain
"mcc228" # Switzerland
]
}]
})

# Zone 3: Asia Pacific
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_Zone_AsiaPacific",
"Prefixes": [
"mcc505", # Australia
"mcc460", # China
"mcc454", # Hong Kong
"mcc440", # Japan
"mcc520", # Thailand
"mcc525", # Singapore
"mcc530" # New Zealand
]
}]
})

# Catch-all for any roaming (use with caution)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_Roaming_All",
"Prefixes": ["mcc"] # Matches ANY PLMN (very broad)
}]
})

用例:

  • 特定网络漫游:“仅在 Verizon 上使用 5GB” → Dest_PLMN_US_Verizon
  • 全国漫游:“在美国(任何网络)使用 10GB” → Dest_PLMN_US_All
  • 区域漫游:“欧洲漫游 15GB” → Dest_PLMN_Zone_Europe
  • 全球漫游:“在任何地方使用 1GB” → Dest_Roaming_All

何时使用每种方法

目的地类型用例示例余额类型
地理拨打/短信到特定国家“100分钟拨打英国号码”语音,SMS
本网 PLMN在您的网络上使用国内数据“100GB 本网数据”数据
特定 PLMN在首选网络上使用高级漫游“仅在 Verizon 上使用 5GB”数据(和漫游语音/SMS)
全国 PLMN在国家内任何网络漫游“在美国(任何网络)使用 5GB”数据(和漫游语音/SMS)
区域 PLMN区域漫游套餐“10GB 欧洲漫游”数据(和漫游语音/SMS)

动态目的地更新和服务访问

目的地更新如何工作

关键概念: CGRateS 中的目的地是 通过 ID 引用,而不是复制。当您更新目的地的前缀或 PLMN 代码并 将 TarifPlan 加载到运行时 时,所有引用该目的地的现有余额会立即受到影响

这意味着:

  • 无需更新单个客户余额,当扩展或限制服务覆盖时
  • 网络范围内的更改,对所有使用该目的地的客户生效,一旦加载了资费计划
  • ⚠️ 更改在加载 TarifPlan 时生效 - 您可以在加载之前多次修改目的地,更改仅在 LoadTariffPlanFromStorDb 后生效

示例 1:扩展覆盖范围

您有一个用于欧洲漫游的目的地:

# Initial configuration - Only 3 countries
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_Zone_Europe",
"Prefixes": [
"mcc262", # Germany
"mcc208", # France
"mcc222" # Italy
]
}]
})

具有余额的客户 引用 Dest_PLMN_Zone_Europe 可以在德国、法国和意大利漫游。

稍后,您添加西班牙和英国:

# Updated configuration - Now 5 countries
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_Zone_Europe",
"Prefixes": [
"mcc262", # Germany
"mcc208", # France
"mcc222", # Italy
"mcc214", # Spain (NEW)
"mcc234" # UK (NEW)
]
}]
})

# Load the tariff plan to make changes active
OCS_Obj.SendData({
'method': 'ApierV1.LoadTariffPlanFromStorDb',
'params': [{
"TPid": tpid,
"DryRun": False,
"Validate": True
}]
})

# Reload the destination cache
OCS_Obj.SendData({
'method': 'CacheSv1.ReloadCache',
'params': [{
"DestinationIDs": ["Dest_PLMN_Zone_Europe"]
}]
})

结果: 加载资费计划后,所有现有客户的余额 Dest_PLMN_Zone_Europe 现在可以在西班牙和英国漫游 - 无需单独更新余额。

示例 2:限制覆盖范围

从目的地中删除一个国家 会在加载资费计划���阻止访问:

# Remove Germany from Europe zone
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_Zone_Europe",
"Prefixes": [
"mcc208", # France
"mcc222", # Italy
"mcc214", # Spain
"mcc234" # UK
# Germany (mcc262) REMOVED
]
}]
})

# Load the tariff plan to make changes active
OCS_Obj.SendData({
'method': 'ApierV1.LoadTariffPlanFromStorDb',
'params': [{
"TPid": tpid,
"DryRun": False,
"Validate": True
}]
})

# Reload cache
OCS_Obj.SendData({
'method': 'CacheSv1.ReloadCache',
'params': [{
"DestinationIDs": ["Dest_PLMN_Zone_Europe"]
}]
})

结果: 加载资费计划后,试图在德国漫游的客户将被 阻止,即使他们仍然有余额用于 Dest_PLMN_Zone_Europe。余额存在,但不再匹配 PLMN 目的地。

示例 3:语音/SMS 地理目的地

同样的原则适用于语音和 SMS 的地理目的地:

# Add Canada to "Domestic" calling
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_Domestic_All",
"Prefixes": [
"1", # Already includes USA (and previously Canada)
# No change needed - "1" prefix already covers both
]
}]
})

# Or create separate North America destination
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_North_America",
"Prefixes": [
"1" # USA + Canada
]
}]
})

影响: 任何具有 DestinationIDs: "Dest_Domestic_All" 的余额现在都适用于拨打美国和加拿大的电话(如果使用前缀“1”)。

服务访问规则

关键: 如果客户尝试使用服务(语音/SMS/数据),并且 没有匹配的目的地,则服务将被 拒绝,即使他们有余额。

场景 1:没有匹配的目的地

# Customer has balance:
{
"BalanceId": "Europe_Data_5GB",
"BalanceType": "*data",
"DestinationIDs": "Dest_PLMN_Zone_Europe", # Only France, Germany, Italy
"Units": 5 * 1024 * 1024 * 1024
}

# Customer roams on network in Spain (mcc214.mnc001)
# Spain is NOT in Dest_PLMN_Zone_Europe

结果:

  • ❌ 数据会话 被阻止(没有匹配的目的地)
  • 余额保持未使用
  • 客户收到“信用不足”或类似错误

修复: 将西班牙���加到 Dest_PLMN_Zone_Europe 或确保客户有带有 DestinationIDs: "*any" 的货币余额作为后备。

场景 2:没有通配符后备

# Customer has two balances:
{
"BalanceId": "UK_Voice_100min",
"BalanceType": "*voice",
"DestinationIDs": "Dest_International_UK", # Only prefix "44"
"Units": 100 * 60 * 1000000000
}
# NO monetary balance with "*any" destination

# Customer calls Australia (+61)

结果:

  • ❌ 呼叫 被阻止(没有目的地匹配前缀“61”)
  • 英国分钟余额未使用(仅匹配“44”)
  • 没有货币后备来覆盖呼叫

修复: 添加带有 DestinationIDs: "*any" 的货币余额或将特定澳大利亚目的地添加到他们的余额中。

场景 3:通配符后备有效

# Customer has:
# Balance 1: UK minutes
{
"BalanceId": "UK_Voice_100min",
"BalanceType": "*voice",
"DestinationIDs": "Dest_International_UK",
"Units": 100 * 60 * 1000000000,
"BalanceWeight": 1200
}

# Balance 2: Monetary with wildcard
{
"BalanceId": "PAYG_Credit",
"BalanceType": "*monetary",
"DestinationIDs": "*any", # Matches ANYTHING
"Units": 5000, # $50
"BalanceWeight": 1000 # Lower priority
}

# Customer calls Australia (+61)

结果:

  • ✅ 呼叫 被允许
  • 英国分钟余额未使用(不匹配“61”)
  • PAYG 信用余额使用(匹配“*any”)
  • 按 PAYG 费率收费拨打澳大利亚

测试和模拟

目的地更改可以在非生产环境中进行测试和模拟,然后再应用于生产。这使您能够:

  • 验证新的 PLMN 代码是否正确
  • 测试覆盖范围扩展/限制的影响
  • 验证现有余额在更新目的地时的行为是否符合预期
  • 确保后备机制正常工作

建议: 在将目的地更新应用于生产之前,始终在具有测试账户的暂存环境中进行测试。

关键要点

  1. 目的地是动态的 - 更改会影响所有引用它们的余额,一旦加载资费计划
  2. 加载 TarifPlan 以激活 - 使用 LoadTariffPlanFromStorDb 使目的地更改在运行时生效
  3. 没有目的地匹配 = 没有服务 - 如果客户的使用不匹配任何目的地,他们将被阻止
  4. 通配符(*any)非常强大 - 用于货币后备以防止意外阻止
  5. 需要重新加载缓存 - 加载资费计划后始终重新加载目的地缓存
  6. 在生产之前测试 - 一旦加载,目的地更改会影响所有客户

PAYG/货币余额的费率配置文件

在使用货币余额(PAYG - 按需付费)时,您需要���义 费率配置文件,指定不同目的地每单位的收费标准。

关于 CGRateS 灵活性的注意事项: CGRateS 非常灵活,可以根据许多因素应用不同的费率和计划,包括:

  • 客户拨打的来源(PLMN - 在这里涵盖)
  • 客户拨打的目的地(地理目的地 - 在这里涵盖)
  • 一天中的时间(高峰/非高峰费率)
  • 客户等级(VIP、标准等)
  • 服务质量水平
  • 以及许多更复杂的计费场景

本指南专注于基于 PLMN 的漫游和基于地理目的地的计费的 CRM 级配置,涵盖最常见的用例。高级计费场景(时间段、客户等级、基于质量的路由)在 CGRateS 中是可能的,但超出了此 CRM 重点文档的范围。

费率配置文件如何工作

定义费率配置文件

费率配置文件定义了不同使用类型的每单位费用。以下是语音、SMS 和数据的示例:

# ===================================================================
# VOICE RATES (Per Minute)
# ===================================================================

# Domestic voice: $0.10/minute
OCS_Obj.SendData({
'method': 'ApierV2.SetTPRate',
'params': [{
"TPid": tpid,
"ID": "Rate_Voice_Domestic",
"RateSlots": [{
"ConnectFee": 0,
"Rate": 0.10,
"RateUnit": "60s", # 1 minute
"RateIncrement": "1s", # Per-second billing
"GroupIntervalStart": "0s"
}]
}]
})

# UK voice: $0.25/minute
OCS_Obj.SendData({
'method': 'ApierV2.SetTPRate',
'params': [{
"TPid": tpid,
"ID": "Rate_Voice_UK",
"RateSlots": [{
"ConnectFee": 0.05, # $0.05 connection fee
"Rate": 0.25,
"RateUnit": "60s",
"RateIncrement": "6s", # 6-second blocks
"GroupIntervalStart": "0s"
}]
}]
})

# ===================================================================
# SMS RATES (Per Message)
# ===================================================================

# Domestic SMS: $0.05/message
OCS_Obj.SendData({
'method': 'ApierV2.SetTPRate',
'params': [{
"TPid": tpid,
"ID": "Rate_SMS_Domestic",
"RateSlots": [{
"ConnectFee": 0,
"Rate": 0.05,
"RateUnit": "1", # 1 SMS
"RateIncrement": "1", # Per message
"GroupIntervalStart": "0s"
}]
}]
})

# ===================================================================
# DATA RATES (Per MB) - For Roaming
# ===================================================================

# Roaming on US Premium Networks (Verizon, AT&T): $2.00/MB
OCS_Obj.SendData({
'method': 'ApierV2.SetTPRate',
'params': [{
"TPid": tpid,
"ID": "Rate_Data_Roaming_US_Premium",
"RateSlots": [{
"ConnectFee": 0,
"Rate": 2.00,
"RateUnit": "1048576", # 1 MB in bytes
"RateIncrement": "1024", # Per KB
"GroupIntervalStart": "0s"
}]
}]
})

费率槽字段:

  • ConnectFee - 每个会话的一次性收费
  • Rate - 每个 RateUnit 的费用
  • RateUnit - 计费单位大小(60s、1MB、1 消息)
  • RateIncrement - 最小可收费单位
  • GroupIntervalStart - 此费率层级开始的时间

将目的地链接到费率

定义费率后,将它们链接到目的地,使用 DestinationRates:

# Link Domestic destination to Domestic voice rate
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestinationRate',
'params': [{
"TPid": tpid,
"ID": "DR_Voice_Domestic",
"DestinationRates": [{
"DestinationId": "Dest_Domestic_All",
"RateId": "Rate_Voice_Domestic",
"RoundingMethod": "*up",
"RoundingDecimals": 4
}]
}]
})

# Link UK destination to UK voice rate
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestinationRate',
'params': [{
"TPid": tpid,
"ID": "DR_Voice_UK",
"DestinationRates": [{
"DestinationId": "Dest_International_UK",
"RateId": "Rate_Voice_UK",
"RoundingMethod": "*up",
"RoundingDecimals": 4
}]
}]
})

# Link Verizon PLMN to roaming data rate
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestinationRate',
'params': [{
"TPid": tpid,
"ID": "DR_Data_Roaming_US_Premium",
"DestinationRates": [{
"DestinationId": "Dest_PLMN_US_Verizon",
"RateId": "Rate_Data_Roaming_US_Premium",
"RoundingMethod": "*up",
"RoundingDecimals": 4
}]
}]
})

创建计费计划

将所有 DestinationRates 组合到一个计费计划中:

OCS_Obj.SendData({
'method': 'ApierV2.SetTPRatingPlan',
'params': [{
"TPid": tpid,
"ID": "RatingPlan_Standard_PAYG",
"RatingPlanBindings": [
# Voice rates (higher weight = more specific)
{"DestinationRatesId": "DR_Voice_UK", "TimingId": "*any", "Weight": 40},
{"DestinationRatesId": "DR_Voice_Domestic", "TimingId": "*any", "Weight": 20},

# SMS rates
{"DestinationRatesId": "DR_SMS_Domestic", "TimingId": "*any", "Weight": 20},

# Data roaming rates
{"DestinationRatesId": "DR_Data_Roaming_US_Premium", "TimingId": "*any", "Weight": 50}
]
}]
})

加载资费计划

最后,将资费计划加载到 CGRateS 中:

# Load tariff plan
OCS_Obj.SendData({
'method': 'ApierV1.LoadTariffPlanFromStorDb',
'params': [{
"TPid": tpid,
"DryRun": False,
"Validate": True
}]
})

# Reload cache
OCS_Obj.SendData({
'method': 'CacheSv1.ReloadCache',
'params': [{
"Tenant": tenant,
"DestinationIDs": ["*all"]
}]
})

另请参阅:

最佳实践

1. 对本网进行具体定义

# Good - specific home network
"DestinationIDs": "Dest_PLMN_OnNet", # mcc505.mnc057

# Bad - too broad, matches competitors
"DestinationIDs": "Dest_PLMN_AU_All", # mcc505 (all AU operators)

2. 使用有意义的目的地名称

# Good - self-documenting
Dest_PLMN_US_Verizon
Dest_International_UK
Dest_PLMN_Zone_Europe

# Bad - unclear
Dest_Data_1
Dest_Voice_Package

3. 逻辑上分组相关目的地

# Good - logical grouping
Dest_Domestic_All
Dest_Domestic_TollFree
Dest_Domestic_Premium

# Bad - too granular
Dest_Area_Code_212
Dest_Area_Code_213
Dest_Area_Code_214

4. 记录 PLMN 来源

定义 PLMN 目的地时,添加注释以指示 MCC/MNC 代码的来源:

# Verizon Wireless
# Source: https://www.mcc-mnc.com/ (verified 2024-12)
OCS_Obj.SendData({
'method': 'ApierV2.SetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_US_Verizon",
"Prefixes": [
"mcc310.mnc004", # Verizon - Nationwide
"mcc310.mnc010", # Verizon - East
...
]
}]
})

故障排除

问题:余额不匹配目的地

症状: 客户有余额,但无法使用于特定目的地

检查:

# 1. 验证目的地是否存在
OCS_Obj.SendData({
'method': 'ApierV2.GetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_US_Verizon"
}]
})

# 2. 检查余额 DestinationIDs 字段
# 确保它包含目的地或 "*any"

# 3. 对于 PLMN:验证客户是否实际在该网��上
# 检查 Diameter CCR 消息中的 Visited-PLMN-Id AVP

问题:数据使用计入漫游

症状: 国内数据使用消耗漫游余额而不是本地余额

原因: 客户的 PLMN 未在 Dest_PLMN_OnNet 中定义

解决方案:

# 检查客户在哪个 PLMN(来自 Diameter CCR)
# 验证余额是否包括该 PLMN:

OCS_Obj.SendData({
'method': 'ApierV2.GetTPDestination',
'params': [{
"TPid": tpid,
"ID": "Dest_PLMN_OnNet"
}]
})
# 确保前缀包括客户的实际网络 PLMN
# 示例:["mcc505.mnc057"] 必须与客户的 SIM 网络匹配

问题:国际电话无法拨打

症状: 客户有“国际分钟”,但拨打失败

检查:

  1. 目的地前缀:拨打的号码是否与目的地前缀匹配?
    • 拨打 +44-20-xxxx → 需要目的地前缀为“44”
  2. 余额 DestinationIDs:余额是否包括该目的地?
    • 检查余额是否包含 "DestinationIDs": "Dest_International_UK""Dest_International_All"
  3. 余额未过期:检查 ExpiryTime
  4. 余额有单位:检查 Units > 0

相关文档