增加统一倍率调整按钮
This commit is contained in:
1 parent
be655b6569
commit
4195525dc7
23 files changed
+750
-16
No files matched your search
@@ -100,6 +100,33 @@ func (s *Store) UpdateBillingPriceRule(_ context.Context, id string, p billing.P
|
||||
r = cloneRule(r)
|
||||
return &r, nil
|
||||
}
|
||||
func (s *Store) UpdateBillingPriceRules(_ context.Context, patch billing.BulkPricePatch) ([]billing.PriceRule, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if len(patch.RuleIDs) == 0 {
|
||||
return nil, billing.ErrPriceNotFound
|
||||
}
|
||||
for _, id := range patch.RuleIDs {
|
||||
if _, ok := s.priceRules[id]; !ok {
|
||||
return nil, billing.ErrPriceNotFound
|
||||
}
|
||||
}
|
||||
now := s.now().UTC().Format(time.RFC3339Nano)
|
||||
out := make([]billing.PriceRule, 0, len(patch.RuleIDs))
|
||||
for _, id := range patch.RuleIDs {
|
||||
rule := cloneRule(s.priceRules[id])
|
||||
rule.MarkupMultiplier = patch.MarkupMultiplier
|
||||
for di := range rule.Dimensions {
|
||||
for ti := range rule.Dimensions[di].Tiers {
|
||||
rule.Dimensions[di].Tiers[ti].MarkupMultiplier = patch.MarkupMultiplier
|
||||
}
|
||||
}
|
||||
rule.UpdatedAt = now
|
||||
s.priceRules[id] = cloneRule(rule)
|
||||
out = append(out, cloneRule(rule))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
func (s *Store) SeedBillingPriceRules(_ context.Context, rules []billing.PriceRule) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
Reference in new issue
Block a user