chore: 并入 iotlcm-worker-svr 历史到 worker-svr/(原提交 96f0f4e)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:03 +08:00
422 changed files with 80993 additions and 0 deletions
@@ -0,0 +1,12 @@
package consts
// BatchSubBatchSize 是批量开停数据 / 停复机执行时,单个上游通道每次请求携带的卡数量上限。
// upstream-chan 对同一通道按卡串行调用运营商接口,单个请求耗时随卡数线性增长;
// 因此超时预算必须按「单卡预算 × 卡数」计算并配置足够上限(见 upstream.proxy.maxTimeout),
// 不能依赖固定 2 分钟上限,否则请求仍在上游办理就会被判失败。
const BatchSubBatchSize = 100
// BatchSubBatchConcurrency 是同一通道内子批次的并发度,受信号量限制:
// 即最多同时向上游发起 BatchSubBatchConcurrency 个请求,等价于最多同时发起同样数量的运营商调用,
// 既避免串行过慢,也避免无节制并发打爆运营商限流。如需更保守可调小该值。
const BatchSubBatchConcurrency = 5
+160
View File
@@ -0,0 +1,160 @@
package consts
func FormalPackageTypes() []int { return []int{PackageTypeCard, PackageTypePool} }
func IsAddPackageType(packageType int) bool {
return packageType == PackageTypeCardAddPackage || packageType == PackageTypePoolAddPackage
}
const (
BatchTypeInbound = 1
BatchTypeAllocate = 3
BatchTypeCardAddPackage = 11
BatchTypePoolAddPackage = 12
BatchTypeSimCardStart = 103
BatchTypeSimCardStop = 104
BatchTypeSimCardRestart = 105
BatchTypeSimCardCancel = 106
BatchTypeSimCardUnsub = 108
BatchTypeDataCut = 107
BatchTypeDataStart = 109
BatchTypeDataStop = 110
BatchTypeSimWarningConfig = 40
BatchTypeTrafficCutoffConfig = 41
BatchTypeTrafficCutoff = BatchTypeTrafficCutoffConfig // Deprecated: use BatchTypeTrafficCutoffConfig.
// 异步续费/变更扩展
BatchTypePrepare = 4 // 预处理(renew/change 共用 prepare)
BatchTypeRenew = 101 // 卡续费
BatchTypeChange = 102 // 卡变更套餐
// t_sim_card_bind_pkg.package_type 中,只有正式卡套餐和池套餐参与续费/变更判断。
PackageTypeCard = 101
PackageTypePool = 102
PackageTypeCardAddPackage = 103
PackageTypePoolAddPackage = 104
BatchSourceTypeBatchSelect = 0
BatchSourceTypeRange = 1
BatchSourceTypeBatchInput = 2
BatchSourceTypeFile = 3
BatchSourceTypeScheduled = 4
BatchSourceTypeExcel = BatchSourceTypeFile
BatchSourceTypeInput = BatchSourceTypeBatchInput
BatchNoPrefixCardAddPackage = "ADP"
BatchNoPrefixPoolAddPackage = "PAP"
SimCardStatusOperTypeStop = "0"
SimCardStatusOperTypeStart = "1"
RestartPhaseCreated = "created"
RestartPhaseWaitingResume = "waiting_resume"
RestartPhaseResuming = "resuming"
RestartPhaseFinished = "finished"
SimBossCardStatusActivated = 2
SimBossCardStatusStopped = 4
SimBossCardStatusCanceled = 9
SimApnOperTypeOpen = "0"
SimApnOperTypeStop = "1"
SimApnNameDefault = "CMIOT"
SimDataServiceStatusEnabled = 1
SimDataServiceStatusDisabled = 0
BatchAsyncStatusPending = 1
BatchAsyncStatusProcessing = 2
BatchAsyncStatusSuccess = 3
BatchAsyncStatusFailed = 4
BatchAsyncStatusPartialSuccess = 5
BatchAsyncStatusUnknown = 6
BatchAsyncStatusReview = 6
BatchRunResultPending = 0
BatchRunResultRunning = 1
BatchRunResultSuccess = 2
BatchRunResultFailed = 3
BatchRunResultPartialSuccess = 4
BatchRunResultUnknown = 5
BatchRunResultReview = 5
BatchDetailStatusPending = 0
BatchDetailStatusRunning = 1
BatchDetailStatusSuccess = 2
BatchDetailStatusFailed = 3
BatchDetailStatusUnknown = 4
BatchDetailStatusNotExecuted = 5
ResourceTypeExcel = 1
DownloadStatusGenerated = 1
ResourceExportSceneCardAddPackage = 11
ResourceExportScenePoolAddPackage = 12
// 卡套餐有效状态
PackageStatusNone = 0
PackageStatusPending = 1
PackageStatusEffective = 2
PackageStatusExpired = 3
// 订购记录有效状态(t_sim_card_bind_pkg.effective_status)
EffectiveStatusPending = 0
EffectiveStatusEffective = 1
EffectiveStatusExpired = 2
EffectiveStatusTerminated = 3
EffectiveStatusVoided = 4
// 退订状态(t_order.return_status)
OrderReturnStatusNone = 0
OrderReturnStatusSuccess = 4
OrderReturnStatusPartial = 3
// Renew/change order contract. These values mirror the Admin cardpackage
// domain and the production t_order/t_order_item enum contract.
OrderTypeCardSubscribe = 1
OrderTypeCardRenew = 2
OrderTypeCardChange = 3
OrderStatusCompleted = 5
CustomerTypeAgent = 1
PayTypeOffline = 3
PayTypeBalance = 4
PayStatusPaid = 2
ProductTypeCard = 1
PayModeYearMonth = 1
ShippingMethodNone = 3
PackageBusinessTypeSubscribe = 0
PackageBusinessTypeChange = 1
PackageBusinessTypeRenew = 2
ResourceBatchDownloadTaskSimCardAddPackage = "单卡加油包结果"
ResourceBatchDownloadTaskSimPoolAddPackage = "流量池加油包结果"
SimCardAddPackageMaxFileSize = 50 << 20
SimPoolAddPackageMaxFileSize = 50 << 20
SimCardAddPackageSubDirImportExcel = "sim-card-add-package/import"
SimCardAddPackageSubDirResultExcel = "sim-card-add-package/result"
SimPoolAddPackageSubDirImportExcel = "sim-pool-add-package/import"
SimPoolAddPackageSubDirResultExcel = "sim-pool-add-package/result"
// 续费/变更结果目录
SimCardRenewResultSubDir = "sim-card-renew/result"
SimCardChangeResultSubDir = "sim-card-change/result"
// 续费/变更结果任务名(沿用 Admin 约定)
ResultTaskSimCardRenew = "卡续费结果"
ResultTaskSimCardChange = "卡变更套餐结果"
ResultTaskSimCardPrepare = "卡续费/变更预处理结果"
)
// RenewPriceSource 续费/变更价格来源
const (
RenewPriceSourceSystem = "system"
RenewPriceSourceAgentDefault = "agentDefault"
RenewPriceSourceTarget = "target"
)
@@ -0,0 +1,42 @@
package consts
import "strings"
const (
BillingMethodMonth = 1
BillingMethodYear = 2
RenewDurationUnitMonth = "month"
RenewDurationUnitYear = "year"
)
func BillingMethodDurationUnit(billingMethod int) string {
if billingMethod == BillingMethodMonth {
return RenewDurationUnitMonth
}
return RenewDurationUnitYear
}
func NormalizeRenewDurationUnit(unit string) string {
if strings.EqualFold(strings.TrimSpace(unit), RenewDurationUnitMonth) {
return RenewDurationUnitMonth
}
return RenewDurationUnitYear
}
func RenewDurationUnitText(unit string) string {
if NormalizeRenewDurationUnit(unit) == RenewDurationUnitMonth {
return "个月"
}
return "年"
}
func DurationValueToMonths(unit string, value int) int {
if value <= 0 {
return 0
}
if NormalizeRenewDurationUnit(unit) == RenewDurationUnitMonth {
return value
}
return value * 12
}
+34
View File
@@ -0,0 +1,34 @@
package consts
const (
QueueTrafficUsageDailyRetry = "iotlcm.traffic_usage.daily.retry"
QueueTrafficUsageMonthlyRetry = "iotlcm.traffic_usage.monthly.retry"
QueueTrafficUsageMonthlyStart = "iotlcm.traffic_usage.monthly.start"
// QueueTrafficUsageDailyStart carries one command per full daily usage run.
// Admin publishes it; Worker owns the card scan and Redis production.
QueueTrafficUsageDailyStart = "iotlcm.traffic_usage.daily.start"
// QueueTrafficUsageMonthlyHistoryStart carries one command per full monthly
// usage history run, which writes the TDengine monthly table. It is distinct
// from QueueTrafficUsageMonthlyStart, which fills the MySQL current-month
// snapshot.
QueueTrafficUsageMonthlyHistoryStart = "iotlcm.traffic_usage.monthly_history.start"
QueueSimStatusQueueStart = "iotlcm.sim_status.queue.start"
QueueSimStatusQueueTask = "iotlcm.sim_status.queue.task"
QueueImeiQueueStart = "iotlcm.imei.queue.start"
QueueWorkOrderAutoClose = "iotlcm.work_order.auto_close"
QueueBalanceRechargeTimeout = "iotlcm.balance.recharge.timeout"
QueueBalanceRechargeDelay = "iotlcm.balance.recharge.delay"
QueueWorkerDiagnostic = "iotlcm.worker.diagnostic"
QueueBatchExecute = "iotlcm.batch.execute"
QueueBatchExecuteRetry = "iotlcm.batch.execute.retry"
QueueBatchExecuteDeadLetter = "iotlcm.batch.execute.dlq"
QueueBatchRestartResumeDelay = "iotlcm.batch.restart.resume.delay"
QueuePackageCustomerSync = "iotlcm.package_customer.sync"
QueueChannelRefresh = "iotlcm.channel.refresh"
// QueueDataReviewQuery 承载"手动同步上游结果"命令:Admin 发布父批号,
// Worker 只对既有 operationId 做只读补查并回写,绝不重发办理。
QueueDataReviewQuery = "iotlcm.data.review.query"
// QueueBalanceRechargeDeadLetter 保存重试次数耗尽后仍失败的充值超时消息,
// 供人工排查(例如支付宝凭据未配置导致的永久失败),不再自动重投。
QueueBalanceRechargeDeadLetter = "iotlcm.balance.recharge.dlq"
)
+11
View File
@@ -0,0 +1,11 @@
package consts
const (
DefaultSystemTenantCode = "000000"
SuperAdminRoleId = int64(1)
SysRoleMenuDataScopeRole = "0"
SysRoleDataScopeAll = "1"
SysRoleDataScopeCustom = "2"
SysRoleDataScopeDeptAndBelow = "4"
QueueAgentRoleSync = "iotlcm.agent.role.sync"
)