refactor(loyalty): remove the dead customer points and tokens code
First part of PC-601 (docs/prd-point-coin.md §10.7): the code that has had no way in since balances moved to the wallet. - The /marketing/customer-points and /marketing/customer-tokens routes were commented out; their 16 handler methods, the GamificationService methods behind them, and the validators, transformers, mappers and contract/model types only they used are gone. - CustomerPointsProcessor loses its "not implemented" stubs; it keeps the customer app's balance, wallet and games endpoints. - CustomerTokensProcessor and the customer points and tokens repositories, wired but no longer called by anything, are gone. What stays until its preconditions are met: the customer_points and customer_tokens tables and their entities, which cmd/wallet-migrate still reads, and the /customer/points, /customer/tokens aliases and the token_used / tokens_remaining fields, until the apps no longer use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
550122f29c
commit
d1e543a79f
@@ -11,26 +11,6 @@ import (
|
||||
)
|
||||
|
||||
type GamificationService interface {
|
||||
// Customer Points
|
||||
CreateCustomerPoints(ctx context.Context, req *contract.CreateCustomerPointsRequest) (*contract.CustomerPointsResponse, error)
|
||||
GetCustomerPoints(ctx context.Context, id uuid.UUID) (*contract.CustomerPointsResponse, error)
|
||||
GetCustomerPointsByCustomerID(ctx context.Context, customerID uuid.UUID) (*contract.CustomerPointsResponse, error)
|
||||
ListCustomerPoints(ctx context.Context, query *contract.ListCustomerPointsRequest) (*contract.PaginatedCustomerPointsResponse, error)
|
||||
UpdateCustomerPoints(ctx context.Context, id uuid.UUID, req *contract.UpdateCustomerPointsRequest) (*contract.CustomerPointsResponse, error)
|
||||
DeleteCustomerPoints(ctx context.Context, id uuid.UUID) error
|
||||
AddCustomerPoints(ctx context.Context, customerID uuid.UUID, req *contract.AddCustomerPointsRequest) (*contract.CustomerPointsResponse, error)
|
||||
DeductCustomerPoints(ctx context.Context, customerID uuid.UUID, req *contract.DeductCustomerPointsRequest) (*contract.CustomerPointsResponse, error)
|
||||
|
||||
// Customer Tokens
|
||||
CreateCustomerTokens(ctx context.Context, req *contract.CreateCustomerTokensRequest) (*contract.CustomerTokensResponse, error)
|
||||
GetCustomerTokens(ctx context.Context, id uuid.UUID) (*contract.CustomerTokensResponse, error)
|
||||
GetCustomerTokensByCustomerIDAndType(ctx context.Context, customerID uuid.UUID, tokenType string) (*contract.CustomerTokensResponse, error)
|
||||
ListCustomerTokens(ctx context.Context, query *contract.ListCustomerTokensRequest) (*contract.PaginatedCustomerTokensResponse, error)
|
||||
UpdateCustomerTokens(ctx context.Context, id uuid.UUID, req *contract.UpdateCustomerTokensRequest) (*contract.CustomerTokensResponse, error)
|
||||
DeleteCustomerTokens(ctx context.Context, id uuid.UUID) error
|
||||
AddCustomerTokens(ctx context.Context, customerID uuid.UUID, tokenType string, req *contract.AddCustomerTokensRequest) (*contract.CustomerTokensResponse, error)
|
||||
DeductCustomerTokens(ctx context.Context, customerID uuid.UUID, tokenType string, req *contract.DeductCustomerTokensRequest) (*contract.CustomerTokensResponse, error)
|
||||
|
||||
// Tiers
|
||||
CreateTier(ctx context.Context, req *contract.CreateTierRequest) (*contract.TierResponse, error)
|
||||
GetTier(ctx context.Context, id uuid.UUID) (*contract.TierResponse, error)
|
||||
@@ -72,18 +52,14 @@ type GamificationService interface {
|
||||
}
|
||||
|
||||
type GamificationServiceImpl struct {
|
||||
customerPointsProcessor *processor.CustomerPointsProcessor
|
||||
customerTokensProcessor *processor.CustomerTokensProcessor
|
||||
tierProcessor *processor.TierProcessor
|
||||
gameProcessor *processor.GameProcessor
|
||||
gamePrizeProcessor *processor.GamePrizeProcessor
|
||||
gamePlayProcessor *processor.GamePlayProcessor
|
||||
omsetTrackerProcessor *processor.OmsetTrackerProcessor
|
||||
tierProcessor *processor.TierProcessor
|
||||
gameProcessor *processor.GameProcessor
|
||||
gamePrizeProcessor *processor.GamePrizeProcessor
|
||||
gamePlayProcessor *processor.GamePlayProcessor
|
||||
omsetTrackerProcessor *processor.OmsetTrackerProcessor
|
||||
}
|
||||
|
||||
func NewGamificationService(
|
||||
customerPointsProcessor *processor.CustomerPointsProcessor,
|
||||
customerTokensProcessor *processor.CustomerTokensProcessor,
|
||||
tierProcessor *processor.TierProcessor,
|
||||
gameProcessor *processor.GameProcessor,
|
||||
gamePrizeProcessor *processor.GamePrizeProcessor,
|
||||
@@ -91,144 +67,14 @@ func NewGamificationService(
|
||||
omsetTrackerProcessor *processor.OmsetTrackerProcessor,
|
||||
) *GamificationServiceImpl {
|
||||
return &GamificationServiceImpl{
|
||||
customerPointsProcessor: customerPointsProcessor,
|
||||
customerTokensProcessor: customerTokensProcessor,
|
||||
tierProcessor: tierProcessor,
|
||||
gameProcessor: gameProcessor,
|
||||
gamePrizeProcessor: gamePrizeProcessor,
|
||||
gamePlayProcessor: gamePlayProcessor,
|
||||
omsetTrackerProcessor: omsetTrackerProcessor,
|
||||
tierProcessor: tierProcessor,
|
||||
gameProcessor: gameProcessor,
|
||||
gamePrizeProcessor: gamePrizeProcessor,
|
||||
gamePlayProcessor: gamePlayProcessor,
|
||||
omsetTrackerProcessor: omsetTrackerProcessor,
|
||||
}
|
||||
}
|
||||
|
||||
// Customer Points Service Methods
|
||||
func (s *GamificationServiceImpl) CreateCustomerPoints(ctx context.Context, req *contract.CreateCustomerPointsRequest) (*contract.CustomerPointsResponse, error) {
|
||||
modelReq := transformer.CreateCustomerPointsRequestToModel(req)
|
||||
response, err := s.customerPointsProcessor.CreateCustomerPoints(ctx, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerPointsModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetCustomerPoints(ctx context.Context, id uuid.UUID) (*contract.CustomerPointsResponse, error) {
|
||||
response, err := s.customerPointsProcessor.GetCustomerPoints(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerPointsModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetCustomerPointsByCustomerID(ctx context.Context, customerID uuid.UUID) (*contract.CustomerPointsResponse, error) {
|
||||
response, err := s.customerPointsProcessor.GetCustomerPointsByCustomerID(ctx, customerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerPointsModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) ListCustomerPoints(ctx context.Context, query *contract.ListCustomerPointsRequest) (*contract.PaginatedCustomerPointsResponse, error) {
|
||||
modelQuery := transformer.ListCustomerPointsRequestToModel(query)
|
||||
response, err := s.customerPointsProcessor.ListCustomerPoints(ctx, modelQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.PaginatedCustomerPointsResponseToContract(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) UpdateCustomerPoints(ctx context.Context, id uuid.UUID, req *contract.UpdateCustomerPointsRequest) (*contract.CustomerPointsResponse, error) {
|
||||
modelReq := transformer.UpdateCustomerPointsRequestToModel(req)
|
||||
response, err := s.customerPointsProcessor.UpdateCustomerPoints(ctx, id, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerPointsModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) DeleteCustomerPoints(ctx context.Context, id uuid.UUID) error {
|
||||
return s.customerPointsProcessor.DeleteCustomerPoints(ctx, id)
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) AddCustomerPoints(ctx context.Context, customerID uuid.UUID, req *contract.AddCustomerPointsRequest) (*contract.CustomerPointsResponse, error) {
|
||||
response, err := s.customerPointsProcessor.AddPoints(ctx, customerID, req.Points)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerPointsModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) DeductCustomerPoints(ctx context.Context, customerID uuid.UUID, req *contract.DeductCustomerPointsRequest) (*contract.CustomerPointsResponse, error) {
|
||||
response, err := s.customerPointsProcessor.DeductPoints(ctx, customerID, req.Points)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerPointsModelToResponse(response), nil
|
||||
}
|
||||
|
||||
// Customer Tokens Service Methods
|
||||
func (s *GamificationServiceImpl) CreateCustomerTokens(ctx context.Context, req *contract.CreateCustomerTokensRequest) (*contract.CustomerTokensResponse, error) {
|
||||
modelReq := transformer.CreateCustomerTokensRequestToModel(req)
|
||||
response, err := s.customerTokensProcessor.CreateCustomerTokens(ctx, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerTokensModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetCustomerTokens(ctx context.Context, id uuid.UUID) (*contract.CustomerTokensResponse, error) {
|
||||
response, err := s.customerTokensProcessor.GetCustomerTokens(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerTokensModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) GetCustomerTokensByCustomerIDAndType(ctx context.Context, customerID uuid.UUID, tokenType string) (*contract.CustomerTokensResponse, error) {
|
||||
response, err := s.customerTokensProcessor.GetCustomerTokensByCustomerIDAndType(ctx, customerID, tokenType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerTokensModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) ListCustomerTokens(ctx context.Context, query *contract.ListCustomerTokensRequest) (*contract.PaginatedCustomerTokensResponse, error) {
|
||||
modelQuery := transformer.ListCustomerTokensRequestToModel(query)
|
||||
response, err := s.customerTokensProcessor.ListCustomerTokens(ctx, modelQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.PaginatedCustomerTokensResponseToContract(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) UpdateCustomerTokens(ctx context.Context, id uuid.UUID, req *contract.UpdateCustomerTokensRequest) (*contract.CustomerTokensResponse, error) {
|
||||
modelReq := transformer.UpdateCustomerTokensRequestToModel(req)
|
||||
response, err := s.customerTokensProcessor.UpdateCustomerTokens(ctx, id, modelReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerTokensModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) DeleteCustomerTokens(ctx context.Context, id uuid.UUID) error {
|
||||
return s.customerTokensProcessor.DeleteCustomerTokens(ctx, id)
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) AddCustomerTokens(ctx context.Context, customerID uuid.UUID, tokenType string, req *contract.AddCustomerTokensRequest) (*contract.CustomerTokensResponse, error) {
|
||||
response, err := s.customerTokensProcessor.AddTokens(ctx, customerID, tokenType, req.Tokens)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerTokensModelToResponse(response), nil
|
||||
}
|
||||
|
||||
func (s *GamificationServiceImpl) DeductCustomerTokens(ctx context.Context, customerID uuid.UUID, tokenType string, req *contract.DeductCustomerTokensRequest) (*contract.CustomerTokensResponse, error) {
|
||||
response, err := s.customerTokensProcessor.DeductTokens(ctx, customerID, tokenType, req.Tokens)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return transformer.CustomerTokensModelToResponse(response), nil
|
||||
}
|
||||
|
||||
// Tier Service Methods
|
||||
func (s *GamificationServiceImpl) CreateTier(ctx context.Context, req *contract.CreateTierRequest) (*contract.TierResponse, error) {
|
||||
modelReq := transformer.CreateTierRequestToModel(req)
|
||||
|
||||
Reference in New Issue
Block a user