diff --git a/internal/architecture/catalog_module_structure_test.go b/internal/architecture/catalog_module_structure_test.go index 38cbcd1b..56a81966 100644 --- a/internal/architecture/catalog_module_structure_test.go +++ b/internal/architecture/catalog_module_structure_test.go @@ -220,7 +220,7 @@ func TestCatalogProductImplementationLivesInNestedBoundedContext(t *testing.T) { }) assertFileDeclaresFunctions(t, filepath.Join(domainRoot, "pricing.go"), []string{ "NormalizeWholesalePrices", "NormalizeWholesalePricesForSKUs", - "ResolveWholesaleUnitPrice", "ResolveWholesaleUnitPriceWithMatchQuantity", "ResolveWholesaleUnitPriceForSKU", + "ResolveWholesaleUnitPrice", "ResolveWholesaleUnitPriceForSKU", }) assertFileDeclaresFunctions(t, filepath.Join(domainRoot, "purchase_policy.go"), []string{ "NormalizePurchaseType", "NormalizeFulfillmentType", "NormalizeStockDisplayMode", diff --git a/internal/modules/catalog/product/domain/pricing.go b/internal/modules/catalog/product/domain/pricing.go index 8e424107..3d770a41 100644 --- a/internal/modules/catalog/product/domain/pricing.go +++ b/internal/modules/catalog/product/domain/pricing.go @@ -182,12 +182,6 @@ func ResolveWholesaleUnitPrice(product *Product, baseUnitPrice decimal.Decimal, return resolveWholesaleUnitPrice(product, baseUnitPrice, 0, "", quantity, quantity) } -// ResolveWholesaleUnitPriceWithMatchQuantity 按 matchQuantity 判断批发档位,按 quantity 计算当前行优惠。 -// 商品存在多 SKU 时,批发门槛按同一商品总购买数判断,但每个订单行只计算自己的优惠金额。 -func ResolveWholesaleUnitPriceWithMatchQuantity(product *Product, baseUnitPrice decimal.Decimal, matchQuantity, quantity int) (unitPrice decimal.Decimal, discount decimal.Decimal, matched bool) { - return resolveWholesaleUnitPrice(product, baseUnitPrice, 0, "", matchQuantity, quantity) -} - // ResolveWholesaleUnitPriceForSKU 按指定 SKU 的批发价阶梯解析成交单价。 func ResolveWholesaleUnitPriceForSKU(product *Product, baseUnitPrice decimal.Decimal, skuID uint, skuCode string, matchQuantity, quantity int) (unitPrice decimal.Decimal, discount decimal.Decimal, matched bool) { return resolveWholesaleUnitPrice(product, baseUnitPrice, skuID, skuCode, matchQuantity, quantity) diff --git a/internal/modules/notification/application/format/template.go b/internal/modules/notification/application/format/template.go index 1e2c2cd6..4e6400e1 100644 --- a/internal/modules/notification/application/format/template.go +++ b/internal/modules/notification/application/format/template.go @@ -63,10 +63,6 @@ func ComposePlainTextMessage(title, body string) string { return title + "\n\n" + body } -func ComposeTelegramMessage(title, body string) string { - return ComposePlainTextMessage(title, body) -} - func JSONToMap(data jsonmap.JSON) map[string]interface{} { if data == nil { return map[string]interface{}{} diff --git a/internal/modules/order/infrastructure/gormstore/order_store.go b/internal/modules/order/infrastructure/gormstore/order_store.go index cfa48659..8a9ac1e4 100644 --- a/internal/modules/order/infrastructure/gormstore/order_store.go +++ b/internal/modules/order/infrastructure/gormstore/order_store.go @@ -40,13 +40,6 @@ func New(db *gorm.DB, guestCredentialSecret string) *Store { return &Store{db: db, guestCredentialSecret: []byte(secret)} } -func (r *Store) bind(tx *gorm.DB) *Store { - if tx == nil { - return r - } - return &Store{db: tx, guestCredentialSecret: r.guestCredentialSecret} -} - func (r *Store) withChildren(query *gorm.DB) *gorm.DB { return query. Where("orders.deleted_at IS NULL"). diff --git a/internal/modules/order/infrastructure/gormstore/risk_gate_test.go b/internal/modules/order/infrastructure/gormstore/risk_gate_test.go index e6e0588e..d7c96d05 100644 --- a/internal/modules/order/infrastructure/gormstore/risk_gate_test.go +++ b/internal/modules/order/infrastructure/gormstore/risk_gate_test.go @@ -92,7 +92,7 @@ func TestRiskGateSerializesConcurrentGuestQuotaChecks(t *testing.T) { defer wg.Done() <-start err := store.db.Transaction(func(dbtx *gorm.DB) error { - txStore := store.bind(dbtx) + txStore := &Store{db: dbtx, guestCredentialSecret: store.guestCredentialSecret} if err := txStore.LockRiskKeys([]string{"guest:ip:1.2.3.4"}); err != nil { return err } diff --git a/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay.go b/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay.go index c3d1a236..78917ca0 100644 --- a/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay.go +++ b/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay.go @@ -238,14 +238,6 @@ func ResolveChain(tokenID string) string { return "" } -// IsSupportedTokenID 判断 token_id 是否已收录在内置映射表中。 -// 该表仅用于精确解析 chain,不再作为准入白名单:未收录但符合命名约定的 token_id -// 同样可用,准入条件是 ResolveChain 能推导出非空 chain。 -func IsSupportedTokenID(tokenID string) bool { - _, ok := supportedTokenChains[strings.ToLower(strings.TrimSpace(tokenID))] - return ok -} - var supportedTokenChains = map[string]string{ "tron-trx": "tron", "tron-usdt": "tron", diff --git a/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay_test.go b/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay_test.go index ab60a726..c9c1b70a 100644 --- a/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay_test.go +++ b/internal/modules/payment/infrastructure/gateway/dujiaopay/dujiaopay_test.go @@ -189,9 +189,6 @@ func TestResolveChainSupportsBSCUSDC(t *testing.T) { if got := ResolveChain("bsc-usdc"); got != "bsc" { t.Fatalf("ResolveChain(bsc-usdc) = %q, want bsc", got) } - if !IsSupportedTokenID("BSC-USDC") { - t.Fatalf("IsSupportedTokenID should accept bsc-usdc case-insensitively") - } } // ResolveChain 对未收录的 token_id 按最后一个连字符切分,使 DujiaoPay 新增链或代币时 diff --git a/internal/modules/payment/transport/presenter/crypto_wallet.go b/internal/modules/payment/transport/presenter/crypto_wallet.go index d5f18518..020ebb50 100644 --- a/internal/modules/payment/transport/presenter/crypto_wallet.go +++ b/internal/modules/payment/transport/presenter/crypto_wallet.go @@ -72,12 +72,6 @@ func ExtractCryptoWalletInfo(providerType, interactionMode string, payload jsonm } } -// ExtractUSDTWalletInfo 从 Payment.ProviderPayload 中提取 USDT 收款钱包地址和链上实付金额。 -func ExtractUSDTWalletInfo(providerType, interactionMode string, payload jsonmap.JSON) (address, chainAmount string) { - info := ExtractCryptoWalletInfo(providerType, interactionMode, payload) - return info.Address, info.ChainAmount -} - func firstPayloadString(values ...string) string { for _, value := range values { if value != "" { diff --git a/internal/modules/payment/transport/presenter/crypto_wallet_test.go b/internal/modules/payment/transport/presenter/crypto_wallet_test.go index a52bce4a..411664b3 100644 --- a/internal/modules/payment/transport/presenter/crypto_wallet_test.go +++ b/internal/modules/payment/transport/presenter/crypto_wallet_test.go @@ -86,7 +86,8 @@ func TestExtractUSDTWalletInfo(t *testing.T) { } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - gotAddr, gotAmount := ExtractUSDTWalletInfo(tc.providerType, tc.interactionMode, tc.payload) + info := ExtractCryptoWalletInfo(tc.providerType, tc.interactionMode, tc.payload) + gotAddr, gotAmount := info.Address, info.ChainAmount if gotAddr != tc.wantAddress { t.Errorf("address: got %q want %q", gotAddr, tc.wantAddress) } diff --git a/internal/modules/settings/application/google_auth_test.go b/internal/modules/settings/application/google_auth_test.go index 654e2ee0..3902040b 100644 --- a/internal/modules/settings/application/google_auth_test.go +++ b/internal/modules/settings/application/google_auth_test.go @@ -23,10 +23,6 @@ func TestGoogleAuthSettingNormalizeValidateAndPublicConfig(t *testing.T) { if err := settingssecurity.ValidateGoogleAuthSetting(settingssecurity.GoogleAuthSetting{Enabled: true}); !errors.Is(err, settingssecurity.ErrGoogleAuthConfigInvalid) { t.Fatalf("missing client id error = %v", err) } - public := settingssecurity.PublicGoogleAuthSetting(setting) - if public["enabled"] != true || public["client_id"] != "client.apps.googleusercontent.com" { - t.Fatalf("unexpected public config: %#v", public) - } } func TestPatchGoogleAuthSettingPersistsNormalizedValue(t *testing.T) { diff --git a/internal/modules/settings/schema/security/google_auth.go b/internal/modules/settings/schema/security/google_auth.go index e5eb9e15..4f088199 100644 --- a/internal/modules/settings/schema/security/google_auth.go +++ b/internal/modules/settings/schema/security/google_auth.go @@ -83,15 +83,6 @@ func MaskGoogleAuthSettingForAdmin(setting GoogleAuthSetting) jsonmap.JSON { return EncodeGoogleAuthSetting(setting) } -// PublicGoogleAuthSetting 返回前台初始化 Google Identity Services 所需的最小配置。 -func PublicGoogleAuthSetting(setting GoogleAuthSetting) map[string]interface{} { - normalized := NormalizeGoogleAuthSetting(setting) - return map[string]interface{}{ - "enabled": normalized.Enabled && normalized.ClientID != "", - "client_id": normalized.ClientID, - } -} - // DecodeGoogleAuthSetting 从持久化 JSON 解码,并对缺失字段使用 fallback。 func DecodeGoogleAuthSetting(raw jsonmap.JSON, fallback GoogleAuthSetting) GoogleAuthSetting { next := fallback diff --git a/internal/selfupdate/updater.go b/internal/selfupdate/updater.go index 0b8f0269..2dfa1faf 100644 --- a/internal/selfupdate/updater.go +++ b/internal/selfupdate/updater.go @@ -81,33 +81,10 @@ func NewUpdater() *Updater { } } -// Apply 下载指定发行版的当前平台归档并替换正在运行的二进制。 -// progress 可为 nil;非 nil 时会在各阶段回调,用于前端展示进度。 -// -// 成功返回后二进制已就位,但进程仍是旧版本,需由调用方决定何时重启。 -func (u *Updater) Apply(ctx context.Context, release *version.Release, progress func(stage Stage, percent int)) error { - execPath, err := ExecutablePath() - if err != nil { - return err - } - - // 覆盖整个下载 + 替换过程,而不只是 swap 那一瞬:下载期间跑一次 CLI 回滚, - // 会把 .backup 消耗掉,随后 swapBinary 又生成一个指向新版本的 .backup, - // 结果是两边都以为自己成功了,可恢复的旧二进制却已经没了。 - unlock, err := acquireBinaryLock(execPath) - if err != nil { - return err - } - defer unlock() - - return u.applyLocked(ctx, release, execPath, progress) -} - // applyLocked 执行实际升级,调用方必须已经持有 execPath 对应的跨进程锁。 // // Manager.Start 在请求 GitHub release 之前取得锁并把所有权传到这里,从而覆盖 -// 「版本检查 → 下载 → 校验 → 替换 → 元数据落盘」完整事务;Apply 这个公开入口 -// 则在上面自行取得同一把锁后再调用。 +// 「版本检查 → 下载 → 校验 → 替换 → 元数据落盘」完整事务。 func (u *Updater) applyLocked(ctx context.Context, release *version.Release, execPath string, progress func(stage Stage, percent int)) error { report := func(stage Stage, percent int) { if progress != nil {