package promotion

import (
	"github.com/pingcap/dbaas/billing2/config"
	"github.com/pingcap/dbaas/billing2/model/marketing"
	"github.com/shopspring/decimal"
)

var referralModel = &marketing.ReferralModel{}

// rewardAmounts holds the credits amount for each event type, read from config.
type rewardAmounts struct {
	Signup               decimal.Decimal
	RefereeSignup        decimal.Decimal
	BindCard             decimal.Decimal
	RefereeBindCard      decimal.Decimal
	FirstUse             decimal.Decimal
	ContinuousUse        decimal.Decimal
	RefereeContinuousUse decimal.Decimal
}

// getRewardAmounts reads per-event-type reward amounts from config.
func getRewardAmounts() rewardAmounts {
	return rewardAmounts{
		Signup:               decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountSignup)),
		RefereeSignup:        decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountRefereeSignup)),
		BindCard:             decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountBindCard)),
		RefereeBindCard:      decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountRefereeBindCard)),
		FirstUse:             decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountFirstUse)),
		ContinuousUse:        decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountContinuousUse)),
		RefereeContinuousUse: decimal.NewFromFloat(config.Get().GetFloat64(config.ReferralAmountRefereeContinuousUse)),
	}
}
