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})