You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
838 B
Go
42 lines
838 B
Go
package stocks
|
|
|
|
import (
|
|
"context"
|
|
"joybuywork/internal/consts"
|
|
"joybuywork/internal/consts/ckey"
|
|
"joybuywork/internal/service/provider/cachecurd"
|
|
)
|
|
|
|
type CampaignParam struct {
|
|
CpnId int64
|
|
RewardLimit int64
|
|
}
|
|
|
|
// Campaign 活动总预算的库存
|
|
type Campaign struct {
|
|
stocks
|
|
}
|
|
|
|
func NewCampaign(ctx context.Context, cpnIds ...int64) (stock *Campaign, err error) {
|
|
stock = &Campaign{}
|
|
|
|
err = stock.Init(ctx, stock, cpnIds)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Campaign) Key(cpnId int64) string {
|
|
return ckey.FissionCampaignPool(cpnId)
|
|
}
|
|
|
|
func (s *Campaign) BuildStock(cpnId int64) (*cachecurd.HMap, error) {
|
|
return cachecurd.NewHMap(s.Ctx, s.Key(cpnId), cachecurd.SetCampaignStock(cpnId), cachecurd.SetHMapExp(consts.TimeDay))
|
|
}
|
|
|
|
func (s *Campaign) Clear() {
|
|
NewCleaner(s.Ctx, s.ids...).ClearCampaign()
|
|
}
|