chore(catalog): 清理 LEWAN_ 列表过滤与商品图 UUID 历史回退
商品列表不再过滤镜像 SKU;图片只按英文 SKU 解析,修正 DLC 预设文案。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,9 +57,8 @@ func mapKeys(values map[string]struct{}) []string {
|
||||
func (h *MerchantHandler) ListProducts(c *gin.Context) {
|
||||
page, size := pageParams(c)
|
||||
list, total, err := h.merchantSvc.ListMerchantProductsWithOptions(middleware.GetMerchantID(c), page, size, service.ListMerchantProductsOptions{
|
||||
Status: strings.TrimSpace(c.Query("status")),
|
||||
Keyword: strings.TrimSpace(c.Query("keyword")),
|
||||
ExcludeLegacyLewanSKU: true, // LEWAN_* 镜像已废弃,列表永不返回
|
||||
Status: strings.TrimSpace(c.Query("status")),
|
||||
Keyword: strings.TrimSpace(c.Query("keyword")),
|
||||
})
|
||||
if err != nil {
|
||||
if err.Error() == "无效的商品状态" {
|
||||
|
||||
@@ -84,10 +84,9 @@ func (s *MerchantService) CreateMerchantProduct(merchantID uint, in CreateMercha
|
||||
}
|
||||
|
||||
type ListMerchantProductsOptions struct {
|
||||
ActiveOnly bool
|
||||
ExcludeLegacyLewanSKU bool
|
||||
Status string // active / inactive;空表示不限(ActiveOnly 优先)
|
||||
Keyword string
|
||||
ActiveOnly bool
|
||||
Status string // active / inactive;空表示不限(ActiveOnly 优先)
|
||||
Keyword string
|
||||
}
|
||||
|
||||
func (s *MerchantService) ListMerchantProducts(merchantID uint, page, size int, activeOnly bool) ([]model.MerchantProduct, int64, error) {
|
||||
@@ -96,11 +95,10 @@ func (s *MerchantService) ListMerchantProducts(merchantID uint, page, size int,
|
||||
})
|
||||
}
|
||||
|
||||
// ListMerchantProductsForClient 商户开放 API / 手工下单选品:排除 LEWAN_* 镜像,只返回英文主 sku。
|
||||
// ListMerchantProductsForClient 商户开放 API / 手工下单选品:只返回在售英文主 sku。
|
||||
func (s *MerchantService) ListMerchantProductsForClient(merchantID uint, page, size int) ([]model.MerchantProduct, int64, error) {
|
||||
return s.ListMerchantProductsWithOptions(merchantID, page, size, ListMerchantProductsOptions{
|
||||
ActiveOnly: true,
|
||||
ExcludeLegacyLewanSKU: true,
|
||||
ActiveOnly: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,9 +114,6 @@ func (s *MerchantService) ListMerchantProductsWithOptions(merchantID uint, page,
|
||||
}
|
||||
tx = tx.Where("status = ?", status)
|
||||
}
|
||||
if opts.ExcludeLegacyLewanSKU {
|
||||
tx = tx.Where("sku NOT ILIKE ?", "lewan_%")
|
||||
}
|
||||
if keyword := strings.TrimSpace(opts.Keyword); keyword != "" {
|
||||
like := "%" + keyword + "%"
|
||||
tx = tx.Where("(sku ILIKE ? OR display_name ILIKE ?)", like, like)
|
||||
|
||||
@@ -879,9 +879,9 @@ export default function PlatformProducts() {
|
||||
<Form.Item
|
||||
name="dlc_good_id"
|
||||
label="第一平台 (DLC) GoodID (选填)"
|
||||
extra="留空将按系统内置预设映射自动选择(例如 yg_60_points 对应 1936306173007360000)"
|
||||
extra="留空则使用系统内置「英文 SKU → DLC GoodID」预设;有乐玩商品请另填乐玩 UUID"
|
||||
>
|
||||
<Input placeholder="留空使用预设映射,或手动指定数字ID" allowClear />
|
||||
<Input placeholder="留空使用内置 DLC 映射,或手动指定上游商品 ID" allowClear />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
export type ProductImageInput = {
|
||||
sku?: string | null
|
||||
/** 上游缩略图 URL(乐玩/DLC);仅在无本地 SKU 图时作回退 */
|
||||
/** 上游缩略图 URL(乐玩/DLC);仅在无本地 SKU 图时作 image-proxy 回退 */
|
||||
url?: string | null
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ export function resolveProductImageBySku(sku?: string | null): string {
|
||||
/**
|
||||
* 解析展示用商品图:
|
||||
* 1. 有 sku → `/images/products/{sku}.webp`
|
||||
* 2. 否则从 url 提取乐玩 UUID → `/images/products/{uuid}.webp`(历史缓存)
|
||||
* 3. 其它外链 → image-proxy(运行时落盘到 data/uploads/products,仅兜底)
|
||||
* 2. 其它外链 → image-proxy(运行时落盘到 data/uploads/products,仅兜底)
|
||||
*/
|
||||
export function resolveProductImage(input?: string | ProductImageInput | null): string {
|
||||
if (input == null) return ''
|
||||
@@ -47,10 +46,5 @@ export function resolveProductImage(input?: string | ProductImageInput | null):
|
||||
if (!url) return ''
|
||||
if (url.startsWith('/')) return url
|
||||
|
||||
const uuidMatch = url.match(/\/products\/([a-zA-Z0-9-]+)(?:\/|\.|$)/)
|
||||
if (uuidMatch?.[1]) {
|
||||
return `/images/products/${uuidMatch[1]}.webp`
|
||||
}
|
||||
|
||||
return `/api/delivery/v1/image-proxy?url=${encodeURIComponent(url)}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user