29 lines
802 B
Go
29 lines
802 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"slogan-agent/styleagent/dao"
|
|
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
type userMemberService struct{}
|
|
|
|
var UserMemberService = new(userMemberService)
|
|
|
|
// IsVip 用户是否有效会员(用于效果图限额等权益判定)
|
|
func (s *userMemberService) IsVip(ctx context.Context, userId int64) bool {
|
|
return dao.UserMember.IsVip(ctx, userId)
|
|
}
|
|
|
|
// Upsert 开通/续期会员
|
|
func (s *userMemberService) Upsert(ctx context.Context, userId, planId int64, expireAt, source string) error {
|
|
return dao.UserMember.Upsert(ctx, userId, planId, expireAt, source)
|
|
}
|
|
|
|
// NextExpire 续期计算:未过期在原有效期上叠加,过期/无记录从现在起算
|
|
func (s *userMemberService) NextExpire(old *gtime.Time, days int) string {
|
|
return NextExpire(old, days)
|
|
}
|