新增荣耀勋章/幸运币商品:迁移、上游商品映射与测试

This commit is contained in:
yml2213
2026-08-03 12:35:39 +08:00
parent e7c875c715
commit 8dc2a4077a
3 changed files with 68 additions and 8 deletions
@@ -0,0 +1,38 @@
-- ============================================================================
-- 新增荣耀勋章 / 幸运币系列商品
-- ============================================================================
INSERT INTO products (code, name, category, status)
SELECT v.code, v.name, v.category, 'active'
FROM (VALUES
('honor_medal_x2', '荣耀勋章2个', '道具'),
('honor_medal_x30', '荣耀勋章30个', '道具'),
('honor_medal_x90', '荣耀勋章90个', '道具'),
('lucky_coin_x2', '幸运币2个', '道具'),
('lucky_coin_x30', '幸运币30个', '道具'),
('lucky_coin_x90', '幸运币90个', '道具')
) AS v(code, name, category)
ON CONFLICT (code) DO NOTHING;
INSERT INTO merchant_products (merchant_id, product_id, sku, display_name, price_amount, cost_amount, currency, stock, status)
SELECT
m.id,
p.id,
p.code,
p.name,
v.price_amount,
v.cost_amount,
'POINT',
-1,
'active'
FROM (VALUES
('honor_medal_x2', 20, 20),
('honor_medal_x30', 300, 300),
('honor_medal_x90', 900, 900),
('lucky_coin_x2', 20, 20),
('lucky_coin_x30', 300, 300),
('lucky_coin_x90', 900, 900)
) AS v(sku, price_amount, cost_amount)
JOIN products p ON p.code = v.sku
JOIN merchants m ON m.code = 'self-operated'
ON CONFLICT (merchant_id, sku) DO NOTHING;
+6
View File
@@ -959,6 +959,12 @@ func deliveryGoodID(channel, sku string) string {
"pack_star_roam_outfit": "682ef39ca8f40c4234c59f3e",
"pack_star_roam_weapon": "682ef39ca8f40c4234c59f3f",
"suit_cloud_bear": "682ef39ca8f40c4234c59f40",
"honor_medal_x2": "682ef39ca8f40c4234c59f45",
"honor_medal_x30": "682ef39ca8f40c4234c59f43",
"honor_medal_x90": "682ef39ca8f40c4234c59f41",
"lucky_coin_x2": "682ef39ca8f40c4234c59f46",
"lucky_coin_x30": "682ef39ca8f40c4234c59f44",
"lucky_coin_x90": "682ef39ca8f40c4234c59f42",
}[sku]
}
+16
View File
@@ -76,6 +76,22 @@ func TestDeliveryLinkGenerateAuthorizeAndRevoke(t *testing.T) {
}
}
func TestDeliveryGoodIDIncludesMedalAndCoinProducts(t *testing.T) {
cases := map[string]string{
"honor_medal_x2": "682ef39ca8f40c4234c59f45",
"honor_medal_x30": "682ef39ca8f40c4234c59f43",
"honor_medal_x90": "682ef39ca8f40c4234c59f41",
"lucky_coin_x2": "682ef39ca8f40c4234c59f46",
"lucky_coin_x30": "682ef39ca8f40c4234c59f44",
"lucky_coin_x90": "682ef39ca8f40c4234c59f42",
}
for sku, want := range cases {
if got := deliveryGoodID("dlc", sku); got != want {
t.Fatalf("unexpected good id for %s: got %q want %q", sku, got, want)
}
}
}
func TestDeliveryMerchantApiBindAndSubmit(t *testing.T) {
db := newServiceTestDB(t)
merchantID, _ := seedFulfillmentMerchant(t, db, "delivery-api", 5000, 5, 100)