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:
efrilm
2026-09-30 14:43:15 +07:00
co-authored by Claude Opus 5.5
parent 550122f29c
commit d1e543a79f
16 changed files with 11 additions and 1731 deletions
@@ -9,20 +9,6 @@ import (
)
type GamificationValidator interface {
// Customer Points
ValidateCreateCustomerPointsRequest(req *contract.CreateCustomerPointsRequest) (error, string)
ValidateUpdateCustomerPointsRequest(req *contract.UpdateCustomerPointsRequest) (error, string)
ValidateListCustomerPointsRequest(req *contract.ListCustomerPointsRequest) (error, string)
ValidateAddCustomerPointsRequest(req *contract.AddCustomerPointsRequest) (error, string)
ValidateDeductCustomerPointsRequest(req *contract.DeductCustomerPointsRequest) (error, string)
// Customer Tokens
ValidateCreateCustomerTokensRequest(req *contract.CreateCustomerTokensRequest) (error, string)
ValidateUpdateCustomerTokensRequest(req *contract.UpdateCustomerTokensRequest) (error, string)
ValidateListCustomerTokensRequest(req *contract.ListCustomerTokensRequest) (error, string)
ValidateAddCustomerTokensRequest(req *contract.AddCustomerTokensRequest) (error, string)
ValidateDeductCustomerTokensRequest(req *contract.DeductCustomerTokensRequest) (error, string)
// Tiers
ValidateCreateTierRequest(req *contract.CreateTierRequest) (error, string)
ValidateUpdateTierRequest(req *contract.UpdateTierRequest) (error, string)
@@ -60,152 +46,6 @@ func NewGamificationValidator() *GamificationValidatorImpl {
}
}
// Customer Points Validators
func (v *GamificationValidatorImpl) ValidateCreateCustomerPointsRequest(req *contract.CreateCustomerPointsRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Balance < 0 {
return errors.New("balance cannot be negative"), "INVALID_BALANCE"
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateUpdateCustomerPointsRequest(req *contract.UpdateCustomerPointsRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Balance < 0 {
return errors.New("balance cannot be negative"), "INVALID_BALANCE"
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateListCustomerPointsRequest(req *contract.ListCustomerPointsRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Page <= 0 {
req.Page = 1
}
if req.Limit <= 0 {
req.Limit = 10
}
if req.Limit > 100 {
req.Limit = 100
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateAddCustomerPointsRequest(req *contract.AddCustomerPointsRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Points <= 0 {
return errors.New("points must be greater than 0"), "INVALID_POINTS"
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateDeductCustomerPointsRequest(req *contract.DeductCustomerPointsRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Points <= 0 {
return errors.New("points must be greater than 0"), "INVALID_POINTS"
}
return nil, ""
}
// Customer Tokens Validators
func (v *GamificationValidatorImpl) ValidateCreateCustomerTokensRequest(req *contract.CreateCustomerTokensRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Balance < 0 {
return errors.New("balance cannot be negative"), "INVALID_BALANCE"
}
validTokenTypes := []string{"SPIN", "RAFFLE", "MINIGAME"}
if !contains(validTokenTypes, req.TokenType) {
return errors.New("invalid token type"), "INVALID_TOKEN_TYPE"
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateUpdateCustomerTokensRequest(req *contract.UpdateCustomerTokensRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Balance < 0 {
return errors.New("balance cannot be negative"), "INVALID_BALANCE"
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateListCustomerTokensRequest(req *contract.ListCustomerTokensRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Page <= 0 {
req.Page = 1
}
if req.Limit <= 0 {
req.Limit = 10
}
if req.Limit > 100 {
req.Limit = 100
}
if req.TokenType != "" {
validTokenTypes := []string{"SPIN", "RAFFLE", "MINIGAME"}
if !contains(validTokenTypes, req.TokenType) {
return errors.New("invalid token type"), "INVALID_TOKEN_TYPE"
}
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateAddCustomerTokensRequest(req *contract.AddCustomerTokensRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Tokens <= 0 {
return errors.New("tokens must be greater than 0"), "INVALID_TOKENS"
}
return nil, ""
}
func (v *GamificationValidatorImpl) ValidateDeductCustomerTokensRequest(req *contract.DeductCustomerTokensRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {
return err, "VALIDATION_ERROR"
}
if req.Tokens <= 0 {
return errors.New("tokens must be greater than 0"), "INVALID_TOKENS"
}
return nil, ""
}
// Tier Validators
func (v *GamificationValidatorImpl) ValidateCreateTierRequest(req *contract.CreateTierRequest) (error, string) {
if err := v.validate.Struct(req); err != nil {