From bb5a5ec6ef53d5db5dca1c3d3620fd80d798c6b4 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 31 Mar 2026 18:11:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20stopCards=20=E5=81=9C=E6=9C=BA=E6=97=B6?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=86=99=E5=85=A5=20stop=5Freason=20?= =?UTF-8?q?=E5=92=8C=20stopped=5Fat=20=E5=AD=97=E6=AE=B5?= 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 --- internal/task/polling_handler.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/task/polling_handler.go b/internal/task/polling_handler.go index beaa751..4c59b50 100644 --- a/internal/task/polling_handler.go +++ b/internal/task/polling_handler.go @@ -365,7 +365,7 @@ func (h *PollingHandler) stopCardByUsageExhausted(ctx context.Context, card *mod updates := map[string]any{ "network_status": 0, // 停机 "stopped_at": now, - "stop_reason": "套餐流量耗尽自动停机", + "stop_reason": constants.StopReasonTrafficExhausted, "updated_at": now, } if err := h.db.Model(&model.IotCard{}). @@ -686,12 +686,13 @@ func (h *PollingHandler) stopCards(ctx context.Context, cards []*model.IotCard, zap.String("iccid", card.ICCID), zap.String("reason", "套餐超额")) - // 更新数据库:卡的网络状态 now := time.Now() if err := h.db.Model(&model.IotCard{}). Where("id = ?", card.ID). Updates(map[string]any{ - "network_status": 0, // 停机 + "network_status": 0, + "stopped_at": now, + "stop_reason": constants.StopReasonTrafficExhausted, "updated_at": now, }).Error; err != nil { h.logger.Error("更新卡状态失败", zap.Uint("card_id", card.ID), zap.Error(err)) @@ -1018,7 +1019,7 @@ func (h *PollingHandler) HandleProtectConsistencyCheck(ctx context.Context, t *a h.db.Model(&model.IotCard{}).Where("id = ?", card.ID).Updates(map[string]any{ "network_status": constants.NetworkStatusOffline, "stopped_at": time.Now(), - "stop_reason": "保护期一致性检查自动停机", + "stop_reason": constants.StopReasonProtectPeriod, }) h.updateCardCache(ctx, card.ID, map[string]any{"network_status": constants.NetworkStatusOffline}) return nil