fix(delivery): 乐玩不可用时回退 DLC,避免提交 UID 绑定失败
legacy 双渠道配置升为 priority;显式 lewan 且具备 DLC 时允许回退,缓解 LEWAN_* 未注入导致的 bind 失败。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -39,12 +39,22 @@ func TestParseProductRoutingConfig(t *testing.T) {
|
||||
t.Fatalf("mismatched IDs: dlc=%s lewan=%s", cfg3.DLCGoodID, cfg3.LewanProductID)
|
||||
}
|
||||
|
||||
// Case 4: 兼容历史 legacy 单 provider 字段
|
||||
// Case 4: 兼容历史 legacy 单 provider 字段(无内置 DLC 时仍为 lewan-only)
|
||||
cfg4JSON := `{"provider":"lewan","lewan_product_id":"uuid-999"}`
|
||||
cfg4 := ParseProductRoutingConfig(cfg4JSON, "any_sku")
|
||||
if cfg4.RoutingMode != RoutingModeLewan || cfg4.LewanProductID != "uuid-999" {
|
||||
t.Fatalf("legacy lewan format failed: %+v", cfg4)
|
||||
}
|
||||
|
||||
// Case 5: legacy 仅有 lewan_product_id,但 SKU 有内置 DLC → 应升为 priority
|
||||
cfg5JSON := `{"lewan_product_id":"b1fff090-e389-4c6c-9c51-32751582239d"}`
|
||||
cfg5 := ParseProductRoutingConfig(cfg5JSON, "suit_romantic_destiny")
|
||||
if cfg5.RoutingMode != RoutingModePriority {
|
||||
t.Fatalf("expected priority for dual-capable legacy config, got %s", cfg5.RoutingMode)
|
||||
}
|
||||
if cfg5.DLCGoodID != "682ef39ca8f40c4234c59f38" {
|
||||
t.Fatalf("expected builtin DLC good id, got %s", cfg5.DLCGoodID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFulfillmentRouterResolution(t *testing.T) {
|
||||
@@ -73,6 +83,18 @@ func TestFulfillmentRouterResolution(t *testing.T) {
|
||||
t.Fatalf("expected Lewan provider, got %d providers", len(providers))
|
||||
}
|
||||
|
||||
// Case 2b: 显式 lewan 但 SKU 有内置 DLC → 应附带 DLC 回退
|
||||
orderLewanWithDLC := &model.FulfillmentOrder{
|
||||
ProductSKU: "suit_romantic_destiny",
|
||||
MerchantProduct: &model.MerchantProduct{
|
||||
FulfillmentConfig: `{"routing_mode":"lewan","lewan_product_id":"b1fff090-e389-4c6c-9c51-32751582239d","dlc_good_id":""}`,
|
||||
},
|
||||
}
|
||||
providers, _ = router.ResolveProviders(orderLewanWithDLC)
|
||||
if len(providers) != 2 || providers[0].Name() != ProviderLewan || providers[1].Name() != ProviderDLC {
|
||||
t.Fatalf("expected [lewan, dlc] fallback, got %v", providerNames(providers))
|
||||
}
|
||||
|
||||
// Case 3: 优先级路由 [lewan, dlc]
|
||||
orderPriority := &model.FulfillmentOrder{
|
||||
ProductSKU: "shared_item",
|
||||
|
||||
Reference in New Issue
Block a user