Files
junhong_cmp_fiber/pkg/constants/integration_log.go
break 5e552d99bc 收口审计治理与套餐任务进展
Constraint: 在线热修前必须保存当前迭代分支全部有效代码进展
Confidence: medium
Scope-risk: broad
Directive: 后续修改需保持审计事件与业务事务边界一致
Tested: git diff --cached --check
Not-tested: 未运行全量测试,提交用于切换分支前保存既有工作
2026-08-05 14:30:54 +08:00

201 lines
9.7 KiB
Go

package constants
import "time"
const (
// IntegrationIDMaxLength 是外部交互稳定ID的数据库长度上限。
IntegrationIDMaxLength = 64
// IntegrationTriggerSeriesMaxLength 是技术尝试序列ID的数据库长度上限。
IntegrationTriggerSeriesMaxLength = 64
// IntegrationCorrelationIDMaxLength 是跨业务链路关联ID的数据库长度上限。
IntegrationCorrelationIDMaxLength = 100
// IntegrationResourceIDMaxLength 是外部交互本地资源ID的数据库长度上限。
IntegrationResourceIDMaxLength = 128
// IntegrationResourceKeyMaxLength 是外部交互资源稳定Key的数据库长度上限。
IntegrationResourceKeyMaxLength = 128
// IntegrationProviderMessageMaxLength 是外部交互结果摘要的数据库长度上限。
IntegrationProviderMessageMaxLength = 500
// IntegrationSafeMessagePrefix 标识调用方已提供的受控可读业务结果摘要。
IntegrationSafeMessagePrefix = "业务结果摘要:"
// IntegrationQueryMaxRange 是调查列表允许的最大连续时间范围。
IntegrationQueryMaxRange = 31 * 24 * time.Hour
// IntegrationPendingStaleAfter 是待处理尝试进入陈旧统计的时长。
IntegrationPendingStaleAfter = 5 * time.Minute
)
const (
// IntegrationDirectionInbound 表示外部系统调用本系统。
IntegrationDirectionInbound = "inbound"
// IntegrationDirectionOutbound 表示本系统调用外部系统。
IntegrationDirectionOutbound = "outbound"
)
const (
// IntegrationProviderCTCC 表示中国电信回调提供方。
IntegrationProviderCTCC = "ctcc"
// IntegrationOperationCTCCRealnameCallback 表示中国电信实名结果回调。
IntegrationOperationCTCCRealnameCallback = "realname_callback"
// IntegrationProviderCMCC 表示中国移动回调提供方。
IntegrationProviderCMCC = "cmcc"
// IntegrationOperationCMCCRealnameCallback 表示中国移动实名结果回调。
IntegrationOperationCMCCRealnameCallback = "realname_callback"
// IntegrationProviderCUCC 表示中国联通回调提供方。
IntegrationProviderCUCC = "cucc"
// IntegrationOperationCUCCRealnameRemovalCallback 表示中国联通解除实名回调。
IntegrationOperationCUCCRealnameRemovalCallback = "realname_removal_callback"
// IntegrationOperationCUCCRealnameCallback 表示中国联通实名成功回调。
IntegrationOperationCUCCRealnameCallback = "realname_callback"
// IntegrationInboundProcessingLease 表示入站回调 pending 记录允许恢复前的处理租约。
IntegrationInboundProcessingLease = time.Minute
// IntegrationProviderWechatPay 表示微信支付提供方。
IntegrationProviderWechatPay = "wechat_pay"
// IntegrationProviderAlipay 表示支付宝提供方。
IntegrationProviderAlipay = "alipay"
// IntegrationProviderFuiou 表示富友支付提供方。
IntegrationProviderFuiou = "fuiou"
// IntegrationOperationPaymentPreCreate 表示扫码支付预下单。
IntegrationOperationPaymentPreCreate = "payment_precreate"
// IntegrationOperationPaymentQuery 表示支付订单查询。
IntegrationOperationPaymentQuery = "payment_query"
// IntegrationOperationPaymentCallback 表示支付渠道异步回调。
IntegrationOperationPaymentCallback = "payment_callback"
// IntegrationResourceTypeAgentRechargePayment 表示代理充值支付单资源。
IntegrationResourceTypeAgentRechargePayment = "agent_recharge_payment"
// IntegrationResourceTypePayment 表示通用支付记录资源。
IntegrationResourceTypePayment = "payment"
)
const (
// IntegrationResultPending 表示外部尝试已建立但尚未终结。
IntegrationResultPending = "pending"
// IntegrationResultSuccess 表示外部尝试成功。
IntegrationResultSuccess = "success"
// IntegrationResultFailed 表示外部尝试明确失败。
IntegrationResultFailed = "failed"
// IntegrationResultUnknown 表示请求已发出但结果未知,需要按记录的策略恢复。
IntegrationResultUnknown = "unknown"
// IntegrationResultNotFound 表示外部资源不存在。
IntegrationResultNotFound = "not_found"
// IntegrationResultInvalidPayload 表示入站载荷无效。
IntegrationResultInvalidPayload = "invalid_payload"
// IntegrationResultConflict 表示入站事实存在唯一性或幂等冲突。
IntegrationResultConflict = "conflict"
// IntegrationResultIgnored 表示外部尝试被安全忽略。
IntegrationResultIgnored = "ignored"
// IntegrationResultMerged 表示尝试被合并且未发送请求。
IntegrationResultMerged = "merged"
// IntegrationResultRateLimited 表示尝试因限频未发送请求。
IntegrationResultRateLimited = "rate_limited"
// IntegrationResultCompleted 表示业务已达预期,尝试提前完成且未发送请求。
IntegrationResultCompleted = "completed"
// IntegrationResultCancelled 表示尝试已取消。
IntegrationResultCancelled = "cancelled"
)
// IntegrationResultName 返回外部尝试结果的中文名称。
func IntegrationResultName(result string) string {
names := map[string]string{
IntegrationResultPending: "待处理",
IntegrationResultSuccess: "成功",
IntegrationResultFailed: "失败",
IntegrationResultUnknown: "结果未知",
IntegrationResultNotFound: "未找到",
IntegrationResultInvalidPayload: "无效载荷",
IntegrationResultConflict: "冲突",
IntegrationResultIgnored: "已忽略",
IntegrationResultMerged: "已合并",
IntegrationResultRateLimited: "已限频",
IntegrationResultCompleted: "已提前完成",
IntegrationResultCancelled: "已取消",
}
return names[result]
}
const (
// IntegrationResultCategoryProcessing 表示仍在处理。
IntegrationResultCategoryProcessing = "processing"
// IntegrationResultCategorySucceeded 表示外部请求实际成功。
IntegrationResultCategorySucceeded = "succeeded"
// IntegrationResultCategoryIndeterminate 表示结果无法确认。
IntegrationResultCategoryIndeterminate = "indeterminate"
// IntegrationResultCategoryFailed 表示外部请求或载荷明确失败。
IntegrationResultCategoryFailed = "failed"
// IntegrationResultCategoryNotSent 表示外部请求未发送。
IntegrationResultCategoryNotSent = "not_sent"
)
// IntegrationResultCategory 返回外部尝试的稳定派生类别。
func IntegrationResultCategory(result string) string {
switch result {
case IntegrationResultPending:
return IntegrationResultCategoryProcessing
case IntegrationResultSuccess:
return IntegrationResultCategorySucceeded
case IntegrationResultUnknown:
return IntegrationResultCategoryIndeterminate
case IntegrationResultFailed, IntegrationResultNotFound, IntegrationResultInvalidPayload, IntegrationResultConflict:
return IntegrationResultCategoryFailed
case IntegrationResultIgnored, IntegrationResultMerged, IntegrationResultRateLimited, IntegrationResultCompleted, IntegrationResultCancelled:
return IntegrationResultCategoryNotSent
default:
return ""
}
}
// IntegrationProviderName 返回外部提供方中文名称。
func IntegrationProviderName(provider string) string {
names := map[string]string{
IntegrationProviderCTCC: "中国电信", IntegrationProviderCMCC: "中国移动",
IntegrationProviderCUCC: "中国联通", IntegrationProviderWechatPay: "微信支付",
IntegrationProviderAlipay: "支付宝", IntegrationProviderFuiou: "富友支付", IntegrationProviderWeCom: "企业微信",
IntegrationProviderGateway: "Gateway",
}
if name := names[provider]; name != "" {
return name
}
return "未知提供方"
}
// IntegrationDirectionName 返回外部交互方向中文名称。
func IntegrationDirectionName(direction string) string {
switch direction {
case IntegrationDirectionInbound:
return "入站"
case IntegrationDirectionOutbound:
return "出站"
default:
return "未知方向"
}
}
// IntegrationOperationName 返回已注册外部操作中文名称。
func IntegrationOperationName(operation string) string {
names := map[string]string{
IntegrationOperationCTCCRealnameCallback: "接收实名结果回调",
IntegrationOperationCUCCRealnameRemovalCallback: "接收解除实名回调",
IntegrationOperationPaymentPreCreate: "支付预下单", IntegrationOperationPaymentQuery: "支付查单",
IntegrationOperationPaymentCallback: "接收支付回调",
IntegrationOperationWeComAccessToken: "获取企业微信访问令牌",
IntegrationOperationWeComVisibleMembers: "查询企业微信可见成员",
IntegrationOperationWeComVisibleDepartments: "查询企业微信可见部门",
IntegrationOperationWeComTemplateDetail: "查询企业微信审批模板",
IntegrationOperationWeComAttachmentUpload: "上传企业微信审批附件",
IntegrationOperationWeComApprovalSubmit: "提交企业微信审批",
IntegrationOperationWeComApprovalCallback: "接收企业微信审批回调",
IntegrationOperationWeComApprovalDetail: "查询企业微信审批详情",
IntegrationOperationWeComApprovalInfo: "查询企业微信审批单号",
IntegrationOperationGatewayRealname: "查询实名状态", IntegrationOperationGatewayTraffic: "查询流量",
IntegrationOperationGatewayNetwork: "查询卡网络状态", IntegrationOperationGatewayDeviceInfo: "查询设备信息",
IntegrationOperationGatewaySpeedTier: "设置卡限速档位", IntegrationOperationGatewayStopCard: "停机",
IntegrationOperationGatewayStartCard: "复机", IntegrationOperationGatewaySetWiFi: "设置设备 Wi-Fi",
IntegrationOperationGatewaySwitchMode: "设置设备切卡模式", IntegrationOperationGatewaySwitchCard: "切换设备当前卡",
IntegrationOperationGatewayReboot: "重启设备",
IntegrationOperationGatewayReset: "恢复设备出厂设置",
}
if name := names[operation]; name != "" {
return name
}
return "未知外部操作"
}