Files
junhong_cmp_fiber/pkg/constants/iot.go
huang 66e12e9629
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m57s
订单相关以及佣金相关修复
2026-04-30 09:52:39 +08:00

428 lines
11 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package constants
// ========================================
// IoT SIM 管理系统常量定义
// ========================================
// ========================================
// 1. 核心业务常量
// ========================================
// IoT 卡状态
const (
IotCardStatusInStock = 1 // 在库
IotCardStatusDistributed = 2 // 已分销
IotCardStatusActivated = 3 // 已激活
IotCardStatusSuspended = 4 // 已停用
)
// IoT 卡业务类型
const (
CardCategoryNormal = "normal" // 普通卡(需要实名认证)
CardCategoryIndustry = "industry" // 行业卡(无需实名认证)
)
// 设备状态
const (
DeviceStatusInStock = 1 // 在库
DeviceStatusDistributed = 2 // 已分销
DeviceStatusActivated = 3 // 已激活
DeviceStatusSuspended = 4 // 已停用
)
// 号卡状态
const (
NumberCardStatusOnSale = 1 // 在售
NumberCardStatusOffSale = 2 // 下架
)
// IoT 卡激活状态
const (
ActivationStatusInactive = 0 // 未激活
ActivationStatusActive = 1 // 已激活
)
// IoT 卡实名状态
const (
RealNameStatusNotVerified = 0 // 未实名
RealNameStatusVerified = 1 // 已实名
)
// PollingRealnameReversalThreshold 实名逆转防抖阈值:连续 N 次检测到逆转才触发停机
const PollingRealnameReversalThreshold = 3
// IoT 卡网络状态
const (
NetworkStatusOffline = 0 // 停机
NetworkStatusOnline = 1 // 开机
)
// IoT 卡停机原因
const (
StopReasonTrafficExhausted = "traffic_exhausted" // 流量耗尽
StopReasonManual = "manual" // 手动停机
StopReasonArrears = "arrears" // 欠费
StopReasonProtectPeriod = "protect_period" // 保护期一致性检查自动停机
StopReasonNoPackage = "no_package" // 停机原因:无有效套餐
StopReasonNotRealname = "not_realname" // 停机原因:非行业卡且未完成实名认证
StopReasonCarrierStopped = "carrier_stopped" // 停机原因:运营商/Gateway 侧主动停机
)
// 套餐流量类型
const (
DataTypeReal = "real" // 真流量
DataTypeVirtual = "virtual" // 虚流量
)
// 套餐类型
const (
PackageTypeFormal = "formal" // 正式套餐
PackageTypeAddon = "addon" // 附加套餐
)
// 套餐价格配置状态
const (
PackagePriceConfigStatusUnconfigured = 0 // 未配置
PackagePriceConfigStatusGiftZero = 1 // 赠送 0 价
PackagePriceConfigStatusConfigured = 2 // 已配置非 0
)
// 订单类型
const (
OrderTypePackage = 1 // 套餐订单
OrderTypeNumberCard = 2 // 号卡订单
)
// 订单状态 (IoT 模块)
const (
IotOrderStatusPending = 1 // 待支付
IotOrderStatusPaid = 2 // 已支付
IotOrderStatusCompleted = 3 // 已完成
IotOrderStatusCancelled = 4 // 已取消
IotOrderStatusRefunded = 5 // 已退款
)
// 支付方式
const (
PaymentMethodWallet = "wallet" // 钱包
PaymentMethodOnline = "online" // 在线支付
PaymentMethodCarrier = "carrier" // 运营商支付
)
// 所有者类型(统一枚举,仅支持 platform 和 shop
const (
OwnerTypePlatform = "platform" // 平台
OwnerTypeShop = "shop" // 店铺(代理商)
)
// 企业卡授权状态
const (
EnterpriseCardAuthStatusValid = 1 // 有效
EnterpriseCardAuthStatusRevoked = 0 // 已回收
)
// 资产分配类型
const (
AssetAllocationTypeAllocate = "allocate" // 分配
AssetAllocationTypeRecall = "recall" // 回收
)
// 资产类型
const (
AssetTypeIotCard = "iot_card" // 物联网卡
AssetTypeDevice = "device" // 设备
)
// 实名认证策略
const (
RealnamePolicyNone = "none" // 无需实名
RealnamePolicyBeforeOrder = "before_order" // 先实名后充值/购买
RealnamePolicyAfterOrder = "after_order" // 先充值/购买后实名
)
// 放款类型
const (
PaymentTypeManual = "manual" // 人工打款
)
// 绑定状态
const (
BindStatusBound = 1 // 已绑定
BindStatusUnbound = 2 // 已解绑
)
// ========================================
// 2. 套餐和轮询相关常量
// ========================================
// 套餐使用类型
const (
PackageUsageTypeSingleCard = "single_card" // 单卡套餐
PackageUsageTypeDevice = "device" // 设备级套餐
)
// 注意:套餐使用状态常量已迁移至 constants.go扩展为 5 个状态0-4
// 轮询配置卡条件
const (
CardConditionNotRealName = "not_real_name" // 未实名
CardConditionRealName = "real_name" // 已实名
CardConditionActivated = "activated" // 已激活
CardConditionSuspended = "suspended" // 已停用
)
// 流量使用记录来源
const (
DataUsageSourcePolling = "polling" // 轮询
DataUsageSourceManual = "manual" // 手动
DataUsageSourceGateway = "gateway" // Gateway回调
)
// ========================================
// 3. 分佣相关常量
// ========================================
// 分佣类型
const (
CommissionTypeOneTime = "one_time" // 一次性分佣
CommissionTypeLongTerm = "long_term" // 长期分佣
CommissionTypeCombined = "combined" // 组合分佣
)
// 分佣模式
const (
CommissionModeFixed = "fixed" // 固定金额
CommissionModePercent = "percent" // 百分比
)
// 分佣状态
const (
CommissionStatusFrozen = 1 // 已冻结
CommissionStatusUnfreezing = 2 // 解冻中
CommissionStatusReleased = 3 // 已发放
CommissionStatusInvalid = 4 // 已失效
CommissionStatusPendingReview = 99 // 待人工修正(链路断裂,需平台处理)
)
// 阶梯类型([预留] 用于分佣阶梯功能,待产品规划)
const (
LadderTypeActivation = "activation" // 激活量([预留]
LadderTypePickup = "pickup" // 提货量([预留]
LadderTypeDeposit = "deposit" // 充值量([预留]
)
// 卡类型
const (
CardTypeNumberCard = "number_card" // 号卡
CardTypeIotCard = "iot_card" // IoT卡
)
// 审批类型([预留] 用于审批流程功能,待产品规划)
const (
ApprovalTypeAuto = "auto" // 自动([预留]
ApprovalTypeManual = "manual" // 人工([预留]
)
// 审批状态([预留] 用于审批流程功能,待产品规划)
const (
ApprovalStatusPending = 1 // 待审批([预留]
ApprovalStatusApproved = 2 // 已通过([预留]
ApprovalStatusRejected = 3 // 已拒绝([预留]
)
// ========================================
// 4. 财务管理常量
// ========================================
// 提现状态
const (
WithdrawalStatusPending = 1 // 待审核
WithdrawalStatusApproved = 2 // 已通过
WithdrawalStatusRejected = 3 // 已拒绝
WithdrawalStatusPaid = 4 // 已到账
)
// 提现方式
const (
WithdrawalMethodAlipay = "alipay" // 支付宝
WithdrawalMethodWechat = "wechat" // 微信
WithdrawalMethodBank = "bank" // 银行卡
)
// ========================================
// 5. 系统管理常量
// ========================================
// ========================================
// 运营商编码
// ========================================
const (
CarrierCodeCMCC = "CMCC" // 中国移动
CarrierCodeCUCC = "CUCC" // 中国联通
CarrierCodeCTCC = "CTCC" // 中国电信
CarrierCodeCBN = "CBN" // 广电
)
// ========================================
// 状态名称映射函数
// ========================================
// GetIotCardStatusName 获取 IoT 卡业务状态名称
// 对应 IotCardStatus* 常量1=在库, 2=已分销, 3=已激活, 4=已停用
func GetIotCardStatusName(status int) string {
switch status {
case IotCardStatusInStock:
return "在库"
case IotCardStatusDistributed:
return "已分销"
case IotCardStatusActivated:
return "已激活"
case IotCardStatusSuspended:
return "已停用"
default:
return "未知"
}
}
// GetActivationStatusName 获取激活状态名称
// 对应 ActivationStatus* 常量0=未激活, 1=已激活
func GetActivationStatusName(status int) string {
switch status {
case ActivationStatusInactive:
return "未激活"
case ActivationStatusActive:
return "已激活"
default:
return "未知"
}
}
// GetRealNameStatusName 获取实名状态名称
// 对应 RealNameStatus* 常量0=未实名, 1=已实名
func GetRealNameStatusName(status int) string {
switch status {
case RealNameStatusNotVerified:
return "未实名"
case RealNameStatusVerified:
return "已实名"
default:
return "未知"
}
}
// GetNetworkStatusName 获取网络状态名称
// 对应 NetworkStatus* 常量0=停机, 1=开机
func GetNetworkStatusName(status int) string {
switch status {
case NetworkStatusOffline:
return "停机"
case NetworkStatusOnline:
return "开机"
default:
return "未知"
}
}
// GetCommissionRecordStatusName 获取佣金记录状态名称
// 对应 CommissionStatus* 常量1=已冻结, 2=解冻中, 3=已发放, 4=已失效, 99=待人工修正
func GetCommissionRecordStatusName(status int) string {
switch status {
case CommissionStatusFrozen:
return "已冻结"
case CommissionStatusUnfreezing:
return "解冻中"
case CommissionStatusReleased:
return "已发放"
case CommissionStatusInvalid:
return "已失效"
case CommissionStatusPendingReview:
return "待人工修正"
default:
return "未知"
}
}
// GetOrderPaymentStatusName 获取订单支付状态名称
// 1=待支付, 2=已支付, 3=已取消, 4=已退款
func GetOrderPaymentStatusName(status int) string {
switch status {
case 1:
return "待支付"
case 2:
return "已支付"
case 3:
return "已取消"
case 4:
return "已退款"
default:
return "未知"
}
}
// GetOrderCommissionStatusName 获取订单佣金流程状态名称
// 1=待计算, 2=已完成, 3=待人工处理
func GetOrderCommissionStatusName(status int) string {
switch status {
case 1:
return "待计算"
case 2:
return "已完成"
case 3:
return "待人工处理"
default:
return "未知"
}
}
// GetOrderCommissionResultName 获取订单佣金业务结果名称
// 0=未知, 1=有佣金, 2=无佣金, 3=链路异常
func GetOrderCommissionResultName(result int) string {
switch result {
case 0:
return "未知"
case 1:
return "有佣金"
case 2:
return "无佣金"
case 3:
return "链路异常"
default:
return "未知"
}
}
// GetRefundStatusName 获取退款申请状态名称
// 1=待审批, 2=已通过, 3=已拒绝, 4=已退回
func GetRefundStatusName(status int) string {
switch status {
case 1:
return "待审批"
case 2:
return "已通过"
case 3:
return "已拒绝"
case 4:
return "已退回"
default:
return "未知"
}
}
// GetWithdrawalStatusName 获取提现申请状态名称
// 对应 WithdrawalStatus* 常量1=待审核, 2=已通过, 3=已拒绝, 4=已到账
func GetWithdrawalStatusName(status int) string {
switch status {
case WithdrawalStatusPending:
return "待审核"
case WithdrawalStatusApproved:
return "已通过"
case WithdrawalStatusRejected:
return "已拒绝"
case WithdrawalStatusPaid:
return "已到账"
default:
return "未知"
}
}