feat: 展示蝦皮主图和店铺 (#142)

This commit is contained in:
chengma
2026-08-11 11:18:51 +08:00
parent a441dfef87
commit 38d6a0a04b
22 changed files with 555 additions and 101 deletions
+35 -11
View File
@@ -18,8 +18,10 @@ import (
//
// 一行对应一个**商品**,不是一个 SKU——见工单 #41。
type ShopeeProductView struct {
GoodsID string
Title string
GoodsID string
Title string
ImageURL string
ShopName string
// ColorCount / SizeCount 只统计 parse_ok = 1 的 SKU(`[必须]`,见 #41)。
ColorCount int
@@ -107,6 +109,8 @@ func ListShopeeProducts(db *sql.DB, filter repository.ShopeeFilter, page int) (*
v := ShopeeProductView{
GoodsID: r.GoodsID,
Title: r.Title,
ImageURL: r.ImageURL,
ShopName: r.ShopeeShopName,
ColorCount: r.ColorCount,
SizeCount: r.SizeCount,
SKUCount: r.SKUCount,
@@ -204,10 +208,14 @@ type ShopeeSpecView struct {
// ShopeeProductDetail 是双击弹窗要显示的全部内容。
type ShopeeProductDetail struct {
GoodsID string
Title string
ShopeeStatus string
MainSKUCode string
GoodsID string
Title string
ShopeeStatus string
MainSKUCode string
ImageURL string
ShopName string
ImageSourceText, ImageObservedAt string
ShopNameSourceText, ShopNameObservedAt string
PddURL string
PddGoodsID string
@@ -238,11 +246,17 @@ func GetShopeeProductDetail(db *sql.DB, goodsID string) (*ShopeeProductDetail, e
}
d := &ShopeeProductDetail{
GoodsID: p.GoodsID,
Title: p.Title,
ShopeeStatus: p.ShopeeStatus,
MainSKUCode: p.MainSKUCode,
PddGoodsID: p.PddGoodsID,
GoodsID: p.GoodsID,
Title: p.Title,
ShopeeStatus: p.ShopeeStatus,
MainSKUCode: p.MainSKUCode,
ImageURL: p.ImageURL,
ShopName: p.ShopeeShopName,
ImageSourceText: catalogFieldSourceText(p.ImageSource, p.ImageIsManual),
ImageObservedAt: formatLocalTime(p.ImageObservedAt),
ShopNameSourceText: catalogFieldSourceText(p.ShopNameSource, p.ShopNameIsManual),
ShopNameObservedAt: formatLocalTime(p.ShopNameObservedAt),
PddGoodsID: p.PddGoodsID,
}
if d.Title == "" {
d.Title = placeholder
@@ -321,3 +335,13 @@ func GetShopeeProductDetail(db *sql.DB, goodsID string) (*ShopeeProductDetail, e
}
return d, nil
}
func catalogFieldSourceText(source string, manual bool) string {
if manual {
return "人工维护"
}
if strings.TrimSpace(source) == "" {
return "—"
}
return source
}