From a3cf98940ad8693c1f21a406e82d8fd54bc4562f Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Tue, 15 Sep 2026 09:51:39 +0800 Subject: [PATCH] fix(#279): only auto-link active pdd products --- server/app/goauto/task/image_search_link.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/app/goauto/task/image_search_link.go b/server/app/goauto/task/image_search_link.go index a10ab59..5cdf7e2 100644 --- a/server/app/goauto/task/image_search_link.go +++ b/server/app/goauto/task/image_search_link.go @@ -40,6 +40,16 @@ func (service *Service) autoLinkImageSearch(ctx context.Context, taskID uint64) if strings.ToUpper(strings.TrimSpace(product.Currency)) != "CNY" { return nil } + var pdd models.PDDProduct + if err := service.DB.WithContext(ctx).Select("id", "status").First(&pdd, *task.PDDProductID).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil + } + return internalError(err) + } + if pdd.Status != "active" { + return nil + } result := service.DB.WithContext(ctx).Model(&models.ShopeeProduct{}). Where("id = ? AND pdd_product_id IS NULL AND image_search_linked = ?", product.ID, false). Updates(map[string]any{"pdd_product_id": *task.PDDProductID, "image_search_linked": true})