feat(v2): 多币种 product(ProductPrice 分币价目 + v1 元回退)+ 结算币种由渠道能力驱动
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
@@ -18,11 +18,19 @@ import (
|
||||
|
||||
type stubResolver struct{}
|
||||
|
||||
func (stubResolver) Resolve(sku string) (int64, string, string, string, error) {
|
||||
func (stubResolver) Resolve(sku, currency string) (int64, string, string, error) {
|
||||
if sku != "pro_year" {
|
||||
return 0, "", "", "", gateway.ErrProductNotFound
|
||||
return 0, "", "", gateway.ErrProductNotFound
|
||||
}
|
||||
// 结算币种驱动金额:USDT 6 位, 其余按分。测试只用 fake(USDT)。
|
||||
switch currency {
|
||||
case "USDT":
|
||||
return 29990000, "Pro 年付", "pro_year", nil
|
||||
case "CNY":
|
||||
return 19900, "Pro 年付", "pro_year", nil
|
||||
default:
|
||||
return 0, "", "", gateway.ErrProductNotFound
|
||||
}
|
||||
return 29990000, "USDT", "Pro 年付", "pro_year", nil
|
||||
}
|
||||
|
||||
type spyEnqueuer struct {
|
||||
@@ -152,3 +160,15 @@ func TestRetrySwitchesAccount(t *testing.T) {
|
||||
t.Fatalf("retry 应换到 fake-a2, got %+v", pend)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateOrderCurrencyFromChannelCapability(t *testing.T) {
|
||||
g, _, _, orders := newGateway(t) // fake provider, SettleCurrencies=["USDT"]
|
||||
res, err := g.CreateOrder(context.Background(), gateway.CreateOrderInput{SKU: "pro_year", Method: "fake"})
|
||||
if err != nil {
|
||||
t.Fatalf("create: %v", err)
|
||||
}
|
||||
o, _ := orders.GetOrder(res.OrderNo)
|
||||
if o.Currency != "USDT" || o.AmountMinor != 29990000 {
|
||||
t.Fatalf("order = %s/%d want USDT/29990000", o.Currency, o.AmountMinor)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user