Files
affiliate_dash/backend/internal/service/merchant_helpers.go
T
yml2213andCursor df1a170d44 refactor(catalog): 废弃 LEWAN_ 镜像,统一英文 SKU 与积分价,商品图按 SKU 缓存
对外目录只保留英文主 sku;迁移硬删镜像并校准 1元=100积分;发货页/凭证优先使用 local {sku}.webp。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 20:00:26 +08:00

49 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package service
import (
"crypto/rand"
"encoding/base64"
"strings"
)
func normalizePage(page, size int) (int, int) {
if page < 1 {
page = 1
}
if size < 1 || size > 100 {
size = 20
}
return page, size
}
func randomToken(prefix string, byteCount int) (string, error) {
raw := make([]byte, byteCount)
if _, err := rand.Read(raw); err != nil {
return "", err
}
return prefix + base64.RawURLEncoding.EncodeToString(raw), nil
}
func scopeList(scopes string) []string {
set := ParseScopes(scopes)
items := make([]string, 0, len(set))
for scope := range set {
items = append(items, scope)
}
return items
}
func fallbackName(value, fallback string) string {
if strings.TrimSpace(value) != "" {
return strings.TrimSpace(value)
}
return fallback
}
// IsLegacyLewanMirrorSKU 判断是否为历史乐玩镜像 sku(LEWAN_*/lewan_*)。
// 对外目录应使用英文主 sku;乐玩只作为履约配置挂接。
func IsLegacyLewanMirrorSKU(sku string) bool {
normalized := strings.ToLower(strings.TrimSpace(sku))
return strings.HasPrefix(normalized, "lewan_")
}