倍率问题和图片问题调整
This commit is contained in:
1 parent
f1993eb388
commit
3f29ba716a
20 files changed
+1210
-24
No files matched your search
@@ -109,6 +109,7 @@ func (s *Store) SeedBillingPriceRules(_ context.Context, rules []billing.PriceRu
|
||||
if ok {
|
||||
r.MarkupMultiplier = existing.MarkupMultiplier
|
||||
r.CreatedAt = existing.CreatedAt
|
||||
r.Dimensions = preserveTierMarkups(r.Dimensions, existing.Dimensions)
|
||||
}
|
||||
if r.CreatedAt == "" {
|
||||
r.CreatedAt = now
|
||||
@@ -119,6 +120,30 @@ func (s *Store) SeedBillingPriceRules(_ context.Context, rules []billing.PriceRu
|
||||
return nil
|
||||
}
|
||||
|
||||
// Defaults own the catalog shape and official costs; administrators own the
|
||||
// markup for each matching dimension/tier. Copy before editing so a reused
|
||||
// default catalog is not changed by one store's customizations.
|
||||
func preserveTierMarkups(defaults, existing []billing.ParameterDimension) []billing.ParameterDimension {
|
||||
markups := make(map[[2]string]float64)
|
||||
for _, dimension := range existing {
|
||||
for _, tier := range dimension.Tiers {
|
||||
if tier.MarkupMultiplier >= 1 && tier.MarkupMultiplier <= 1000 {
|
||||
markups[[2]string{dimension.Key, fmt.Sprint(tier.Value)}] = tier.MarkupMultiplier
|
||||
}
|
||||
}
|
||||
}
|
||||
merged := append([]billing.ParameterDimension(nil), defaults...)
|
||||
for di := range merged {
|
||||
merged[di].Tiers = append([]billing.ParameterTier(nil), merged[di].Tiers...)
|
||||
for ti := range merged[di].Tiers {
|
||||
if markup, ok := markups[[2]string{merged[di].Key, fmt.Sprint(merged[di].Tiers[ti].Value)}]; ok {
|
||||
merged[di].Tiers[ti].MarkupMultiplier = markup
|
||||
}
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
func (s *Store) PostBillingWalletEntry(ctx context.Context, p billing.WalletPostParams) (billing.WalletPosting, error) {
|
||||
return s.PostWalletEntry(ctx, p)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user