chore(catalog): 清理 LEWAN_ 列表过滤与商品图 UUID 历史回退

商品列表不再过滤镜像 SKU;图片只按英文 SKU 解析,修正 DLC 预设文案。

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