package apple import ( "encoding/json" "time" ) type ProductMapping struct { DurationDays int64 `json:"durationDays"` Tier string `json:"tier"` Description string `json:"description"` PriceText string `json:"priceText"` SubscribeId int64 `json:"subscribeId"` } type ProductMap struct { Items map[string]ProductMapping `json:"iapProductMap"` } func ParseProductMap(customData string) (*ProductMap, error) { if customData == "" { return &ProductMap{Items: map[string]ProductMapping{}}, nil } var obj ProductMap if err := json.Unmarshal([]byte(customData), &obj); err != nil { return &ProductMap{Items: map[string]ProductMapping{}}, nil } if obj.Items == nil { obj.Items = map[string]ProductMapping{} } return &obj, nil } func CalcExpire(start time.Time, days int64) time.Time { if days <= 0 { return time.UnixMilli(0) } return start.Add(time.Duration(days) * 24 * time.Hour) }