@@ -18,12 +18,10 @@ import (
|
||||
//
|
||||
// 一行对应一个**商品**,不是一个 SKU——见工单 #41。
|
||||
type ShopeeProductView struct {
|
||||
GoodsID string
|
||||
Title string
|
||||
ImageURL string
|
||||
ShopName string
|
||||
BusinessShopName string
|
||||
ShopUnlinked bool
|
||||
GoodsID string
|
||||
Title string
|
||||
ImageURL string
|
||||
ShopName string
|
||||
|
||||
// ColorCount / SizeCount 只统计 parse_ok = 1 的 SKU(`[必须]`,见 #41)。
|
||||
ColorCount int
|
||||
@@ -103,26 +101,24 @@ func ListShopeeProducts(db *sql.DB, filter repository.ShopeeFilter, page int) (*
|
||||
Rows: make([]ShopeeProductView, 0, len(rows)),
|
||||
Total: total,
|
||||
HasAnyProducts: hasAny > 0,
|
||||
IsFiltered: strings.TrimSpace(filter.Keyword) != "" || strings.TrimSpace(filter.ShopName) != "" || filter.Status != "" || filter.Shop != "" || filter.Image != "" || filter.StoreID != "" || filter.Deleted,
|
||||
IsFiltered: strings.TrimSpace(filter.Keyword) != "" || filter.Status != "" || filter.Deleted || filter.Unlinked,
|
||||
Page: page,
|
||||
PageSize: PageSize,
|
||||
TotalPages: totalPages,
|
||||
}
|
||||
for _, r := range rows {
|
||||
v := ShopeeProductView{
|
||||
GoodsID: r.GoodsID,
|
||||
Title: r.Title,
|
||||
ImageURL: r.ImageURL,
|
||||
ShopName: r.ShopeeShopName,
|
||||
BusinessShopName: r.BusinessShopName,
|
||||
ShopUnlinked: r.ShopID == "",
|
||||
ColorCount: r.ColorCount,
|
||||
SizeCount: r.SizeCount,
|
||||
SKUCount: r.SKUCount,
|
||||
PendingCount: r.PendingCount,
|
||||
SourceText: shopeeSourceText(r.Source),
|
||||
UpdatedAt: formatLocalTime(r.UpdatedAt),
|
||||
Deleted: r.IsDeleted(),
|
||||
GoodsID: r.GoodsID,
|
||||
Title: r.Title,
|
||||
ImageURL: r.ImageURL,
|
||||
ShopName: r.ShopeeShopName,
|
||||
ColorCount: r.ColorCount,
|
||||
SizeCount: r.SizeCount,
|
||||
SKUCount: r.SKUCount,
|
||||
PendingCount: r.PendingCount,
|
||||
SourceText: shopeeSourceText(r.Source),
|
||||
UpdatedAt: formatLocalTime(r.UpdatedAt),
|
||||
Deleted: r.IsDeleted(),
|
||||
}
|
||||
|
||||
if r.PddGoodsID == "" {
|
||||
@@ -194,23 +190,22 @@ func ShopeeStatusLabel(status string) string {
|
||||
return shopeeStatusTexts[status]
|
||||
}
|
||||
|
||||
// ShopeePresenceOptions 返回资料字段的三态选项。使用下拉框而不是复选框,
|
||||
// 让“全部”和“无资料”都有明确表达,不把未勾选误解成任意状态。
|
||||
func ShopeePresenceOptions(hasText, missingText string) []ShopeeStatusOption {
|
||||
// ShopeeSearchFieldOptions 返回关键词可以查询的三个字段。
|
||||
func ShopeeSearchFieldOptions() []ShopeeStatusOption {
|
||||
return []ShopeeStatusOption{
|
||||
{"", "全部"},
|
||||
{"has", hasText},
|
||||
{"missing", missingText},
|
||||
{"goods_id", "商品 ID"},
|
||||
{"title", "商品名称"},
|
||||
{"shop_name", "店铺名"},
|
||||
}
|
||||
}
|
||||
|
||||
// ParseShopeePresence 校验店铺/图片筛选参数;未知值按“全部”处理。
|
||||
func ParseShopeePresence(s string) string {
|
||||
// ParseShopeeSearchField 使用固定白名单,避免把请求参数当成 SQL 列名。
|
||||
func ParseShopeeSearchField(s string) string {
|
||||
value := strings.TrimSpace(s)
|
||||
if value == "has" || value == "missing" {
|
||||
if value == "title" || value == "shop_name" {
|
||||
return value
|
||||
}
|
||||
return ""
|
||||
return "goods_id"
|
||||
}
|
||||
|
||||
// ---------- 弹窗 ----------
|
||||
|
||||
Reference in New Issue
Block a user