Documentation
¶
Overview ¶
Package selfsub implements the user self-service subscription management of the subscription module: viewing, token reset, notes, and the two-phase cancellation with its billing refund. Only the module facade may reach it.
Index ¶
- func CalculateRemainingAmount(ctx context.Context, deps Deps, userSubscribeId int64) (int64, error)
- type Deps
- type GetSubscribeLogLogic
- type PreUnsubscribeLogic
- type QueryUserSubscribeLogic
- type ResetUserSubscribeTokenLogic
- type Service
- func (s *Service) GetSubscribeLog(ctx context.Context, req *dto.GetSubscribeLogRequest) (*dto.GetSubscribeLogResponse, error)
- func (s *Service) PreUnsubscribe(ctx context.Context, req *dto.PreUnsubscribeRequest) (*dto.PreUnsubscribeResponse, error)
- func (s *Service) QueryUserSubscribe(ctx context.Context) (*dto.QueryUserSubscribeListResponse, error)
- func (s *Service) ResetUserSubscribeToken(ctx context.Context, req *dto.ResetUserSubscribeTokenRequest) error
- func (s *Service) Unsubscribe(ctx context.Context, req *dto.UnsubscribeRequest) error
- func (s *Service) UpdateUserSubscribeNote(ctx context.Context, req *dto.UpdateUserSubscribeNoteRequest) error
- type Store
- type UnsubscribeLogic
- type UpdateUserSubscribeNoteLogic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Deps ¶
type Deps struct {
UserSubs repository.UserSubscriptionRepo
Plans repository.SubscribeRepo
// Users/Orders/Logs are read (and, for the refund, wallet) ports onto the
// identity, billing and platform domains.
Users repository.UserRepo
Orders repository.OrderRepo
Cache repository.UserCacheRepo
Logs repository.LogRepo
Inbox repository.InboxRepo
Store Store
// SingleModel forbids holding more than one blocking subscription;
// runtime-mutable, read per request.
SingleModel func() bool
}
type GetSubscribeLogLogic ¶
func (*GetSubscribeLogLogic) GetSubscribeLog ¶
func (l *GetSubscribeLogLogic) GetSubscribeLog(req *dto.GetSubscribeLogRequest) (resp *dto.GetSubscribeLogResponse, err error)
type PreUnsubscribeLogic ¶
func (*PreUnsubscribeLogic) PreUnsubscribe ¶
func (l *PreUnsubscribeLogic) PreUnsubscribe(req *dto.PreUnsubscribeRequest) (resp *dto.PreUnsubscribeResponse, err error)
type QueryUserSubscribeLogic ¶
func (*QueryUserSubscribeLogic) QueryUserSubscribe ¶
func (l *QueryUserSubscribeLogic) QueryUserSubscribe() (resp *dto.QueryUserSubscribeListResponse, err error)
type ResetUserSubscribeTokenLogic ¶
type ResetUserSubscribeTokenLogic struct {
logger.Logger
// contains filtered or unexported fields
}
func (*ResetUserSubscribeTokenLogic) ResetUserSubscribeToken ¶
func (l *ResetUserSubscribeTokenLogic) ResetUserSubscribeToken(req *dto.ResetUserSubscribeTokenRequest) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) GetSubscribeLog ¶
func (s *Service) GetSubscribeLog(ctx context.Context, req *dto.GetSubscribeLogRequest) (*dto.GetSubscribeLogResponse, error)
func (*Service) PreUnsubscribe ¶
func (s *Service) PreUnsubscribe(ctx context.Context, req *dto.PreUnsubscribeRequest) (*dto.PreUnsubscribeResponse, error)
func (*Service) QueryUserSubscribe ¶
func (*Service) ResetUserSubscribeToken ¶
func (*Service) Unsubscribe ¶
func (*Service) UpdateUserSubscribeNote ¶
type Store ¶ added in v1.20.3
type Store interface {
repository.BillingTransactor
repository.SubscriptionTransactor
}
Store is the persistence capability required by this package. It excludes unrelated repositories and application-wide transactions.
type UnsubscribeLogic ¶
func (*UnsubscribeLogic) Unsubscribe ¶
func (l *UnsubscribeLogic) Unsubscribe(req *dto.UnsubscribeRequest) error
Unsubscribe cancels the subscription in a subscription-domain transaction, then settles the refund in a billing-domain transaction (gift amount first for balance-paid orders, then regular balance). A crash between the two is repaired when the user retries: a Deducted subscription whose refund marker is missing resumes at the refund stage.
type UpdateUserSubscribeNoteLogic ¶
type UpdateUserSubscribeNoteLogic struct {
logger.Logger
// contains filtered or unexported fields
}
func (*UpdateUserSubscribeNoteLogic) UpdateUserSubscribeNote ¶
func (l *UpdateUserSubscribeNoteLogic) UpdateUserSubscribeNote(req *dto.UpdateUserSubscribeNoteRequest) error