From 49e8ebed60f388a64007f147784085b721e4a696 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 31 Mar 2026 18:12:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=87=E6=9C=9F=E5=A5=97=E9=A4=90?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=89=A9=E5=B1=95=E8=A6=86=E7=9B=96=20Deplet?= =?UTF-8?q?ed=20=E7=8A=B6=E6=80=81=EF=BC=88status=20IN=20(1,2)=EF=BC=89?= 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/polling/package_activation_handler.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/polling/package_activation_handler.go b/internal/polling/package_activation_handler.go index 715c022..546b228 100644 --- a/internal/polling/package_activation_handler.go +++ b/internal/polling/package_activation_handler.go @@ -59,7 +59,7 @@ func NewPackageActivationHandler( func (h *PackageActivationHandler) HandlePackageActivationCheck(ctx context.Context) error { startTime := time.Now() - // 任务 19.2: 查询已过期的主套餐(status=1 AND expires_at <= NOW) + // 任务 19.2: 查询已过期的主套餐(status IN (1,2) AND expires_at <= NOW) expiredPackages, err := h.findExpiredMainPackages(ctx) if err != nil { h.logger.Error("查询过期主套餐失败", zap.Error(err)) @@ -97,12 +97,11 @@ func (h *PackageActivationHandler) findExpiredMainPackages(ctx context.Context) var packages []*model.PackageUsage now := time.Now() - // 查询 status=1 (生效中) AND expires_at <= NOW AND master_usage_id IS NULL (主套餐) err := h.db.WithContext(ctx). - Where("status = ?", constants.PackageUsageStatusActive). + Where("status IN ?", []int{constants.PackageUsageStatusActive, constants.PackageUsageStatusDepleted}). Where("expires_at <= ?", now). - Where("master_usage_id IS NULL"). // 主套餐没有 master_usage_id - Limit(1000). // 每次最多处理 1000 个,避免长事务 + Where("master_usage_id IS NULL"). + Limit(1000). Find(&packages).Error return packages, err