From 7f42d198eba8d8a5076fe4d9e82ba29ad2478f6a Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 31 Mar 2026 18:11:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=20StopReasonProtectPe?= =?UTF-8?q?riod=20=E5=B8=B8=E9=87=8F=E5=92=8C=20RedisCardResumeLockKey=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- pkg/constants/iot.go | 1 + pkg/constants/redis.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/pkg/constants/iot.go b/pkg/constants/iot.go index 5fecc0d..3c83358 100644 --- a/pkg/constants/iot.go +++ b/pkg/constants/iot.go @@ -59,6 +59,7 @@ const ( StopReasonTrafficExhausted = "traffic_exhausted" // 流量耗尽 StopReasonManual = "manual" // 手动停机 StopReasonArrears = "arrears" // 欠费 + StopReasonProtectPeriod = "protect_period" // 保护期一致性检查自动停机 ) // 套餐流量类型 diff --git a/pkg/constants/redis.go b/pkg/constants/redis.go index cb77cd4..f90a6ef 100644 --- a/pkg/constants/redis.go +++ b/pkg/constants/redis.go @@ -289,6 +289,17 @@ func RedisPollingInitProgressKey() string { return "polling:init:progress" } +// ======================================== +// 复机并发保护相关 Redis Key +// ======================================== + +// RedisCardResumeLockKey 生成卡复机操作分布式锁的 Redis 键 +// 用途:防止同一张卡并发触发多次 gateway.StartCard +// 过期时间:30 秒 +func RedisCardResumeLockKey(cardID uint) string { + return fmt.Sprintf("card:resume:lock:%d", cardID) +} + // ======================================== // 套餐激活锁相关键 // ========================================